问题描述
我正在编写日历集成,并使用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 (将#修改为@)