示例#1
0
        public CalendarItemCollection GetRange(DateTime start, DateTime end)
        {
            var nowItems  = _client.GetRange(start, end);
            var lastItems = LoadLastItems();

#if false
            DumpCalendarItemCollection(nowItems, @"d:\temp\nowItems.xml");
            DumpCalendarItemCollection(lastItems, @"d:\temp\lastItems.xml");
#endif
            var nowItemsDict = new CalendarItemDictionary();
            nowItemsDict.AddRange(nowItems);

            foreach (var lastItem in lastItems)
            {
                if (lastItem.Cancelled)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(lastItem.ID))
                {
                    continue;
                }
                if (nowItemsDict.ContainsKey(lastItem.ID) == false)
                {
                    lastItem.Cancelled = true;
                    nowItems.Add(lastItem);
                }
            }

            return(nowItems);
        }
        public CalendarItemCollection GetRange(DateTime start, DateTime end)
        {
            var nowItems  = _client.GetRange(start, end);
            var lastItems = LoadLastItems();

#if false
            DumpCalendarItemCollection(nowItems, @"d:\temp\nowItems.xml");
            DumpCalendarItemCollection(lastItems, @"d:\temp\lastItems.xml");
#endif
            var nowItemsDict = new CalendarItemDictionary(a => a.SyngronizeGuid.ToString());
            nowItemsDict.AddRange(nowItems);

            foreach (var lastItem in lastItems)
            {
                if (lastItem.Cancelled)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(lastItem.ID))
                {
                    continue;
                }
                if (nowItemsDict.ContainsKey(lastItem) == false)
                {
                    lastItem.Cancelled = true;
                    lastItem.ID        = string.Empty;
                    lastItem.Changed   = false;
                    nowItems.Add(lastItem);
                }
            }

            foreach (var item in nowItems)
            {
                item.Name     = item.Name ?? string.Empty;
                item.Location = item.Location ?? string.Empty;
                item.Body     = item.Body ?? string.Empty;
            }

            return(nowItems);
        }