Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 private bool ShowPreExecuteDialog()
 {
     var resp = TaskDialog.Show(new TaskDialogOptions
     {
         Title = "Krileのメンテナンス",
         MainIcon = VistaTaskDialogIcon.Warning,
         MainInstruction = "Krileが保持するデータを管理できます。",
         Content = "消去したデータはもとに戻せません。必要なデータは予めバックアップしてください。",
         CommandButtons = new[]
         {
             /* 0 */ "このまま起動(&C)",
             /* 1 */ "データベースを消去して起動(&D)",
             /* 2 */ "すべての設定・データベースを消去して起動(&R)",
             /* 3 */ "すべての設定・データベースを消去して終了(&E)",
             /* 4 */ "最新版をクリーンインストール(&U)",
             /* 5 */ "キャンセル(&X)"
         },
         FooterIcon = VistaTaskDialogIcon.Information,
         FooterText = "クリーンインストールを行うと、全ての設定・データベースが消去されます。"
     });
     if (!resp.CommandButtonResult.HasValue || resp.CommandButtonResult.Value == 5)
     {
         return false;
     }
     switch (resp.CommandButtonResult.Value)
     {
         case 1:
             // remove database
             if (File.Exists(DatabaseFilePath))
             {
                 File.Delete(DatabaseFilePath);
             }
             break;
         case 2:
         case 3:
         case 4:
             // remove all
             if (ExecutionMode == ExecutionMode.Standalone)
             {
                 // remove each
                 var files = new[]
                 {
                     DatabaseFilePath, DatabaseFilePath, HashtagTempFilePath, ListUserTempFilePath,
                     Path.Combine(ConfigurationDirectoryPath, ProfileFileName)
                 };
                 var dirs = new[]
                 {
                     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(ConfigurationDirectoryPath))
                 {
                     Directory.Delete(ConfigurationDirectoryPath, true);
                 }
             }
             break;
     }
     if (resp.CommandButtonResult.Value == 4)
     {
         // force update
         var w = new AwaitDownloadingUpdateWindow();
         w.ShowDialog();
     }
     return resp.CommandButtonResult.Value < 3;
 }