示例#1
0
        private async void AddTimer(object sender, RoutedEventArgs e)
        {
            if (DataModel.SelectedSearchResult == null)
            {
                await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "No Selected Item", "You Need To Select An Item To Add A Timer For It");

                Focus();
                return;
            }

            modelHelpers.CloseFlyout(this);
            if (openFromAdd || openFromEdit)
            {
                SelectedJira = DataModel.SelectedSearchResult;
            }
            else
            {
                var addFlyout = new AddTimer(modelHelpers, DataModel.SelectedSearchResult.Reference, selectedDateTab);
                await modelHelpers.OpenFlyout(addFlyout);

                if (addFlyout.AddedTimer)
                {
                    modelHelpers.SetSelectedTimer(addFlyout.NewTimerId);
                }
                else
                {
                    await modelHelpers.OpenFlyout(this);
                }
            }
        }
示例#2
0
        private async void ShowAddTimer(string preLoadJiraRef = null)
        {
            var selected        = DataModel.LockedTimers.Where(x => x.IsSelected).ToList();
            var selectedTimers  = selected.Select(x => modelHelpers.Gallifrey.IdleTimerCollection.GetTimer(x.UniqueId)).Where(x => x != null).ToList();
            var lockedTimerDate = selected.First().DateForTimer;

            modelHelpers.CloseFlyout(this);
            var addFlyout = new AddTimer(modelHelpers, startDate: lockedTimerDate, enableDateChange: false, idleTimers: selectedTimers, jiraRef: preLoadJiraRef);
            await modelHelpers.OpenFlyout(addFlyout);

            if (addFlyout.AddedTimer)
            {
                foreach (var lockedTimerModel in selected)
                {
                    modelHelpers.Gallifrey.IdleTimerCollection.RemoveTimer(lockedTimerModel.UniqueId);
                }

                if (modelHelpers.Gallifrey.IdleTimerCollection.GetUnusedLockTimers().Any())
                {
                    modelHelpers.OpenFlyout(this);
                    DataModel.RefreshLockedTimers(modelHelpers.Gallifrey.IdleTimerCollection.GetUnusedLockTimers());
                }
                else
                {
                    modelHelpers.SetSelectedTimer(addFlyout.NewTimerId);
                }
            }
            else
            {
                modelHelpers.OpenFlyout(this);
            }
        }
示例#3
0
        private async void SearchButton(object sender, RoutedEventArgs e)
        {
            modelHelpers.HideFlyout(this);
            var searchFlyout = new Search(modelHelpers, openFromEdit: true);
            await modelHelpers.OpenFlyout(searchFlyout);

            if (searchFlyout.SelectedJira != null)
            {
                DataModel.SetJiraReference(searchFlyout.SelectedJira.Reference);
            }
            await modelHelpers.OpenFlyout(this);
        }
示例#4
0
        private async void ChangeLogButton(object sender, RoutedEventArgs e)
        {
            modelHelpers.HideFlyout(this);
            var changeLog = modelHelpers.Gallifrey.GetChangeLog(XDocument.Parse(Properties.Resources.ChangeLog)).ToList();

            if (changeLog.Any())
            {
                await modelHelpers.OpenFlyout(new ChangeLog(changeLog));
            }
            else
            {
                await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "No Change Log", "There Is No Change Log To Show");
            }
            await modelHelpers.OpenFlyout(this);
        }
示例#5
0
        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();
        }
示例#6
0
        private async void SetupContext(List <JiraTimer> timers, List <BulkExportModel> oldModels = null)
        {
            await Task.Delay(50);

            modelHelpers.HideFlyout(this);
            var timersToShow = new List <BulkExportModel>();

            try
            {
                var jiraDownloadResult = await progressDialogHelper.Do(controller => GetTimers(timers), "Downloading Jira Work Logs To Ensure Accurate Export", true, true);

                switch (jiraDownloadResult.Status)
                {
                case ProgressResult.JiraHelperStatus.Cancelled:
                    modelHelpers.CloseFlyout(this);
                    return;

                case ProgressResult.JiraHelperStatus.Success:
                    timersToShow = jiraDownloadResult.RetVal;
                    break;
                }
            }
            catch (BulkExportException ex)
            {
                await modelHelpers.ShowMessageAsync("Unable To Locate Jira", ex.Message);

                modelHelpers.CloseFlyout(this);
                return;
            }

            if (!timersToShow.Any())
            {
                await modelHelpers.ShowMessageAsync("Nothing To Export", "There Is No Time To Export");

                modelHelpers.CloseFlyout(this);
            }
            else if (timersToShow.Count == 1)
            {
                modelHelpers.CloseFlyout(this);
                await modelHelpers.OpenFlyout(new Export(modelHelpers, timersToShow.First().Timer.UniqueId, null, true));
            }
            else
            {
                var jiraComparer = new JiraReferenceComparer();
                timersToShow.Sort((a, b) =>
                {
                    int cmp = b.ExportDate.Date.CompareTo(a.ExportDate.Date);
                    if (cmp == 0)
                    {
                        cmp = jiraComparer.Compare(a.JiraRef, b.JiraRef);
                    }
                    return(cmp);
                });
                timersToShow.ForEach(x => DataModel.BulkExports.Add(x));
                if (oldModels != null)
                {
                    foreach (var oldModel in oldModels)
                    {
                        foreach (var newModel in DataModel.BulkExports)
                        {
                            if (oldModel.JiraRef == newModel.JiraRef && oldModel.ExportDate.Date == newModel.ExportDate.Date)
                            {
                                newModel.ShouldExport     = oldModel.ShouldExport;
                                newModel.ToExportHours    = oldModel.ToExportHours;
                                newModel.ToExportMinutes  = oldModel.ToExportMinutes;
                                newModel.WorkLogStrategy  = oldModel.WorkLogStrategy;
                                newModel.RemainingHours   = oldModel.RemainingHours;
                                newModel.RemainingMinutes = oldModel.RemainingMinutes;
                                newModel.Comment          = oldModel.Comment;
                                newModel.StandardComment  = oldModel.StandardComment;
                                newModel.ChangeStatus     = oldModel.ChangeStatus;
                            }
                        }
                    }
                }

                await modelHelpers.OpenFlyout(this);
            }
        }
