예제 #1
0
파일: GGSync.cs 프로젝트: wertkh32/gg
        /// <summary>
        /// Sync local GGItem to GG calendar
        /// </summary>
        /// <param name="addToLocal">List of GGItems to be added to local GGList</param>
        /// <param name="removeFromLocal">List of GGItems to be removed from local GGList</param>
        /// <param name="GGService">Google calendar service object</param>
        /// <param name="GGCalendar">GG calendar</param>
        /// <param name="GGEvents">Google event query results</param>
        /// <param name="server">List of bools to indicate if a Google event has a local version</param>
        /// <param name="ggItem">The local GGItem to be synced</param>
        private void SyncFromLocalToServer(List<GGItem> addToLocal, List<GGItem> removeFromLocal, CalendarService GGService, CalendarEntry GGCalendar, EventFeed GGEvents, List<bool> server, GGItem ggItem)
        {
            if (ggItem.GetEventAbsoluteUrl() == String.Empty)
            {   // Not synced : add to GG Calendar
                Log("Never synced");
                ggItem.SetEventAbsoluteUrl(AddGGEvent(GGService, GGCalendar, ggItem));
                Log("Add to server: " + ggItem.ToString());
            }
            else
            {   // Synced before
                Log("Synced before");
                string id = ggItem.GetEventAbsoluteUrl();

                // Find the coresponding Google event
                AtomEntry theEvent = FindGoogleEvent(GGEvents, server, id);

                if (theEvent == null)
                {   // Not found: deleted on GG calendar : remove from local list
                    Log("Event is deleted on server");
                    removeFromLocal.Add(ggItem);
                    Log("Removed in local list");
                }
                else
                {   // Found
                    SolveConflict(addToLocal, removeFromLocal, GGService, GGCalendar, ggItem, theEvent);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Parse a GGItem to CSV string
        /// </summary>
        /// <param name="ggItem"></param>
        /// <returns></returns>
        private string ToCSVString(GGItem ggItem)
        {
            string description = ggItem.GetDescription().Replace(Environment.NewLine, "[newline]");
            description = description.Replace(",", "[comma]");

            string tag = ggItem.GetTag().Replace(Environment.NewLine, "[newline]");
            tag = tag.Replace(",", "[comma]");
            CultureInfo usCulture = CultureInfo.CreateSpecificCulture("en-US");

            return description + ","
                   + ggItem.GetEndDate().ToString(usCulture) + ","
                   + tag + ","
                   + ggItem.GetLastModifiedTime().ToString() + ","
                   + ggItem.GetEventAbsoluteUrl() + ","
                   + ggItem.GetPath();
        }
예제 #3
0
파일: GGSync.cs 프로젝트: wertkh32/gg
 /// <summary>
 /// Delete a event on Google calendar
 /// </summary>
 /// <param name="GGEvents">Google event query results</param>
 /// <param name="server">List of bools to indicate if a Google event has a local version</param>
 /// <param name="ggItem">local version of the Google Event</param>
 private void DeleteEvents(EventFeed GGEvents, List<bool> server, GGItem ggItem)
 {
     if (ggItem.GetEventAbsoluteUrl().CompareTo(string.Empty) != 0)
     {
         AtomEntry theEvent = FindGoogleEvent(GGEvents, server, ggItem.GetEventAbsoluteUrl());
         if (theEvent != null)
         {
             theEvent.Delete();
         }
     }
 }