Exemple #1
0
        private void LogGatheredCalendarItems(GatheredCalenderItems gatheredCalendarItems)
        {
            var log  = TraceLog.TheInstance;
            var guid = gatheredCalendarItems.Guid;

            log.WriteLine("  同期イベント集合 GUID:{0}", guid.ToString("B"));
            foreach (var calendarItem in gatheredCalendarItems.GoogleItems)
            {
                log.WriteLine("    [Google ] 名前:{0} 開始時刻:{1} 終了時刻:{2} GUID:{3} キャンセル:{4,-5} 場所:{5}",
                              calendarItem.Name,
                              calendarItem.Start.ToString("u"),
                              calendarItem.End.ToString("u"),
                              calendarItem.SyngronizeGuid.ToString("B"),
                              calendarItem.Cancelled,
                              calendarItem.Location);
            }
            foreach (var calendarItem in gatheredCalendarItems.OutlookItems)
            {
                log.WriteLine("    [Outlook] 名前:{0} 開始時刻:{1} 終了時刻:{2} GUID:{3} キャンセル:{4,-5} 場所:{5}",
                              calendarItem.Name,
                              calendarItem.Start.ToString("u"),
                              calendarItem.End.ToString("u"),
                              calendarItem.SyngronizeGuid.ToString("B"),
                              calendarItem.Cancelled,
                              calendarItem.Location);
            }
        }
Exemple #2
0
 private void AddCalendarItemsWithoutGuid(CalendarItemCollection calendarItems, GatheredCalenderItems.CalendarItemTypes itemType)
 {
     foreach (var calendarItem in calendarItems)
     {
         if (calendarItem.SyngronizeGuid == Guid.Empty)
         {
             var gatheredCalendarItems = FindGatheredCalendarItems(calendarItem);
             if (gatheredCalendarItems == null)
             {
                 var guid = Guid.NewGuid();
                 gatheredCalendarItems           = new GatheredCalenderItems(guid);
                 _gatheredCalendarItemDict[guid] = gatheredCalendarItems;
             }
             gatheredCalendarItems.AddItem(calendarItem, itemType);
         }
     }
 }
Exemple #3
0
 private void AddCalendarItemsWithGuid(CalendarItemCollection calendarItems, GatheredCalenderItems.CalendarItemTypes itemType)
 {
     foreach (var calendarItem in calendarItems)
     {
         if (calendarItem.SyngronizeGuid != Guid.Empty)
         {
             var guid = calendarItem.SyngronizeGuid;
             var gatheredCalendarItems = default(GatheredCalenderItems);
             var r = _gatheredCalendarItemDict.TryGetValue(guid, out gatheredCalendarItems);
             if (r == false)
             {
                 gatheredCalendarItems           = new GatheredCalenderItems(guid);
                 _gatheredCalendarItemDict[guid] = gatheredCalendarItems;
             }
             gatheredCalendarItems.AddItem(calendarItem, itemType);
         }
     }
 }
Exemple #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;
                    }
                }
            }
        }
Exemple #5
0
        private bool IsChangeRequired(GatheredCalenderItems gatheredCalendarItems, int googleItemCount, int outlookItemCount)
        {
            var guid = gatheredCalendarItems.Guid;
            var key  = gatheredCalendarItems.Key;

            if (key.Cancelled == false)
            {
                if ((googleItemCount == 0) || (outlookItemCount == 0))
                {
                    return(true);
                }
            }
            foreach (var calendarItem in gatheredCalendarItems.Items)
            {
                var r = IsChangeRequired(guid, key, calendarItem);
                if (r)
                {
                    return(true);
                }
            }

            return(false);
        }