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); } } }
private void DeleteEvent(Google.Apis.Calendar.v3.Data.Event googleEvent) { PSCalendarContract.Dto.GoogleEvent @event = CalendarSyncBL.GetEvent(googleEvent.Id); CalendarCoreBL.Delete(@event.EventGuid); CalendarSyncBL.SyncAccountEventMarkAsDeleted(@event.GoogleCalendarEventId); CalendarSyncBL.UpdateLogItem(@event.EventGuid, googleEvent.Updated.Value); }
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); }
private bool GoogleEventIsMoreUpdated(Google.Apis.Calendar.v3.Data.Event googleEvent) { var psGoogleEvent = GetGoogleEvent(googleEvent.Id); var lastSyncAccountLogItemModyficationDate = CalendarSyncBL.GetLastSyncAccountLogItemModyficationDate(psGoogleEvent.EventGuid); var r = googleEvent.Updated.Value.TrimMilliseconds() > lastSyncAccountLogItemModyficationDate.TrimMilliseconds(); return(r); }
private void MoveEvent(string calendarId, EventType eventType, Google.Apis.Calendar.v3.Data.Event googleEvent) { var psGoogleEvent = GetGoogleEvent(googleEvent.Id); CalendarSyncBL.UpdateGoogleCalendar(this.Account, psGoogleEvent.EventGuid, eventType, calendarId); //we are not updating date, as we want to perform update of elements //CalendarSyncBL.UpdateLogItem(psGoogleEvent.EventGuid, googleEvent.Updated.Value); }
private void AddGoogleEventToPSTable(string calendarId, Google.Apis.Calendar.v3.Data.Event googleEvent) { PSCalendarContract.Dto.Event @event = ConvertEvent(googleEvent); @event.Type = this.CalendarList.Single(x => x.Value == calendarId).Key; Guid eventGuid = CalendarCoreBL.AddEvent(@event); CalendarSyncBL.AddSyncAccountEvent(Account, eventGuid, googleEvent.Id, calendarId); CalendarSyncBL.UpdateLogItem(eventGuid, googleEvent.Updated.Value); }
private void UpdateEvent(Google.Apis.Calendar.v3.Data.Event googleEvent) { var psGoogleEvent = GetGoogleEvent(googleEvent.Id); var lastSyncAccountLogItemModyficationDate = CalendarSyncBL.GetLastSyncAccountLogItemModyficationDate(psGoogleEvent.EventGuid); if (googleEvent.Updated.Value.TrimMilliseconds() > lastSyncAccountLogItemModyficationDate.TrimMilliseconds()) { UpdateEventInPSTable(googleEvent, this.Account); CalendarSyncBL.UpdateLogItem(psGoogleEvent.EventGuid, googleEvent.Updated.Value); } }
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); }
private void MarkEventInDatabaseAsDeleted(string googleCalendarEventId) { CalendarSyncBL.MarkEventAsDeleted(googleCalendarEventId); }
public GoogleToPSSync(string account, DateTime start, DateTime end, Dictionary <EventType, string> calendarList) : base(account, start, end, calendarList) { PsEventsWithAdditionalInfo = CalendarSyncBL.GetSyncEvents(Account, Start, End); }