简体   繁体   English

如果已经为该日期/时间创建了事件,则Google Calender API v3避免创建事件(C#.NET)

[英]Google Calender API v3 avoid creating event if one already is created for that date/time ( C# .NET)

How can I check if I will end up making events at the same time in the Google Calendar API v3 in a certain calendar? 如何检查某个日历中的Google Calendar API v3是否最终会同时进行事件?

Google didn't give any help and the API documentation is consfusing and lacks .NET examples. Google没有提供任何帮助,API文档令人困惑,并且缺少.NET示例。

I found that you can get all the events on a calendar with this: https://developers.google.com/resources/api-libraries/documentation/calendar/v3/csharp/latest/classGoogle_1_1Apis_1_1Calendar_1_1v3_1_1EventsResource.html#aad662ad7f7ba3a29b0264cbdcec9f722 我发现您可以使用以下命令在日历上获取所有事件: https : //developers.google.com/resources/api-libraries/documentation/calendar/v3/csharp/latest/classGoogle_1_1Apis_1_1Calendar_1_1v3_1_1EventsResource.html#aad662ad7f7ba3a29b0264cbdcec9f722

Then I could get these events into a list in C# with this code 然后,我可以使用以下代码将这些事件放入C#的列表中

List<Event> list = service.Events.List(calenderID).Execute().Items.ToList();

Then you iterate and see if it matches 然后您进行迭代,看看是否匹配

foreach (Event e in list)
{
    if ( e.Start.DateTime == shift.start && e.End.DateTime == shift.end )
    {
        // Event conflicts
        safe = false; break;
    }
}

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

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