From 63579cee4493c4a8e3d64348d644fd2eecaca055 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 21 Jan 2019 13:53:00 +0200 Subject: PPC v1.0.0 --- .../Tango.PPC.Events/Properties/AssemblyInfo.cs | 2 +- .../AppButtons/StartPrintingButton.cs | 2 +- .../Tango.PPC.Jobs/Properties/AssemblyInfo.cs | 2 +- .../Tango.PPC.Logging/Properties/AssemblyInfo.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../Tango.PPC.Power/Properties/AssemblyInfo.cs | 2 +- .../Tango.PPC.Power/ViewModels/MainViewVM.cs | 25 +++++++ .../Modules/Tango.PPC.Power/Views/MainView.xaml | 2 +- .../Tango.PPC.Storage/Properties/AssemblyInfo.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../Connection/DefaultMachineProvider.cs | 4 ++ .../OS/DefaultOperationSystemManager.cs | 25 +++++-- .../PPC/Tango.PPC.Common/PPCSettings.cs | 2 +- .../Tango.PPC.Common/Properties/AssemblyInfo.cs | 2 +- .../DefaultRemoteAssistanceProvider.cs | 61 +++++++++++----- .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 7 +- Software/Visual_Studio/PPC/Tango.PPC.UI/App.config | 81 +--------------------- .../PPC/Tango.PPC.UI/MainWindow.xaml.cs | 2 +- .../PPCApplication/DefaultPPCApplicationManager.cs | 2 +- .../PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs | 2 +- .../PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs | 15 +++- .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- 22 files changed, 126 insertions(+), 122 deletions(-) (limited to 'Software/Visual_Studio/PPC') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Properties/AssemblyInfo.cs index 62cabff0f..96fc79687 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Events Module")] -[assembly: AssemblyVersion("2.0.1.1407")] +[assembly: AssemblyVersion("1.0.0.0")] [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/AppButtons/StartPrintingButton.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/AppButtons/StartPrintingButton.cs index 8efd46e18..001888c92 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/AppButtons/StartPrintingButton.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/AppButtons/StartPrintingButton.cs @@ -11,7 +11,7 @@ namespace Tango.PPC.Jobs.AppButtons { public class StartPrintingButton : AppButton { - public StartPrintingButton(RelayCommand command, IMachineOperator op) : base("START DYEING", command) + public StartPrintingButton(RelayCommand command, IMachineOperator op) : base("DYE", command) { op.StatusChanged += Op_StatusChanged; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Properties/AssemblyInfo.cs index 095f10d3b..3f8126e3f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Jobs Module")] -[assembly: AssemblyVersion("2.0.7.1119")] +[assembly: AssemblyVersion("1.0.0.0")] [assembly:ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/AssemblyInfo.cs index 612af80ce..a834fd095 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Logging/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Logging Module")] -[assembly: AssemblyVersion("2.0.4.1119")] +[assembly: AssemblyVersion("1.0.0.0")] [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Properties/AssemblyInfo.cs index d07b99ec8..36ac78345 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Settings Module")] -[assembly: AssemblyVersion("2.0.4.1119")] +[assembly: AssemblyVersion("1.0.0.0")] [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Power/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Power/Properties/AssemblyInfo.cs index a88d39005..def518165 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Power/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Power/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango Power Module")] -[assembly: AssemblyVersion("2.0.1.1407")] +[assembly: AssemblyVersion("1.0.0.0")] [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Power/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Power/ViewModels/MainViewVM.cs index b92a43489..bd8fe65f9 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Power/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Power/ViewModels/MainViewVM.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.Commands; using Tango.PPC.Common; namespace Tango.PPC.Power.ViewModels @@ -13,6 +14,19 @@ namespace Tango.PPC.Power.ViewModels /// public class MainViewVM : PPCViewModel { + /// + /// Gets or sets the restart command. + /// + public RelayCommand RestartCommand { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public MainViewVM() + { + RestartCommand = new RelayCommand(RestartApplication); + } + /// /// Called when the application has been started /// @@ -20,5 +34,16 @@ namespace Tango.PPC.Power.ViewModels { //Start initializing here rather then in the constructor. } + + /// + /// Restarts the application. + /// + private async void RestartApplication() + { + if (await NotificationProvider.ShowQuestion("Are you sure you want to restart the application?")) + { + ApplicationManager.Restart(); + } + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Power/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Power/Views/MainView.xaml index 42c43eb32..4add8e94c 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Power/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Power/Views/MainView.xaml @@ -42,7 +42,7 @@ - RESTART + RESTART diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Properties/AssemblyInfo.cs index 201341ef7..804d83e9d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Storage Module")] -[assembly: AssemblyVersion("2.0.2.1119")] +[assembly: AssemblyVersion("1.0.0.0")] [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/AssemblyInfo.cs index 0f2c9f8c4..41efbaf89 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango Module")] -[assembly: AssemblyVersion("2.0.2.1119")] +[assembly: AssemblyVersion("1.0.0.0")] [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs index 340b64765..7c6287933 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs @@ -93,6 +93,8 @@ namespace Tango.PPC.Common.Connection MachineOperator.EnableEventsNotification = true; MachineOperator.EnableJobResume = true; MachineOperator.UseKeepAlive = true; + MachineOperator.EnableDiagnostics = false; + MachineOperator.EnableEmbeddedDebugging = false; } private async void ConnectionThreadMethod() @@ -128,6 +130,8 @@ namespace Tango.PPC.Common.Connection LogManager.Log("Connecting machine operator..."); MachineOperatorChanged?.Invoke(this, new MachineOperatorChangedEventArgs(MachineOperator, MachineOperator)); await MachineOperator.Connect(); + + } else { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs index 36b31e888..23722319c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs @@ -10,13 +10,14 @@ using Tango.PPC.Common.Scripting; namespace Tango.PPC.Common.OS { using System.Collections.ObjectModel; + using Tango.Core; using SLID = Guid; //SLID id declaration as typedef GUID SLID; in slpublic.h /// /// Represents the default windows activation manager. /// /// - public class DefaultOperationSystemManager : IOperationSystemManager + public class DefaultOperationSystemManager : ExtendedObject, IOperationSystemManager { #region Win32 @@ -43,6 +44,8 @@ namespace Tango.PPC.Common.OS { return Task.Factory.StartNew(() => { + LogManager.Log("Validating windows activation..."); + Guid ApplicationID = new Guid("55c92734-d682-4d71-983e-d6ec3f16059f"); //Application ID GUID http://technet.microsoft.com/en-us/library/dd772270.aspx SLID windowsSlid = (Guid)ApplicationID; try @@ -51,11 +54,12 @@ namespace Tango.PPC.Common.OS uint ResultInt = SLIsGenuineLocal(ref windowsSlid, ref genuineState, IntPtr.Zero); if (ResultInt == 0) { + LogManager.Log("OS activation status: " + genuineState.ToString()); return (genuineState == SL_GENUINE_STATE.SL_GEN_STATE_IS_GENUINE); } else { - throw new InvalidOperationException("An error occurred while trying to get the OS activation status."); + throw LogManager.Log(new InvalidOperationException("An error occurred while trying to get the OS activation status.")); } } @@ -73,12 +77,21 @@ namespace Tango.PPC.Common.OS /// public async Task Activate(string activationKey) { - CmdCommand command = new CmdCommand("cscript", $"C:\\Windows\\System32\\slmgr.vbs -ipk {activationKey}"); - await command.Run(); + if (!(await IsActivated())) + { + CmdCommand command = new CmdCommand("cscript", $"C:\\Windows\\System32\\slmgr.vbs -ipk {activationKey}"); + await command.Run(); + + await Task.Delay(5000); - if (!await IsActivated()) + if (!await IsActivated()) + { + throw new ApplicationException("The activation was completed but activation status returned a false response."); + } + } + else { - throw new ApplicationException("The activation was completed but activation status returned a false response."); + LogManager.Log("Windows is already activated. Skipping activation..."); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index 7ef9f9fdc..7b617ddaa 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -90,7 +90,7 @@ namespace Tango.PPC.Common EmbeddedComPort = null; ExternalBridgePassword = "Aa123456"; HotSpotPassword = "Aa123456"; - DeploymentSlot = DeploymentSlot.PROD; + DeploymentSlot = DeploymentSlot.TEST; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Properties/AssemblyInfo.cs index d7075ef50..5d595893c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango Panel PC Common Library")] -[assembly: AssemblyVersion("2.0.12.1608")] +[assembly: AssemblyVersion("1.0.0.0")] [assembly:ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs index 040546b59..e8d19aa20 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs @@ -94,6 +94,36 @@ namespace Tango.PPC.Common.RemoteAssistance } } + private async Task IsRemoteAssistanceInstalled() + { + bool exist = false; + + for (int i = 0; i < 6; i++) + { + LogManager.Log("Checking remote assistance service..."); + await Task.Delay(1000); + CmdCommand command = new CmdCommand("sc.exe", "query TeamViewer"); + try + { + await command.Run(); + exist = true; + break; + } + catch { } + } + + if (exist) + { + LogManager.Log("Remote assistance service found."); + } + else + { + LogManager.Log("Remote assistance service was not found."); + } + + return exist; + } + /// /// Installs the remote assistance. /// @@ -108,31 +138,26 @@ namespace Tango.PPC.Common.RemoteAssistance throw new FileNotFoundException($"The remote assistance installer file could not be found at {_installer_path}."); } - CmdCommand command = new CmdCommand("msiexec.exe", $"/i \"{_installer_path}\" /qn CUSTOMCONFIGID=ke43ann APITOKEN=4765529-gon1LwO1N1TTrlLI21ji ASSIGNMENTOPTIONS=\" --reassign --alias {"TANGO-" + machineSerialNumber} --grant-easy-access\""); - await command.Run(); + if (!(await IsRemoteAssistanceInstalled())) + { + CmdCommand command = new CmdCommand("msiexec.exe", $"/i \"{_installer_path}\" /qn CUSTOMCONFIGID=ke43ann APITOKEN=4765529-gon1LwO1N1TTrlLI21ji ASSIGNMENTOPTIONS=\" --reassign --alias {"TANGO-" + machineSerialNumber} --grant-easy-access\""); + command.Timeout = TimeSpan.FromSeconds(30); + await command.Run(); - bool exist = false; + bool exist = await IsRemoteAssistanceInstalled(); - for (int i = 0; i < 6; i++) - { - await Task.Delay(1000); - command = new CmdCommand("sc.exe", "query TeamViewer"); - try + if (exist) { - await command.Run(); - exist = true; - break; + await DisableRemoteAssistance(); + } + else + { + throw new ApplicationException("The remote assistance service was installed but could not be found."); } - catch { } - } - - if (exist) - { - await DisableRemoteAssistance(); } else { - throw new ApplicationException("The remote assistance service was installed but could not be found."); + LogManager.Log("Remote assistance is already installed."); } } catch (Exception ex) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 8230d5a38..1b51876d7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -86,7 +86,10 @@ True - + + + True + @@ -350,7 +353,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config index c4cbcdc32..330ca08df 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config @@ -9,86 +9,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs index 302e401fb..765c792b1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs @@ -51,7 +51,7 @@ namespace Tango.PPC.UI WindowStyle = WindowStyle.None; ResizeMode = ResizeMode.NoResize; WindowStartupLocation = WindowStartupLocation.Manual; - Topmost = true; // sure? + Topmost = false; // sure? Left = touch_screen.Bounds.Left; Top = touch_screen.Bounds.Top; Width = touch_screen.Bounds.Width; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 3916d6345..2929908cc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -172,7 +172,7 @@ namespace Tango.PPC.UI.PPCApplication LogManager.Log("Initializing ObservablesStaticCollections..."); ObservablesStaticCollections.Instance.Initialize(); LogManager.Log("Loading machine from database..."); - _machine = new MachineBuilder(ObservablesContext.CreateDefault()).SetFirst().WithOrganization().WithConfiguration().Build(); + _machine = new MachineBuilder(ObservablesContext.CreateDefault()).SetFirst().WithOrganization().WithConfiguration().WithSpools().Build(); } initialized = true; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs index d4951edda..e9e31e73b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs @@ -8,4 +8,4 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Application")] -[assembly: AssemblyVersion("2.0.18.1608")] +[assembly: AssemblyVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs index 516349a18..f926a0f4c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -21,6 +21,7 @@ using Tango.PPC.Jobs; using Tango.SharedUI; using System.Data.Entity; using Tango.BL.Enumerations; +using Tango.BL.Builders; namespace Tango.PPC.UI.ViewModels { @@ -79,7 +80,19 @@ namespace Tango.PPC.UI.ViewModels if (db.Users.Count() == 1 || machine.AutoLogin) { - var user = await db.Users.FirstAsync(); + var user = await new UserBuilder(db).SetFirst().WithRolesAndPermissions().BuildAsync(); + + if (!user.HasRole(Roles.PPCUser)) + { + var role = db.Roles.Single(x => x.Code == (int)Roles.PPCUser); + user.Roles.Add(role); + db.UsersRoles.Add(new BL.Entities.UsersRole() + { + User = user, + Role = role, + }); + await db.SaveChangesAsync(); + } LogManager.Log($"Application started. Single user/Auto login detected ({user.Email}). Skipping LoginView..."); await AuthenticationProvider.Login(user.Email, user.Password, false); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index efc5f8179..d72e75011 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + -- cgit v1.3.1