aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs72
1 files changed, 72 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
index acd9e7925..fb2cd5c82 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
@@ -6,6 +6,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@@ -19,6 +20,7 @@ using Tango.MachineStudio.Common.Modules;
using Tango.MachineStudio.Common.Navigation;
using Tango.MachineStudio.Common.Notifications;
using Tango.MachineStudio.Common.StudioApplication;
+using Tango.MachineStudio.Common.Update;
using Tango.MachineStudio.UI.StudioApplication;
using Tango.MachineStudio.UI.SupervisingController;
using Tango.MachineStudio.UI.Views;
@@ -39,6 +41,7 @@ namespace Tango.MachineStudio.UI.ViewModels
private IStudioModule _currentModule;
private INavigationManager _navigation;
private bool _isDisconnecting;
+ private Thread _updateCheckThread;
/// <summary>
/// Gets or sets the current loaded module.
@@ -149,6 +152,38 @@ namespace Tango.MachineStudio.UI.ViewModels
set { _applicationManager = value; RaisePropertyChangedAuto(); }
}
+ private bool _isUpdateAvailable;
+ /// <summary>
+ /// Gets or sets a value indicating whether a new version update is available.
+ /// </summary>
+ public bool IsUpdateAvailable
+ {
+ get { return _isUpdateAvailable; }
+ set { _isUpdateAvailable = value; RaisePropertyChangedAuto(); }
+ }
+
+ private String _latestVersion;
+ /// <summary>
+ /// Gets or sets the latest version.
+ /// </summary>
+ public String LatestVersion
+ {
+ get { return _latestVersion; }
+ set { _latestVersion = value; RaisePropertyChangedAuto(); }
+ }
+
+
+ private bool _disableCheckForUpdates;
+ /// <summary>
+ /// Gets or sets a value indicating whether [disable check for updates].
+ /// </summary>
+ public bool DisableCheckForUpdates
+ {
+ get { return _disableCheckForUpdates; }
+ set { _disableCheckForUpdates = value; RaisePropertyChangedAuto(); }
+ }
+
+
/// <summary>
/// Initializes a new instance of the <see cref="MainViewVM"/> class.
/// </summary>
@@ -181,6 +216,43 @@ namespace Tango.MachineStudio.UI.ViewModels
OpenModuleInWindowCommand = new RelayCommand<IStudioModule>(OpenModuleInWindow);
ExitCommand = new RelayCommand(ExitApplication);
UpdateCenterCommand = new RelayCommand(NavigateToUpdateCenter);
+
+ _updateCheckThread = new Thread(UpdateCheckThreadMethod);
+ _updateCheckThread.IsBackground = true;
+ _updateCheckThread.Start();
+ }
+
+ private void UpdateCheckThreadMethod()
+ {
+ while (!DisableCheckForUpdates)
+ {
+ Thread.Sleep(TimeSpan.FromMinutes(1));
+
+ try
+ {
+ if (_authenticationProvider.CurrentUser != null)
+ {
+ var service = UpdateServiceHelper.GetUpdateServiceChannel();
+ var client = service.CreateChannel();
+
+ CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest()
+ {
+ Email = _authenticationProvider.CurrentUser.Email,
+ Password = _authenticationProvider.CurrentUser.Password,
+ Version = _applicationManager.Version,
+ });
+
+ IsUpdateAvailable = response.IsUpdateAvailable;
+ LatestVersion = response.Version;
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error in version update periodic check...");
+ }
+
+ Thread.Sleep(TimeSpan.FromMinutes(4));
+ }
}
/// <summary>