示例#7
0
        private async void SetupContext(JiraTimer timerToShow, TimeSpan?exportTime, bool skipJiraCheck)
        {
            await Task.Delay(50);

            modelHelpers.HideFlyout(this);
            if (timerToShow.TempTimer)
            {
                await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Temp Timer", "You Cannot Export A Temporary Timer!");

                modelHelpers.CloseHiddenFlyout(this);
                return;
            }

            DataContext = new ExportModel(timerToShow, exportTime, modelHelpers.Gallifrey.Settings.ExportSettings);

            if (!skipJiraCheck)
            {
                Issue jiraIssue      = null;
                var   requireRefresh = !timerToShow.LastJiraTimeCheck.HasValue || timerToShow.LastJiraTimeCheck < DateTime.UtcNow.AddMinutes(-15);
                var   showError      = false;
                try
                {
                    var jiraDownloadResult = await progressDialogHelper.Do(() => modelHelpers.Gallifrey.JiraConnection.GetJiraIssue(timerToShow.JiraReference, requireRefresh), "Downloading Jira Work Logs To Ensure Accurate Export", true, false);

                    switch (jiraDownloadResult.Status)
                    {
                    case ProgressResult.JiraHelperStatus.Cancelled:
                        modelHelpers.CloseHiddenFlyout(this);
                        return;

                    case ProgressResult.JiraHelperStatus.Errored:
                        showError = true;
                        break;

                    case ProgressResult.JiraHelperStatus.Success:
                        jiraIssue = jiraDownloadResult.RetVal;
                        break;
                    }
                }
                catch (Exception)
                {
                    showError = true;
                }

                if (showError)
                {
                    await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Unable To Locate Jira", $"Unable To Locate Jira {timerToShow.JiraReference}!\nCannot Export Time\nPlease Verify/Correct Jira Reference");

                    modelHelpers.CloseHiddenFlyout(this);
                    return;
                }

                if (requireRefresh)
                {
                    modelHelpers.Gallifrey.JiraTimerCollection.RefreshFromJira(timerToShow.UniqueId, jiraIssue, modelHelpers.Gallifrey.JiraConnection.CurrentUser);
                    timerToShow = modelHelpers.Gallifrey.JiraTimerCollection.GetTimer(timerToShow.UniqueId);
                }

                DataModel.UpdateTimer(timerToShow, jiraIssue);
            }

            if (timerToShow.FullyExported)
            {
                await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Nothing To Export", "There Is No Time To Export");

                modelHelpers.CloseHiddenFlyout(this);
                return;
            }

            if (timerToShow.IsRunning)
            {
                await DialogCoordinator.Instance.ShowMessageAsync(modelHelpers.DialogContext, "Timer Is Running", "You Cannot Export A Timer While It Is Running");

                modelHelpers.CloseHiddenFlyout(this);
                return;
            }

            await modelHelpers.OpenFlyout(this);
        }
示例#8
0
        private async Task MainWindow_OnLoaded()
        {
            var result = await progressDialogHelper.Do(Initialise, "Initialising Gallifrey", true, true);

            if (result.Status == ProgressResult.JiraHelperStatus.Cancelled)
            {
                await modelHelpers.ShowMessageAsync("Gallifrey Not Initialised", "Gallifrey Initialisation Was Cancelled", MessageDialogStyle.Affirmative, new MetroDialogSettings { AffirmativeButtonText = "Close Gallifrey" });

                forceClosed = true;
                modelHelpers.CloseApp();
            }

            var checkedUpdate = false;

            if (result.RetVal != InitialiseResult.DebuggerNotAttached && result.RetVal != InitialiseResult.MultipleGallifreyRunning && result.RetVal != InitialiseResult.NoInternetConnection)
            {
                await PerformUpdate(UpdateType.StartUp);

                checkedUpdate = true;
            }

            if (result.RetVal == InitialiseResult.DebuggerNotAttached)
            {
                await modelHelpers.ShowMessageAsync("Debugger Not Running", "It Looks Like Your Running Without Auto-Update\nPlease Use The Installed Shortcut To Start Gallifrey Or Download Again From gallifrey.blyth.me.uk", MessageDialogStyle.Affirmative, new MetroDialogSettings { AffirmativeButtonText = "Close Gallifrey" });

                forceClosed = true;
                modelHelpers.CloseApp();
            }
            else if (result.RetVal == InitialiseResult.MultipleGallifreyRunning)
            {
                modelHelpers.Gallifrey.TrackEvent(TrackingType.MultipleInstancesRunning);
                await modelHelpers.ShowMessageAsync("Multiple Instances", "You Can Only Have One Instance Of Gallifrey Running At A Time", MessageDialogStyle.Affirmative, new MetroDialogSettings { AffirmativeButtonText = "Close Gallifrey" });

                forceClosed = true;
                modelHelpers.CloseApp();
            }
            else if (result.RetVal == InitialiseResult.NoInternetConnection)
            {
                modelHelpers.Gallifrey.TrackEvent(TrackingType.NoInternet);
                var userChoice = await modelHelpers.ShowMessageAsync("No Internet Connection", "Gallifrey Requires An Active Internet Connection To Work.", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Check Again", NegativeButtonText = "Close Now" });

                if (userChoice == MessageDialogResult.Affirmative)
                {
                    await MainWindow_OnLoaded();

                    return;
                }

                forceClosed = true;
                modelHelpers.CloseApp();
            }
            else if (result.RetVal == InitialiseResult.NewUser)
            {
                modelHelpers.Gallifrey.TrackEvent(TrackingType.SettingsMissing);
                await modelHelpers.ShowMessageAsync("Welcome To Gallifrey", "You Have No Settings In Gallifrey\n\nTo Get Started, We Need Your Jira Details");

                await NewUserOnBoarding();

                modelHelpers.Gallifrey.Settings.InternalSettings.SetNewUser(false);
                modelHelpers.Gallifrey.SaveSettings(false, false);
                await MainWindow_OnLoaded();

                return;
            }
            else if (result.RetVal == InitialiseResult.JiraConnectionError || result.RetVal == InitialiseResult.TempoConnectionError || result.RetVal == InitialiseResult.MissingConfig)
            {
                modelHelpers.Gallifrey.TrackEvent(TrackingType.ConnectionError);
                var message = string.Empty;
                switch (result.RetVal)
                {
                case InitialiseResult.JiraConnectionError:
                    message = "We Were Unable To Authenticate To Jira, Please Confirm Login Details";
                    break;

                case InitialiseResult.TempoConnectionError:
                    message = "We Were Unable To Authenticate To Tempo, Please Confirm Login Details";
                    break;

                case InitialiseResult.MissingConfig:
                    message = "There Are Missing Configuration Items For Jira/Tempo, Please Confirm Login Details";
                    break;
                }

                var userUpdate = await modelHelpers.ShowMessageAsync("Login Failure", message, MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary, new MetroDialogSettings { AffirmativeButtonText = "Update Details", NegativeButtonText = "Cancel", FirstAuxiliaryButtonText = "Retry" });

                switch (userUpdate)
                {
                case MessageDialogResult.Negative:
                    await modelHelpers.ShowMessageAsync("Come Back Soon", "Without A Correctly Configured Jira Connection Gallifrey Will Close, Please Come Back Soon!");

                    modelHelpers.CloseApp();
                    break;

                case MessageDialogResult.FirstAuxiliary:
                    await MainWindow_OnLoaded();

                    return;

                default:
                    await UserLoginFailure(result.RetVal == InitialiseResult.TempoConnectionError);
                    await MainWindow_OnLoaded();

                    return;
                }
            }

            if (!checkedUpdate)
            {
                await PerformUpdate(UpdateType.StartUp);
            }

            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();
            exceptionlessHelper.TrackFeature("Initialised");
            updateHeartbeat.Enabled                   = true;
            idleDetectionHeartbeat.Enabled            = true;
            flyoutOpenCheck.Enabled                   = true;
            modelHelpers.Gallifrey.NoActivityEvent   += GallifreyOnNoActivityEvent;
            modelHelpers.Gallifrey.ExportPromptEvent += GallifreyOnExportPromptEvent;
            modelHelpers.Gallifrey.SettingsChanged   += GallifreyOnSettingsChanged;
            SystemEvents.SessionSwitch               += SessionSwitchHandler;
        }
示例#9
0
        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;
        }