12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Threading.Tasks;
- using System.Windows;
- namespace Vinno.FIS.Sonopost.Upgrade
- {
-
-
-
- public partial class App : Application
- {
- protected override void OnStartup(StartupEventArgs e)
- {
- base.OnStartup(e);
- if (e.Args.Length == 3)
- {
- var upgradePath = e.Args[0];
- var targetPath = e.Args[1];
- var deleteAllFiles = false;
- bool.TryParse(e.Args[2], out deleteAllFiles);
- StartUpgradeThread(upgradePath, targetPath, deleteAllFiles);
- }
- else
- {
- Process.GetCurrentProcess().Kill();
- }
- }
- private void StartUpgradeThread(string upgradePath, string targetPath, bool deleteAllFiles)
- {
- Task.Run(() =>
- {
- var upgrade = new UpgradeOperator(upgradePath, targetPath, deleteAllFiles);
- try
- {
- upgrade.StartUpgrade();
- }
- catch (Exception ex)
- {
- File.AppendAllText("UpgradeLog.txt", ex.ToString());
- upgrade.InstallSonopostTask();
- }
- finally
- {
- Process.GetCurrentProcess().Kill();
- }
- });
- }
- }
- }
|