diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2020-01-27 09:19:11 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2020-01-27 09:19:11 +0200 |
| commit | ddda6089bff56e80703c8d2dce297919edc58bf1 (patch) | |
| tree | 7702c5cf169124d522eacc7f1a9e0878373baedd /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels | |
| parent | 1d4d327571d4c0c9f4e17411551bd4dae1e2aed0 (diff) | |
| parent | bf2f3245339b9fd9148a2ad25b5ba3320e970cc1 (diff) | |
| download | Tango-ddda6089bff56e80703c8d2dce297919edc58bf1.tar.gz Tango-ddda6089bff56e80703c8d2dce297919edc58bf1.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels')
7 files changed, 382 insertions, 99 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs index 16f6938a0..40479895d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs @@ -95,11 +95,11 @@ namespace Tango.MachineStudio.UI.ViewModels using (ObservablesContext db = ObservablesContext.CreateDefault()) { - var jobs = await db.Jobs.Include(x => x.JobRuns).Where(x => x.MachineGuid == ApplicationManager.Machine.Guid).ToListAsync(); + var jobRuns = await db.JobRuns.Where(x => x.MachineGuid == ApplicationManager.Machine.Guid).ToListAsync(); - TotalMachineWorkTime = TimeSpan.FromHours(jobs.SelectMany(x => x.JobRuns).Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours)).ToString(@"hh\:mm\:ss"); + TotalMachineWorkTime = TimeSpan.FromHours(jobRuns.Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours)).ToString(@"hh\:mm\:ss"); - int meters = (int)jobs.SelectMany(x => x.JobRuns).Select(x => x.EndPosition).Sum(); + int meters = (int)jobRuns.Select(x => x.EndPosition).Sum(); TotalMachineMeters = $"{meters.ToString("N0")} meters"; } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs index f1f4f69c0..e96f0ab62 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs @@ -3,12 +3,76 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Timers; +using System.Windows.Threading; using Tango.SharedUI; namespace Tango.MachineStudio.UI.ViewModels { public class ConnectionLostViewVM : DialogViewVM { + private Timer _reconnectTimer; + public String Exception { get; set; } + + private int _reconnectinSeconds; + public int ReconnectinSeconds + { + get { return _reconnectinSeconds; } + set { _reconnectinSeconds = value; RaisePropertyChangedAuto(); } + } + + private bool _autoReconnect; + public bool AutoReconnect + { + get { return _autoReconnect; } + set { _autoReconnect = value; RaisePropertyChangedAuto(); } + } + + + public ConnectionLostViewVM() : base() + { + ReconnectinSeconds = 10; + _reconnectTimer = new Timer(); + _reconnectTimer.Interval = TimeSpan.FromSeconds(1).TotalMilliseconds; + _reconnectTimer.Elapsed += _reconnectTimer_Elapsed; + } + + private void _reconnectTimer_Elapsed(object sender, ElapsedEventArgs e) + { + ReconnectinSeconds--; + + if (ReconnectinSeconds == -1) + { + _reconnectTimer.Stop(); + + InvokeUI(() => + { + Accept(); + }); + } + } + + public override void OnShow() + { + base.OnShow(); + + if (AutoReconnect) + { + _reconnectTimer.Start(); + } + } + + protected override void Accept() + { + _reconnectTimer.Stop(); + base.Accept(); + } + + protected override void Cancel() + { + base.Cancel(); + _reconnectTimer.Stop(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs index e45c29f73..365c1db49 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs @@ -207,6 +207,11 @@ namespace Tango.MachineStudio.UI.ViewModels } } + protected override bool CanOK() + { + return base.CanOK() && CanClose; + } + private async void AbortUpgrade() { CanClose = true; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs index cf34764d9..c00caf72a 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -22,6 +22,9 @@ using Tango.MachineStudio.UI.Messages; using Tango.Settings; using Tango.SharedUI; using Tango.Web; +using SimpleValidator.Extensions; +using Tango.BL.Entities; +using System.Data.Entity; namespace Tango.MachineStudio.UI.ViewModels { @@ -38,6 +41,7 @@ namespace Tango.MachineStudio.UI.ViewModels private Rfc2898Cryptographer cryptographer; private MachineStudioSettings _settings; private MachineStudioWebClient _machineStudioWebClient; + private TaskCompletionSource<object> _updatePasswordCompletionSource; private String _email; /// <summary> @@ -82,6 +86,14 @@ namespace Tango.MachineStudio.UI.ViewModels set { _isLogging = value; RaisePropertyChangedAuto(); } } + private bool _showLogginDetails; + public bool ShowLoggingDetails + { + get { return _showLogginDetails; } + set { _showLogginDetails = value; RaisePropertyChangedAuto(); } + } + + private bool _rememberMe; /// <summary> /// Gets or sets a value indicating whether to remember the last user email and password. @@ -102,6 +114,47 @@ namespace Tango.MachineStudio.UI.ViewModels set { _enableSlotSelection = value; RaisePropertyChangedAuto(); } } + private bool _isActiveDirectory; + public bool IsActiveDirectory + { + get { return _isActiveDirectory; } + set { _isActiveDirectory = value; RaisePropertyChangedAuto(); if (value) IsStandardUser = false; } + } + + private bool _isStandardUser; + public bool IsStandardUser + { + get { return _isStandardUser; } + set { _isStandardUser = value; RaisePropertyChangedAuto(); if (value) IsActiveDirectory = false; } + } + + private String _progressLog; + public String ProgressLog + { + get { return _progressLog; } + set { _progressLog = value; RaisePropertyChangedAuto(); } + } + + private bool _isChangingPassword; + public bool IsChangingPassword + { + get { return _isChangingPassword; } + set { _isChangingPassword = value; RaisePropertyChangedAuto(); } + } + + private String _newPassword1; + public String NewPassword1 + { + get { return _newPassword1; } + set { _newPassword1 = value; RaisePropertyChangedAuto(); } + } + + private String _newPassword2; + public String NewPassword2 + { + get { return _newPassword2; } + set { _newPassword2 = value; RaisePropertyChangedAuto(); } + } /// <summary> /// Gets or sets the login command. @@ -109,6 +162,11 @@ namespace Tango.MachineStudio.UI.ViewModels public RelayCommand LoginCommand { get; set; } /// <summary> + /// Gets or sets the update password command. + /// </summary> + public RelayCommand UpdatePasswordCommand { get; set; } + + /// <summary> /// Initializes a new instance of the <see cref="LoginViewVM"/> class. /// </summary> /// <param name="authenticationProvider">The authentication provider.</param> @@ -117,6 +175,7 @@ namespace Tango.MachineStudio.UI.ViewModels public LoginViewVM(MachineStudioWebClient machineStudioWebClient, IAuthenticationProvider authenticationProvider, INavigationManager navigationManager, INotificationProvider notificationProvider, IEventLogger eventLogger) { EnableSlotSelection = true; + ShowLoggingDetails = true; _machineStudioWebClient = machineStudioWebClient; _settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>(); @@ -126,12 +185,22 @@ namespace Tango.MachineStudio.UI.ViewModels _authenticationProvider = authenticationProvider; _eventLogger = eventLogger; LoginCommand = new RelayCommand(Login, () => !IsLogging); + UpdatePasswordCommand = new RelayCommand(UpdatePassword, () => IsChangingPassword); cryptographer = new Rfc2898Cryptographer(); Email = _settings.LastLoginEmail; DeploymentSlot = _settings.DeploymentSlot; RememberMe = _settings.RememberMe; + if (_settings.LastLoginMethod == LoginMethod.ActiveDirectory) + { + IsActiveDirectory = true; + } + else + { + IsStandardUser = true; + } + try { Password = cryptographer.Decrypt(_settings.LastLoginPassword); @@ -152,13 +221,22 @@ namespace Tango.MachineStudio.UI.ViewModels try { IsLogging = true; + ShowLoggingDetails = false; + NewPassword1 = String.Empty; + NewPassword2 = String.Empty; + InvalidateRelayCommands(); + LoginMethod loginMethod = IsActiveDirectory ? LoginMethod.ActiveDirectory : LoginMethod.StandardUser; + await Task.Factory.StartNew(() => { _settings.DeploymentSlot = DeploymentSlot; - LoginResponse result = _authenticationProvider.Login(Email, Password, _settings.ByPassEnvironmentVersionCheck).Response; + LoginResponse result = _authenticationProvider.Login(Email, Password, loginMethod, _settings.ByPassEnvironmentVersionCheck, (progress) => + { + ProgressLog = progress; + }).Response; if (result.VersionChangeRequired && !_settings.ByPassEnvironmentVersionCheck) { @@ -177,31 +255,115 @@ namespace Tango.MachineStudio.UI.ViewModels return; } + if (result.PasswordChangeRequired) + { + StartUpdatePassword().Task.GetAwaiter().GetResult(); + Password = NewPassword1; + Login(); + return; + } + _eventLogger.Log(EventTypes.APPLICATION_STARTED, "Application Started!"); _navigationManager.NavigateTo(NavigationView.MainView); _settings.LastLoginEmail = Email; _settings.RememberMe = RememberMe; + _settings.LastLoginMethod = loginMethod; _settings.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null; _settings.Save(); _eventLogger.Log("User logged in."); EnableSlotSelection = false; + + IsLogging = false; + ShowLoggingDetails = true; + IsChangingPassword = false; + InvalidateRelayCommands(); }); } catch (Exception ex) { + IsLogging = false; + ShowLoggingDetails = true; + IsChangingPassword = false; + InvalidateRelayCommands(); LogManager.Log(ex, "Login Error."); _notificationProvider.ShowError($"An error occurred while trying to perform the log-in operation.\n{ex.FlattenMessage()}"); } - finally + } + } + + private TaskCompletionSource<object> StartUpdatePassword() + { + _updatePasswordCompletionSource = new TaskCompletionSource<object>(); + + IsChangingPassword = true; + ShowLoggingDetails = false; + IsLogging = false; + InvalidateRelayCommands(); + + return _updatePasswordCompletionSource; + } + + private async void UpdatePassword() + { + await Task.Factory.StartNew(() => + { + try + { + if (!Validate()) + { + return; + } + + ProgressLog = "Updating your password..."; + IsChangingPassword = false; + IsLogging = true; + InvalidateRelayCommands(); + + using (var db = ObservablesContext.CreateDefault()) + { + var user = db.Users.SingleOrDefault(x => x.Email == Email); + user.PasswordChangeRequired = false; + user.Password = User.GetPasswordHash(NewPassword1); + db.SaveChanges(); + } + + _updatePasswordCompletionSource.SetResult(true); + } + catch (Exception ex) { IsLogging = false; + IsChangingPassword = false; + ShowLoggingDetails = true; InvalidateRelayCommands(); + _updatePasswordCompletionSource.SetException(ex); + } + finally + { + InvalidateRelayCommands(); + } + }); + } + + protected override void OnValidating() + { + if (IsChangingPassword) + { + if (!NewPassword1.IsBetweenLength(6, 8)) + { + InsertError(nameof(NewPassword1), "Password must be 6 to 8 characters long"); + } + + if (NewPassword1 != NewPassword2) + { + InsertError(nameof(NewPassword2), "Passwords do not match"); } } + + base.OnValidating(); } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs index d1f3cc69e..5e44bf43d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; +using Tango.Core.DI; using Tango.Emulations.ExternalBridge; using Tango.Integration.ExternalBridge; using Tango.MachineStudio.Common; @@ -52,7 +53,18 @@ namespace Tango.MachineStudio.UI.ViewModels { if (_scanner == null) { + var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>(); _scanner = new ExternalBridgeScanner(); + _scanner.SignalRConfiguration.Enabled = settings.EnableExternalBridgeSignalR; + if (App.StartupArgs.Contains("-webDebug")) + { + _scanner.SignalRConfiguration.Address = "http://localhost:1111/"; //settings.DeploymentSlot.ToAddress(); + } + else + { + _scanner.SignalRConfiguration.Address = settings.DeploymentSlot.ToAddress(); + } + _scanner.SignalRConfiguration.Hub = settings.ExternalBridgeSignalRHub; } EnableDiagnostics = true; @@ -108,6 +120,8 @@ namespace Tango.MachineStudio.UI.ViewModels catch (Exception ex) { LogManager.Log(ex, "Error starting external bridge scanner."); + Cancel(); + TangoIOC.Default.GetInstance<INotificationProvider>().ShowError($"There is a problem with machine scanning.\n{ex.FlattenMessage()}"); } } 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 b22d65192..2a00386dc 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -58,6 +58,8 @@ namespace Tango.MachineStudio.UI.ViewModels private IEventLogger _eventLogger; private MachineStudioSettings _settings; private MachineStudioWebClient _machineStudioWebClient; + private IExternalBridgeSecureClient _reconnectionMachine; + private MachineLoginViewVM _reconnectionMachineConfig; /// <summary> /// Gets or sets the current loaded module. @@ -344,6 +346,13 @@ namespace Tango.MachineStudio.UI.ViewModels AboutCommand = new RelayCommand(ShowAboutDialog); ChangeAppThemeCommand = new RelayCommand<MachineStudioTheme>(ChangeTheme); + + ApplicationManager.ReconnectionRequired += ApplicationManager_ReconnectionRequired; + } + + private void ApplicationManager_ReconnectionRequired(object sender, EventArgs e) + { + ConnectToMachineSecure(_reconnectionMachine, _reconnectionMachineConfig); } private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable<MachinesEvent> e) @@ -455,70 +464,23 @@ namespace Tango.MachineStudio.UI.ViewModels x.SelectedMachine.EnableEventsNotification = x.EnableDiagnostics; x.SelectedMachine.UseKeepAlive = x.EnableKeepAlive; x.SelectedMachine.JobUnitsMethod = _settings.JobUnitsMethod; + x.SelectedMachine.JobRunsLogger.JobSource = BL.Enumerations.JobSource.Remote; if (x.SelectedMachine is ExternalBridgeTcpClient) { x.SelectedMachine.As<ExternalBridgeTcpClient>().EnableApplicationLogs = x.EnableApplicationLogs; + x.SelectedMachine.RequestTimeout = _settings.ExternalBridgeRequestTimeout; + x.SelectedMachine.ContinuousRequestTimeout = _settings.ExternalBridgeContinuousRequestTimeout; } - if (x.SelectedMachine.RequiresAuthentication) + if (x.SelectedMachine.Adapter is TcpTransportAdapter) { - //Check machine exist on my database first - if (x.SelectedMachine.Machine == null) - { - _notificationProvider.ShowError($"The specified machine '{x.SelectedMachine.SerialNumber}' could not be found on the database. Aborting connection."); - return; - } - - _notificationProvider.ShowModalDialog<MachineLoginViewVM>(async (login) => - { - using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.ToString() + "...")) - { - try - { - await x.SelectedMachine.As<IExternalBridgeSecureClient>().Connect(new PMR.Integration.ExternalBridgeLoginRequest() - { - AppID = "Machine Studio", - HostName = Environment.MachineName, - Password = login.Password, - UserGuid = AuthenticationProvider.CurrentUser.Guid, - Intent = login.Intent, - }); - - ApplicationManager.SetConnectedMachine(x.SelectedMachine); - (x.SelectedMachine as IExternalBridgeSecureClient).SessionClosed += (_, __) => - { - InvokeUI(() => - { - _notificationProvider.ShowError("The remote machine has closed the current session. Machine disconnected."); - ApplicationManager.SetConnectedMachine(null); - }); - }; - PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine }); - _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber)); - - //if (x.UploadHardwareConfiguration) - //{ - // UploadHardwareConfiguration(false); - //} - - } - catch (ResponseErrorException ex) - { - LogManager.Log(ex); - _eventLogger.Log(ex, "Error connecting to machine " + x.SelectedMachine.SerialNumber); - _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Container.ErrorMessage); - } - catch (Exception ex) - { - LogManager.Log(ex); - _eventLogger.Log(ex, "Error connecting to machine " + x.SelectedMachine.SerialNumber); - _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Message); - } + (x.SelectedMachine.Adapter as TcpTransportAdapter).WriteMode = _settings.TcpTransportAdapterWriteMode; + } - InvalidateRelayCommands(); - } - }); + if (x.SelectedMachine.RequiresAuthentication) + { + ConnectToMachineSecure(x.SelectedMachine as IExternalBridgeSecureClient); } else { @@ -631,6 +593,77 @@ namespace Tango.MachineStudio.UI.ViewModels InvalidateRelayCommands(); } + private async void ConnectToMachineSecure(IExternalBridgeSecureClient machine, MachineLoginViewVM config) + { + using (NotificationProvider.PushTaskItem("Connecting to machine " + machine.ToString() + "...")) + { + try + { + await machine.Connect(new PMR.Integration.ExternalBridgeLoginRequest() + { + AppID = "Machine Studio", + HostName = Environment.MachineName, + Password = config.Password, + UserGuid = AuthenticationProvider.CurrentUser.Guid, + Intent = config.Intent, + }); + + _reconnectionMachine = machine; + _reconnectionMachineConfig = config; + + ApplicationManager.SetConnectedMachine(machine); + machine.SessionClosed -= Machine_SessionClosed; + machine.SessionClosed += Machine_SessionClosed; + PostMessage(new MachineConnectionChangedMessage() { Machine = machine }); + _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", machine.SerialNumber)); + + //if (x.UploadHardwareConfiguration) + //{ + // UploadHardwareConfiguration(false); + //} + + } + catch (ResponseErrorException ex) + { + LogManager.Log(ex); + _eventLogger.Log(ex, "Error connecting to machine " + machine.SerialNumber); + _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Container.ErrorMessage); + } + catch (Exception ex) + { + LogManager.Log(ex); + _eventLogger.Log(ex, "Error connecting to machine " + machine.SerialNumber); + _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Message); + } + + InvalidateRelayCommands(); + } + } + + private void ConnectToMachineSecure(IExternalBridgeSecureClient machine) + { + //Check machine exist on my database first + if (machine.Machine == null) + { + _notificationProvider.ShowError($"The specified machine '{machine.SerialNumber}' could not be found on the database. Aborting connection."); + return; + } + + _notificationProvider.ShowModalDialog<MachineLoginViewVM>((login) => + { + ConnectToMachineSecure(machine, login); + }); + } + + private void Machine_SessionClosed(object sender, EventArgs e) + { + InvokeUI(() => + { + _notificationProvider.ShowError("The remote machine has closed the current session. Machine disconnected."); + ApplicationManager.SetConnectedMachine(null); + }); + } + private async void UploadHardwareConfiguration(bool showSuccessMessage = true) { try @@ -666,7 +699,7 @@ namespace Tango.MachineStudio.UI.ViewModels /// Starts the specified module. /// </summary> /// <param name="module">The module.</param> - internal void StartModule(IStudioModule module) + internal async void StartModule(IStudioModule module) { IsMenuOpened = false; @@ -691,10 +724,9 @@ namespace Tango.MachineStudio.UI.ViewModels m.IsLoaded = false; } - CurrentModule = module; - if (module != null) { + CurrentModule = module; CurrentModule.IsLoaded = true; IsModuleLoaded = true; @@ -705,7 +737,10 @@ namespace Tango.MachineStudio.UI.ViewModels { IsModuleLoaded = false; LogManager.Log(String.Format("Navigating to Home...")); - (MainView.Self as MainView).NavigationControl.NavigateTo("Home"); + (MainView.Self as MainView).NavigationControl.NavigateTo("Home", () => + { + CurrentModule = module; + }); } } @@ -713,7 +748,7 @@ namespace Tango.MachineStudio.UI.ViewModels /// Opens the module in a new window. /// </summary> /// <param name="module">The module.</param> - private void OpenModuleInWindow(IStudioModule module, Rect? bounds = null, WindowState? state = null) + private async void OpenModuleInWindow(IStudioModule module, Rect? bounds = null, WindowState? state = null) { if (module == null) return; @@ -723,6 +758,8 @@ namespace Tango.MachineStudio.UI.ViewModels StartModule(null); + await Task.Delay(1000); + LogManager.Log(String.Format("Starting module '{0}' in new window...", module.Name)); if (!(MainView.Self as MainView).NavigationControl.Elements.ToList().Exists(x => x.GetType() == module.MainViewType)) 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 4a94322fb..160041b5f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -173,12 +173,13 @@ namespace Tango.MachineStudio.UI.ViewModels DownloadLatestVersionResponse response = await _machineStudioWebClient.DownloadLatestVersion(new DownloadLatestVersionRequest() { - + }); _updateInfo = new CheckForUpdatesResponse(); _updateInfo.BlobAddress = response.BlobAddress; _updateInfo.Version = response.Version; + _updateInfo.CdnAddress = response.CdnAddress; LatestVersion = _updateInfo.Version; StartUpdate(); @@ -270,9 +271,9 @@ namespace Tango.MachineStudio.UI.ViewModels { logManager.Log("Creating temporary file " + tempFile); - using (StorageBlobDownloader downloader = new StorageBlobDownloader(_updateInfo.BlobAddress, tempFile.Path)) + using (AutoFileDownloader downloader = new AutoFileDownloader(_updateInfo.BlobAddress, _updateInfo.CdnAddress, tempFile.Path)) { - downloader.Progress += (x, e) => + downloader.Progress += (x, e) => { InvokeUINow(() => { @@ -326,40 +327,40 @@ namespace Tango.MachineStudio.UI.ViewModels } } - try - { - LogManager.Log("Backing up current version..."); - CurrentUpdateFile = "Backing up current version..."; + //try + //{ + // LogManager.Log("Backing up current version..."); + // CurrentUpdateFile = "Backing up current version..."; - String rollbackFolder = GetRollbackFolder(); - Directory.CreateDirectory(rollbackFolder); + // String rollbackFolder = GetRollbackFolder(); + // Directory.CreateDirectory(rollbackFolder); - String backFile = GetRollbackFile(); + // String backFile = GetRollbackFile(); - if (File.Exists(backFile)) - { - File.Delete(backFile); - } + // if (File.Exists(backFile)) + // { + // File.Delete(backFile); + // } - using (ZipFile backZip = new ZipFile(backFile)) - { - int currentEntry = 0; + // using (ZipFile backZip = new ZipFile(backFile)) + // { + // int currentEntry = 0; - backZip.SaveProgress += (_, e) => - { - UpdateProgress = ((double)(currentEntry++) / (double)backZip.Entries.Count) * 100d; - }; + // backZip.SaveProgress += (_, e) => + // { + // UpdateProgress = ((double)(currentEntry++) / (double)backZip.Entries.Count) * 100d; + // }; - backZip.Password = "Aa123456"; - backZip.AddDirectory(_appPath); - backZip.Save(); - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Could not construct rollback."); - _notification.ShowWarning("Update center has failed to construct a rollback point for the current version. Version rollback will not be available."); - } + // backZip.Password = "Aa123456"; + // backZip.AddDirectory(_appPath); + // backZip.Save(); + // } + //} + //catch (Exception ex) + //{ + // LogManager.Log(ex, "Could not construct rollback."); + // _notification.ShowWarning("Update center has failed to construct a rollback point for the current version. Version rollback will not be available."); + //} TangoIOC.Default.GetInstance<MainViewVM>().DisableCheckForUpdates = true; Status = UpdateStatus.UpdateCompleted; @@ -385,8 +386,8 @@ namespace Tango.MachineStudio.UI.ViewModels { try { - LogManager.Log("Clearing EF model store..."); - ObservablesContext.ClearModelStore(); + //LogManager.Log("Clearing EF model store..."); + //ObservablesContext.ClearModelStore(); Process p = new Process(); |
