From 2fe707abce023813d234b57b097a731174fd4a26 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 20 Feb 2018 15:08:22 +0200 Subject: Implemented module popping! --- .../ViewModels/MainViewVM.cs | 34 ++++++++++++++++++++++ .../ViewModels/ModuleWindowVM.cs | 30 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ModuleWindowVM.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels') 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 679ba5ff3..503532223 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -7,6 +7,9 @@ using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; using Tango.Core.Commands; using Tango.Integration.Services; using Tango.Logging; @@ -18,8 +21,10 @@ using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.StudioApplication; using Tango.MachineStudio.UI.SupervisingController; using Tango.MachineStudio.UI.Views; +using Tango.MachineStudio.UI.Windows; using Tango.PMR.Stubs; using Tango.SharedUI; +using Tango.SharedUI.Helpers; using Tango.Transport.Adapters; namespace Tango.MachineStudio.UI.ViewModels @@ -68,6 +73,11 @@ namespace Tango.MachineStudio.UI.ViewModels /// public RelayCommand StartModuleCommand { get; set; } + /// + /// Gets or sets the open module in window command. + /// + public RelayCommand OpenModuleInWindowCommand { get; set; } + /// /// Gets or sets the home command. /// @@ -157,6 +167,7 @@ namespace Tango.MachineStudio.UI.ViewModels ConnectCommand = new RelayCommand(ConnectToMachine); SignoutCommand = new RelayCommand(SignOut); DisconnectCommand = new RelayCommand(DisconnectFromMachine, (x) => ApplicationManager.IsMachineConnected && !_isDisconnecting); + OpenModuleInWindowCommand = new RelayCommand(OpenModuleInWindow); } /// @@ -302,5 +313,28 @@ namespace Tango.MachineStudio.UI.ViewModels { base.OnViewAttached(); } + + private void OpenModuleInWindow(IStudioModule module) + { + module.InNewWindow = true; + + var parent = (MainView.Self as MainView).TransitionControl.Controls.SingleOrDefault(x => x.Tag.ToString() == module.Name).Content as Grid; + + var view = parent.Children[0] as FrameworkElement; + parent.Children.Remove(view); + + ModuleWindowVM vm = new ModuleWindowVM(module, parent); + ModuleWindow window = new ModuleWindow(this, vm, view); + + window.Closing += (x, y) => + { + window.grid.Children.Remove(view); + parent.Children.Add(view); + module.InNewWindow = false; + }; + + window.Owner = MainWindow.Instance; + window.Show(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ModuleWindowVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ModuleWindowVM.cs new file mode 100644 index 000000000..a5b737b59 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ModuleWindowVM.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using Tango.MachineStudio.Common; +using Tango.SharedUI; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class ModuleWindowVM : ViewModel + { + private IStudioModule _module; + + public IStudioModule Module + { + get { return _module; } + set { _module = value; RaisePropertyChangedAuto(); } + } + + public Grid Parent { get; set; } + + public ModuleWindowVM(IStudioModule module, Grid parent) + { + Parent = parent; + Module = module; + } + } +} -- cgit v1.3.1 From db89412e079e151a3217ed2a108820ebe6ba2f30 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 20 Feb 2018 15:53:44 +0200 Subject: Improved module popout.. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../ViewModels/MachineTechViewVM.cs | 29 ++++---------- .../DefaultStudioApplicationManager.cs | 44 +++++++++++++++------ .../ViewModels/MainViewVM.cs | 43 +++++++++++++------- .../Tango.MachineStudio.UI/Views/MainView.xaml | 4 ++ 6 files changed, 72 insertions(+), 48 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 68202a1cd..01616fe12 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index bfb8f24d4..cc9745188 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index 6ccc1caa0..ad763fe54 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -18,6 +18,7 @@ using Tango.Editors; using Tango.Integration.Observables; using Tango.Integration.Observables.Enumerations; using Tango.Integration.Operators; +using Tango.MachineStudio.Common.Diagnostics; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.StudioApplication; using Tango.MachineStudio.Technician.Editors; @@ -168,19 +169,7 @@ namespace Tango.MachineStudio.Technician.ViewModels /// /// The application manager. /// The notification provider. - [PreferredConstructor] - public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider) : this(applicationManager, notificationProvider, true) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// The application manager. - /// The notification provider. - /// if set to true [load last project]. - public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, bool loadLastProject) + public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider _diagnosticsFrameProvider) { _notification = notificationProvider; _singleControllers = new Dictionary(); @@ -200,10 +189,12 @@ namespace Tango.MachineStudio.Technician.ViewModels _lastTechProjectFile = SettingsManager.Default.MachineStudio.TechnicianModule.LasTechProjectFile; - if (File.Exists(_lastTechProjectFile) && loadLastProject) + if (File.Exists(_lastTechProjectFile)) { OpenProjectFile(_lastTechProjectFile); } + + _diagnosticsFrameProvider.FrameReceived += DiagnosticsFrameProvider_FrameReceived; } #endregion @@ -218,20 +209,14 @@ namespace Tango.MachineStudio.Technician.ViewModels private void ApplicationManager_ConnectedMachineChanged(object sender, Integration.Services.IExternalBridgeClient machine) { MachineOperator = machine; - - if (MachineOperator != null) - { - MachineOperator.DiagnosticsDataAvailable -= MachineOperator_DiagnosticsDataAvailable; - MachineOperator.DiagnosticsDataAvailable += MachineOperator_DiagnosticsDataAvailable; - } } /// - /// Machines the operator diagnostics data available. + /// Handles the diagnostics frame provider data. /// /// The sender. /// The response. - private void MachineOperator_DiagnosticsDataAvailable(object sender, PushDiagnosticsResponse response) + private void DiagnosticsFrameProvider_FrameReceived(object sender, PushDiagnosticsResponse response) { PopulateDiagnosticsData(response); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index 886985c92..ee1724435 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -17,6 +17,7 @@ using Tango.Logging; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common; using Tango.Settings; +using System.Windows; namespace Tango.MachineStudio.UI.StudioApplication { @@ -29,6 +30,7 @@ namespace Tango.MachineStudio.UI.StudioApplication { private INavigationManager _navigationManager; private IStudioModuleLoader _moduleLoader; + private List _openedWindows; /// /// Initializes a new instance of the class. @@ -38,6 +40,7 @@ namespace Tango.MachineStudio.UI.StudioApplication { _moduleLoader = moduleLoader; _navigationManager = navigationManager; + _openedWindows = new List(); } /// @@ -137,35 +140,45 @@ namespace Tango.MachineStudio.UI.StudioApplication } } + foreach (var vm in ServiceLocator.Current.GetAllInstancesByBase()) + { + vm.OnShuttingDown(); + } + try { - if (ConnectedMachine != null) - { - ConnectedMachine.Disconnect().Wait(); - } + SettingsManager.SaveDefaultSettings(); } catch (Exception ex) { - LogManager.Log(ex, "Error disconnecting from machine."); + LogManager.Log(ex, "Error saving settings."); } - foreach (var vm in ServiceLocator.Current.GetAllInstancesByBase()) + _navigationManager.NavigateTo(NavigationView.ShutdownView); + + Thread.Sleep(1500); + + foreach (var window in _openedWindows) { - vm.OnShuttingDown(); + ThreadsHelper.InvokeUI(() => + { + window.Close(); + }); } try { - SettingsManager.SaveDefaultSettings(); + if (ConnectedMachine != null) + { + ConnectedMachine.Disconnect().Wait(); + } } catch (Exception ex) { - LogManager.Log(ex, "Error saving settings."); + LogManager.Log(ex, "Error disconnecting from machine."); } - _navigationManager.NavigateTo(NavigationView.ShutdownView); - - Thread.Sleep(3000); + Thread.Sleep(1500); Environment.Exit(0); @@ -196,5 +209,12 @@ namespace Tango.MachineStudio.UI.StudioApplication throw new InvalidOperationException("The module was not found or you do not have sufficient privileges."); } } + + public void RegisterOpenedWindow(Window window) + { + _openedWindows.Add(window); + + window.Closed += (x, y) => { _openedWindows.Remove(window); }; + } } } 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 503532223..da73e8eae 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -19,6 +19,7 @@ using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.StudioApplication; +using Tango.MachineStudio.UI.StudioApplication; using Tango.MachineStudio.UI.SupervisingController; using Tango.MachineStudio.UI.Views; using Tango.MachineStudio.UI.Windows; @@ -316,25 +317,39 @@ namespace Tango.MachineStudio.UI.ViewModels private void OpenModuleInWindow(IStudioModule module) { - module.InNewWindow = true; + if (module == null) return; - var parent = (MainView.Self as MainView).TransitionControl.Controls.SingleOrDefault(x => x.Tag.ToString() == module.Name).Content as Grid; + try + { + StartModule(null); - var view = parent.Children[0] as FrameworkElement; - parent.Children.Remove(view); + module.InNewWindow = true; - ModuleWindowVM vm = new ModuleWindowVM(module, parent); - ModuleWindow window = new ModuleWindow(this, vm, view); + var parent = (MainView.Self as MainView).TransitionControl.Controls.SingleOrDefault(x => x.Tag.ToString() == module.Name).Content as Grid; - window.Closing += (x, y) => - { - window.grid.Children.Remove(view); - parent.Children.Add(view); - module.InNewWindow = false; - }; + var view = parent.Children[0] as FrameworkElement; + parent.Children.Remove(view); + + ModuleWindowVM vm = new ModuleWindowVM(module, parent); + ModuleWindow window = new ModuleWindow(this, vm, view); + + window.Closing += (x, y) => + { + window.grid.Children.Remove(view); + parent.Children.Add(view); + module.InNewWindow = false; + }; - window.Owner = MainWindow.Instance; - window.Show(); + window.Owner = MainWindow.Instance; + window.Show(); + + (_applicationManager as DefaultStudioApplicationManager).RegisterOpenedWindow(window); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error popping out module " + module.Name); + _notificationProvider.ShowError("Error popping out module " + module.Name); + } } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index 19a5283c2..9a2cc37a4 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -18,6 +18,7 @@ + @@ -70,6 +71,7 @@ @@ -122,6 +124,8 @@ public RelayCommand SignoutCommand { get; set; } + /// + /// Gets or sets the exit command. + /// + public RelayCommand ExitCommand { get; set; } + + /// + /// Gets or sets the update center command. + /// + public RelayCommand UpdateCenterCommand { get; set; } + private IAuthenticationProvider _authenticationProvider; /// /// Gets or sets the authentication provider. @@ -169,6 +179,8 @@ namespace Tango.MachineStudio.UI.ViewModels SignoutCommand = new RelayCommand(SignOut); DisconnectCommand = new RelayCommand(DisconnectFromMachine, (x) => ApplicationManager.IsMachineConnected && !_isDisconnecting); OpenModuleInWindowCommand = new RelayCommand(OpenModuleInWindow); + ExitCommand = new RelayCommand(ExitApplication); + UpdateCenterCommand = new RelayCommand(NavigateToUpdateCenter); } /// @@ -315,6 +327,10 @@ namespace Tango.MachineStudio.UI.ViewModels base.OnViewAttached(); } + /// + /// Opens the module in a new window. + /// + /// The module. private void OpenModuleInWindow(IStudioModule module) { if (module == null) return; @@ -351,5 +367,21 @@ namespace Tango.MachineStudio.UI.ViewModels _notificationProvider.ShowError("Error popping out module " + module.Name); } } + + /// + /// Navigates to update center. + /// + private void NavigateToUpdateCenter() + { + _navigation.NavigateTo(NavigationView.UpdateView); + } + + /// + /// Exits the application. + /// + private void ExitApplication() + { + _applicationManager.ShutDown(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs new file mode 100644 index 000000000..014aecdb6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.Authentication; +using Tango.MachineStudio.Common.Navigation; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; +using Tango.MachineStudio.Common.Update; +using Tango.SharedUI; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public enum UpdateStatus + { + None, + CheckingForUpdate, + UpToDate, + UpdateAvailable, + Downloading, + Updating, + UpdateCompleted, + Error, + } + + public class UpdateViewVM : ViewModel + { + private INotificationProvider _notification; + private INavigationManager _navigation; + private IStudioApplicationManager _application; + private IAuthenticationProvider _authentication; + + private UpdateStatus _status; + public UpdateStatus Status + { + get { return _status; } + set { _status = value; RaisePropertyChangedAuto(); } + } + + private String _latestVersion; + public String LatestVersion + { + get { return _latestVersion; } + set { _latestVersion = value; RaisePropertyChangedAuto(); } + } + + private double _downloadProgress; + + public double DownloadProgress + { + get { return _downloadProgress; } + set { _downloadProgress = value; RaisePropertyChangedAuto(); } + } + + private double _updateProgress; + + public double UpdateProgress + { + get { return _updateProgress; } + set { _updateProgress = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand UpdateCommand { get; set; } + + public RelayCommand BackCommand { get; set; } + + public RelayCommand RestartCommand { get; set; } + + public RelayCommand TryAgainCommand { get; set; } + + public UpdateViewVM(INotificationProvider notification, IAuthenticationProvider authentication, INavigationManager navigation, IStudioApplicationManager application) + { + _notification = notification; + _navigation = navigation; + _application = application; + _authentication = authentication; + + LatestVersion = "1.0.0.2"; + Status = UpdateStatus.CheckingForUpdate; + 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); + } + + public void OnNavigatedInto() + { + CheckForUpdates(); + } + + private void CheckForUpdates() + { + Status = UpdateStatus.CheckingForUpdate; + + Task.Factory.StartNew(() => + { + var service = UpdateServiceHelper.GetUpdateServiceChannel(); + var client = service.CreateChannel(); + + CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() + { + Email = _authentication.CurrentUser.Email, + Password = _authentication.CurrentUser.Password, + Version = _application.Version, + }); + + var a = response; + + Thread.Sleep(5000); + Status = UpdateStatus.UpdateAvailable; + }); + } + + private void BackToApplication() + { + if (Status == UpdateStatus.Downloading) + { + if (!_notification.ShowQuestion("This will abort all update operations. Are you sure?")) + { + return; + } + } + + _navigation.NavigateTo(NavigationView.MainView); + Status = UpdateStatus.None; + } + + private void StartUpdate() + { + DownloadProgress = 0; + UpdateProgress = 0; + + Status = UpdateStatus.Downloading; + + Task.Factory.StartNew(() => + { + for (int i = 0; i < 100; i++) + { + DownloadProgress++; + Thread.Sleep(30); + } + + Status = UpdateStatus.Updating; + + for (int i = 0; i < 100; i++) + { + UpdateProgress++; + Thread.Sleep(30); + } + + Status = UpdateStatus.UpdateCompleted; + }); + } + + private void TryAgain() + { + CheckForUpdates(); + } + + private void RestartApplication() + { + _application.ShutDown(); + } + + protected override void RaisePropertyChangedAuto([CallerMemberName] string caller = null) + { + base.RaisePropertyChangedAuto(caller); + InvalidateRelayCommands(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml index 2478c1155..aaf4accd4 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml @@ -13,6 +13,10 @@ Machine Studio + + v + + Twine Solutions diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index 9a2cc37a4..355bdc1fd 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -126,7 +126,9 @@ + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml.cs new file mode 100644 index 000000000..75b74f65d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.UI.ViewModels; +using static Tango.SharedUI.Controls.MultiTransitionControl; + +namespace Tango.MachineStudio.UI.Views +{ + /// + /// Interaction logic for UpdateView.xaml + /// + public partial class UpdateView : UserControl, ITransitionView + { + private UpdateViewVM _vm; + + public UpdateView() + { + InitializeComponent(); + + this.Loaded += (x, y) => + { + _vm = DataContext as UpdateViewVM; + }; + } + + public void OnTransitionCompleted() + { + _vm.OnNavigatedInto(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc new file mode 100644 index 000000000..bad3e4fcd --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc @@ -0,0 +1 @@ +<%@ ServiceHost Language="C#" Debug="true" Service="Tango.MachineStudio.UpdateService.MachineStudioUpdateService" CodeBehind="MachineStudioUpdateService.svc.cs" %> \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs new file mode 100644 index 000000000..4cfea1b8a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Runtime.Serialization; +using System.ServiceModel; +using System.ServiceModel.Web; +using System.Text; +using Tango.Integration.Observables; +using Tango.Logging; +using Tango.MachineStudio.Common.Update; + +namespace Tango.MachineStudio.UpdateService +{ + public class MachineStudioUpdateService : IMachineStudioUpdateService + { + public CheckForUpdatesResponse CheckForUpdates(CheckForUpdatesRequest request) + { + LogManager.Log("Request received..."); + + try + { + CheckForUpdatesResponse response = new CheckForUpdatesResponse(); + + using (ObservablesContext db = ObservablesContext.CreateDefaultForWeb()) + { + db.Configuration.LazyLoadingEnabled = false; + + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); + + if (user != null) + { + var latestVersion = db.MachineStudioVersions.FirstOrDefault(); + Version currentVersionNumber = Version.Parse(request.Version); + + if (latestVersion != null && Version.Parse(latestVersion.Version) > currentVersionNumber) + { + response.IsUpdateAvailable = true; + + response.FtpHost = ConfigurationManager.AppSettings["FtpHost"].ToString(); + response.UserName = ConfigurationManager.AppSettings["UserName"].ToString(); + response.Password = ConfigurationManager.AppSettings["Password"].ToString(); + response.FilePath = latestVersion.FtpFilePath; + response.Version = latestVersion.Version; + } + } + else + { + throw new FaultException("Invalid user credentials."); + } + } + + return response; + } + catch (Exception ex) + { + LogManager.Log(ex); + throw new FaultException(ex.ToString()); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..6b9387721 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.MachineStudio.UpdateService")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.MachineStudio.UpdateService")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("cc6d62e9-c300-42f3-b452-79966e902b10")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj new file mode 100644 index 000000000..c9400b2d1 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj @@ -0,0 +1,142 @@ + + + + Debug + AnyCPU + + + 2.0 + {CC6D62E9-C300-42F3-B452-79966E902B10} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Tango.MachineStudio.UpdateService + Tango.MachineStudio.UpdateService + v4.6 + True + true + true + + + + + + + + true + full + false + ..\..\Build\Debug\Web\Machine Studio Update Service\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + ..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + MachineStudioUpdateService.svc + + + + + + + + + + + Web.config + + + Web.config + + + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {4206ac58-3b57-4699-8835-90bf6db01a61} + Tango.Integration + + + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} + Tango.Logging + + + {cb0b0aa2-bb24-4bca-a720-45e397684e12} + Tango.MachineStudio.Common + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 65206 + / + http://localhost:53044/ + False + False + + + False + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Debug.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Debug.config new file mode 100644 index 000000000..fae9cfefa --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config new file mode 100644 index 000000000..da6e960b8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.config new file mode 100644 index 000000000..b0d2452f0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.config @@ -0,0 +1,55 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/packages.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/packages.config new file mode 100644 index 000000000..9256e1591 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphEx.csproj b/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphEx.csproj index dd332943a..cc8eda5a4 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphEx.csproj +++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphEx.csproj @@ -34,11 +34,12 @@ pdbonly - true + false bin\Release\ - TRACE + TRACE;WPF prompt 4 + true diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs new file mode 100644 index 000000000..9d0fa2365 --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs @@ -0,0 +1,27 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.DAL.Remote.DB +{ + using System; + using System.Collections.Generic; + + public partial class MACHINE_STUDIO_VERSIONS + { + public int ID { get; set; } + public string GUID { get; set; } + public System.DateTime LAST_UPDATED { get; set; } + public string VERSION { get; set; } + public string FTP_FILE_PATH { get; set; } + public string COMMENTS { get; set; } + public string USER_GUID { get; set; } + + public virtual USER USER { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs index ebec02eab..660f660b3 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs @@ -54,6 +54,7 @@ namespace Tango.DAL.Remote.DB public virtual DbSet LINEAR_MASS_DENSITY_UNITS { get; set; } public virtual DbSet LIQUID_TYPES { get; set; } public virtual DbSet LIQUID_TYPES_RMLS { get; set; } + public virtual DbSet MACHINE_STUDIO_VERSIONS { get; set; } public virtual DbSet MACHINE_VERSIONS { get; set; } public virtual DbSet MACHINES { get; set; } public virtual DbSet MACHINES_CONFIGURATIONS { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 3f935c70f..a711bbd9e 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -391,6 +391,18 @@ + + + + + + + + + + + + @@ -1078,6 +1090,18 @@ + + + + + + + + + + + + @@ -1460,6 +1484,7 @@ + @@ -1602,6 +1627,10 @@ + + + + @@ -1749,6 +1778,7 @@ + @@ -1939,6 +1969,10 @@ + + + + @@ -2451,6 +2485,19 @@ + + + + + + + + + + + + + @@ -2804,6 +2851,7 @@ + @@ -3341,6 +3389,18 @@ + + + + + + + + + + + + @@ -3964,6 +4024,19 @@ + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index b2b732414..96cebcca5 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,61 +5,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -101,6 +102,7 @@ + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/USER.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/USER.cs index e7cfb212f..28dc2a2b8 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/USER.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/USER.cs @@ -18,6 +18,7 @@ namespace Tango.DAL.Remote.DB public USER() { this.JOBS = new HashSet(); + this.MACHINE_STUDIO_VERSIONS = new HashSet(); this.MACHINES_EVENTS = new HashSet(); this.USERS_ROLES = new HashSet(); } @@ -37,6 +38,8 @@ namespace Tango.DAL.Remote.DB [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection JOBS { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection MACHINE_STUDIO_VERSIONS { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection MACHINES_EVENTS { get; set; } public virtual ORGANIZATION ORGANIZATION { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] diff --git a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj index 58ed81525..561cf44ff 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj +++ b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj @@ -161,6 +161,9 @@ RemoteADO.tt + + RemoteADO.tt + RemoteADO.tt diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Entities/MachineStudioVersion.cs b/Software/Visual_Studio/Tango.Integration/Observables/Entities/MachineStudioVersion.cs new file mode 100644 index 000000000..9ff07682b --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Observables/Entities/MachineStudioVersion.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Xml.Serialization; +using Newtonsoft.Json; +using System.Linq; +using Tango.DAL.Remote.DB; + +namespace Tango.Integration.Observables +{ + [Table("MACHINE_STUDIO_VERSIONS")] + public partial class MachineStudioVersion : ObservableEntity + { + + protected String _version; + /// + /// Gets or sets the machinestudioversion version. + /// + [Column("VERSION")] + + public String Version + { + get + { + return _version; + } + + set + { + _version = value; RaisePropertyChanged(nameof(Version)); + } + + } + + protected String _ftpfilepath; + /// + /// Gets or sets the machinestudioversion ftp file path. + /// + [Column("FTP_FILE_PATH")] + + public String FtpFilePath + { + get + { + return _ftpfilepath; + } + + set + { + _ftpfilepath = value; RaisePropertyChanged(nameof(FtpFilePath)); + } + + } + + protected String _comments; + /// + /// Gets or sets the machinestudioversion comments. + /// + [Column("COMMENTS")] + + public String Comments + { + get + { + return _comments; + } + + set + { + _comments = value; RaisePropertyChanged(nameof(Comments)); + } + + } + + protected String _userguid; + /// + /// Gets or sets the machinestudioversion user guid. + /// + [Column("USER_GUID")] + [ForeignKey("User")] + + public String UserGuid + { + get + { + return _userguid; + } + + set + { + _userguid = value; RaisePropertyChanged(nameof(UserGuid)); + } + + } + + protected User _user; + /// + /// Gets or sets the machinestudioversion user. + /// + + [XmlIgnore] + [JsonIgnore] + public virtual User User + { + get + { + return _user; + } + + set + { + _user = value; RaisePropertyChanged(nameof(User)); + } + + } + + /// + /// Initializes a new instance of the class. + /// + public MachineStudioVersion() : base() + { + } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Entities/User.cs b/Software/Visual_Studio/Tango.Integration/Observables/Entities/User.cs index 3acfb8fb6..50ca7e775 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/Entities/User.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/Entities/User.cs @@ -198,6 +198,25 @@ namespace Tango.Integration.Observables } + protected ObservableCollection _machinestudioversions; + /// + /// Gets or sets the user machine studio versions. + /// + + public virtual ObservableCollection MachineStudioVersions + { + get + { + return _machinestudioversions; + } + + set + { + _machinestudioversions = value; RaisePropertyChanged(nameof(MachineStudioVersions)); + } + + } + protected ObservableCollection _machinesevents; /// /// Gets or sets the user machines events. @@ -265,6 +284,8 @@ namespace Tango.Integration.Observables Jobs = new ObservableCollection(); + MachineStudioVersions = new ObservableCollection(); + MachinesEvents = new ObservableCollection(); UsersRoles = new ObservableCollection(); diff --git a/Software/Visual_Studio/Tango.Integration/Observables/ObservablesContext.cs b/Software/Visual_Studio/Tango.Integration/Observables/ObservablesContext.cs index 6c5947306..37830081d 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/ObservablesContext.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/ObservablesContext.cs @@ -30,7 +30,7 @@ namespace Tango.Integration.Observables { if (!isFile) { - return String.Format("Data Source={0};Initial Catalog=Tango;Integrated Security=true", source); + return String.Format("Data Source={0};Initial Catalog=Tango;User Id=Developer;Password=1111;", source); } else { @@ -47,6 +47,11 @@ namespace Tango.Integration.Observables return new ObservablesContext(SettingsManager.Default.DataBase.SQLServerAddress, false); } + public static ObservablesContext CreateDefaultForWeb() + { + return new ObservablesContext("localhost\\SQLEXPRESS", false); + } + /// /// Gets or sets the ActionTypes. /// @@ -279,6 +284,14 @@ namespace Tango.Integration.Observables get; set; } + /// + /// Gets or sets the MachineStudioVersions. + /// + public DbSet MachineStudioVersions + { + get; set; + } + /// /// Gets or sets the MachineVersions. /// diff --git a/Software/Visual_Studio/Tango.Integration/Observables/ObservablesEntitiesAdapterExtension.cs b/Software/Visual_Studio/Tango.Integration/Observables/ObservablesEntitiesAdapterExtension.cs index 70aad649d..b8aef34f7 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/ObservablesEntitiesAdapterExtension.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/ObservablesEntitiesAdapterExtension.cs @@ -1050,6 +1050,42 @@ namespace Tango.Integration.Observables } + private ObservableCollection _machinestudioversions; + /// + /// Gets or sets the MachineStudioVersions. + /// + public ObservableCollection MachineStudioVersions + { + get + { + return _machinestudioversions; + } + + set + { + _machinestudioversions = value; RaisePropertyChanged(nameof(MachineStudioVersions)); + } + + } + + private ICollectionView _machinestudioversionsViewSource; + /// + /// Gets or sets the MachineStudioVersions View Source. + /// + public ICollectionView MachineStudioVersionsViewSource + { + get + { + return _machinestudioversionsViewSource; + } + + set + { + _machinestudioversionsViewSource = value; RaisePropertyChanged(nameof(MachineStudioVersionsViewSource)); + } + + } + private ObservableCollection _machineversions; /// /// Gets or sets the MachineVersions. @@ -2050,6 +2086,8 @@ namespace Tango.Integration.Observables LiquidTypesRmlsViewSource = CreateCollectionView(LiquidTypesRmls); + MachineStudioVersionsViewSource = CreateCollectionView(MachineStudioVersions); + MachineVersionsViewSource = CreateCollectionView(MachineVersions); MachinesViewSource = CreateCollectionView(Machines); diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj index 1a053a937..3f4d2056b 100644 --- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj +++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj @@ -113,6 +113,7 @@ + diff --git a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs index 4811280d1..9ea29b24f 100644 --- a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs +++ b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs @@ -22,7 +22,7 @@ namespace Tango.PMR.Common { static MessageTypeReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbiqREAoLTWVz", + "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbirJFAoLTWVz", "c2FnZVR5cGUSCAoETm9uZRAAEhQKEENhbGN1bGF0ZVJlcXVlc3QQAxIVChFD", "YWxjdWxhdGVSZXNwb25zZRAEEhMKD1Byb2dyZXNzUmVxdWVzdBAFEhQKEFBy", "b2dyZXNzUmVzcG9uc2UQBhIcChhTdHViQ2FydHJpZGdlUmVhZFJlcXVlc3QQ", @@ -44,32 +44,45 @@ namespace Tango.PMR.Common { "ChBTdHViVmFsdmVSZXF1ZXN0EB8SFQoRU3R1YlZhbHZlUmVzcG9uc2UQIBIb", "ChdTdHViRXh0Rmxhc2hSZWFkUmVxdWVzdBAhEhwKGFN0dWJFeHRGbGFzaFJl", "YWRSZXNwb25zZRAiEhwKGFN0dWJFeHRGbGFzaFdyaXRlUmVxdWVzdBAjEh0K", - "GVN0dWJFeHRGbGFzaFdyaXRlUmVzcG9uc2UQJBIlCiBFeHRlcm5hbEJyaWRn", - "ZVVkcERpc2NvdmVyeVBhY2tldBDoBxIfChpFeHRlcm5hbENsaWVudExvZ2lu", - "UmVxdWVzdBDpBxIgChtFeHRlcm5hbENsaWVudExvZ2luUmVzcG9uc2UQ6gcS", - "IQocRGlyZWN0U3luY2hyb25pemF0aW9uUmVxdWVzdBDrBxIiCh1EaXJlY3RT", - "eW5jaHJvbml6YXRpb25SZXNwb25zZRDsBxIcChdPdmVycmlkZURhdGFCYXNl", - "UmVxdWVzdBDtBxIdChhPdmVycmlkZURhdGFCYXNlUmVzcG9uc2UQ7gcSFQoQ", - "S2VlcEFsaXZlUmVxdWVzdBDvBxIWChFLZWVwQWxpdmVSZXNwb25zZRDwBxIb", - "ChZQdXNoRGlhZ25vc3RpY3NSZXF1ZXN0ENAPEhwKF1B1c2hEaWFnbm9zdGlj", - "c1Jlc3BvbnNlENEPEhwKF01vdG9yQWJvcnRIb21pbmdSZXF1ZXN0ENIPEh0K", - "GE1vdG9yQWJvcnRIb21pbmdSZXNwb25zZRDTDxIXChJNb3RvckhvbWluZ1Jl", - "cXVlc3QQ1A8SGAoTTW90b3JIb21pbmdSZXNwb25zZRDVDxIYChNNb3Rvckpv", - "Z2dpbmdSZXF1ZXN0ENYPEhkKFE1vdG9ySm9nZ2luZ1Jlc3BvbnNlENcPEh0K", - "GE1vdG9yQWJvcnRKb2dnaW5nUmVxdWVzdBDYDxIeChlNb3RvckFib3J0Sm9n", - "Z2luZ1Jlc3BvbnNlENkPEiAKG0Rpc3BlbnNlckFib3J0SG9taW5nUmVxdWVz", - "dBDaDxIhChxEaXNwZW5zZXJBYm9ydEhvbWluZ1Jlc3BvbnNlENsPEhsKFkRp", - "c3BlbnNlckhvbWluZ1JlcXVlc3QQ3A8SHAoXRGlzcGVuc2VySG9taW5nUmVz", - "cG9uc2UQ3Q8SHAoXRGlzcGVuc2VySm9nZ2luZ1JlcXVlc3QQ3g8SHQoYRGlz", - "cGVuc2VySm9nZ2luZ1Jlc3BvbnNlEN8PEiEKHERpc3BlbnNlckFib3J0Sm9n", - "Z2luZ1JlcXVlc3QQ4A8SIgodRGlzcGVuc2VyQWJvcnRKb2dnaW5nUmVzcG9u", - "c2UQ4Q8SGQoUU2V0RGlnaXRhbE91dFJlcXVlc3QQ4g8SGgoVU2V0RGlnaXRh", - "bE91dFJlc3BvbnNlEOMPEhkKFFRocmVhZEpvZ2dpbmdSZXF1ZXN0EOQPEhoK", - "FVRocmVhZEpvZ2dpbmdSZXNwb25zZRDlDxIeChlUaHJlYWRBYm9ydEpvZ2dp", - "bmdSZXF1ZXN0EOYPEh8KGlRocmVhZEFib3J0Sm9nZ2luZ1Jlc3BvbnNlEOcP", - "Eg8KCkpvYlJlcXVlc3QQuBcSEAoLSm9iUmVzcG9uc2UQuRcSFAoPQWJvcnRK", - "b2JSZXF1ZXN0ELoXEhUKEEFib3J0Sm9iUmVzcG9uc2UQuxdCHAoaY29tLnR3", - "aW5lLnRhbmdvLnBtci5jb21tb25iBnByb3RvMw==")); + "GVN0dWJFeHRGbGFzaFdyaXRlUmVzcG9uc2UQJBIeChpTdHViRlBHQVJlYWRC", + "YWNrUmVnUmVxdWVzdBAlEh8KG1N0dWJGUEdBUmVhZEJhY2tSZWdSZXNwb25z", + "ZRAmEh4KGlN0dWJGUEdBUmVhZFZlcnNpb25SZXF1ZXN0ECcSHwobU3R1YkZQ", + "R0FSZWFkVmVyc2lvblJlc3BvbnNlECgSGgoWU3R1Ykw2NDcwRHJpdmVyUmVx", + "dWVzdBApEhsKF1N0dWJMNjQ3MERyaXZlclJlc3BvbnNlECoSGAoUU3R1Yk1v", + "dG9ySW5pdFJlcXVlc3QQKxIZChVTdHViTW90b3JJbml0UmVzcG9uc2UQLBIX", + "ChNTdHViTW90b3JSdW5SZXF1ZXN0EC0SGAoUU3R1Yk1vdG9yUnVuUmVzcG9u", + "c2UQLhIYChRTdHViTW90b3JTdG9wUmVxdWVzdBAvEhkKFVN0dWJNb3RvclN0", + "b3BSZXNwb25zZRAwEhoKFlN0dWJNb3RvclN0YXR1c1JlcXVlc3QQMRIbChdT", + "dHViTW90b3JTdGF0dXNSZXNwb25zZRAyEhcKE1N0dWJNb3Rvck1vdlJlcXVl", + "c3QQMxIYChRTdHViTW90b3JNb3ZSZXNwb25zZRA0EhkKFVN0dWJNb3RvclNw", + "ZWVkUmVxdWVzdBA1EhoKFlN0dWJNb3RvclNwZWVkUmVzcG9uc2UQNhIcChhT", + "dHViTW90b3JQb3NpdGlvblJlcXVlc3QQNxIdChlTdHViTW90b3JQb3NpdGlv", + "blJlc3BvbnNlEDgSJQogRXh0ZXJuYWxCcmlkZ2VVZHBEaXNjb3ZlcnlQYWNr", + "ZXQQ6AcSHwoaRXh0ZXJuYWxDbGllbnRMb2dpblJlcXVlc3QQ6QcSIAobRXh0", + "ZXJuYWxDbGllbnRMb2dpblJlc3BvbnNlEOoHEiEKHERpcmVjdFN5bmNocm9u", + "aXphdGlvblJlcXVlc3QQ6wcSIgodRGlyZWN0U3luY2hyb25pemF0aW9uUmVz", + "cG9uc2UQ7AcSHAoXT3ZlcnJpZGVEYXRhQmFzZVJlcXVlc3QQ7QcSHQoYT3Zl", + "cnJpZGVEYXRhQmFzZVJlc3BvbnNlEO4HEhUKEEtlZXBBbGl2ZVJlcXVlc3QQ", + "7wcSFgoRS2VlcEFsaXZlUmVzcG9uc2UQ8AcSGwoWUHVzaERpYWdub3N0aWNz", + "UmVxdWVzdBDQDxIcChdQdXNoRGlhZ25vc3RpY3NSZXNwb25zZRDRDxIcChdN", + "b3RvckFib3J0SG9taW5nUmVxdWVzdBDSDxIdChhNb3RvckFib3J0SG9taW5n", + "UmVzcG9uc2UQ0w8SFwoSTW90b3JIb21pbmdSZXF1ZXN0ENQPEhgKE01vdG9y", + "SG9taW5nUmVzcG9uc2UQ1Q8SGAoTTW90b3JKb2dnaW5nUmVxdWVzdBDWDxIZ", + "ChRNb3RvckpvZ2dpbmdSZXNwb25zZRDXDxIdChhNb3RvckFib3J0Sm9nZ2lu", + "Z1JlcXVlc3QQ2A8SHgoZTW90b3JBYm9ydEpvZ2dpbmdSZXNwb25zZRDZDxIg", + "ChtEaXNwZW5zZXJBYm9ydEhvbWluZ1JlcXVlc3QQ2g8SIQocRGlzcGVuc2Vy", + "QWJvcnRIb21pbmdSZXNwb25zZRDbDxIbChZEaXNwZW5zZXJIb21pbmdSZXF1", + "ZXN0ENwPEhwKF0Rpc3BlbnNlckhvbWluZ1Jlc3BvbnNlEN0PEhwKF0Rpc3Bl", + "bnNlckpvZ2dpbmdSZXF1ZXN0EN4PEh0KGERpc3BlbnNlckpvZ2dpbmdSZXNw", + "b25zZRDfDxIhChxEaXNwZW5zZXJBYm9ydEpvZ2dpbmdSZXF1ZXN0EOAPEiIK", + "HURpc3BlbnNlckFib3J0Sm9nZ2luZ1Jlc3BvbnNlEOEPEhkKFFNldERpZ2l0", + "YWxPdXRSZXF1ZXN0EOIPEhoKFVNldERpZ2l0YWxPdXRSZXNwb25zZRDjDxIZ", + "ChRUaHJlYWRKb2dnaW5nUmVxdWVzdBDkDxIaChVUaHJlYWRKb2dnaW5nUmVz", + "cG9uc2UQ5Q8SHgoZVGhyZWFkQWJvcnRKb2dnaW5nUmVxdWVzdBDmDxIfChpU", + "aHJlYWRBYm9ydEpvZ2dpbmdSZXNwb25zZRDnDxIPCgpKb2JSZXF1ZXN0ELgX", + "EhAKC0pvYlJlc3BvbnNlELkXEhQKD0Fib3J0Sm9iUmVxdWVzdBC6FxIVChBB", + "Ym9ydEpvYlJlc3BvbnNlELsXQhwKGmNvbS50d2luZS50YW5nby5wbXIuY29t", + "bW9uYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Common.MessageType), }, null)); @@ -120,6 +133,26 @@ namespace Tango.PMR.Common { [pbr::OriginalName("StubExtFlashReadResponse")] StubExtFlashReadResponse = 34, [pbr::OriginalName("StubExtFlashWriteRequest")] StubExtFlashWriteRequest = 35, [pbr::OriginalName("StubExtFlashWriteResponse")] StubExtFlashWriteResponse = 36, + [pbr::OriginalName("StubFPGAReadBackRegRequest")] StubFpgareadBackRegRequest = 37, + [pbr::OriginalName("StubFPGAReadBackRegResponse")] StubFpgareadBackRegResponse = 38, + [pbr::OriginalName("StubFPGAReadVersionRequest")] StubFpgareadVersionRequest = 39, + [pbr::OriginalName("StubFPGAReadVersionResponse")] StubFpgareadVersionResponse = 40, + [pbr::OriginalName("StubL6470DriverRequest")] StubL6470DriverRequest = 41, + [pbr::OriginalName("StubL6470DriverResponse")] StubL6470DriverResponse = 42, + [pbr::OriginalName("StubMotorInitRequest")] StubMotorInitRequest = 43, + [pbr::OriginalName("StubMotorInitResponse")] StubMotorInitResponse = 44, + [pbr::OriginalName("StubMotorRunRequest")] StubMotorRunRequest = 45, + [pbr::OriginalName("StubMotorRunResponse")] StubMotorRunResponse = 46, + [pbr::OriginalName("StubMotorStopRequest")] StubMotorStopRequest = 47, + [pbr::OriginalName("StubMotorStopResponse")] StubMotorStopResponse = 48, + [pbr::OriginalName("StubMotorStatusRequest")] StubMotorStatusRequest = 49, + [pbr::OriginalName("StubMotorStatusResponse")] StubMotorStatusResponse = 50, + [pbr::OriginalName("StubMotorMovRequest")] StubMotorMovRequest = 51, + [pbr::OriginalName("StubMotorMovResponse")] StubMotorMovResponse = 52, + [pbr::OriginalName("StubMotorSpeedRequest")] StubMotorSpeedRequest = 53, + [pbr::OriginalName("StubMotorSpeedResponse")] StubMotorSpeedResponse = 54, + [pbr::OriginalName("StubMotorPositionRequest")] StubMotorPositionRequest = 55, + [pbr::OriginalName("StubMotorPositionResponse")] StubMotorPositionResponse = 56, /// ///Integration /// diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index 3674c3e73..9e1f2dd76 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -24,8 +24,8 @@ pdbonly - true - bin\Release\ + false + ..\Build\Release\ TRACE prompt 4 diff --git a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs index 0cb35199f..111c959f7 100644 --- a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs +++ b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs @@ -28,6 +28,11 @@ namespace Tango.Settings.MachineStudioSettings /// public bool RememberMe { get; set; } + /// + /// Gets or sets the update service address. + /// + public String UpdateServiceAddress { get; set; } + /// /// Gets or sets the logging categories. /// @@ -69,6 +74,7 @@ namespace Tango.Settings.MachineStudioSettings StubsModule = new StubsModule(); TechnicianModule = new TechnicianModule(); DeveloperModule = new DeveloperModule(); + UpdateServiceAddress = "http://localhost/MachineStudioUpdateService/MachineStudioUpdateService.svc"; } } } diff --git a/Software/Visual_Studio/Tango.Video/Tango.Video.csproj b/Software/Visual_Studio/Tango.Video/Tango.Video.csproj index f24d3a625..cb08ec0f9 100644 --- a/Software/Visual_Studio/Tango.Video/Tango.Video.csproj +++ b/Software/Visual_Studio/Tango.Video/Tango.Video.csproj @@ -24,18 +24,20 @@ DEBUG;TRACE prompt 4 - x86 + AnyCPU true pdbonly - true - bin\Release\ + false + ..\Build\Release\ TRACE prompt 4 + true + x86 diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index f5fe8c1c0..ec84fa212 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -127,6 +127,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Visuals", "Tango.Visu EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.DataCapture", "MachineStudio\Modules\Tango.MachineStudio.DataCapture\Tango.MachineStudio.DataCapture.csproj", "{FC337A7F-1214-41D8-9992-78092A3B961E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.UpdateService", "MachineStudio\Tango.MachineStudio.UpdateService\Tango.MachineStudio.UpdateService.csproj", "{CC6D62E9-C300-42F3-B452-79966E902B10}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1657,6 +1659,36 @@ Global {FC337A7F-1214-41D8-9992-78092A3B961E}.Release|x64.Build.0 = Release|Any CPU {FC337A7F-1214-41D8-9992-78092A3B961E}.Release|x86.ActiveCfg = Release|Any CPU {FC337A7F-1214-41D8-9992-78092A3B961E}.Release|x86.Build.0 = Release|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Debug|ARM.ActiveCfg = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Debug|ARM.Build.0 = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Debug|ARM64.Build.0 = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Debug|x64.ActiveCfg = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Debug|x64.Build.0 = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Debug|x86.ActiveCfg = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Debug|x86.Build.0 = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.DefaultBuild|ARM.ActiveCfg = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.DefaultBuild|ARM.Build.0 = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.DefaultBuild|ARM64.ActiveCfg = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.DefaultBuild|ARM64.Build.0 = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.DefaultBuild|x64.ActiveCfg = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.DefaultBuild|x64.Build.0 = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.DefaultBuild|x86.ActiveCfg = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.DefaultBuild|x86.Build.0 = Debug|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|Any CPU.Build.0 = Release|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|ARM.ActiveCfg = Release|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|ARM.Build.0 = Release|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|ARM64.ActiveCfg = Release|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|ARM64.Build.0 = Release|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|x64.ActiveCfg = Release|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|x64.Build.0 = Release|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|x86.ActiveCfg = Release|Any CPU + {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1692,5 +1724,6 @@ Global {37E4CEAB-B54B-451F-B535-04CF7DA9C459} = {EC62BC9C-F2FE-4333-B7E4-110E38D43958} {5B954D98-4020-4AC6-939F-C52B5646E8E6} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} {FC337A7F-1214-41D8-9992-78092A3B961E} = {B2AF4F3F-2828-47C3-8F3E-A0EA0BD66FF8} + {CC6D62E9-C300-42F3-B452-79966E902B10} = {57DF2A95-5DDD-4830-A4AF-B484B59C7C2B} EndGlobalSection EndGlobal -- cgit v1.3.1 From f991f37a95a854e9b2aada52982d83ddaa0ca1b0 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 21 Feb 2018 21:30:45 +0200 Subject: Working on macine studio update center.. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Tango.MachineStudio.Common.csproj | 1 + .../Update/FileStreamWrapper.cs | 56 ++++++ .../Tango.MachineStudio.UI/App.config | 2 +- .../Tango.MachineStudio.UI.csproj | 9 + .../ViewModels/UpdateViewVM.cs | 189 ++++++++++++++++++--- .../Tango.MachineStudio.UI/packages.config | 2 + 8 files changed, 235 insertions(+), 24 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/FileStreamWrapper.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 736485c47..88080fdb5 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 02e398280..7991ff3a9 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index a363ffc44..1c4a9d465 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -100,6 +100,7 @@ + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/FileStreamWrapper.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/FileStreamWrapper.cs new file mode 100644 index 000000000..83fbdf7ea --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/FileStreamWrapper.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Update +{ + /// + /// Represents a FileStream Wrapper dedicated for delivering Read/Write progress callbacks. + /// + /// + public class FileStreamWrapper : FileStream + { + private Action _callback; + + /// + /// Initializes a new instance of the class. + /// + /// Name of the file. + /// The mode. + /// The callback. + public FileStreamWrapper(String fileName, FileMode mode, Action callback) : base(fileName, mode) + { + _callback = callback; + } + + /// + /// Writes a block of bytes to the file stream. + /// + /// The buffer containing data to write to the stream. + /// The zero-based byte offset in from which to begin copying bytes to the stream. + /// The maximum number of bytes to write. + public override void Write(byte[] array, int offset, int count) + { + _callback?.Invoke(Length); + base.Write(array, offset, count); + } + + /// + /// Reads a block of bytes from the stream and writes the data in a given buffer. + /// + /// When this method returns, contains the specified byte array with the values between and ( + - 1 replaced by the bytes read from the current source. + /// The byte offset in at which the read bytes will be placed. + /// The maximum number of bytes to read. + /// + /// The total number of bytes read into the buffer. This might be less than the number of bytes requested if that number of bytes are not currently available, or zero if the end of the stream is reached. + /// + public override int Read(byte[] array, int offset, int count) + { + _callback?.Invoke(Position); + return base.Read(array, offset, count); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config index 0bd51a469..1a0e57043 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config @@ -9,7 +9,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 0ad97907b..61ea92566 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -48,6 +48,9 @@ ..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll + + ..\..\packages\FluentFTP.19.1.2\lib\net45\FluentFTP.dll + ..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll @@ -63,6 +66,9 @@ ..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + ..\..\packages\Ionic.Zip.1.9.1.8\lib\Ionic.Zip.dll + ..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll @@ -94,6 +100,7 @@ True + ..\..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll @@ -110,7 +117,9 @@ ..\..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll + + 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 014aecdb6..e5f3d7a46 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -1,11 +1,17 @@ -using System; +using FluentFTP; +using Ionic.Zip; +using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Runtime.CompilerServices; +using System.ServiceModel; using System.Text; using System.Threading; using System.Threading.Tasks; using Tango.Core.Commands; +using Tango.Core.Helpers; +using Tango.Logging; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; @@ -29,10 +35,13 @@ namespace Tango.MachineStudio.UI.ViewModels public class UpdateViewVM : ViewModel { + private String _appPath = AppDomain.CurrentDomain.BaseDirectory; + private INotificationProvider _notification; private INavigationManager _navigation; private IStudioApplicationManager _application; private IAuthenticationProvider _authentication; + private CheckForUpdatesResponse _updateInfo; private UpdateStatus _status; public UpdateStatus Status @@ -85,6 +94,11 @@ namespace Tango.MachineStudio.UI.ViewModels BackCommand = new RelayCommand(BackToApplication, () => Status != UpdateStatus.Updating); RestartCommand = new RelayCommand(RestartApplication, () => Status == UpdateStatus.UpdateCompleted); TryAgainCommand = new RelayCommand(TryAgain, () => Status == UpdateStatus.CheckingForUpdate); + + foreach (var file in Directory.GetFiles(_appPath, "*.tmp")) + { + PathHelper.TryDeleteFile(file); + } } public void OnNavigatedInto() @@ -96,22 +110,47 @@ namespace Tango.MachineStudio.UI.ViewModels { Status = UpdateStatus.CheckingForUpdate; + ChannelFactory service = null; + Task.Factory.StartNew(() => { - var service = UpdateServiceHelper.GetUpdateServiceChannel(); - var client = service.CreateChannel(); - - CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() + try { - Email = _authentication.CurrentUser.Email, - Password = _authentication.CurrentUser.Password, - Version = _application.Version, - }); + Thread.Sleep(2000); + + service = UpdateServiceHelper.GetUpdateServiceChannel(); + var client = service.CreateChannel(); - var a = response; + CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() + { + Email = _authentication.CurrentUser.Email, + Password = _authentication.CurrentUser.Password, + Version = _application.Version, + }); - Thread.Sleep(5000); - Status = UpdateStatus.UpdateAvailable; + if (response.IsUpdateAvailable) + { + _updateInfo = response; + Status = UpdateStatus.UpdateAvailable; + LatestVersion = response.Version; + } + else + { + Status = UpdateStatus.UpToDate; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error while checking for version update!"); + Status = UpdateStatus.Error; + } + finally + { + if (service != null) + { + service.Close(); + } + } }); } @@ -128,7 +167,7 @@ namespace Tango.MachineStudio.UI.ViewModels _navigation.NavigateTo(NavigationView.MainView); Status = UpdateStatus.None; } - + private void StartUpdate() { DownloadProgress = 0; @@ -138,24 +177,128 @@ namespace Tango.MachineStudio.UI.ViewModels Task.Factory.StartNew(() => { - for (int i = 0; i < 100; i++) + try { - DownloadProgress++; - Thread.Sleep(30); - } + var tempFile = PathHelper.GetTempFilePath() + ".zip"; + + LogManager.Log("Creating temporary file " + tempFile); + + int fileSize = 0; + + using (FileStreamWrapper fs = new FileStreamWrapper(tempFile, FileMode.Create, (current) => + { + InvokeUINow(() => + { + Thread.Sleep(10); + DownloadProgress = ((double)current / (double)fileSize) * 100d; + }); + })) + { + using (FtpClient ftp = new FtpClient(_updateInfo.FtpHost, _updateInfo.UserName, _updateInfo.Password)) + { + LogManager.Log("Connecting to FTP site: " + _updateInfo.FtpHost); + ftp.ConnectAsync().Wait(); + LogManager.Log("Retrieving download size..."); + fileSize = (int)ftp.GetFileSize(_updateInfo.FilePath); + LogManager.Log("Download size: " + fileSize + " bytes."); + LogManager.Log("Starting download..."); + ftp.DownloadAsync(fs, _updateInfo.FilePath).Wait(); + } + } + + + Status = UpdateStatus.Updating; - Status = UpdateStatus.Updating; + int lockedCounter = 0; - for (int i = 0; i < 100; i++) + using (ZipFile zip = ZipFile.Read(tempFile)) + { + int currentEntry = 0; + + zip.ExtractProgress += (x, args) => + { + if (args.EventType == ZipProgressEventType.Extracting_AfterExtractEntry) + { + LogManager.Log("Extracting " + Path.GetFileName(args.CurrentEntry.FileName)); + UpdateProgress = ((double)(currentEntry++) / (double)zip.Entries.Count) * 100d; + } + }; + + foreach (ZipEntry entry in zip) + { + Thread.Sleep(10); + + string newPath = Path.Combine(_appPath, entry.FileName); + + try + { + if (entry.IsDirectory) + { + Directory.CreateDirectory(newPath); + } + else + { + if (!IsFileLocked(newPath)) + { + entry.Extract(_appPath, ExtractExistingFileAction.OverwriteSilently); + } + else + { + LogManager.Log("File locked: " + entry.FileName); + File.Move(newPath, newPath + ".tmp"); + entry.Extract(_appPath, ExtractExistingFileAction.OverwriteSilently); + LogManager.Log("Performed overwrite bypass... (changes will be applied on restart)."); + lockedCounter++; + } + } + } + catch + { + LogManager.Log("Could not overwrite " + entry.FileName); + } + } + } + + Status = UpdateStatus.UpdateCompleted; + } + catch (Exception ex) { - UpdateProgress++; - Thread.Sleep(30); + LogManager.Log(ex, "Error while extracting update package."); + Status = UpdateStatus.Error; } - - Status = UpdateStatus.UpdateCompleted; }); } + /// + /// Determines whether [is file locked] [the specified file]. + /// + /// The file. + + -- cgit v1.3.1 From 042b4d3e7b0af729792ca20e086756c36d2f5768 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 22 Feb 2018 13:23:49 +0200 Subject: Working on machine studio update center ! --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Tango.MachineStudio.Common.csproj | 3 + .../Update/IMachineStudioUpdateService.cs | 9 + .../Update/UploadCompletedRequest.cs | 16 ++ .../Update/UploadVersionRequest.cs | 25 +++ .../Update/UploadVersionResponse.cs | 31 ++++ .../Tango.MachineStudio.Publisher/App.config | 14 ++ .../Tango.MachineStudio.Publisher/App.xaml | 9 + .../Tango.MachineStudio.Publisher/App.xaml.cs | 17 ++ .../Images/machine-trans.png | Bin 0 -> 45618 bytes .../Images/update.png | Bin 0 -> 5289 bytes .../Tango.MachineStudio.Publisher/MainWindow.xaml | 71 ++++++++ .../MainWindow.xaml.cs | 35 ++++ .../Tango.MachineStudio.Publisher/MainWindowVM.cs | 201 +++++++++++++++++++++ .../Properties/AssemblyInfo.cs | 7 + .../Properties/Resources.Designer.cs | 71 ++++++++ .../Properties/Resources.resx | 117 ++++++++++++ .../Properties/Settings.Designer.cs | 30 +++ .../Properties/Settings.settings | 7 + .../Tango.MachineStudio.Publisher.csproj | 139 ++++++++++++++ .../Tango.MachineStudio.Publisher/packages.config | 5 + .../ViewModels/UpdateViewVM.cs | 67 ++----- .../Tango.MachineStudio.UI/Views/UpdateView.xaml | 2 +- .../MachineStudioUpdateService.svc.cs | 130 ++++++++++++- .../Tango.MachineStudio.Updater/App.config | 6 + .../Tango.MachineStudio.Updater/App.xaml | 9 + .../Tango.MachineStudio.Updater/App.xaml.cs | 24 +++ .../Images/machine-trans.png | Bin 0 -> 45618 bytes .../Tango.MachineStudio.Updater/Images/update.png | Bin 0 -> 5289 bytes .../Tango.MachineStudio.Updater/MainWindow.xaml | 37 ++++ .../Tango.MachineStudio.Updater/MainWindow.xaml.cs | 146 +++++++++++++++ .../Properties/AssemblyInfo.cs | 17 ++ .../Properties/Resources.Designer.cs | 71 ++++++++ .../Properties/Resources.resx | 117 ++++++++++++ .../Properties/Settings.Designer.cs | 30 +++ .../Properties/Settings.settings | 7 + .../Tango.MachineStudio.Updater.csproj | 110 +++++++++++ .../Tango.MachineStudio.Updater/app.manifest | 76 ++++++++ Software/Visual_Studio/Tango.sln | 66 +++++++ 40 files changed, 1666 insertions(+), 56 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.config create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Images/machine-trans.png create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Images/update.png create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Resources.resx create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Settings.settings create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/packages.config create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.config create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Images/machine-trans.png create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Images/update.png create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Resources.resx create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Settings.settings create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Tango.MachineStudio.Updater.csproj create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/app.manifest (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 88080fdb5..9f4b4ca30 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 7991ff3a9..81e9f8578 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index 1c4a9d465..abe888d73 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -103,6 +103,9 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs index 7b7269d23..53e49e52c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs @@ -13,5 +13,14 @@ namespace Tango.MachineStudio.Common.Update { [OperationContract] CheckForUpdatesResponse CheckForUpdates(CheckForUpdatesRequest request); + + [OperationContract] + UploadVersionResponse UploadVersion(UploadVersionRequest request); + + [OperationContract] + void NotifyUploadCompleted(UploadCompletedRequest request); + + [OperationContract] + String GetLatestVersion(); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs new file mode 100644 index 000000000..ce6096792 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Update +{ + [DataContract] + public class UploadCompletedRequest + { + [DataMember] + public String Token { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs new file mode 100644 index 000000000..71ce04f1f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Update +{ + [DataContract] + public class UploadVersionRequest + { + [DataMember] + public String Email { get; set; } + + [DataMember] + public String Password { get; set; } + + [DataMember] + public String Version { get; set; } + + [DataMember] + public String Comments { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs new file mode 100644 index 000000000..36dc3df30 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Update +{ + [DataContract] + public class UploadVersionResponse + { + [DataMember] + public String FtpHost { get; set; } + + [DataMember] + public String FilePath { get; set; } + + [DataMember] + public String FileName { get; set; } + + [DataMember] + public String UserName { get; set; } + + [DataMember] + public String Password { get; set; } + + [DataMember] + public String Token { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.config new file mode 100644 index 000000000..f2af62f53 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.xaml new file mode 100644 index 000000000..582bd0034 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.xaml.cs new file mode 100644 index 000000000..499f46424 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace Tango.MachineStudio.Publisher +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Images/machine-trans.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Images/machine-trans.png new file mode 100644 index 000000000..a7cf65852 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Images/machine-trans.png differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Images/update.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Images/update.png new file mode 100644 index 000000000..a82777414 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Images/update.png differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml new file mode 100644 index 000000000..9f592ca6d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + MACHINE STUDIO + + + + + + + + Latest Version: + + + + Current Version: + + + + + Email: + + + + + Password: + + + + Comments + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml.cs new file mode 100644 index 000000000..db1922d59 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Publisher +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + + ContentRendered += MainWindow_ContentRendered; + } + + private void MainWindow_ContentRendered(object sender, EventArgs e) + { + DataContext = new MainWindowVM(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs new file mode 100644 index 000000000..2ceb36994 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs @@ -0,0 +1,201 @@ +using FluentFTP; +using Ionic.Zip; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.ServiceModel; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using Tango.Core.Commands; +using Tango.Core.Cryptography; +using Tango.MachineStudio.Common.Update; +using Tango.Settings; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Publisher +{ + public class MainWindowVM : ViewModel + { + private String _appPath = AppDomain.CurrentDomain.BaseDirectory; + private ChannelFactory _service; + private IMachineStudioUpdateService _client; + + private String _email; + + public String Email + { + get { return _email; } + set { _email = value; RaisePropertyChangedAuto(); } + } + + private String _password; + + public String Password + { + get { return _password; } + set { _password = value; RaisePropertyChangedAuto(); } + } + + private String _comments; + + public String Comments + { + get { return _comments; } + set { _comments = value; RaisePropertyChangedAuto(); } + } + + private String _currentVersion; + + public String CurrentVersion + { + get { return _currentVersion; } + set { _currentVersion = value; RaisePropertyChangedAuto(); } + } + + private String _latestVersion; + + public String LatestVersion + { + get { return _latestVersion; } + set { _latestVersion = value; RaisePropertyChangedAuto(); } + } + + private double _maxProgress; + + public double MaxProgress + { + get { return _maxProgress; } + set { _maxProgress = value; RaisePropertyChangedAuto(); } + } + + private double _progress; + + public double Progress + { + get { return _progress; } + set { _progress = value; RaisePropertyChangedAuto(); } + } + + private bool _isUpdating; + + public bool IsUpdating + { + get { return _isUpdating; } + set { _isUpdating = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand PublishCommand { get; set; } + + public MainWindowVM() + { + MaxProgress = 100; + + PublishCommand = new RelayCommand(Publish, () => Email != null && Password != null && Comments != null && CurrentVersion != null && LatestVersion != null && !IsUpdating && Version.Parse(CurrentVersion) > Version.Parse(LatestVersion)); + + _service = UpdateServiceHelper.GetUpdateServiceChannel(); + _client = _service.CreateChannel(); + + UpdateVersions(); + + Email = SettingsManager.Default.MachineStudio.LastLoginEmail; + + var cryptographer = new Rfc2898Cryptographer(); + Password = cryptographer.Decrypt(SettingsManager.Default.MachineStudio.LastLoginPassword); + } + + private void UpdateVersions() + { + CurrentVersion = typeof(MainWindowVM).Assembly.GetName().Version.ToString(); + LatestVersion = _client.GetLatestVersion(); + } + + private void Publish() + { + MaxProgress = 100; + Progress = 0; + + Task.Factory.StartNew(() => + { + IsUpdating = true; + + try + { + var response = _client.UploadVersion(new UploadVersionRequest() + { + Email = Email, + Password = Password, + Version = CurrentVersion.ToString(), + Comments = Comments, + }); + + String tempFile = Path.Combine(Path.GetTempPath(), response.FileName); + + using (ZipFile zip = new ZipFile()) + { + zip.AddDirectory(Path.Combine(_appPath, "x86"), "/x86"); + zip.AddDirectory(Path.Combine(_appPath, "x64"), "/x64"); + + foreach (var file in Directory.GetFiles(_appPath, "*.*", SearchOption.TopDirectoryOnly)) + { + zip.AddFile(file, "/"); + } + + zip.SaveProgress += (x, e) => + { + MaxProgress = e.TotalBytesToTransfer; + Progress = e.BytesTransferred; + }; + + zip.Save(tempFile); + } + + Progress = 0; + MaxProgress = 100; + + FileStreamWrapper fs = null; + + using (fs = new FileStreamWrapper(tempFile, FileMode.Open, (current) => + { + InvokeUINow(() => + { + Thread.Sleep(10); + Progress = ((double)current / (double)fs.Length) * 100d; + }); + })) + { + using (FtpClient ftp = new FtpClient(response.FtpHost, response.UserName, response.Password)) + { + ftp.ConnectAsync().Wait(); + ftp.UploadAsync(fs, response.FilePath, FtpExists.Overwrite, true).Wait(); + } + } + + UpdateVersions(); + } + catch (Exception ex) + { + ShowError(ex.Message.ToString()); + } + finally + { + IsUpdating = false; + } + }); + } + + private void ShowError(String error) + { + MessageBox.Show(error, "Machine Studio Publisher", MessageBoxButton.OK, MessageBoxImage.Error); + } + + protected override void RaisePropertyChangedAuto([CallerMemberName] string caller = null) + { + base.RaisePropertyChangedAuto(caller); + InvalidateRelayCommands(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..8d5288e3c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)] +[assembly: AssemblyTitle("Tango - Machine Studio Publish Utility")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Resources.Designer.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Resources.Designer.cs new file mode 100644 index 000000000..2538f4ffa --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.Publisher.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.MachineStudio.Publisher.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Resources.resx b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Settings.Designer.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Settings.Designer.cs new file mode 100644 index 000000000..3fae4577d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.Publisher.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Settings.settings b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj new file mode 100644 index 000000000..00bbe3539 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj @@ -0,0 +1,139 @@ + + + + + Debug + AnyCPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A} + WinExe + Tango.MachineStudio.Publisher + Tango.MachineStudio.Publisher + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + ..\..\Build\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\FluentFTP.19.1.2\lib\net45\FluentFTP.dll + + + ..\..\packages\Ionic.Zip.1.9.1.8\lib\Ionic.Zip.dll + + + + + + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + GlobalVersionInfo.cs + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + + + + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + {cb0b0aa2-bb24-4bca-a720-45e397684e12} + Tango.MachineStudio.Common + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/packages.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/packages.config new file mode 100644 index 000000000..83ee077e4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file 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 e5f3d7a46..c24204fb6 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -2,6 +2,7 @@ using Ionic.Zip; using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.CompilerServices; @@ -42,6 +43,7 @@ namespace Tango.MachineStudio.UI.ViewModels private IStudioApplicationManager _application; private IAuthenticationProvider _authentication; private CheckForUpdatesResponse _updateInfo; + private String _newPackageTempFolder; private UpdateStatus _status; public UpdateStatus Status @@ -94,11 +96,6 @@ namespace Tango.MachineStudio.UI.ViewModels BackCommand = new RelayCommand(BackToApplication, () => Status != UpdateStatus.Updating); RestartCommand = new RelayCommand(RestartApplication, () => Status == UpdateStatus.UpdateCompleted); TryAgainCommand = new RelayCommand(TryAgain, () => Status == UpdateStatus.CheckingForUpdate); - - foreach (var file in Directory.GetFiles(_appPath, "*.tmp")) - { - PathHelper.TryDeleteFile(file); - } } public void OnNavigatedInto() @@ -117,7 +114,7 @@ namespace Tango.MachineStudio.UI.ViewModels try { Thread.Sleep(2000); - + service = UpdateServiceHelper.GetUpdateServiceChannel(); var client = service.CreateChannel(); @@ -167,7 +164,7 @@ namespace Tango.MachineStudio.UI.ViewModels _navigation.NavigateTo(NavigationView.MainView); Status = UpdateStatus.None; } - + private void StartUpdate() { DownloadProgress = 0; @@ -209,7 +206,7 @@ namespace Tango.MachineStudio.UI.ViewModels Status = UpdateStatus.Updating; - int lockedCounter = 0; + _newPackageTempFolder = PathHelper.GetTempFolderPath(); using (ZipFile zip = ZipFile.Read(tempFile)) { @@ -228,7 +225,7 @@ namespace Tango.MachineStudio.UI.ViewModels { Thread.Sleep(10); - string newPath = Path.Combine(_appPath, entry.FileName); + string newPath = Path.Combine(_newPackageTempFolder, entry.FileName); try { @@ -238,23 +235,12 @@ namespace Tango.MachineStudio.UI.ViewModels } else { - if (!IsFileLocked(newPath)) - { - entry.Extract(_appPath, ExtractExistingFileAction.OverwriteSilently); - } - else - { - LogManager.Log("File locked: " + entry.FileName); - File.Move(newPath, newPath + ".tmp"); - entry.Extract(_appPath, ExtractExistingFileAction.OverwriteSilently); - LogManager.Log("Performed overwrite bypass... (changes will be applied on restart)."); - lockedCounter++; - } + entry.Extract(_newPackageTempFolder, ExtractExistingFileAction.OverwriteSilently); } } catch { - LogManager.Log("Could not overwrite " + entry.FileName); + LogManager.Log("Could not extract file " + entry.FileName); } } } @@ -269,36 +255,6 @@ namespace Tango.MachineStudio.UI.ViewModels }); } - /// - /// Determines whether [is file locked] [the specified file]. - /// - /// The file. Updating Machine Studio, please wait... - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs index 4cfea1b8a..e573a0d77 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; using System.Configuration; +using System.IO; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; +using Tango.Core.Helpers; using Tango.Integration.Observables; using Tango.Logging; using Tango.MachineStudio.Common.Update; @@ -14,6 +16,26 @@ namespace Tango.MachineStudio.UpdateService { public class MachineStudioUpdateService : IMachineStudioUpdateService { + private class PendingUpload + { + public String Token { get; set; } + + public String Version { get; set; } + + public String UserGuid { get; set; } + + public String Comments { get; set; } + + public String FilePath { get; set; } + } + + private static List _pendingUploads; + + MachineStudioUpdateService() + { + _pendingUploads = new List(); + } + public CheckForUpdatesResponse CheckForUpdates(CheckForUpdatesRequest request) { LogManager.Log("Request received..."); @@ -31,9 +53,9 @@ namespace Tango.MachineStudio.UpdateService if (user != null) { var latestVersion = db.MachineStudioVersions.FirstOrDefault(); - Version currentVersionNumber = Version.Parse(request.Version); + Version currentVersion = Version.Parse(request.Version); - if (latestVersion != null && Version.Parse(latestVersion.Version) > currentVersionNumber) + if (latestVersion != null && Version.Parse(latestVersion.Version) > currentVersion) { response.IsUpdateAvailable = true; @@ -58,5 +80,109 @@ namespace Tango.MachineStudio.UpdateService throw new FaultException(ex.ToString()); } } + + public UploadVersionResponse UploadVersion(UploadVersionRequest request) + { + try + { + UploadVersionResponse response = new UploadVersionResponse(); + + using (ObservablesContext db = ObservablesContext.CreateDefaultForWeb()) + { + db.Configuration.LazyLoadingEnabled = false; + + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); + + if (user != null) + { + var latestVersion = db.MachineStudioVersions.FirstOrDefault(); + Version currentVersion = Version.Parse(request.Version); + + String newVersionFileName = Path.GetRandomFileName() + ".zip"; + + String newVersionFilePath = "/machine studio versions/" + newVersionFileName; + + if (currentVersion > Version.Parse(latestVersion.Version)) + { + response.FtpHost = ConfigurationManager.AppSettings["FtpHost"].ToString(); + response.UserName = ConfigurationManager.AppSettings["UserName"].ToString(); + response.Password = ConfigurationManager.AppSettings["Password"].ToString(); + response.FilePath = newVersionFilePath; + response.FileName = newVersionFileName; + response.Token = Guid.NewGuid().ToString(); + + _pendingUploads.Add(new PendingUpload() + { + UserGuid = user.Guid, + Comments = request.Comments, + Token = response.Token, + Version = request.Version, + FilePath = response.FilePath, + }); + } + else + { + throw new FaultException("New version must be greater than latest version."); + } + } + else + { + throw new FaultException("Invalid user credentials."); + } + } + + return response; + } + catch (Exception ex) + { + LogManager.Log(ex); + throw new FaultException(ex.ToString()); + } + } + + public void NotifyUploadCompleted(UploadCompletedRequest request) + { + try + { + PendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); + + if (upload != null) + { + _pendingUploads.RemoveAll(x => x.Token == upload.Token); + + using (ObservablesContext db = ObservablesContext.CreateDefaultForWeb()) + { + db.Configuration.LazyLoadingEnabled = false; + + db.MachineStudioVersions.Add(new MachineStudioVersion() + { + Comments = upload.Comments, + FtpFilePath = upload.FilePath, + UserGuid = upload.UserGuid, + Version = upload.Version + }); + + db.SaveChanges(); + } + } + else + { + throw new FaultException("Invalid Token."); + } + } + catch (Exception ex) + { + LogManager.Log(ex); + throw new FaultException(ex.ToString()); + } + } + + public string GetLatestVersion() + { + using (ObservablesContext db = ObservablesContext.CreateDefaultForWeb()) + { + return db.MachineStudioVersions.FirstOrDefault().Version; + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.config new file mode 100644 index 000000000..8324aa6ff --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.xaml new file mode 100644 index 000000000..c3e63550a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.xaml.cs new file mode 100644 index 000000000..6c3dce868 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.xaml.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace Tango.MachineStudio.Updater +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + public static String[] StartupArgs { get; private set; } + + protected override void OnStartup(StartupEventArgs e) + { + StartupArgs = e.Args; + base.OnStartup(e); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Images/machine-trans.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Images/machine-trans.png new file mode 100644 index 000000000..a7cf65852 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Images/machine-trans.png differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Images/update.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Images/update.png new file mode 100644 index 000000000..a82777414 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Images/update.png differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml new file mode 100644 index 000000000..a8d428650 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + MACHINE STUDIO + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml.cs new file mode 100644 index 000000000..e0e9e7f0d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Threading; + +namespace Tango.MachineStudio.Updater +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + private String _appPath = AppDomain.CurrentDomain.BaseDirectory; + private String _msProcessName = "Tango.MachineStudio.UI"; + private String _sourceFolder = App.StartupArgs.FirstOrDefault(); + + public MainWindow() + { + if (!Directory.Exists(_sourceFolder)) + { + ShowError("This update utility can only be executed by Machine Studio."); + Environment.Exit(0); + } + + InitializeComponent(); + ContentRendered += MainWindow_ContentRendered; + } + + private void MainWindow_ContentRendered(object sender, EventArgs e) + { + Update(); + } + + private void Update() + { + EnsureMachineStudioIsDown(); + ReplaceFiles(); + StartMachineStudio(); + Environment.Exit(0); + } + + private void StartMachineStudio() + { + txtStatus.Text = "Update completed. Starting Machine Studio..."; + DoEvents(); + Thread.Sleep(1000); + + Process p = new Process(); + p.StartInfo.FileName = _appPath + "\\" + _msProcessName + ".exe"; + p.StartInfo.LoadUserProfile = true; + p.StartInfo.UseShellExecute = true; + p.Start(); + } + + private void ReplaceFiles() + { + int maxProgress = Directory.GetFiles(_sourceFolder, "*.*", SearchOption.AllDirectories).Length; + int progress = 0; + + foreach (string dirPath in Directory.GetDirectories(_sourceFolder, "*", SearchOption.AllDirectories)) + { + try + { + Directory.CreateDirectory(dirPath.Replace(_sourceFolder, _appPath)); + } + catch (Exception ex) + { + ShowError("Could not create directory " + Path.GetFileName(dirPath) + Environment.NewLine + ex.Message); + } + } + + foreach (string newPath in Directory.GetFiles(_sourceFolder, "*.*", SearchOption.AllDirectories)) + { + try + { + txtStatus.Text = "Copying file " + Path.GetFileName(newPath); + DoEvents(); + + File.Copy(newPath, newPath.Replace(_sourceFolder, _appPath), true); + + prog.Maximum = maxProgress; + prog.Value = progress++; + DoEvents(); + + Thread.Sleep(30); + } + catch (Exception ex) + { + ShowError("Could not create file " + Path.GetFileName(newPath) + Environment.NewLine + ex.Message); + } + } + } + + private void EnsureMachineStudioIsDown() + { + Process appProcess = null; + + int tries = 0; + + do + { + appProcess = Process.GetProcessesByName(_msProcessName).FirstOrDefault(); + + if (appProcess != null) + { + tries++; + appProcess.Kill(); + Thread.Sleep(1000); + } + + if (tries > 10) + { + ShowError("The main Machine Studio process seems to in a frozen state. Please restart your computer and try again."); + Environment.Exit(0); + } + + } while (appProcess != null); + } + + /// + /// Forces UI rendering. + /// + private void DoEvents() + { + Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { })); + } + + private void ShowError(String error) + { + MessageBox.Show(error, "Machine Studio Update", MessageBoxButton.OK, MessageBoxImage.Error); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..7a79d1042 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/AssemblyInfo.cs @@ -0,0 +1,17 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +[assembly: AssemblyTitle("Tango - Machine Studio Updater Utility")] +[assembly: ComVisible(false)] + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Resources.Designer.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Resources.Designer.cs new file mode 100644 index 000000000..5061e6179 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.Updater.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.MachineStudio.Updater.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Resources.resx b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Settings.Designer.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Settings.Designer.cs new file mode 100644 index 000000000..a18e7398e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.Updater.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Settings.settings b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Tango.MachineStudio.Updater.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Tango.MachineStudio.Updater.csproj new file mode 100644 index 000000000..c77222c03 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/Tango.MachineStudio.Updater.csproj @@ -0,0 +1,110 @@ + + + + + Debug + AnyCPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3} + WinExe + Tango.MachineStudio.Updater + Tango.MachineStudio.Updater + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + ..\..\Build\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + app.manifest + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + GlobalVersionInfo.cs + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/app.manifest b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/app.manifest new file mode 100644 index 000000000..467015914 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/app.manifest @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index ec84fa212..5ef4a806b 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -129,6 +129,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.DataCap EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.UpdateService", "MachineStudio\Tango.MachineStudio.UpdateService\Tango.MachineStudio.UpdateService.csproj", "{CC6D62E9-C300-42F3-B452-79966E902B10}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.Updater", "MachineStudio\Tango.MachineStudio.Updater\Tango.MachineStudio.Updater.csproj", "{844787CE-F409-4F18-BCCC-F3809ECB86F3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.Publisher", "MachineStudio\Tango.MachineStudio.Publisher\Tango.MachineStudio.Publisher.csproj", "{E711CD86-89C1-432C-9C60-BFF30BBBFB3A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1689,6 +1693,66 @@ Global {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|x64.Build.0 = Release|Any CPU {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|x86.ActiveCfg = Release|Any CPU {CC6D62E9-C300-42F3-B452-79966E902B10}.Release|x86.Build.0 = Release|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Debug|ARM.ActiveCfg = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Debug|ARM.Build.0 = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Debug|ARM64.Build.0 = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Debug|x64.ActiveCfg = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Debug|x64.Build.0 = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Debug|x86.ActiveCfg = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Debug|x86.Build.0 = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.DefaultBuild|ARM.ActiveCfg = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.DefaultBuild|ARM.Build.0 = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.DefaultBuild|ARM64.ActiveCfg = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.DefaultBuild|ARM64.Build.0 = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.DefaultBuild|x64.ActiveCfg = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.DefaultBuild|x64.Build.0 = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.DefaultBuild|x86.ActiveCfg = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.DefaultBuild|x86.Build.0 = Debug|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Release|Any CPU.Build.0 = Release|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Release|ARM.ActiveCfg = Release|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Release|ARM.Build.0 = Release|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Release|ARM64.ActiveCfg = Release|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Release|ARM64.Build.0 = Release|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Release|x64.ActiveCfg = Release|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Release|x64.Build.0 = Release|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Release|x86.ActiveCfg = Release|Any CPU + {844787CE-F409-4F18-BCCC-F3809ECB86F3}.Release|x86.Build.0 = Release|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Debug|ARM.ActiveCfg = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Debug|ARM.Build.0 = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Debug|ARM64.Build.0 = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Debug|x64.ActiveCfg = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Debug|x64.Build.0 = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Debug|x86.ActiveCfg = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Debug|x86.Build.0 = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.DefaultBuild|ARM.ActiveCfg = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.DefaultBuild|ARM.Build.0 = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.DefaultBuild|ARM64.ActiveCfg = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.DefaultBuild|ARM64.Build.0 = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.DefaultBuild|x64.ActiveCfg = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.DefaultBuild|x64.Build.0 = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.DefaultBuild|x86.ActiveCfg = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.DefaultBuild|x86.Build.0 = Debug|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|Any CPU.Build.0 = Release|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|ARM.ActiveCfg = Release|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|ARM.Build.0 = Release|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|ARM64.ActiveCfg = Release|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|ARM64.Build.0 = Release|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|x64.ActiveCfg = Release|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|x64.Build.0 = Release|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|x86.ActiveCfg = Release|Any CPU + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1725,5 +1789,7 @@ Global {5B954D98-4020-4AC6-939F-C52B5646E8E6} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} {FC337A7F-1214-41D8-9992-78092A3B961E} = {B2AF4F3F-2828-47C3-8F3E-A0EA0BD66FF8} {CC6D62E9-C300-42F3-B452-79966E902B10} = {57DF2A95-5DDD-4830-A4AF-B484B59C7C2B} + {844787CE-F409-4F18-BCCC-F3809ECB86F3} = {57DF2A95-5DDD-4830-A4AF-B484B59C7C2B} + {E711CD86-89C1-432C-9C60-BFF30BBBFB3A} = {57DF2A95-5DDD-4830-A4AF-B484B59C7C2B} EndGlobalSection EndGlobal -- cgit v1.3.1 From 2b781099f7cb08d6a5b9363b9079fab5be108541 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 23 Feb 2018 23:14:27 +0200 Subject: Implemented machine studio periodical update checking. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Notifications/DefaultNotificationProvider.cs | 6 +- .../ViewModels/MainViewVM.cs | 72 +++++++++++++++++++++ .../ViewModels/UpdateViewVM.cs | 42 +++++++++--- .../Tango.MachineStudio.UI/Views/LoadingView.xaml | 10 +-- .../Tango.MachineStudio.UI/Views/MainView.xaml | 40 ++++++++++-- .../Tango.MachineStudio.UI/Views/UpdateView.xaml | 12 +++- .../MachineStudioUpdateService.svc.cs | 6 ++ .../Tango.Integration/Observables/Partials/User.cs | 6 +- 10 files changed, 168 insertions(+), 26 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 2535145b6..cf21e36de 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 24e3fbc9c..881504581 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs index 1ea22c587..4dd17b500 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -225,7 +225,7 @@ namespace Tango.MachineStudio.UI.Notifications /// The message. public void ShowError(string message) { - ShowMessageBox(PackIconKind.Exclamation, Brushes.Red, message, false); + ShowMessageBox(PackIconKind.AlertOctagon, Brushes.Red, message, false); } /// @@ -234,7 +234,7 @@ namespace Tango.MachineStudio.UI.Notifications /// The message. public void ShowInfo(string message) { - ShowMessageBox(PackIconKind.Information, Brushes.Black, message, false); + ShowMessageBox(PackIconKind.CommentAlertOutline, Brushes.Black, message, false); } /// @@ -253,7 +253,7 @@ namespace Tango.MachineStudio.UI.Notifications /// The message. public void ShowWarning(string message) { - ShowMessageBox(PackIconKind.Exclamation, Brushes.DarkOrange, message, false); + ShowMessageBox(PackIconKind.AlertOutline, Brushes.DarkOrange, message, false); } /// 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; /// /// Gets or sets the current loaded module. @@ -149,6 +152,38 @@ namespace Tango.MachineStudio.UI.ViewModels set { _applicationManager = value; RaisePropertyChangedAuto(); } } + private bool _isUpdateAvailable; + /// + /// Gets or sets a value indicating whether a new version update is available. + /// + public bool IsUpdateAvailable + { + get { return _isUpdateAvailable; } + set { _isUpdateAvailable = value; RaisePropertyChangedAuto(); } + } + + private String _latestVersion; + /// + /// Gets or sets the latest version. + /// + public String LatestVersion + { + get { return _latestVersion; } + set { _latestVersion = value; RaisePropertyChangedAuto(); } + } + + + private bool _disableCheckForUpdates; + /// + /// Gets or sets a value indicating whether [disable check for updates]. + /// + public bool DisableCheckForUpdates + { + get { return _disableCheckForUpdates; } + set { _disableCheckForUpdates = value; RaisePropertyChangedAuto(); } + } + + /// /// Initializes a new instance of the class. /// @@ -181,6 +216,43 @@ namespace Tango.MachineStudio.UI.ViewModels OpenModuleInWindowCommand = new RelayCommand(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)); + } } /// 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().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); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml index aaf4accd4..5f65100df 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml @@ -13,15 +13,17 @@ Machine Studio - - v - - Twine Solutions Loading, please wait... + + + + v + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index 355bdc1fd..19c0c47df 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -19,6 +19,7 @@ + @@ -153,14 +154,8 @@ - + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml index a08bcbddb..dabbaab94 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml @@ -17,7 +17,7 @@ - + @@ -68,10 +68,14 @@ - New version is available! + + Version + + is available! + - A new version of Machine Studio is available to download + A new version of Machine Studio is available for download Click 'Update' to start the update process. @@ -111,6 +115,8 @@ Updating Machine Studio, please wait... + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs index bf737c7a9..2f001b281 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs @@ -48,6 +48,12 @@ namespace Tango.MachineStudio.UpdateService { db.Configuration.LazyLoadingEnabled = false; + //Load relation first... + db.Roles.ToList(); + db.Permissions.ToList(); + db.UsersRoles.ToList(); + db.RolesPermissions.ToList(); + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); if (user != null && user.HasPermission(Permissions.RunMachineStudio)) diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/User.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/User.cs index b70aae8a4..4f498372c 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/User.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/User.cs @@ -33,7 +33,11 @@ namespace Tango.Integration.Observables /// public List Permissions { - get { return UsersRoles.Select(x => x.Role).ToList().SelectMany(x => x.RolesPermissions).Select(x => (Permissions)x.Permission.Code).ToList(); } + + get + { + return UsersRoles.Select(x => x.Role).ToList().SelectMany(x => x.RolesPermissions).Select(x => (Permissions)x.Permission.Code).ToList(); + } } } } -- cgit v1.3.1