コード例 #1
0
        private bool CompareTime(Event googleItem, object outlookItem)
        {
            var instancesRequest = CalendarService.Events.Instances(_googleCalendar.Id, googleItem.Id);

            instancesRequest.ShowDeleted = true;
            var googleExceptions     = instancesRequest.Execute().Items.Where(e => e.Status == "cancelled").ToList();
            var googleEventSchedule  = new EventSchedule(googleItem, this._googleCalendar, this.CalendarService /*googleExceptions*/);
            var outlookEventSchedule = new EventSchedule((Outlook.AppointmentItem)outlookItem);

            return
                (googleEventSchedule == outlookEventSchedule &&
                 this.CompareReminder(googleItem, outlookItem));
        }
コード例 #2
0
 /// <summary>
 /// Sets recurrence in direction Outlook -> Google
 /// </summary>
 /// <param name="outlookItem">Source Outlook event</param>
 /// <param name="googleItem">Target Google event</param>
 private void SetRecurrence(Outlook.AppointmentItem outlookItem, Event googleItem)
 {
     if (outlookItem.IsRecurring)
     {
         /// Times property doesn't contain anything for recurrent events
         var outlookItemSchedule = new EventSchedule(outlookItem);
         googleItem.Recurrence = outlookItemSchedule.GetGoogleRecurrence();
         /// Recurrence exceptions can be set for Google item only after the item is create or updated
         /// Only in this case all recurrence instances are created
         //this.SetRecurrenceExceptions((outlookItem), googleItem);
     }
     else
     {
         googleItem.Recurrence = null;
     }
 }
コード例 #3
0
        private void SetTime(Event googleItem, object item, Target target)
        {
            var outlookItem = (Outlook.AppointmentItem)item;

            /// in order to prevent situation when start is later then end
            /// we should process both times simultaniously and check what time should be changed first
            if (target == Target.Google)
            {
                //var schedule = new EventSchedule(((Outlook.AppointmentItem)outlookItem));
                if (outlookItem.AllDayEvent)
                {
                    googleItem.Start.Date = outlookItem.Start.ToString("yyyy-MM-dd");
                    googleItem.End.Date   = outlookItem.End.ToString("yyyy-MM-dd");
                }
                else
                {
                    googleItem.Start.DateTime = outlookItem.Start;
                    googleItem.Start.TimeZone = TimeZones.GetTZ(outlookItem.StartTimeZone.ID);
                    googleItem.End.DateTime   = outlookItem.End;
                    googleItem.End.TimeZone   = TimeZones.GetTZ(outlookItem.EndTimeZone.ID);
                }
                if (outlookItem.IsRecurring && (outlookItem.RecurrenceState == Outlook.OlRecurrenceState.olApptMaster))
                {
                    this.SetRecurrence(outlookItem, googleItem);
                }
            }
            else
            {
                if (googleItem.Recurrence == null)
                {
                    var schedule = new EventSchedule(googleItem);
                    outlookItem.Start       = schedule.StartTime;
                    outlookItem.End         = schedule.EndTime;
                    outlookItem.AllDayEvent = schedule.AllDayEvent;
                }
                else
                {
                    this.SetRecurrence(googleItem, outlookItem);
                }
            }
            this.SetReminder(googleItem, outlookItem, target);
        }