简体   繁体   English

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

[英]Google Calendar Events inserted using api not printing

Events inserted using google's api and service account shows up fine when I view the calendar, but they are not included when I print the calendar.当我查看日历时,使用 google 的 api 和服务帐户插入的事件显示正常,但在我打印日历时不包括在内。

Events manually inserted are printed as expected.手动插入的事件按预期打印。 I am using the following code.我正在使用以下代码。

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();

Here is a composite screen shot of what I see when I view and print the calendar.这是我查看和打印日历时看到的合成屏幕截图。 https://i.stack.imgur.com/8FqAk.png https://i.stack.imgur.com/8FqAk.png

I was able to work this out, but it was really just ended up being a proof of concept, so I don't have code I look back on.我能够解决这个问题,但它实际上只是一个概念证明,所以我没有回头看的代码。 As I remember it the problem ended up being the value I used as my endDate.正如我所记得的,问题最终成为我用作 endDate 的值。 I don't remember specifics, but maybe I used the same date as the startDate and added the end time of midnight.我不记得具体细节,但也许我使用了与 startDate 相同的日期并添加了午夜的结束时间。 Something like that anyway.反正就是这样。 Good luck and sorry I couldn't be more helpful.祝你好运,对不起,我不能提供更多帮助。

Using the information provided by mikeh as a hint,使用 mikeh 提供的信息作为提示,

we were able to resolve the issue "All-day events are not displayed when printing".我们能够解决“打印时不显示全天事件”的问题。

The solution in my case by...在我的情况下的解决方案...

setting the start to "YYYY-MM-DDT00:00:00" and...将开始设置为“YYYY-MM-DDT00:00:00”和...

setting the end to 00:00:00 on the "next day" of the start.在开始的“第二天”将结束设置为 00:00:00。

Thank you.谢谢你。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM