From 956f9ea033553136ebf199fff30f288dc26fbeb0 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 21 Feb 2018 20:21:57 +0200 Subject: Working on machine studio update center.. --- .../MachineStudioUpdateService.svc | 1 + .../MachineStudioUpdateService.svc.cs | 62 +++++++++ .../Properties/AssemblyInfo.cs | 36 ++++++ .../Tango.MachineStudio.UpdateService.csproj | 142 +++++++++++++++++++++ .../Web.Debug.config | 30 +++++ .../Web.Release.config | 31 +++++ .../Tango.MachineStudio.UpdateService/Web.config | 55 ++++++++ .../packages.config | 4 + 8 files changed, 361 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Debug.config create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.config create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/packages.config (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService') 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 -- 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.UpdateService') 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 fadf83a50071ffba21db05eceff10c51c18f5fb3 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 23 Feb 2018 12:03:18 +0200 Subject: Machine Studio Update & Publish. Improved user roles & permissions structure. Added permission for version publish. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../DataCaptureModule.cs | 2 +- .../Tango.MachineStudio.Stubs/StubsModule.cs | 2 +- .../Tango.MachineStudio.Publisher/MainWindow.xaml | 22 +++++----- .../Tango.MachineStudio.Publisher/MainWindowVM.cs | 10 ++++- .../DefaultAuthenticationProvider.cs | 7 ++- .../Tango.MachineStudio.UI.csproj | 4 ++ .../MachineStudioUpdateService.svc.cs | 6 +-- .../Tango.MachineStudio.UpdateService.csproj | 4 +- .../Web.Release.config | 2 +- .../Tango.MachineStudio.Updater/MainWindow.xaml.cs | 5 ++- .../Templates/ObservablesContextCodeFile.cshtml | 29 +------------ .../Observables/Enumerations/Permissions.cs | 24 +++++++++++ .../Observables/Enumerations/Roles.cs | 20 +++++++-- .../Observables/ObservablesContext.cs | 34 +-------------- .../Observables/ObservablesContextExtension.cs | 48 +++++++++++++++++++++ .../Tango.Integration/Tango.Integration.csproj | 1 + Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 6 +++ .../MachineStudioSettings/MachineStudio.cs | 2 +- .../Utilities/Tango.UITests/MainWindow.xaml | 1 - 21 files changed, 140 insertions(+), 89 deletions(-) create mode 100644 Software/Visual_Studio/Tango.Integration/Observables/ObservablesContextExtension.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 9f4b4ca30..2535145b6 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 81e9f8578..24e3fbc9c 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.DataCapture/DataCaptureModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs index ee650dc13..b138af4f3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs @@ -69,7 +69,7 @@ namespace Tango.MachineStudio.DataCapture { get { - return Permissions.RunTechnicianModule; + return Permissions.RunDataCaptureModule; } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs index 817c68b49..4dd0bdff1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs @@ -41,7 +41,7 @@ namespace Tango.MachineStudio.Stubs /// /// Gets the permission required to see and load this module. /// - public override Permissions Permission => Permissions.RunSynchronizationModule; + public override Permissions Permission => Permissions.RunStubsModule; /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml index 9f592ca6d..ab7e503ff 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml @@ -26,28 +26,28 @@ - - - Latest Version: + + + Remote Version: - - Current Version: + + Local Version: - + Email: - + - + Password: - + - Comments - + Comments + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs index 2ceb36994..34d2f1b1f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using System.Windows; using Tango.Core.Commands; using Tango.Core.Cryptography; +using Tango.Core.Helpers; using Tango.MachineStudio.Common.Update; using Tango.Settings; using Tango.SharedUI; @@ -121,6 +122,7 @@ namespace Tango.MachineStudio.Publisher Task.Factory.StartNew(() => { IsUpdating = true; + String tempFile = String.Empty; try { @@ -132,7 +134,7 @@ namespace Tango.MachineStudio.Publisher Comments = Comments, }); - String tempFile = Path.Combine(Path.GetTempPath(), response.FileName); + tempFile = Path.Combine(Path.GetTempPath(), response.FileName); using (ZipFile zip = new ZipFile()) { @@ -174,6 +176,11 @@ namespace Tango.MachineStudio.Publisher } } + _client.NotifyUploadCompleted(new UploadCompletedRequest() + { + Token = response.Token, + }); + UpdateVersions(); } catch (Exception ex) @@ -183,6 +190,7 @@ namespace Tango.MachineStudio.Publisher finally { IsUpdating = false; + PathHelper.TryDeleteFile(tempFile); } }); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs index 82aba268d..110e4d148 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -50,7 +50,12 @@ namespace Tango.MachineStudio.UI.Authentication if (user == null) { - throw new AuthenticationException("Login failed for user " + email); + throw new AuthenticationException("Invalid credentials for " + email); + } + + if (!user.HasPermission(Permissions.RunMachineStudio)) + { + throw new AuthenticationException("It seems like you do not have sufficient privileges to run Machine Studio. Please contact your administrator."); } CurrentUser = user; 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 61ea92566..4cfa99a9b 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 @@ -363,6 +363,10 @@ {cb0b0aa2-bb24-4bca-a720-45e397684e12} Tango.MachineStudio.Common + + {844787ce-f409-4f18-bccc-f3809ecb86f3} + Tango.MachineStudio.Updater + 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 e573a0d77..bf737c7a9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs @@ -31,7 +31,7 @@ namespace Tango.MachineStudio.UpdateService private static List _pendingUploads; - MachineStudioUpdateService() + static MachineStudioUpdateService() { _pendingUploads = new List(); } @@ -50,7 +50,7 @@ namespace Tango.MachineStudio.UpdateService var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); - if (user != null) + if (user != null && user.HasPermission(Permissions.RunMachineStudio)) { var latestVersion = db.MachineStudioVersions.FirstOrDefault(); Version currentVersion = Version.Parse(request.Version); @@ -93,7 +93,7 @@ namespace Tango.MachineStudio.UpdateService var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); - if (user != null) + if (user != null && user.HasPermission(Permissions.PublishMachineStudioVersion)) { var latestVersion = db.MachineStudioVersions.FirstOrDefault(); Version currentVersion = Version.Parse(request.Version); 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 index c9400b2d1..0b4d78195 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj @@ -26,7 +26,7 @@ true full false - ..\..\Build\Debug\Web\Machine Studio Update Service\ + bin\ DEBUG;TRACE prompt 4 @@ -118,7 +118,7 @@ - True + False True 65206 / diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config index da6e960b8..d2da57796 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config @@ -15,7 +15,7 @@ --> - + @@ -183,6 +178,37 @@ + + 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 From e83057fa22e28c5fd231ae06a5a91464a6e3f596 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 25 Feb 2018 15:14:20 +0200 Subject: Integrated DB & MSUS to Twine Server. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Tango.MachineStudio.Publisher.csproj | 27 +++++++++++++++++++++ .../MachineStudioUpdateService.svc.cs | 17 +++++++++++-- .../Tango.MachineStudio.UpdateService.csproj | 3 +++ .../Tango.MachineStudio.UpdateService/Web.config | 6 ++--- .../Observables/ObservablesContextExtension.cs | 4 +-- Software/Visual_Studio/Tango.Settings/DataBase.cs | 7 +----- .../MachineStudioSettings/MachineStudio.cs | 2 +- 9 files changed, 52 insertions(+), 14 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 683e47294..13144a5b4 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 6afb62f52..e58af856d 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.Publisher/Tango.MachineStudio.Publisher.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj index 00bbe3539..7b59fa319 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj @@ -13,6 +13,21 @@ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 true + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true AnyCPU @@ -135,5 +150,17 @@ Tango.MachineStudio.Common + + + False + Microsoft .NET Framework 4.6 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ 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 index 2f001b281..5cc95c617 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs @@ -97,6 +97,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.PublishMachineStudioVersion)) @@ -185,9 +191,16 @@ namespace Tango.MachineStudio.UpdateService public string GetLatestVersion() { - using (ObservablesContext db = ObservablesContext.CreateDefaultForWeb()) + try { - return db.MachineStudioVersions.FirstOrDefault().Version; + using (ObservablesContext db = ObservablesContext.CreateDefaultForWeb()) + { + return db.MachineStudioVersions.FirstOrDefault().Version; + } + } + catch (Exception ex) + { + throw new FaultException(ex.ToString()); } } } 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 index 0b4d78195..9e41b1725 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj @@ -81,6 +81,9 @@ + + + Web.config diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.config index b0d2452f0..1805380e9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.config @@ -6,8 +6,8 @@ - - + + @@ -21,7 +21,7 @@ - + diff --git a/Software/Visual_Studio/Tango.Integration/Observables/ObservablesContextExtension.cs b/Software/Visual_Studio/Tango.Integration/Observables/ObservablesContextExtension.cs index e6618eae2..9484520c5 100644 --- a/Software/Visual_Studio/Tango.Integration/Observables/ObservablesContextExtension.cs +++ b/Software/Visual_Studio/Tango.Integration/Observables/ObservablesContextExtension.cs @@ -19,7 +19,7 @@ namespace Tango.Integration.Observables { if (!isFile) { - return String.Format("Data Source={0};Initial Catalog=Tango;User Id=Developer;Password=1111;", source); + return String.Format("Data Source={0};Initial Catalog=Tango;Integrated Security=True;", source); } else { @@ -42,7 +42,7 @@ namespace Tango.Integration.Observables /// public static ObservablesContext CreateDefaultForWeb() { - return new ObservablesContext("localhost\\SQLEXPRESS", false); + return new ObservablesContext("localhost\\SQLTWINE", false); } } } diff --git a/Software/Visual_Studio/Tango.Settings/DataBase.cs b/Software/Visual_Studio/Tango.Settings/DataBase.cs index 4e5213b3f..22bbfe9a9 100644 --- a/Software/Visual_Studio/Tango.Settings/DataBase.cs +++ b/Software/Visual_Studio/Tango.Settings/DataBase.cs @@ -17,17 +17,12 @@ namespace Tango.Settings /// public String SQLServerAddress { get; set; } - /// - /// Gets or sets a value indicating whether to delete a record from database instead of setting IsDeleted to 'true'. - /// - public bool DeleteForReal { get; set; } - /// /// Initializes a new instance of the class. /// public DataBase() { - SQLServerAddress = "localhost\\SQLEXPRESS"; + SQLServerAddress = "twine01\\SQLTWINE"; } } } diff --git a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs index bfec7af3f..ecaa15153 100644 --- a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs +++ b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs @@ -74,7 +74,7 @@ namespace Tango.Settings.MachineStudioSettings StubsModule = new StubsModule(); TechnicianModule = new TechnicianModule(); DeveloperModule = new DeveloperModule(); - UpdateServiceAddress = "http://localhost:65206/MachineStudioUpdateService.svc"; + UpdateServiceAddress = "http://twine01/MachineStudioUpdateService/MachineStudioUpdateService.svc"; } } } -- cgit v1.3.1