Exemple #1
0
        int SynchronizeCalendar(DateTime utcModifiedAfter)
        {
            int itemsUpdated = 0;

            try
            {
                var modifiedEvents = GetModifiedCalendarEvents(utcModifiedAfter);
                foreach (Event e in modifiedEvents)
                {
                    Guid itemID = new Guid(e.ExtendedProperties.Private[ExtensionItemID]);
                    Item item   = storage.GetItem(user, itemID);
                    if (item != null)
                    {   // Name, DueDate, EndDate, and Description (support Location?)
                        item.Name = e.Summary;
                        item.GetFieldValue(FieldNames.DueDate).Value = e.Start.DateTime;
                        item.GetFieldValue(FieldNames.EndDate).Value = e.End.DateTime;
                        FieldValue fvDescription = item.GetFieldValue(FieldNames.Description, (e.Description != null));
                        if (fvDescription != null)
                        {
                            fvDescription.Value = e.Description;
                        }
                        itemsUpdated++;
                    }
                }
                if (itemsUpdated > 0)
                {
                    storage.SaveChanges();
                }
            }
            catch (Exception e)
            {
                TraceLog.TraceException("Could not get modified Calendar events", e);
            }
            return(itemsUpdated);
        }