Beispiel #1
0
        /// <summary>
        /// Show rescue option dialog (TaskDialog)
        /// </summary>
        /// <returns>when returning false, should abort execution</returns>
        private static bool ShowRescueDialog()
        {
#if DEBUG
            return(true);
#else
            var resp = ConfirmationMassages.ConfirmRescue();
            if (!resp.CommandButtonResult.HasValue || resp.CommandButtonResult.Value == 2)
            {
                return(false);
            }
            if (resp.CommandButtonResult.Value == 0)
            {
                return(true);
            }
            return(ShowMaintenanceDialog());
#endif
        }
Beispiel #2
0
        /// <summary>
        /// Show maintenance option dialog (TaskDialog)
        /// </summary>
        /// <returns>when returning false, should abort execution</returns>
        private static bool ShowMaintenanceDialog()
        {
            var resp = ConfirmationMassages.ConfirmMaintenance();

            if (!resp.CommandButtonResult.HasValue || resp.CommandButtonResult.Value == 5)
            {
                return(false);
            }
            try
            {
                switch (resp.CommandButtonResult.Value)
                {
                case 1:
                    // optimize database
                    ScheduleDatabaseOptimization();
                    break;

                case 2:
                    // remove database
                    if (File.Exists(App.DatabaseFilePath))
                    {
                        File.Delete(App.DatabaseFilePath);
                    }
                    break;

                case 3:
                case 4:
                case 5:
                    // remove all
                    if (App.ExecutionMode == ExecutionMode.Standalone)
                    {
                        // remove each
                        var files = new[]
                        {
                            App.DatabaseFilePath, App.DatabaseFilePath,
                            App.HashtagTempFilePath, App.ListUserTempFilePath,
                            Path.Combine(App.ConfigurationDirectoryPath, App.ProfileFileName)
                        };
                        var dirs = new[]
                        {
                            App.KeyAssignProfilesDirectory
                        };
                        files.Where(File.Exists).ForEach(File.Delete);
                        dirs.Where(Directory.Exists).ForEach(d => Directory.Delete(d, true));
                    }
                    else
                    {
                        // remove whole directory
                        if (Directory.Exists(App.ConfigurationDirectoryPath))
                        {
                            Directory.Delete(App.ConfigurationDirectoryPath, true);
                        }
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                FailMessages.GeneralProcessFailed(ex);
            }
            if (resp.CommandButtonResult.Value == 5)
            {
                // force update
                var w = new AwaitDownloadingUpdateWindow();
                w.ShowDialog();
            }
            return(resp.CommandButtonResult.Value < 4);
        }