private void bSync_Click(object sender, RibbonControlEventArgs e) { if (_itemType != Outlook.OlItemType.olJournalItem) { SetUIWorking(); try { if (!_isSynced) { _touch = Globals.ThisAddIn.NewTouch(_itemType); if (IsEmail) { Globals.ThisAddIn.CompareAndSync(_touch, _mail); details detailsForm = new details(_touch, _mail, true); DialogResult result = detailsForm.ShowDialog(); detailsForm.Dispose(); if (result == DialogResult.Yes) { Globals.ThisAddIn.RegisterTouchUpdate(_touch, Outlook.OlItemType.olMailItem); Globals.ThisAddIn.CompareAndSync(_touch, _mail); //Globals.ThisAddIn.CaptureEml(_mail, _touch); Globals.ThisAddIn.RegisterEmailWrite(_mail); Globals.ThisAddIn.AddTouchId(_mail, _touch.Id); //Globals.ThisAddIn.InitTheSync(); _isSynced = true; } } else { Globals.ThisAddIn.CompareAndSync(_touch, _appt); details detailsForm = new details(_touch, _appt, true); DialogResult result = detailsForm.ShowDialog(); detailsForm.Dispose(); if (result == DialogResult.Yes) { Globals.ThisAddIn.RegisterTouchUpdate(_touch, Outlook.OlItemType.olAppointmentItem); Globals.ThisAddIn.CompareAndSync(_touch, _appt); Globals.ThisAddIn.RegisterApptWrite(_appt); Globals.ThisAddIn.AddTouchId(_appt, _touch.Id); //Globals.ThisAddIn.InitTheSync(); _isSynced = true; } } } else { if (_touch.Id != Guid.Empty) { RefreshTouch(); } if (IsEmail && _mail != null && _touch.Id == Guid.Empty) { Globals.ThisAddIn.CompareAndSync(_touch, _mail); } else if (_appt != null && _touch.Id == Guid.Empty) { Globals.ThisAddIn.CompareAndSync(_touch, _appt); } else if (_appt != null) { Globals.ThisAddIn.ResolveRecipientsAppt(_touch, _appt); } details detsForm = null; if (IsEmail) { detsForm = new details(_touch, _mail, false); } else { detsForm = new details(_touch, _appt, false); } DialogResult res = detsForm.ShowDialog(); detsForm.Dispose(); if (res == DialogResult.Yes) { if (IsEmail) { Globals.ThisAddIn.RegisterTouchUpdate(_touch, Outlook.OlItemType.olMailItem); Globals.ThisAddIn.CompareAndSync(_touch, _mail); } else { Globals.ThisAddIn.RegisterTouchUpdate(_touch, Outlook.OlItemType.olAppointmentItem); Globals.ThisAddIn.CompareAndSync(_touch, _appt); } } } SetUI(); } catch (Exception ex) { DataAPI.HandleError("RibbonExplorer : bSync", ex); SetUI(); } } }
private void bSync_Click(object sender, RibbonControlEventArgs e) { if (_itemType != Outlook.OlItemType.olJournalItem) { SetUIWorking(); try { if (!_isSynced) { _touch = Globals.ThisAddIn.NewTouch(_itemType); //present details as dialog since this is new details detailsForm = null; if (IsEmail) { Globals.ThisAddIn.CompareAndSync(_touch, _mail); detailsForm = new details(_touch, _mail, true); } else { //check Recurrance if (_appt.IsRecurring) { MessageBox.Show("Recurring appointments may not be synced.", "Shuri App", MessageBoxButtons.OK, MessageBoxIcon.Error); SetUI(); return; } Globals.ThisAddIn.CompareAndSync(_touch, _appt); detailsForm = new details(_touch, _appt, true); } DialogResult result = detailsForm.ShowDialog(); detailsForm.Dispose(); if (result == DialogResult.Yes) { Globals.ThisAddIn.RegisterTouchUpdate(_touch, (IsEmail) ? Outlook.OlItemType.olMailItem : Outlook.OlItemType.olAppointmentItem); if (IsEmail) { Globals.ThisAddIn.CompareAndSync(_touch, _mail); //Globals.ThisAddIn.CaptureEml(_mail, _touch); Globals.ThisAddIn.RegisterEmailWrite(_mail); Globals.ThisAddIn.AddTouchId(_mail, _touch.Id); } else { Globals.ThisAddIn.CompareAndSync(_touch, _appt); Globals.ThisAddIn.RegisterApptWrite(_appt); Globals.ThisAddIn.AddTouchId(_appt, _touch.Id); } _isSynced = true; } } else { if (_touch.Id != Guid.Empty) { RefreshTouch(); if (_isDirty) { Globals.ThisAddIn.RegisterOLItemUpdate(_touch, (IsEmail) ? _mail.EntryID : _appt.EntryID); } } if (IsEmail && _mail != null && (_touch.Id == Guid.Empty || _isDirty)) { Globals.ThisAddIn.CompareAndSync(_touch, _mail); } else if (_appt != null && (_touch.Id == Guid.Empty || _isDirty)) { Globals.ThisAddIn.CompareAndSync(_touch, _appt); } else if (_appt != null) { Globals.ThisAddIn.ResolveRecipientsAppt(_touch, _appt); } _isDirty = false; details detsForm = null; if (IsEmail) { detsForm = new details(_touch, _mail, false); } else { detsForm = new details(_touch, _appt, false); } DialogResult res = detsForm.ShowDialog(); detsForm.Dispose(); if (res == DialogResult.Yes) { if (IsEmail) { Globals.ThisAddIn.CompareAndSync(_touch, _mail); } else { Globals.ThisAddIn.CompareAndSync(_touch, _appt); } } } SetUI(); } catch (Exception ex) { DataAPI.HandleError("RibbonInspector : bSync", ex); SetUI(); } } }