コード例 #1
0
        private void UpdateEvent(Event item)
        {
            //var calendarId = GetCalendarId(item.Type);
            var googleCalendarEventId = AlreadyCreatedItems[item.EventGuid].GoogleCalendarEventId;
            var calendarId            = AlreadyCreatedItems[item.EventGuid].GoogleCalendarId;

            var googleCalendarEvent = SyncGoogleCalendarAPI.GetEvent(this.Account, googleCalendarEventId, calendarId);
            var lastSyncAccountLogItemModyficationDate = CalendarSyncBL.GetLastSyncAccountLogItemModyficationDate(item.EventGuid);

            if (GoogleEventDeleted(googleCalendarEvent))
            {
                MarkEventInDatabaseAsDeleted(googleCalendarEventId);
            }
            else
            {
                if (GoogleEventIsMoreUpdatedThanPS(googleCalendarEvent, lastSyncAccountLogItemModyficationDate))
                {
                    //  throw new Exception("what the f**k");
                    UpdateEventInPSTable(googleCalendarEvent, this.Account);
                    CalendarSyncBL.UpdateLogItem(item.EventGuid, googleCalendarEvent.Updated.Value);
                }

                if (PSEventIsMoreUpdatedThanGoogle(googleCalendarEvent, lastSyncAccountLogItemModyficationDate))
                {
                    var @event = UpdateEventInGoogleCalendar(this.Account, item, googleCalendarEvent, calendarId);
                    CalendarSyncBL.UpdateLogItem(item.EventGuid, @event.Updated.Value);
                }
            }
        }
コード例 #2
0
        private void AddEventToGoogleCalendar(Event item)
        {
            var calendarId          = GetCalendarId(item.Type);
            var googleCalendarEvent = SyncGoogleCalendarAPI.AddEvent(this.Account, item, calendarId);

            CalendarSyncBL.AddSyncAccountEvent(this.Account, item.EventGuid, googleCalendarEvent.Id, calendarId);
            CalendarSyncBL.UpdateLogItem(item.EventGuid, googleCalendarEvent.Updated.Value);
        }
コード例 #3
0
        private void DeleteEvent(Event item)
        {
            //var calendarId = GetCalendarId(item.Type);
            var googleCalendarEventId = AlreadyCreatedItems[item.EventGuid].GoogleCalendarEventId;
            var calendarId            = AlreadyCreatedItems[item.EventGuid].GoogleCalendarId;

            SyncGoogleCalendarAPI.Delete(this.Account, googleCalendarEventId, calendarId);
            CalendarSyncBL.SyncAccountEventMarkAsDeleted(googleCalendarEventId);

            var googleCalendarEvent = SyncGoogleCalendarAPI.GetEvent(this.Account, googleCalendarEventId, calendarId);

            CalendarSyncBL.UpdateLogItem(item.EventGuid, googleCalendarEvent.Updated.Value);
        }
コード例 #4
0
        private void SyncCalendar(EventType eventType)
        //private void SyncCalendar(string calendarId)
        {
            string calendarId           = GetCalendarId(eventType);
            var    googleCalendarEvents = SyncGoogleCalendarAPI.GetGoogleCalendarEvents(Account, Start, End, calendarId);

            foreach (var googleEvent in googleCalendarEvents.Items)
            {
                if (EventExistsInPSTable(googleEvent))
                {
                    if (GoogleEventDeleted(googleEvent))
                    {
                        DeleteEvent(googleEvent);
                    }
                    else
                    {
                        if (EventIsInDifferentCalendar(googleEvent, calendarId))
                        {
                            MoveEvent(calendarId, eventType, googleEvent);
                        }

                        if (GoogleEventIsMoreUpdated(googleEvent))
                        {
                            UpdateEvent(googleEvent);
                        }
                    }
                }
                else
                {
                    if (GoogleEventDeleted(googleEvent) == false)
                    {
                        AddGoogleEventToPSTable(calendarId, googleEvent);
                    }
                }
            }
        }
コード例 #5
0
        private Google.Apis.Calendar.v3.Data.Event UpdateEventInGoogleCalendar(string account, Event item, Google.Apis.Calendar.v3.Data.Event googleCalendarEvent, string calendarid)
        {
            var r = SyncGoogleCalendarAPI.UpdateEvent(account, item, googleCalendarEvent.Id, calendarid);

            return(r);
        }