使用 api 插入的 Google 日历事件未打印



当我查看日历时,使用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

我能够解决这个问题,但它实际上只是最终成为概念证明,所以我没有回头看的代码。我记得问题最终是我用作结束日期的值。我不记得具体细节,但也许我使用了与开始日期相同的日期,并添加了午夜的结束时间。反正就是这样。祝你好运,对不起,我不能更乐于助人。

使用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'
}

最新更新