如何解决Outlook如何与Google中创建的事件同步?
我正在编写日历集成,并使用Google Calendar API和Outlook Graph API来同步日历事件。随着事件的更改,我收到Webhook通知,因此我需要一种方法来识别Google中的事件和Outlook中的事件是相同(或不同)的事件。从理论上讲,这应该使用iCalUId完成。
但是,当我在Google中创建具有Outlook与会者的事件时,在Outlook中创建的事件与Google中的事件没有相同的iCalUId。
我通过从Google发送到Outlook的附件中读取iCalUId来创建了解决方法。但是,Outlook事件本身仍然具有与Google事件不同的iCalUId,这使得处理将来的更新变得困难。
从概念上讲,Outlook可以在Google更新事件时更新事件(并在日历上显示更新的事件)。因此,Outlook必须存储一些对Google事件的引用。
有人知道该引用是什么,是否可以通过Graph API / SDK访问它?
更新 这是我使用Google API / SDK在Google中保存事件的代码:
var service = await GoogleAuthenticationProvider.GetCalendarService(CALENDAR_CLIENT_ID,CALENDAR_CLIENT_SECRET,CALENDAR_ACCESS_SCOPES,Person.CalendarRefreshToken).ConfigureAwait(false);
var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(Person.TimeZone);
//in google,having the organizer as an attendee causes the organizer to receive notification emails from google- which we don't want,so remove him/her from the attendees
var attendees = Event.Attendees.Where(a => a.Value != Event.OrganizerEmail);
var tmpEvent = new Google.Apis.Calendar.v3.Data.Event
{
Id = ExternalID.IsNullOrEmptyExtension() ? Convert.ToString(Event.ID) : ExternalID,Start = new EventDateTime
{
DateTime = Event.StartDate,TimeZone = GetGoogleTimeZoneFromSystemTimeZone(timeZoneInfo.Id)
},End = new EventDateTime
{
DateTime = Event.EndDate,Summary = Event.Title,Description = Event.Description,Attendees = attendees.Select(a => new EventAttendee
{
Email = a.Value,ResponseStatus = "accepted"
}).ToList(),GuestsCanInviteOthers = false,Location = Event.Location,Recurrence = Event.RecurrenceRule.IsNullOrEmptyExtension() ? new List<string> { } : new List<string> { "RRULE:" + Event.RecurrenceRule }
};
var savedEvent = new Google.Apis.Calendar.v3.Data.Event { };
if (ExternalID.IsNullOrEmptyExtension())
{
EventsResource.InsertRequest insertRequest = service.Events.Insert(tmpEvent,GOOGLE_PRIMARY_CALENDARID);
insertRequest.SendUpdates = EventsResource.InsertRequest.SendUpdatesEnum.All;
savedEvent = await insertRequest.ExecuteAsync().ConfigureAwait(false);
}
else
{
var updateRequest = service.Events.Update(tmpEvent,GOOGLE_PRIMARY_CALENDARID,ExternalID);
updateRequest.SendUpdates = EventsResource.UpdateRequest.SendUpdatesEnum.All;
savedEvent = await updateRequest.ExecuteAsync().ConfigureAwait(false);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。