private InitialiseResult Initialise() { if (Process.GetProcesses().Count(process => process.ProcessName.Contains("Gallifrey")) > 1) { return(InitialiseResult.MultipleGallifreyRunning); } if (!modelHelpers.Gallifrey.VersionControl.IsAutomatedDeploy && !Debugger.IsAttached) { return(InitialiseResult.DebuggerNotAttached); } try { using (var client = new WebClient()) { client.DownloadData("https://gallifrey-releases.blyth.me.uk"); } } catch { return(InitialiseResult.NoInternetConnection); } try { modelHelpers.Gallifrey.Initialise(); } catch (MissingConfigException) { return(InitialiseResult.NewUser); } catch (MissingJiraConfigException) { return(InitialiseResult.MissingConfig); } catch (JiraConnectionException) { return(InitialiseResult.JiraConnectionError); } catch (TempoConnectionException) { return(InitialiseResult.TempoConnectionError); } modelHelpers.RefreshModel(); modelHelpers.SelectRunningTimer(); return(InitialiseResult.Ok); }
public MainWindow(InstanceType instance, AppType appType) { InitializeComponent(); var gallifrey = new Backend(instance, appType); modelHelpers = new ModelHelpers(gallifrey, FlyoutsControl); exceptionlessHelper = new ExceptionlessHelper(modelHelpers); exceptionlessHelper.RegisterExceptionless(); var viewModel = new MainViewModel(modelHelpers); modelHelpers.RefreshModel(); modelHelpers.SelectRunningTimer(); DataContext = viewModel; gallifrey.NoActivityEvent += GallifreyOnNoActivityEvent; gallifrey.ExportPromptEvent += GallifreyOnExportPromptEvent; SystemEvents.SessionSwitch += SessionSwitchHandler; Height = gallifrey.Settings.UiSettings.Height; Width = gallifrey.Settings.UiSettings.Width; Title = gallifrey.VersionControl.AppName; ThemeHelper.ChangeTheme(gallifrey.Settings.UiSettings.Theme, gallifrey.Settings.UiSettings.Accent); if (gallifrey.VersionControl.IsAutomatedDeploy) { PerformUpdate(false, true); var updateHeartbeat = new Timer(60000); updateHeartbeat.Elapsed += AutoUpdateCheck; updateHeartbeat.Enabled = true; } }
private async void OnLoaded(object sender, RoutedEventArgs e) { var multipleInstances = false; var showSettings = false; try { modelHelpers.Gallifrey.Initialise(); } catch (MissingJiraConfigException) { showSettings = true; } catch (JiraConnectionException) { showSettings = true; } catch (MultipleGallifreyRunningException) { multipleInstances = true; } if (multipleInstances) { modelHelpers.Gallifrey.TrackEvent(TrackingType.MultipleInstancesRunning); await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Multiple Instances", "You Can Only Have One Instance Of Gallifrey Running At A Time\nPlease Close The Other Instance"); modelHelpers.CloseApp(); } else if (showSettings) { modelHelpers.Gallifrey.TrackEvent(TrackingType.SettingsMissing); await modelHelpers.OpenFlyout(new Flyouts.Settings(modelHelpers)); if (!modelHelpers.Gallifrey.JiraConnection.IsConnected) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Connection Required", "You Must Have A Working Jira Connection To Use Gallifrey"); modelHelpers.CloseApp(); } modelHelpers.RefreshModel(); } if (modelHelpers.Gallifrey.VersionControl.IsAutomatedDeploy && modelHelpers.Gallifrey.VersionControl.IsFirstRun) { var changeLog = modelHelpers.Gallifrey.GetChangeLog(XDocument.Parse(Properties.Resources.ChangeLog)).Where(x => x.NewVersion).ToList(); if (changeLog.Any()) { await modelHelpers.OpenFlyout(new Flyouts.ChangeLog(changeLog)); } } exceptionlessHelper.RegisterExceptionless(); }
public MainWindow(InstanceType instance) { InitializeComponent(); var gallifrey = new Backend(instance); modelHelpers = new ModelHelpers(gallifrey, FlyoutsControl); exceptionlessHelper = new ExceptionlessHelper(modelHelpers); exceptionlessHelper.RegisterExceptionless(); progressDialogHelper = new ProgressDialogHelper(modelHelpers.DialogContext); var viewModel = new MainViewModel(modelHelpers); modelHelpers.RefreshModel(); modelHelpers.SelectRunningTimer(); DataContext = viewModel; gallifrey.NoActivityEvent += GallifreyOnNoActivityEvent; gallifrey.ExportPromptEvent += GallifreyOnExportPromptEvent; SystemEvents.SessionSwitch += SessionSwitchHandler; Height = gallifrey.Settings.UiSettings.Height; Width = gallifrey.Settings.UiSettings.Width; ThemeHelper.ChangeTheme(gallifrey.Settings.UiSettings.Theme, gallifrey.Settings.UiSettings.Accent); updateHeartbeat = new Timer(TimeSpan.FromMinutes(1).TotalMilliseconds); updateHeartbeat.Elapsed += AutoUpdateCheck; idleDetectionHeartbeat = new Timer(TimeSpan.FromSeconds(30).TotalMilliseconds); idleDetectionHeartbeat.Elapsed += IdleDetectionCheck; flyoutOpenCheck = new Timer(100); flyoutOpenCheck.Elapsed += FlyoutOpenCheck; }
private async void SaveButton(object sender, RoutedEventArgs e) { if (DataModel.HasModifiedRunDate) { if (!DataModel.RunDate.HasValue) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Missing Date", "You Must Enter A Start Date"); Focus(); return; } if (DataModel.RunDate.Value < DataModel.MinDate || DataModel.RunDate.Value > DataModel.MaxDate) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Invalid Date", $"You Must Enter A Start Date Between {DataModel.MinDate.ToShortDateString()} And {DataModel.MaxDate.ToShortDateString()}"); Focus(); return; } try { EditedTimerId = modelHelpers.Gallifrey.JiraTimerCollection.ChangeTimerDate(EditedTimerId, DataModel.RunDate.Value); } catch (DuplicateTimerException ex) { var handlerd = await MergeTimers(ex); if (!handlerd) { Focus(); return; } } } else if (DataModel.HasModifiedJiraReference) { if (DataModel.TempTimer) { modelHelpers.Gallifrey.JiraTimerCollection.ChangeTempTimerDescription(EditedTimerId, DataModel.TempTimerDescription); } else { Issue jiraIssue; try { jiraIssue = modelHelpers.Gallifrey.JiraConnection.GetJiraIssue(DataModel.JiraReference); } catch (NoResultsFoundException) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Invalid Jira", "Unable To Locate The Jira"); Focus(); return; } var result = await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Correct Jira?", $"Jira found!\n\nRef: {jiraIssue.key}\nName: {jiraIssue.fields.summary}\n\nIs that correct?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No", DefaultButtonFocus = MessageDialogResult.Affirmative }); if (result == MessageDialogResult.Negative) { return; } try { EditedTimerId = modelHelpers.Gallifrey.JiraTimerCollection.RenameTimer(EditedTimerId, jiraIssue); } catch (DuplicateTimerException ex) { var handlerd = await MergeTimers(ex); if (!handlerd) { Focus(); return; } } } } if (DataModel.HasModifiedTime) { var originalTime = new TimeSpan(DataModel.OriginalHours, DataModel.OriginalMinutes, 0); var newTime = new TimeSpan(DataModel.Hours, DataModel.Minutes, 0); var difference = newTime.Subtract(originalTime); var addTime = difference.TotalSeconds > 0; modelHelpers.Gallifrey.JiraTimerCollection.AdjustTime(EditedTimerId, Math.Abs(difference.Hours), Math.Abs(difference.Minutes), addTime); } modelHelpers.RefreshModel(); modelHelpers.SetSelectedTimer(EditedTimerId); modelHelpers.CloseFlyout(this); }
private async void SaveButton(object sender, RoutedEventArgs e) { if (DataModel.HasModifiedRunDate) { if (!DataModel.RunDate.HasValue) { await modelHelpers.ShowMessageAsync("Missing Date", "You Must Enter A Start Date"); Focus(); return; } if (DataModel.RunDate.Value.Date < DataModel.MinDate.Date || DataModel.RunDate.Value.Date > DataModel.MaxDate.Date) { await modelHelpers.ShowMessageAsync("Invalid Date", $"You Must Enter A Start Date Between {DataModel.MinDate.ToShortDateString()} And {DataModel.MaxDate.ToShortDateString()}"); Focus(); return; } try { EditedTimerId = modelHelpers.Gallifrey.JiraTimerCollection.ChangeTimerDate(EditedTimerId, DataModel.RunDate.Value); } catch (DuplicateTimerException ex) { var handled = await MergeTimers(ex); if (!handled) { Focus(); return; } } } else if (DataModel.HasModifiedJiraReference) { if (DataModel.LocalTimer) { try { EditedTimerId = modelHelpers.Gallifrey.JiraTimerCollection.ChangeLocalTimerDescription(EditedTimerId, DataModel.LocalTimerDescription); } catch (DuplicateTimerException) { await modelHelpers.ShowMessageAsync("Something Went Wrong", "An Error Occured Trying To Edit That Timer, Please Try Again"); Focus(); return; } } else { Issue jiraIssue = null; var jiraRef = DataModel.JiraReference; void GetIssue() { if (modelHelpers.Gallifrey.JiraConnection.DoesJiraExist(jiraRef)) { jiraIssue = modelHelpers.Gallifrey.JiraConnection.GetJiraIssue(jiraRef); } } var jiraDownloadResult = await progressDialogHelper.Do(GetIssue, "Searching For Jira Issue", true, false); if (jiraDownloadResult.Status == ProgressResult.JiraHelperStatus.Cancelled) { Focus(); return; } if (jiraIssue == null) { await modelHelpers.ShowMessageAsync("Invalid Jira", $"Unable To Locate The Jira '{jiraRef}'"); Focus(); return; } var result = await modelHelpers.ShowMessageAsync("Correct Jira?", $"Jira found!\n\nRef: {jiraIssue.key}\nName: {jiraIssue.fields.summary}\n\nIs that correct?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No", DefaultButtonFocus = MessageDialogResult.Affirmative }); if (result == MessageDialogResult.Negative) { return; } try { EditedTimerId = modelHelpers.Gallifrey.JiraTimerCollection.RenameTimer(EditedTimerId, jiraIssue); } catch (DuplicateTimerException ex) { var handled = await MergeTimers(ex); if (!handled) { Focus(); return; } } } } if (DataModel.HasModifiedTime) { var originalTime = new TimeSpan(DataModel.OriginalHours, DataModel.OriginalMinutes, 0); var newTime = new TimeSpan(DataModel.Hours ?? 0, DataModel.Minutes ?? 0, 0); var difference = newTime.Subtract(originalTime); var addTime = difference.TotalSeconds > 0; modelHelpers.Gallifrey.JiraTimerCollection.AdjustTime(EditedTimerId, Math.Abs(difference.Hours), Math.Abs(difference.Minutes), addTime); } modelHelpers.RefreshModel(); modelHelpers.SetSelectedTimer(EditedTimerId); modelHelpers.CloseFlyout(this); }
private async void AddButton(object sender, RoutedEventArgs e) { if (!modelHelpers.Gallifrey.Settings.InternalSettings.IsPremium) { if (DataModel.LocalTimer) { if (modelHelpers.Gallifrey.JiraTimerCollection.GetAllLocalTimers().Count() >= 2) { modelHelpers.ShowGetPremiumMessage("Without Gallifrey Premium You Are Limited To A Maximum Of 2 Local Timers"); Focus(); return; } } } if (!DataModel.StartDate.HasValue) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Missing Date", "You Must Enter A Start Date"); Focus(); return; } if (DataModel.StartDate.Value.Date < DataModel.MinDate.Date || DataModel.StartDate.Value.Date > DataModel.MaxDate.Date) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Invalid Date", $"You Must Enter A Start Date Between {DataModel.MinDate.ToShortDateString()} And {DataModel.MaxDate.ToShortDateString()}"); Focus(); return; } TimeSpan seedTime; if (DataModel.TimeEditable) { seedTime = new TimeSpan(DataModel.StartHours ?? 0, DataModel.StartMinutes ?? 0, 0); } else { seedTime = new TimeSpan(); } Issue jiraIssue = null; var jiraRef = string.Empty; if (!DataModel.LocalTimer) { try { jiraRef = DataModel.JiraReference; var jiraDownloadResult = await progressDialogHelper.Do(() => modelHelpers.Gallifrey.JiraConnection.GetJiraIssue(jiraRef), "Searching For Jira Issue", true, true); if (jiraDownloadResult.Status == ProgressResult.JiraHelperStatus.Success) { jiraIssue = jiraDownloadResult.RetVal; } else { Focus(); return; } } catch (NoResultsFoundException) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Invalid Jira", $"Unable To Locate The Jira '{jiraRef}'"); Focus(); return; } if (DataModel.JiraReferenceEditable) { var result = await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Correct Jira?", $"Jira found!\n\nRef: {jiraIssue.key}\nName: {jiraIssue.fields.summary}\n\nIs that correct?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No", DefaultButtonFocus = MessageDialogResult.Affirmative }); if (result == MessageDialogResult.Negative) { Focus(); return; } } } if (DataModel.DatePeriod) { AddedTimer = await AddPeriodTimer(jiraIssue, seedTime); } else { AddedTimer = await AddSingleTimer(jiraIssue, seedTime, DataModel.StartDate.Value); } if (!AddedTimer) { Focus(); return; } var stillDoingThings = false; if (!DataModel.LocalTimer) { if (DataModel.AssignToMe) { try { await progressDialogHelper.Do(() => modelHelpers.Gallifrey.JiraConnection.AssignToCurrentUser(jiraRef), "Assigning Issue", false, true); } catch (JiraConnectionException) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Assign Jira Error", "Unable To Locate Assign Jira To Current User"); } } if (DataModel.ChangeStatus) { try { var transitionResult = await progressDialogHelper.Do(() => modelHelpers.Gallifrey.JiraConnection.GetTransitions(jiraRef), "Getting Transitions To Change Status", false, true); if (transitionResult.Status == ProgressResult.JiraHelperStatus.Success) { var transitionsAvaliable = transitionResult.RetVal; var timeSelectorDialog = (BaseMetroDialog)this.Resources["TransitionSelector"]; await DialogCoordinator.Instance.ShowMetroDialogAsync(modelHelpers.DialogContext, timeSelectorDialog); var comboBox = timeSelectorDialog.FindChild <ComboBox>("Items"); comboBox.ItemsSource = transitionsAvaliable.Select(x => x.name).ToList(); var messageBox = timeSelectorDialog.FindChild <TextBlock>("Message"); messageBox.Text = $"Please Select The Status Update You Would Like To Perform To {DataModel.JiraReference}"; stillDoingThings = true; } } catch (Exception) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Status Update Error", "Unable To Change The Status Of This Issue"); } } } if (!stillDoingThings) { modelHelpers.CloseFlyout(this); modelHelpers.RefreshModel(); } }
private async void SaveButton(object sender, RoutedEventArgs e) { if (DataModel.HasModifiedRunDate) { if (!DataModel.RunDate.HasValue) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Missing Date", "You Must Enter A Start Date"); Focus(); return; } if (DataModel.RunDate.Value.Date < DataModel.MinDate.Date || DataModel.RunDate.Value.Date > DataModel.MaxDate.Date) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Invalid Date", $"You Must Enter A Start Date Between {DataModel.MinDate.ToShortDateString()} And {DataModel.MaxDate.ToShortDateString()}"); Focus(); return; } try { EditedTimerId = modelHelpers.Gallifrey.JiraTimerCollection.ChangeTimerDate(EditedTimerId, DataModel.RunDate.Value); } catch (DuplicateTimerException ex) { var handlerd = await MergeTimers(ex); if (!handlerd) { Focus(); return; } } } else if (DataModel.HasModifiedJiraReference) { if (DataModel.LocalTimer) { var currentTimer = modelHelpers.Gallifrey.JiraTimerCollection.GetTimer(EditedTimerId); if (!currentTimer.LocalTimer) { if (!modelHelpers.Gallifrey.Settings.InternalSettings.IsPremium) { var localTimersCount = modelHelpers.Gallifrey.JiraTimerCollection.GetAllLocalTimers().Count(); if (localTimersCount >= 2) { modelHelpers.ShowGetPremiumMessage("Without Gallifrey Premium You Are Limited To A Maximum Of 2 Local Timers"); Focus(); return; } } } try { EditedTimerId = modelHelpers.Gallifrey.JiraTimerCollection.ChangeLocalTimerDescription(EditedTimerId, DataModel.LocalTimerDescription); } catch (DuplicateTimerException) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Something Went Wrong", "An Error Occured Trying To Edit That Timer, Please Try Again"); Focus(); return; } } else { Issue jiraIssue; var jiraRef = string.Empty; try { jiraRef = DataModel.JiraReference; var jiraDownloadResult = await progressDialogHelper.Do(() => modelHelpers.Gallifrey.JiraConnection.GetJiraIssue(jiraRef), "Searching For Jira Issue", true, true); if (jiraDownloadResult.Status == ProgressResult.JiraHelperStatus.Success) { jiraIssue = jiraDownloadResult.RetVal; } else { Focus(); return; } } catch (NoResultsFoundException) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Invalid Jira", $"Unable To Locate The Jira '{jiraRef}'"); Focus(); return; } var result = await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Correct Jira?", $"Jira found!\n\nRef: {jiraIssue.key}\nName: {jiraIssue.fields.summary}\n\nIs that correct?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No", DefaultButtonFocus = MessageDialogResult.Affirmative }); if (result == MessageDialogResult.Negative) { return; } try { EditedTimerId = modelHelpers.Gallifrey.JiraTimerCollection.RenameTimer(EditedTimerId, jiraIssue); } catch (DuplicateTimerException ex) { var handlerd = await MergeTimers(ex); if (!handlerd) { Focus(); return; } } } } if (DataModel.HasModifiedTime) { var originalTime = new TimeSpan(DataModel.OriginalHours, DataModel.OriginalMinutes, 0); var newTime = new TimeSpan(DataModel.Hours ?? 0, DataModel.Minutes ?? 0, 0); var difference = newTime.Subtract(originalTime); var addTime = difference.TotalSeconds > 0; modelHelpers.Gallifrey.JiraTimerCollection.AdjustTime(EditedTimerId, Math.Abs(difference.Hours), Math.Abs(difference.Minutes), addTime); } modelHelpers.RefreshModel(); modelHelpers.SetSelectedTimer(EditedTimerId); modelHelpers.CloseFlyout(this); }
private async void AddButton(object sender, RoutedEventArgs e) { if (!DataModel.StartDate.HasValue) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Missing Date", "You Must Enter A Start Date"); Focus(); return; } if (DataModel.StartDate.Value < DataModel.MinDate || DataModel.StartDate.Value > DataModel.MaxDate) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Invalid Date", $"You Must Enter A Start Date Between {DataModel.MinDate.ToShortDateString()} And {DataModel.MaxDate.ToShortDateString()}"); Focus(); return; } TimeSpan seedTime; if (DataModel.TimeEditable) { seedTime = new TimeSpan(DataModel.StartHours, DataModel.StartMinutes, 0); } else { seedTime = new TimeSpan(); } Issue jiraIssue = null; if (!DataModel.TempTimer) { try { jiraIssue = modelHelpers.Gallifrey.JiraConnection.GetJiraIssue(DataModel.JiraReference); } catch (NoResultsFoundException) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Invalid Jira", "Unable To Locate The Jira"); Focus(); return; } if (DataModel.JiraReferenceEditable) { var result = await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Correct Jira?", $"Jira found!\n\nRef: {jiraIssue.key}\nName: {jiraIssue.fields.summary}\n\nIs that correct?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No", DefaultButtonFocus = MessageDialogResult.Affirmative }); if (result == MessageDialogResult.Negative) { Focus(); return; } } } try { if (DataModel.TempTimer) { NewTimerId = modelHelpers.Gallifrey.JiraTimerCollection.AddTempTimer(DataModel.TempTimerDescription, DataModel.StartDate.Value, seedTime, DataModel.StartNow); } else { NewTimerId = modelHelpers.Gallifrey.JiraTimerCollection.AddTimer(jiraIssue, DataModel.StartDate.Value, seedTime, DataModel.StartNow); } AddedTimer = true; if (!DataModel.TimeEditable) { modelHelpers.Gallifrey.JiraTimerCollection.AddIdleTimer(NewTimerId, DataModel.IdleTimers); } } catch (DuplicateTimerException ex) { var doneSomething = false; if (seedTime.TotalMinutes > 0 || !DataModel.TimeEditable) { var result = await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Duplicate Timer", "The Timer Already Exists, Would You Like To Add The Time?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No", DefaultButtonFocus = MessageDialogResult.Affirmative }); if (result == MessageDialogResult.Affirmative) { if (DataModel.TimeEditable) { modelHelpers.Gallifrey.JiraTimerCollection.AdjustTime(ex.TimerId, seedTime.Hours, seedTime.Minutes, true); } else { modelHelpers.Gallifrey.JiraTimerCollection.AddIdleTimer(ex.TimerId, DataModel.IdleTimers); } doneSomething = true; } else { Focus(); return; } } if (DataModel.StartNow) { modelHelpers.Gallifrey.JiraTimerCollection.StartTimer(ex.TimerId); doneSomething = true; } if (!doneSomething) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Duplicate Timer", "This Timer Already Exists!"); Focus(); return; } NewTimerId = ex.TimerId; } if (!DataModel.TempTimer) { if (DataModel.AssignToMe) { try { modelHelpers.Gallifrey.JiraConnection.AssignToCurrentUser(DataModel.JiraReference); } catch (JiraConnectionException) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Assign Jira Error", "Unable To Locate Assign Jira To Current User"); } } if (DataModel.InProgress) { try { modelHelpers.Gallifrey.JiraConnection.SetInProgress(DataModel.JiraReference); } catch (StateChangedException) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Error Changing Status", "Unable To Set Issue As In Progress"); } } } AddedTimer = true; modelHelpers.CloseFlyout(this); modelHelpers.RefreshModel(); }
private async void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { await PerformUpdate(UpdateType.StartUp); var debuggerMissing = false; var multipleInstances = false; var missingConfig = false; var connectionError = false; var noInternet = false; try { var progressDialogHelper = new ProgressDialogHelper(modelHelpers.DialogContext); var result = await progressDialogHelper.Do(modelHelpers.Gallifrey.Initialise, "Initialising Gallifrey", true, true); if (result.Status == ProgressResult.JiraHelperStatus.Cancelled) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Gallifrey Not Initialised", "Gallifrey Initialisation Was Cancelled, The App Will Now Close"); modelHelpers.CloseApp(); } } catch (NoInternetConnectionException) { noInternet = true; } catch (MissingJiraConfigException) { missingConfig = true; } catch (JiraConnectionException) { connectionError = true; } catch (MultipleGallifreyRunningException) { multipleInstances = true; } catch (DebuggerException) { debuggerMissing = true; } if (debuggerMissing) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Debugger Not Running", "It Looks Like Your Running Without Auto-Update\nPlease Use The Installed Shortcut To Start Gallifrey Or Download Again From GallifreyApp.co.uk"); modelHelpers.CloseApp(); } else if (multipleInstances) { modelHelpers.Gallifrey.TrackEvent(TrackingType.MultipleInstancesRunning); await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Multiple Instances", "You Can Only Have One Instance Of Gallifrey Running At A Time\nPlease Close The Other Instance"); modelHelpers.CloseApp(); } else if (noInternet) { modelHelpers.Gallifrey.TrackEvent(TrackingType.NoInternet); await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "No Internet Connection ", "Gallifrey Requires An Active Internet Connection To Work.\nPlease Try Again When You Have Internet"); modelHelpers.CloseApp(); } else if (missingConfig) { modelHelpers.Gallifrey.TrackEvent(TrackingType.SettingsMissing); await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Welcome To Gallifrey", "You Current Have No Jira Settings In Gallifrey\nWe Therefore Think Your A New User, So Welcome!\n\nTo Get Started, We Need Your Jira Details"); await NewUserOnBoarding(); modelHelpers.RefreshModel(); } else if (connectionError) { modelHelpers.Gallifrey.TrackEvent(TrackingType.ConnectionError); var userUpdate = await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Login Failure", "We Were Unable To Authenticate To Jira, Please Confirm Login Details\nWould You Like To Update Your Details?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No" }); if (userUpdate == MessageDialogResult.Negative) { await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Come Back Soon", "Without A Correctly Configured Jira Connection Gallifrey Will Close, Please Come Back Soon!"); modelHelpers.CloseApp(); } await UserLoginFailure(); } if (modelHelpers.Gallifrey.VersionControl.IsAutomatedDeploy && modelHelpers.Gallifrey.VersionControl.IsFirstRun) { var changeLog = modelHelpers.Gallifrey.GetChangeLog(XDocument.Parse(Properties.Resources.ChangeLog)).Where(x => x.NewVersion).ToList(); if (changeLog.Any()) { await modelHelpers.OpenFlyout(new Flyouts.ChangeLog(changeLog)); } } exceptionlessHelper.RegisterExceptionless(); updateHeartbeat.Enabled = true; idleDetectionHeartbeat.Enabled = true; flyoutOpenCheck.Enabled = true; }