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 | |
| 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')
14 files changed, 132 insertions, 142 deletions
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 fd68ed8d1..ccaedb359 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -10,6 +10,9 @@ using Tango.MachineStudio.Common.Authentication; using Tango.BL; using Tango.BL.Enumerations; using System.Data.Entity; +using Tango.Transport.Web; +using Tango.Settings; +using Tango.MachineStudio.Common; namespace Tango.MachineStudio.UI.Authentication { @@ -49,11 +52,29 @@ namespace Tango.MachineStudio.UI.Authentication /// <exception cref="AuthenticationException">Login failed for user " + email</exception> public User Login(string email, string password) { - using (ObservablesContext db = ObservablesContext.CreateDefault()) + var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>(); + + + IWebTransportClient service = new WebTransportClient(); + var response = service.PostJson<LoginRequest, LoginResponse>(settings.GetMachineServiceAddress() + "/api/MachineStudio/Login", new LoginRequest() + { + + Email = email, + Password = password, + + }).Result; + + AccessToken = response.Token; + + if (settings.Environment == MachineStudioSettings.WorkingEnvironment.Remote) { + ObservablesContext.OverrideSettingsDataSource(response.DataSource); + } - String hash = User.GetPasswordHash(password); + ObservablesStaticCollections.Instance.Initialize(); + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { db.Roles.Load(); db.Permissions.Load(); db.RolesPermissions.Load(); @@ -62,24 +83,13 @@ namespace Tango.MachineStudio.UI.Authentication .Include(x => x.UsersRoles) .Include(x => x.Contact) .Include(x => x.Address) - .Include(x => x.Organization).SingleOrDefault(x => x.Email.ToLower() == email.ToLower() && x.Password == hash); + .Include(x => x.Organization).SingleOrDefault(x => x.Email.ToLower() == email.ToLower()); if (user == null) { 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."); - } - - if (user != null) - { - user.LastLogin = DateTime.UtcNow; - db.SaveChanges(); - } - CurrentUser = user; return user; } @@ -92,5 +102,10 @@ namespace Tango.MachineStudio.UI.Authentication { CurrentUser = null; } + + /// <summary> + /// Gets the access token that was retrieved at the last login. + /// </summary> + public string AccessToken { get; private set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs index 701fd50b9..c311df44b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs @@ -4,5 +4,5 @@ using System.Runtime.InteropServices; [assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)] [assembly: AssemblyTitle("Tango - Machine Studio")] -[assembly: AssemblyVersion("3.5.78.18305")] +[assembly: AssemblyVersion("3.5.79.18305")] [assembly: ComVisible(false)]
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index 6303b1ac8..baa550017 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -26,7 +26,6 @@ using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.UI.Views; using Tango.Integration.Operation; using Tango.MachineStudio.UI.Windows; -using Tango.MachineStudio.Common.JobRunsLogging; namespace Tango.MachineStudio.UI.StudioApplication { @@ -40,7 +39,6 @@ namespace Tango.MachineStudio.UI.StudioApplication private INavigationManager _navigationManager; private IStudioModuleLoader _moduleLoader; private INotificationProvider _notification; - private IJobRunsLogger _jobRunsLogger; private List<Window> _openedWindows; private List<IStudioViewModel> _notified_view_models; @@ -53,9 +51,8 @@ namespace Tango.MachineStudio.UI.StudioApplication /// Initializes a new instance of the <see cref="DefaultStudioApplicationManager" /> class. /// </summary> /// <param name="navigationManager">The navigation manager.</param> - public DefaultStudioApplicationManager(INavigationManager navigationManager, IStudioModuleLoader moduleLoader, INotificationProvider notification, IJobRunsLogger jobRunsLogger) + public DefaultStudioApplicationManager(INavigationManager navigationManager, IStudioModuleLoader moduleLoader, INotificationProvider notification) { - _jobRunsLogger = jobRunsLogger; _moduleLoader = moduleLoader; _navigationManager = navigationManager; _notification = notification; @@ -350,7 +347,6 @@ namespace Tango.MachineStudio.UI.StudioApplication }); ApplicationReady?.Invoke(this, new EventArgs()); - _jobRunsLogger.Init(this); } /// <summary> @@ -362,6 +358,12 @@ namespace Tango.MachineStudio.UI.StudioApplication if (connectedMachine != null) { Machine = ObservablesStaticCollections.Instance.Machines.SingleOrDefault(x => x.SerialNumber == connectedMachine.SerialNumber); + + if (Machine == null) + { + throw new NullReferenceException($"The specified machine '{connectedMachine.SerialNumber}' could not be found on the database."); + } + ConnectedMachine = connectedMachine; ConnectedMachine.SetMachine(Machine); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs index edce9d3c1..46bf63194 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs @@ -226,30 +226,7 @@ namespace Tango.MachineStudio.UI.TFS sysModel.Machine = machine; sysModel.EmbeddedVersion = app.ConnectedMachine.DeviceInformation.Version; - MachineDesigner.Views.MainView machineView = new MachineDesigner.Views.MainView(); - machineView.Width = 1280; - machineView.Height = 1100; - machineView.PanelColumnDefinition.Width = new GridLength(0); - machineView.stackHeader.Visibility = Visibility.Collapsed; - machineView.Background = System.Windows.Media.Brushes.White; - - - var machineDesignerVM = new MachineDesigner.ViewModels.MainViewVM(); - machineDesignerVM.SetSelectedMachine(machine); - machineDesignerVM.Configuration = machine.Configuration; - machineView.DataContext = machineDesignerVM; - - var configImageFile = _tempFolder.CreateImaginaryFile(); - machineView.RenderToFile(configImageFile.Path, System.Drawing.Imaging.ImageFormat.Jpeg, new Size(machineView.Width, machineView.Height), 100); - - item.Attachments.Add(new Attachment() - { - Description = "Machine Configuration", - FilePath = configImageFile.Path, - Name = "Machine Configuration.jpg" - }); - - sysModel.ConfigurationString = machine.Configuration.Clone().ToJsonString(nameof(Configuration.MachinesConfigurations), nameof(Configuration.MachineVersions)); + sysModel.ConfigurationString = machine.Configuration.Clone().ToJsonString(); if (app.ConnectedMachine.CurrentProcessParameters != null) { 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 b3926190f..fb84d64bd 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 @@ -69,6 +69,7 @@ <Reference Include="MaterialDesignThemes.Wpf, Version=2.3.1.953, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath> </Reference> + <Reference Include="Microsoft.WindowsAzure.Storage, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <Reference Include="SimpleValidator, Version=0.6.1.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\SimpleValidator.0.6.1.0\lib\net40\SimpleValidator.dll</HintPath> </Reference> @@ -422,6 +423,14 @@ <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> <Name>Tango.Transport</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.Web\Tango.Web.csproj"> + <Project>{5001990f-977b-48ff-b217-0236a5022ad8}</Project> + <Name>Tango.Web</Name> + </ProjectReference> + <ProjectReference Include="..\Modules\MachineStudio.Dispensers\Tango.MachineStudio.Dispensers.csproj"> + <Project>{f69da3a8-f823-461e-87cf-a9275abc0b15}</Project> + <Name>Tango.MachineStudio.Dispensers</Name> + </ProjectReference> <ProjectReference Include="..\Modules\Tango.MachineStudio.ColorLab\Tango.MachineStudio.ColorLab.csproj"> <Project>{4d183aca-552b-4135-ae81-7c5a8e5fc3b1}</Project> <Name>Tango.MachineStudio.ColorLab</Name> @@ -609,7 +618,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\Microsoft.WITDataStore32.dll" "$(Ta </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.DeltaBaseYearDayOfYear" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_BuildVersioningStyle="None.None.Increment.DeltaBaseYearDayOfYear" BuildVersion_UpdateFileVersion="True" BuildVersion_DetectChanges="True" BuildVersion_UseGlobalSettings="False" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index cac4ee0c0..3c548855d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -8,7 +8,6 @@ using Tango.MachineStudio.Common.Diagnostics; using Tango.MachineStudio.Common.EventLogging; using Tango.MachineStudio.Common.FirmwareUpgrade; using Tango.MachineStudio.Common.Html; -using Tango.MachineStudio.Common.JobRunsLogging; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; @@ -71,7 +70,6 @@ namespace Tango.MachineStudio.UI TangoIOC.Default.Unregister<IHtmlPresenter>(); TangoIOC.Default.Unregister<ITeamFoundationServiceClient>(); TangoIOC.Default.Unregister<IDispatcherProvider>(); - TangoIOC.Default.Unregister<IJobRunsLogger>(); TangoIOC.Default.Unregister<IFirmwareUpgrader>(); @@ -80,7 +78,6 @@ namespace Tango.MachineStudio.UI TangoIOC.Default.Register<IAuthenticationProvider, DefaultAuthenticationProvider>(); TangoIOC.Default.Register<INavigationManager, DefaultNavigationManager>(); TangoIOC.Default.Register<IStudioModuleLoader, DefaultStudioModuleLoader>(); - TangoIOC.Default.Register<IJobRunsLogger, DefaultJobRunsLogger>(); TangoIOC.Default.Register<IStudioApplicationManager, DefaultStudioApplicationManager>(); TangoIOC.Default.Register<ExternalBridgeScanner, ExternalBridgeScanner>(); TangoIOC.Default.Register<IVideoCaptureProvider, DefaultVideoCaptureProvider>(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs index e8d33b0ca..c05ce9982 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; using Tango.Core; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.StudioApplication; @@ -19,11 +20,14 @@ namespace Tango.MachineStudio.UI.ViewModels public MachineStudioSettings MachineStudioSettings { get; set; } + public DataSource DataSource { get; set; } + public AboutViewVM(IStudioApplicationManager applicationManager) { ApplicationManager = applicationManager; Settings = SettingsManager.Default.GetOrCreate<CoreSettings>(); MachineStudioSettings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>(); + DataSource = ObservablesContext.GetActualDataSource(); } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 4032c946c..283ea3637 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -69,6 +69,9 @@ namespace Tango.MachineStudio.UI.ViewModels _notificationProvider = notificationProvider; } + /// <summary> + /// Called when the application has been started + /// </summary> public override void OnApplicationStarted() { base.OnApplicationStarted(); @@ -88,48 +91,6 @@ namespace Tango.MachineStudio.UI.ViewModels { try { - Status = "Checking for critical updates..."; - - LogManager.Log("Checking for forced update..."); - var service = UpdateServiceHelper.GetUpdateServiceChannel(); - var client = service.CreateChannel(); - - CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() - { - Email = "ForceUpdate", - Password = "ForceUpdate", - Version = ApplicationManager.Version.ToString(), - }); - - if (response.IsUpdateAvailable && response.ForcedUpdate) - { - LogManager.Log("Forced update found, Navigating to update view!"); - - InvokeUI(() => - { - if (_notificationProvider.ShowQuestion("Machine Studio has detected a critical update which must be installed in order for the application to run properly. Do you wish to download and install this update?")) - { - TangoMessenger.Default.Send(new Messages.ForcedUpdateMessage() { UpdateResponse = response }); - _navigationManager.NavigateTo(NavigationView.UpdateView); - } - else - { - ApplicationManager.ShutDown(); - } - - IsLoading = false; - }); - - return; - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error checking for forced update!"); - } - - try - { Status = "Connecting to Team Foundation Services..."; _tfs.Initialize(); Thread.Sleep(500); @@ -141,9 +102,8 @@ namespace Tango.MachineStudio.UI.ViewModels Status = "Loading, please wait..."; - ObservablesStaticCollections.Instance.Initialize(); - - _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); + //ObservablesStaticCollections.Instance.Initialize(); + //_eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); Status = "Starting application..."; 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 a37879a5e..492e23963 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -6,6 +6,8 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Enumerations; using Tango.Core.Commands; using Tango.Core.Cryptography; using Tango.MachineStudio.Common; @@ -15,6 +17,7 @@ using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; using Tango.Settings; using Tango.SharedUI; +using Tango.Web; namespace Tango.MachineStudio.UI.ViewModels { @@ -44,6 +47,9 @@ namespace Tango.MachineStudio.UI.ViewModels } private String _password; + /// <summary> + /// Gets or sets the password. + /// </summary> [Required(ErrorMessage = "Password is required")] public String Password { @@ -51,6 +57,16 @@ namespace Tango.MachineStudio.UI.ViewModels set { _password = value; RaisePropertyChangedAuto(); } } + private DeploymentSlot _deploymentSlot; + /// <summary> + /// Gets or sets the deployment slot. + /// </summary> + public DeploymentSlot DeploymentSlot + { + get { return _deploymentSlot; } + set { _deploymentSlot = value; RaisePropertyChangedAuto(); } + } + private bool _isLogging; /// <summary> /// Gets or sets a value indicating whether this instance is logging. @@ -90,10 +106,11 @@ namespace Tango.MachineStudio.UI.ViewModels _navigationManager = navigationManager; _authenticationProvider = authenticationProvider; _eventLogger = eventLogger; - LoginCommand = new RelayCommand(Login,() => !IsLogging); + LoginCommand = new RelayCommand(Login, () => !IsLogging); cryptographer = new Rfc2898Cryptographer(); Email = _settings.LastLoginEmail; + DeploymentSlot = _settings.DeploymentSlot; RememberMe = _settings.RememberMe; try @@ -120,21 +137,26 @@ namespace Tango.MachineStudio.UI.ViewModels await Task.Factory.StartNew(() => { + _settings.DeploymentSlot = DeploymentSlot; + _authenticationProvider.Login(Email, Password); + + _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); + _navigationManager.NavigateTo(NavigationView.MainView); + _settings.LastLoginEmail = Email; _settings.RememberMe = RememberMe; - _settings.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null; _settings.Save(); - _eventLogger.Log("User logged in"); + _eventLogger.Log("User logged in."); }); } - catch (Exception) + catch (Exception ex) { - - _notificationProvider.ShowError("Invalid credentials. Please try again."); + LogManager.Log(ex, "Login Error."); + _notificationProvider.ShowError($"The specified email or password was incorrect, or you don't have a permission to run this application.\nError: {ex.FlattenMessage()}"); } finally { 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 70378a4d5..e3a8b4e7c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -359,16 +359,14 @@ namespace Tango.MachineStudio.UI.ViewModels { if (_authenticationProvider.CurrentUser != null) { - var service = UpdateServiceHelper.GetUpdateServiceChannel(); - var client = service.CreateChannel(); + var client = new MachineStudioUpdateService(); CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() { - Email = _authenticationProvider.CurrentUser.Email, - Password = _authenticationProvider.CurrentUser.Password, + AccessToken = _authenticationProvider.AccessToken, Version = _applicationManager.Version.ToString(), AcceptBetaRelease = _settings.AcceptBetaRelease, - }); + }).Result; IsUpdateAvailable = response.IsUpdateAvailable; LatestVersion = response.Version; @@ -453,6 +451,13 @@ namespace Tango.MachineStudio.UI.ViewModels if (x.SelectedMachine.RequiresAuthentication) { + //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() + "...")) 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; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/AboutView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/AboutView.xaml index 682cc9ed9..696cc051f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/AboutView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/AboutView.xaml @@ -12,6 +12,7 @@ <UserControl.Resources> <converters:VersionToShortVersionConverter x:Key="VersionToShortVersionConverter" /> + <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" /> </UserControl.Resources> <Grid> @@ -42,20 +43,28 @@ - <controls:TableGrid RowHeight="25" Height="150" DockPanel.Dock="Top"> + <controls:TableGrid RowHeight="25" DockPanel.Dock="Top"> <TextBlock FontWeight="SemiBold">Machine Studio:</TextBlock> <TextBlock><Run>v</Run><Run Text="{Binding ApplicationManager.Version,Mode=OneWay}"></Run></TextBlock> <TextBlock FontWeight="SemiBold">Core Libraries:</TextBlock> <TextBlock><Run>v</Run><Run Text="{Binding ApplicationManager.CoreVersion,Mode=OneWay}"></Run></TextBlock> <TextBlock FontWeight="SemiBold">Build Date:</TextBlock> <TextBlock Text="{Binding ApplicationManager.BuildDate,Mode=OneWay}"></TextBlock> + <TextBlock FontWeight="SemiBold">Environment Mode:</TextBlock> + <TextBlock Text="{Binding MachineStudioSettings.Environment,Mode=OneWay}"></TextBlock> + <TextBlock FontWeight="SemiBold">Environment Slot:</TextBlock> + <TextBlock Text="{Binding MachineStudioSettings.DeploymentSlot,Mode=OneWay}"></TextBlock> + <TextBlock FontWeight="SemiBold">Machine Service:</TextBlock> + <TextBlock Text="{Binding MachineStudioSettings.DeploymentSlot,Converter={StaticResource EnumToDescriptionConverter},Mode=OneWay}"></TextBlock> <TextBlock FontWeight="SemiBold">Data Source:</TextBlock> - <TextBlock Text="{Binding Settings.DataSource.Address,Mode=OneWay}"></TextBlock> + <TextBlock><Run Text="{Binding DataSource.Address,Mode=OneWay}"></Run> + <Run>(</Run><Run Foreground="Gray" Text="{Binding DataSource.Catalog,Mode=OneWay}"></Run><Run>)</Run> + </TextBlock> <TextBlock FontWeight="SemiBold">Allow BETA Updates:</TextBlock> <ToggleButton IsChecked="{Binding MachineStudioSettings.AcceptBetaRelease,Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Bottom"></ToggleButton> </controls:TableGrid> - <DockPanel> + <DockPanel Margin="0 0 0 0"> <TextBlock DockPanel.Dock="Top" FontWeight="SemiBold">Change Log:</TextBlock> <TextBox Margin="0 5 0 0" Style="{x:Null}" IsReadOnly="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" TextWrapping="Wrap" AcceptsReturn="True" Foreground="DimGray" Text="{Binding ApplicationManager.ChangeLog,Mode=OneWay}"> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml index b1502f374..2e2dd1285 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml @@ -95,6 +95,8 @@ <ToggleButton IsChecked="{Binding EnableDiagnostics}" HorizontalAlignment="Left"></ToggleButton> <TextBlock FontWeight="SemiBold" Text="Enable Embedded Debug Logs:" /> <ToggleButton IsChecked="{Binding EnableEmbeddedDebugging}" HorizontalAlignment="Left"></ToggleButton> + <TextBlock FontWeight="SemiBold" Text="Enable KeepAlive:" /> + <ToggleButton IsChecked="{Binding UseKeepAlive}" HorizontalAlignment="Left"></ToggleButton> <TextBlock FontWeight="SemiBold" Text="Enable Events:" /> <ToggleButton IsChecked="{Binding EnableEventsNotification}" HorizontalAlignment="Left"></ToggleButton> </controls:TableGrid> @@ -181,6 +183,8 @@ <ToggleButton IsChecked="{Binding EnableDiagnostics}" HorizontalAlignment="Left"></ToggleButton> <TextBlock FontWeight="SemiBold" Text="Enable Embedded Debug Logs:" /> <ToggleButton IsChecked="{Binding EnableEmbeddedDebugging}" HorizontalAlignment="Left"></ToggleButton> + <TextBlock FontWeight="SemiBold" Text="Enable KeepAlive:" /> + <ToggleButton IsChecked="{Binding UseKeepAlive}" HorizontalAlignment="Left"></ToggleButton> <TextBlock FontWeight="SemiBold" Text="Enable Events:" /> <ToggleButton IsChecked="{Binding EnableEventsNotification}" HorizontalAlignment="Left"></ToggleButton> </controls:TableGrid> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml index 68334ad24..b479dd03f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml @@ -6,9 +6,11 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:web="clr-namespace:Tango.Web;assembly=Tango.Web" xmlns:automation="clr-namespace:Tango.MachineStudio.Common.Automation;assembly=Tango.MachineStudio.Common" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:helpers="clr-namespace:Tango.SharedUI.Helpers;assembly=Tango.SharedUI" + xmlns:common="clr-namespace:Tango.MachineStudio.Common;assembly=Tango.MachineStudio.Common" xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" mc:Ignorable="d" d:DesignHeight="720" d:DesignWidth="1280" DataContext="{Binding LoginViewVM, Source={StaticResource Locator}}" Background="Transparent"> @@ -17,6 +19,7 @@ <rules:Required x:Key="Required"></rules:Required> <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> <converters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter" /> + <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> </UserControl.Resources> @@ -28,7 +31,7 @@ <Image Source="/Images/machine-trans.png" RenderOptions.BitmapScalingMode="Fant" Width="100"></Image> <TextBlock Margin="20 0 0 0" VerticalAlignment="Center" FontSize="70" Foreground="{StaticResource AccentColorBrush}">Machine Studio</TextBlock> </StackPanel> - <DockPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="320" Margin="0 120 0 0" Height="398"> + <DockPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="320" Margin="0 120 0 0" Height="480"> <Button DockPanel.Dock="Bottom" AutomationProperties.AutomationId="{x:Static automation:UI.LoginButton}" Margin="25 20 0 0" Height="50" Command="{Binding LoginCommand}" Content="LOGIN"></Button> @@ -44,6 +47,10 @@ <materialDesign:PackIcon Margin="0 0 0 0" Width="20" Height="20" VerticalAlignment="Top" Foreground="{Binding ElementName=txtPass, Path=BorderBrush}" Kind="Key" /> <PasswordBox x:Name="txtPass" helpers:PasswordHelper.Attach="True" helpers:PasswordHelper.Password="{Binding Password,Mode=TwoWay}" Margin="5 0 0 0" materialDesign:HintAssist.FloatingScale="0.50" materialDesign:HintAssist.Hint="Password" materialDesign:TextFieldAssist.TextBoxViewMargin="1 0 1 0" FontSize="20" Style="{StaticResource MaterialDesignFloatingHintPasswordBox}" AutomationProperties.IsRequiredForForm="True" /> </DockPanel> + <DockPanel Margin="0 40 0 0"> + <materialDesign:PackIcon Margin="0 0 0 0" Width="20" Height="20" VerticalAlignment="Top" Foreground="{Binding ElementName=combo, Path=BorderBrush}" Kind="Settings" /> + <ComboBox x:Name="combo" ItemsSource="{Binding Source={x:Type web:DeploymentSlot},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding DeploymentSlot}" SelectedValuePath="Value" DisplayMemberPath="DisplayName" Margin="5 0 0 0" materialDesign:HintAssist.FloatingScale="0.50" materialDesign:HintAssist.Hint="Environment" materialDesign:TextFieldAssist.TextBoxViewMargin="1 0 1 0" FontSize="20" /> + </DockPanel> <CheckBox Margin="25 20 0 0" IsChecked="{Binding RememberMe}">Remember me</CheckBox> </StackPanel> |
