private void Add_BTN_Click(object sender, EventArgs e)
        {
            if (GoogleCal_CB.SelectedIndex >= 0 && OutlookCal_CB.SelectedIndex >= 0)
            {
                var pair       = new SyncPair();
                var googleCal  = m_googleFolders.Items[GoogleCal_CB.SelectedIndex];
                var outlookCal = m_outlookFolders[OutlookCal_CB.SelectedIndex];

                pair.GoogleName  = googleCal.Summary;
                pair.GoogleId    = googleCal.Id;
                pair.OutlookName = outlookCal.Name;
                pair.OutlookId   = outlookCal.EntryID;

                if (!Pair_LB.Items.Contains(pair))
                {
                    Pair_LB.Items.Add(pair);
                    Scheduler.Scheduler.Instance.AddTask(new SchedulerTask {
                        Event = SchedulerEvent.Automatically, Pair = pair
                    });
                    Next_BTN.Enabled = true;
                }
            }
            else
            {
                MessageBox.Show(this, "You need to select a calendar from both lists.", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Synchronizes a SyncPair.
        /// </summary>
        /// <param name="pair">The pair to sync</param>
        /// <param name="precedence">The precendence used when performing silent syncing</param>
        /// <param name="silentSync">Perform a silent sync?</param>
        public SyncerResult SynchornizePairs(SyncPair pair, Precedence precedence = Precedence.None, bool silentSync = false)
        {
            m_precedence = precedence;
            m_silentSync = silentSync;

            var result = SynchornizePairs(new List <SyncPair> {
                pair
            }, new BackgroundWorker());

            m_silentSync       = false;
            m_precedence       = Precedence.None;
            PerformActionToAll = false;

            return(result);
        }
        /// <summary>
        /// Searches through the specified SyncPair and finds events that were deleted.
        /// </summary>
        /// <param name="pair">The pair to search</param>
        /// <returns>A list of IDs of the deleted events</returns>
        public List <Identifier> FindDeletedEvents(SyncPair pair)
        {
            var list = new List <Identifier>();

            m_outlookSync.SetOutlookWorkingFolder(pair.OutlookId);
            m_archiver.CurrentPair = pair;

            var outlookAppts = m_outlookSync.PullListOfAppointments();
            var archlist     = m_archiver.GetListForSyncPair(pair);

            foreach (var id in archlist)
            {
                if (outlookAppts.Find(x => x.CalendarItemIdentifier.Equals(id)) == null)
                {
                    list.Add(id);
                }
            }

            return(list);
        }
        private void Sync_BTN_Click(object sender, EventArgs e)
        {
            // Create the SyncPair
            var pair = new SyncPair {
                GoogleName  = googleCal_CB.SelectedItem.ToString(),
                GoogleId    = m_googleFolders.Items[googleCal_CB.SelectedIndex].Id,
                OutlookName = outlookCal_CB.SelectedItem.ToString(),
                OutlookId   = m_outlookFolders[outlookCal_CB.SelectedIndex].EntryID
            };

            // Set the current outlook working folder to the folder selected by the user.
            pair.OutlookId = m_outlookFolders.First(x => x.Name == pair.OutlookName).EntryID;
            OutlookSync.Syncer.SetOutlookWorkingFolder(pair.OutlookId);

            // Set the current Google working folder
            pair.GoogleId = m_googleFolders.Items.First(x => x.Summary.Equals(pair.GoogleName)).Id;
            GoogleSync.Syncer.SetGoogleWorkingFolder(pair.GoogleId);

            Archiver.Instance.CurrentPair = pair;

            // Get the final list using the Syncer
            var finalList = m_syncer.GetFinalList(checkBox1.Checked, Start_DTP.Value, End_DTP.Value);

            if (finalList.Count == 0)
            {
                MessageBox.Show($"There are no differences between the {pair.GoogleName} Google Calender and the {pair.OutlookName} Outlook Calender.", "No Events", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            else
            {
                // Display the differences
                var compare = new CompareForm();
                compare.SetParent(this);
                compare.SetCalendars(pair);
                compare.LoadData(finalList);
                compare.Show(this);
            }
        }
 public void SetCalendars(SyncPair pair)
 {
     Outlook_LBL.Text = pair.OutlookName;
     Google_LBL.Text  = pair.GoogleName;
 }
Exemple #6
0
 protected bool Equals(SyncPair other)
 {
     return(string.Equals(GoogleName, other.GoogleName) && string.Equals(GoogleId, other.GoogleId) && string.Equals(OutlookName, other.OutlookName) && string.Equals(OutlookId, other.OutlookId));
 }
 public List <Identifier> GetListForSyncPair(SyncPair pair)
 {
     return(m_data.ContainsKey(pair) ? m_data[pair] : null);
 }