private void AllowTrackingClick(object sender, RoutedEventArgs e) { if (!modelHelpers.Gallifrey.Settings.InternalSettings.IsPremium && !DataModel.AllowTracking) { modelHelpers.ShowGetPremiumMessage("To Opt-Out Of Tracking You Need To Have Gallifrey Premium"); DataModel.EnableTracking(); } }
private void ExportAllButton(object sender, RoutedEventArgs e) { if (modelHelpers.Gallifrey.Settings.InternalSettings.IsPremium || DataModel.BulkExports.Count <= NonPremiumMaxExport) { foreach (var bulkExportModel in DataModel.BulkExports) { bulkExportModel.ShouldExport = true; } } else { modelHelpers.ShowGetPremiumMessage("Without Gallifrey Premium You Are Limited To A Maximum Of 5 Bulk Exports"); for (int i = 0; i < NonPremiumMaxExport; i++) { DataModel.BulkExports[i].ShouldExport = true; } } }
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 void GetPremium(object sender, RoutedEventArgs e) { modelHelpers.ShowGetPremiumMessage(); }