【问题标题】:Google Calendar Events inserted using api not printing使用 api 插入的 Google 日历事件未打印
【发布时间】:2018-10-20 15:55:35
【问题描述】:

使用 google 的 api 和服务帐户插入的事件在我查看日历时显示正常,但在我打印日历时它们不包括在内。

手动插入的事件按预期打印。我正在使用以下代码。

string[] scopes = new string[] { CalendarService.Scope.Calendar };
GoogleCredential credential;
using (var stream = new FileStream("mikeServiceAccount.json", FileMode.Open, 
  FileAccess.Read))
{
    credential = GoogleCredential.FromStream(stream).CreateScoped(scopes);
}

// Create the Calendar service.
var service = new CalendarService(new BaseClientService.Initializer()
{
    HttpClientInitializer = credential,
    ApplicationName = "Calendar Authentication Sample",
});

Event myEvent = new Event
{
    Summary = "Summary Title",
    Description = "event description"
    Location = "Nashville, TN"
    Start = new EventDateTime()
            {
                Date = "2018-10-19"
            },
            End = new EventDateTime()
            {
                Date = "2018-10-19"
            }
}; 
service.Events.Insert(myEvent,"b4sbsrsdf9r82sbj0@group.calendar.google.com").Execute();

这是我查看和打印日历时看到的合成屏幕截图。 https://i.stack.imgur.com/8FqAk.png

【问题讨论】:

  • 打印日历是什么意思?
  • 我看到所有事件只是查看日历,但是当我点击 ctrl-p 时,我只能看到打印预览屏幕中手动添加的事件。我有屏幕截图。让我看看是否可以将它们添加到我的问题中。谢谢!
  • 然后请包含您的打印屏幕代码
  • 使用的 c# 代码是我在最初的帖子中包含的。这是屏幕截图本身的链接。 i.stack.imgur.com/8FqAk.png
  • 您发布的代码中包含任何用于打印的内容。

标签: c# google-api google-calendar-api google-api-dotnet-client


【解决方案1】:

我能够解决这个问题,但它实际上只是一个概念证明,所以我没有回头看的代码。我记得问题最终是我用作 endDate 的值。我不记得具体细节,但也许我使用了与 startDate 相同的日期并添加了午夜的结束时间。反正是这样的。祝你好运,很抱歉我不能提供更多帮助。

【讨论】:

    【解决方案2】:

    使用 mikeh 提供的信息作为提示,

    我们能够解决“打印时不显示全天事件”的问题。

    我的解决方案...

    将开始设置为“YYYY-MM-DDT00:00:00”并且...

    在开始的“第二天”将结束设置为 00:00:00。

    谢谢。

    start: {
      dateTime : new Date("2020-01-25T00:00:00").toISOString()
      ,timeZone: 'Asia/Tokyo'
    }
    ,end: {
      dateTime : new Date("2020-01-26T00:00:00").toISOString()
      ,timeZone: 'Asia/Tokyo'
    }
    

    【讨论】:

      猜你喜欢
      • 2017-02-19
      • 1970-01-01
      • 1970-01-01
      • 2012-10-10
      • 2017-05-22
      • 1970-01-01
      • 1970-01-01
      • 2015-01-30
      • 2018-09-13
      相关资源
      最近更新 更多