diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-01-02 08:47:29 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-01-02 08:47:29 +0200 |
| commit | 520e878bf98efcec9c75abcfe483175ff72620a2 (patch) | |
| tree | 62a7221e3c22187821f6a5e399eca0f7bd31168a /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs | |
| parent | 30574fe4a6e1bb4f60a43e9000acaf919811689a (diff) | |
| parent | 25f5e6ddef7ef2fa0a747305847eeb4ceee5a2c9 (diff) | |
| download | Tango-520e878bf98efcec9c75abcfe483175ff72620a2.tar.gz Tango-520e878bf98efcec9c75abcfe483175ff72620a2.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs | 47 |
1 files changed, 13 insertions, 34 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs index a9624da2d..60a023071 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -24,6 +24,7 @@ using Tango.SharedUI; using Tango.MachineStudio.UI.Messages; using Tango.Settings; using Tango.MachineStudio.Common; +using Tango.Transport.Web; namespace Tango.MachineStudio.UI.ViewModels { @@ -185,24 +186,20 @@ namespace Tango.MachineStudio.UI.ViewModels var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>(); - ChannelFactory<IMachineStudioUpdateService> service = null; - Task.Factory.StartNew(() => { try { Thread.Sleep(2000); - service = UpdateServiceHelper.GetUpdateServiceChannel(); - var client = service.CreateChannel(); + var client = new MachineStudioUpdateService(); CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() { - Email = _authentication.CurrentUser.Email, - Password = _authentication.CurrentUser.Password, + AccessToken = _authentication.AccessToken, Version = _application.Version.ToString(), AcceptBetaRelease = settings.AcceptBetaRelease, - }); + }).Result; if (response.IsUpdateAvailable) { @@ -221,13 +218,6 @@ namespace Tango.MachineStudio.UI.ViewModels logManager.Log(ex, "Error while checking for version update!"); Status = UpdateStatus.Error; } - finally - { - if (service != null) - { - service.Close(); - } - } }); } @@ -260,29 +250,18 @@ namespace Tango.MachineStudio.UI.ViewModels { logManager.Log("Creating temporary file " + tempFile); - int fileSize = 0; - - using (FileStreamWrapper fs = new FileStreamWrapper(tempFile.Path, FileMode.Create, (current) => + using (StorageBlobDownloader downloader = new StorageBlobDownloader(_updateInfo.BlobAddress, tempFile.Path)) { - InvokeUINow(() => + downloader.Progress += (x, e) => { - 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(); - } - } + InvokeUINow(() => + { + DownloadProgress = ((double)e.Current / (double)e.Total) * 100d; + }); + }; + downloader.Download().Wait(); + } Status = UpdateStatus.Updating; |
