From c3ed01b6c75c44cfeca650b43deb058b1551a9bb Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 19 Dec 2018 14:52:54 +0200 Subject: Moved machine studio update azure !!! --- .../Tango.MachineStudio.Publisher/MainWindowVM.cs | 40 +++++++++------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs index ffeefb820..73f3f5bed 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs @@ -19,6 +19,7 @@ using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Update; using Tango.Settings; using Tango.SharedUI; +using Tango.Transport.Web; namespace Tango.MachineStudio.Publisher { @@ -26,7 +27,6 @@ namespace Tango.MachineStudio.Publisher { private BasicHashGenerator _hashGenerator; private String _appPath = AppDomain.CurrentDomain.BaseDirectory + "..\\Release"; - private ChannelFactory _service; private IMachineStudioUpdateService _client; private String _email; @@ -114,14 +114,15 @@ namespace Tango.MachineStudio.Publisher public MainWindowVM() { + _client = new MachineStudioUpdateService(); + MaxProgress = 100; _hashGenerator = new BasicHashGenerator(); 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(); + var client = new MachineStudioUpdateService(); UpdateVersions(); @@ -136,7 +137,7 @@ namespace Tango.MachineStudio.Publisher private void UpdateVersions() { CurrentVersion = FileVersionInfo.GetVersionInfo(_appPath + "\\Tango.MachineStudio.UI.exe").ProductVersion; - LatestVersion = _client.GetLatestVersion(); + LatestVersion = _client.GetLatestVersion(new LatestVersionRequest()).Result.Version; } private void Publish() @@ -152,7 +153,7 @@ namespace Tango.MachineStudio.Publisher Task.Factory.StartNew(() => { IsUpdating = true; - String tempFile = String.Empty; + String tempFile = TemporaryManager.CreateFile(); try { @@ -164,9 +165,7 @@ namespace Tango.MachineStudio.Publisher Comments = Comments, ForcedUpdate = ForcedUpdate, IsStable = IsStable, - }); - - tempFile = Path.Combine(Path.GetTempPath(), response.FileName); + }).Result; using (ZipFile zip = new ZipFile()) { @@ -190,28 +189,23 @@ namespace Tango.MachineStudio.Publisher 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 (StorageBlobUploader uploader = new StorageBlobUploader(response.BlobAddress,tempFile)) { - using (FtpClient ftp = new FtpClient(response.FtpHost, response.UserName, response.Password)) + uploader.Progress += (x, e) => { - ftp.ConnectAsync().Wait(); - ftp.UploadAsync(fs, response.FilePath, FtpExists.Overwrite, true).Wait(); - } + InvokeUINow(() => + { + Progress = ((double)e.Current / (double)e.Total) * 100d; + }); + }; + + uploader.Upload().Wait(); } _client.NotifyUploadCompleted(new UploadCompletedRequest() { Token = response.Token, - }); + }).Wait(); Progress = 0; UpdateVersions(); -- cgit v1.3.1