public void OnSync(Office.IRibbonControl control) { try { OutlookUtils.SelectCalenderModule(); SyncForm form = new SyncForm(); // get calender list and initialize the form ICollection <String> calendars = OutlookUtils.GetCalendarList(config.CalendarName); form.Init(calendars, config); if (form.ShowDialog() == DialogResult.OK) { config.CalendarName = form.SelectedCalendar; //Get by id Release release = NgaUtils.GetSelectedRelease(); //NgaUtils.GetReleaseById(releaseId); EntityListResult <Sprint> sprints = NgaUtils.GetSprintsByRelease(release.Id); OutlookSyncUtils.SyncSprintsToOutlook(config.CalendarName, release, sprints); EntityListResult <Milestone> milestones = NgaUtils.GetMilestonesByRelease(release.Id); OutlookSyncUtils.SyncMilestonesToOutlook(config.CalendarName, release, milestones); String str = String.Format("Sync completed successfully.{0}Summary : {1} sprints and {2} milestones.", Environment.NewLine, sprints.data.Count, milestones.data.Count); MessageBox.Show(str, "Sync completed", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (ServerUnavailableException) { ShowServerIsNotAvailableMsg(); } catch (Exception e) { String errorMsg = "Sync failed : " + e.Message; MessageBox.Show(errorMsg, "Sync Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void OnLogin(Office.IRibbonControl control) { if (isLoggedIn) { // disconnect SettingsForm.RestConnector.Disconnect(); isLoggedIn = false; } else { // connect SettingsForm form = new SettingsForm(); String calendarName = null; if (config != null) { calendarName = config.CalendarName; } form.Configuration = config; if (form.ShowDialog() == DialogResult.OK) { config = form.Configuration; config.CalendarName = calendarName; NgaUtils.init(config.SharedSpaceId, config.WorkspaceId, config.ReleaseId); isLoggedIn = true; // select the calendar tab OutlookUtils.SelectCalenderModule(); } } if (ribbon != null) { ribbon.Invalidate(); } }