aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
diff options
context:
space:
mode:
authorRoy <roy.mail.net@gmail.com>2018-02-23 23:14:27 +0200
committerRoy <roy.mail.net@gmail.com>2018-02-23 23:14:27 +0200
commit2b781099f7cb08d6a5b9363b9079fab5be108541 (patch)
tree41cd2acfa8047cea0399bfc6f46ab851b484aaac /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
parentfadf83a50071ffba21db05eceff10c51c18f5fb3 (diff)
downloadTango-2b781099f7cb08d6a5b9363b9079fab5be108541.tar.gz
Tango-2b781099f7cb08d6a5b9363b9079fab5be108541.zip
Implemented machine studio periodical update checking.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs42
1 files changed, 34 insertions, 8 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
index c24204fb6..6be4ba4ca 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
@@ -1,5 +1,6 @@
using FluentFTP;
using Ionic.Zip;
+using Microsoft.Practices.ServiceLocation;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -75,6 +76,14 @@ namespace Tango.MachineStudio.UI.ViewModels
set { _updateProgress = value; RaisePropertyChangedAuto(); }
}
+ private String _currentUpdateFile;
+
+ public String CurrentUpdateFile
+ {
+ get { return _currentUpdateFile; }
+ set { _currentUpdateFile = value; RaisePropertyChanged(nameof(CurrentUpdateFile)); }
+ }
+
public RelayCommand UpdateCommand { get; set; }
public RelayCommand BackCommand { get; set; }
@@ -95,7 +104,7 @@ namespace Tango.MachineStudio.UI.ViewModels
UpdateCommand = new RelayCommand(StartUpdate, () => Status == UpdateStatus.UpdateAvailable);
BackCommand = new RelayCommand(BackToApplication, () => Status != UpdateStatus.Updating);
RestartCommand = new RelayCommand(RestartApplication, () => Status == UpdateStatus.UpdateCompleted);
- TryAgainCommand = new RelayCommand(TryAgain, () => Status == UpdateStatus.CheckingForUpdate);
+ TryAgainCommand = new RelayCommand(TryAgain, () => Status == UpdateStatus.Error);
}
public void OnNavigatedInto()
@@ -174,10 +183,10 @@ namespace Tango.MachineStudio.UI.ViewModels
Task.Factory.StartNew(() =>
{
+ var tempFile = PathHelper.GetTempFilePath() + ".zip";
+
try
{
- var tempFile = PathHelper.GetTempFilePath() + ".zip";
-
LogManager.Log("Creating temporary file " + tempFile);
int fileSize = 0;
@@ -235,6 +244,7 @@ namespace Tango.MachineStudio.UI.ViewModels
}
else
{
+ CurrentUpdateFile = Path.GetFileName(entry.FileName);
entry.Extract(_newPackageTempFolder, ExtractExistingFileAction.OverwriteSilently);
}
}
@@ -245,6 +255,7 @@ namespace Tango.MachineStudio.UI.ViewModels
}
}
+ ServiceLocator.Current.GetInstance<MainViewVM>().DisableCheckForUpdates = true;
Status = UpdateStatus.UpdateCompleted;
}
catch (Exception ex)
@@ -252,6 +263,10 @@ namespace Tango.MachineStudio.UI.ViewModels
LogManager.Log(ex, "Error while extracting update package.");
Status = UpdateStatus.Error;
}
+ finally
+ {
+ PathHelper.TryDeleteFile(tempFile);
+ }
});
}
@@ -262,11 +277,22 @@ namespace Tango.MachineStudio.UI.ViewModels
private void RestartApplication()
{
- Process p = new Process();
- p.StartInfo.FileName = _appPath + "\\Tango.MachineStudio.Updater.exe";
- p.StartInfo.UseShellExecute = true;
- p.StartInfo.Arguments = _newPackageTempFolder;
- p.Start();
+ try
+ {
+ Process p = new Process();
+ p.StartInfo.FileName = _appPath + "\\Tango.MachineStudio.Updater.exe";
+ p.StartInfo.UseShellExecute = true;
+ p.StartInfo.Arguments = _newPackageTempFolder;
+ p.Start();
+ }
+ catch (Exception ex)
+ {
+ if (ex.Message == "The operation was canceled by the user")
+ {
+ _notification.ShowWarning("It seems like you refused to invoke our update utility. This prevents Machine Studio from completing the update process!");
+ return;
+ }
+ }
Environment.Exit(0);
}