Beispiel #1
0
        private CalendarItem CreateCalendarItem(Guid guid, CalendarItem key)
        {
            var calendarItem = new CalendarItem();

            calendarItem.SyngronizeGuid = guid;
            calendarItem.Name           = key.Name;
            calendarItem.Start          = key.Start;
            calendarItem.End            = key.End;
            calendarItem.AllDayEvent    = key.AllDayEvent;
            calendarItem.Cancelled      = key.Cancelled;
            calendarItem.Location       = key.Location;
            calendarItem.Body           = key.Body;
            calendarItem.Changed        = true;
            return(calendarItem);
        }
Beispiel #2
0
 private void DoAddItem(CalendarItem calendarItem, List <CalendarItem> list)
 {
     _allCalendarItems.Add(calendarItem);
     list.Add(calendarItem);
     if (_key == null)
     {
         _key = calendarItem;
     }
     else
     {
         if (_key.LastModified < calendarItem.LastModified)
         {
             _key = calendarItem;
         }
     }
 }
Beispiel #3
0
        private void SynchronizeItem(Guid guid, CalendarItem key, CalendarItem calendarItem)
        {
            var changed = false;

            if (calendarItem.SyngronizeGuid != guid)
            {
                calendarItem.SyngronizeGuid = guid;
                changed = true;
            }
            if (calendarItem.Name != key.Name)
            {
                calendarItem.Name = key.Name;
                changed           = true;
            }
            if (calendarItem.Start != key.Start)
            {
                calendarItem.Start = key.Start;
                changed            = true;
            }
            if (calendarItem.End != key.End)
            {
                calendarItem.End = key.End;
                changed          = true;
            }
            if (calendarItem.AllDayEvent != key.AllDayEvent)
            {
                calendarItem.AllDayEvent = key.AllDayEvent;
                changed = true;
            }
            if (calendarItem.Cancelled != key.Cancelled)
            {
                calendarItem.Cancelled = key.Cancelled;
                changed = true;
            }
            if (calendarItem.Location != key.Location)
            {
                calendarItem.Location = key.Location;
                changed = true;
            }
            if (calendarItem.Body != key.Body)
            {
                calendarItem.Body = key.Body;
                changed           = true;
            }
            calendarItem.Changed = changed;
        }
Beispiel #4
0
        private void SynchronizeGatheredCalendarItems(GatheredCalenderItems gatheredCalendarItems, int googleItemCount, int outlookItemCount)
        {
            var guid = gatheredCalendarItems.Guid;
            var key  = gatheredCalendarItems.Key;

            if (key.Cancelled == false)
            {
                // 予定の同期は、非キャンセルな項目に全てに対して行う。
                // ただし、非キャンセルな項目が無ければ新たに追加する。
                if (googleItemCount == 0)
                {
                    var newCalendarItem = new CalendarItem();
                    _googleCalendarItems.Add(newCalendarItem);
                    gatheredCalendarItems.AddItem(newCalendarItem, GatheredCalenderItems.CalendarItemTypes.Google);
                }
                if (outlookItemCount == 0)
                {
                    var newCalendarItem = new CalendarItem();
                    _outlookCalendarItems.Add(newCalendarItem);
                    gatheredCalendarItems.AddItem(newCalendarItem, GatheredCalenderItems.CalendarItemTypes.Outlook);
                }
                foreach (var calendarItem in gatheredCalendarItems.Items)
                {
                    if (calendarItem.Cancelled == false)
                    {
                        SynchronizeItem(guid, key, calendarItem);
                    }
                }
            }
            else
            {
                // 予定のキャンセルは、マッチした全項目に対して行う。
                foreach (var calendarItem in gatheredCalendarItems.Items)
                {
                    if (calendarItem.Cancelled == false)
                    {
                        calendarItem.Cancelled = true;
                        calendarItem.Changed   = true;
                    }
                }
            }
        }
Beispiel #5
0
 private bool MatchCalendarItems(CalendarItem lhs, CalendarItem rhs)
 {
     if (lhs.Name != rhs.Name)
     {
         return(false);
     }
     if (lhs.AllDayEvent != rhs.AllDayEvent)
     {
         return(false);
     }
     if (lhs.Start != rhs.Start)
     {
         return(false);
     }
     if (lhs.End != rhs.End)
     {
         return(false);
     }
     return(true);
 }
Beispiel #6
0
 private bool IsChangeRequired(Guid guid, CalendarItem key, CalendarItem calendarItem)
 {
     if (calendarItem.SyngronizeGuid != guid)
     {
         return(true);
     }
     if (calendarItem.Name != key.Name)
     {
         return(true);
     }
     if (calendarItem.Start != key.Start)
     {
         return(true);
     }
     if (calendarItem.End != key.End)
     {
         return(true);
     }
     if (calendarItem.AllDayEvent != key.AllDayEvent)
     {
         return(true);
     }
     if (calendarItem.Cancelled != key.Cancelled)
     {
         return(true);
     }
     if (calendarItem.Location != key.Location)
     {
         return(true);
     }
     if (calendarItem.Body != key.Body)
     {
         return(true);
     }
     return(false);
 }
Beispiel #7
0
        public void AddItem(CalendarItem calendarItem, CalendarItemTypes type)
        {
            List <CalendarItem> list = (type == CalendarItemTypes.Google) ? _googleCalendarItems : _outlookCalendarItems;

            DoAddItem(calendarItem, list);
        }