diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-12-24 19:01:11 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-12-24 19:01:11 +0200 |
| commit | 2f85568170b4c11c6c5876b7fac9e662a004d47f (patch) | |
| tree | 587b0a30e8de36322583a10b136c7d43b25edd34 /Software/Visual_Studio/PPC | |
| parent | 7a9e8e8721e895b30a2652e2aaaeb6401b72250e (diff) | |
| download | Tango-2f85568170b4c11c6c5876b7fac9e662a004d47f.tar.gz Tango-2f85568170b4c11c6c5876b7fac9e662a004d47f.zip | |
Implemented PPC time zone modification !
Diffstat (limited to 'Software/Visual_Studio/PPC')
11 files changed, 98 insertions, 17 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index b8638b158..488206590 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -38,7 +38,7 @@ namespace Tango.PPC.Common.MachineSetup { private IRemoteAssistanceProvider _remoteAssistance; private IUnifiedWriteFilterManager _uwf; - private IWindowsActivationManager _windows_activation_manager; + private IOperationSystemManager _windows_manager; #region Events @@ -71,11 +71,11 @@ namespace Tango.PPC.Common.MachineSetup /// Initializes a new instance of the <see cref="MachineSetupManager"/> class. /// </summary> /// <param name="remoteAssistance">The remote assistance.</param> - public MachineSetupManager(IRemoteAssistanceProvider remoteAssistance, IUnifiedWriteFilterManager unifiedWriterFilterManager, IWindowsActivationManager windowsActivationManager) + public MachineSetupManager(IRemoteAssistanceProvider remoteAssistance, IUnifiedWriteFilterManager unifiedWriterFilterManager, IOperationSystemManager operationSystemManager) { _remoteAssistance = remoteAssistance; _uwf = unifiedWriterFilterManager; - _windows_activation_manager = windowsActivationManager; + _windows_manager = operationSystemManager; } #endregion @@ -140,7 +140,7 @@ namespace Tango.PPC.Common.MachineSetup { LogManager.Log("Activating windows license..."); UpdateProgress("Activating operation system license", "Activating..."); - await _windows_activation_manager.Activate(setup_response.OSKey); + await _windows_manager.Activate(setup_response.OSKey); } if (setup_response.SetupRemoteAssistance) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultWindowsActivationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs index 610328bc2..5e6b9c156 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultWindowsActivationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs @@ -9,14 +9,17 @@ using Tango.PPC.Common.Scripting; namespace Tango.PPC.Common.OS { + using System.Collections.ObjectModel; using SLID = Guid; //SLID id declaration as typedef GUID SLID; in slpublic.h /// <summary> /// Represents the default windows activation manager. /// </summary> - /// <seealso cref="Tango.PPC.Common.OS.IWindowsActivationManager" /> - public class DefaultWindowsActivationManager : IWindowsActivationManager + /// <seealso cref="Tango.PPC.Common.OS.IOperationSystemManager" /> + public class DefaultOperationSystemManager : IOperationSystemManager { + #region Win32 + private enum SL_GENUINE_STATE { SL_GEN_STATE_IS_GENUINE = 0, @@ -30,6 +33,8 @@ namespace Tango.PPC.Common.OS [PreserveSigAttribute()] private static extern uint SLIsGenuineLocal(ref SLID slid, [In, Out] ref SL_GENUINE_STATE genuineState, IntPtr val3); + #endregion + /// <summary> /// Determines whether the OS is activated. /// </summary> @@ -86,5 +91,25 @@ namespace Tango.PPC.Common.OS { throw new NotImplementedException("Deactivating windows license is not supported."); } + + /// <summary> + /// Gets the available time zones. + /// </summary> + /// <returns></returns> + public ReadOnlyCollection<TimeZoneInfo> GetAvailableTimeZones() + { + return TimeZoneInfo.GetSystemTimeZones(); + } + + /// <summary> + /// Changes the operation system time zone. + /// </summary> + /// <param name="timeZone">The time zone.</param> + /// <returns></returns> + public async Task ChangeTimeZone(TimeZoneInfo timeZone) + { + CmdCommand cmd = new CmdCommand("tzutil", $"/s \"{timeZone.StandardName}\""); + await cmd.Run(); + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IWindowsActivationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs index 2fc79e5bb..d7898d174 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IWindowsActivationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,7 +10,7 @@ namespace Tango.PPC.Common.OS /// <summary> /// Represents a windows license activation manager. /// </summary> - public interface IWindowsActivationManager + public interface IOperationSystemManager { /// <summary> /// Determines whether the OS is activated. @@ -29,5 +30,18 @@ namespace Tango.PPC.Common.OS /// </summary> /// <returns></returns> Task Deactivate(); + + /// <summary> + /// Gets the available time zones. + /// </summary> + /// <returns></returns> + ReadOnlyCollection<TimeZoneInfo> GetAvailableTimeZones(); + + /// <summary> + /// Changes the operation system time zone. + /// </summary> + /// <param name="timeZone">The time zone.</param> + /// <returns></returns> + Task ChangeTimeZone(TimeZoneInfo timeZone); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index d6fa39af0..8413e5a4f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -77,7 +77,7 @@ namespace Tango.PPC.Common { MachineScanningTimeoutSeconds = 20; LoggingCategories = new List<LogCategory>(); - MachineServiceAddress = "http://machineservice.twine-srv.com/"; + MachineServiceAddress = "https://machineservice.twine-srv.com/"; EmbeddedComPort = null; ExternalBridgePassword = "Aa123456"; HotSpotPassword = "Aa123456"; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs index 289683855..b9a0d8483 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs @@ -109,7 +109,6 @@ namespace Tango.PPC.Common [TangoInject] public IEventLogger EventLogger { get; set; } - private PPCSettings _settings; /// <summary> /// Gets the main PPC settings. 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 790f69ff8..c8c6575a5 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 @@ -167,8 +167,8 @@ <DependentUpon>MessageNotificationItemView.xaml</DependentUpon> </Compile> <Compile Include="Notifications\TaskBarItem.cs" /> - <Compile Include="OS\IWindowsActivationManager.cs" /> - <Compile Include="OS\DefaultWindowsActivationManager.cs" /> + <Compile Include="OS\IOperationSystemManager.cs" /> + <Compile Include="OS\DefaultOperationSystemManager.cs" /> <Compile Include="PPCModuleAttribute.cs" /> <Compile Include="PPCModuleBase.cs" /> <Compile Include="Printing\IPrintingManager.cs" /> @@ -344,7 +344,7 @@ </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/time-zone.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/time-zone.png Binary files differnew file mode 100644 index 000000000..10b5d996c --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/time-zone.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 836878152..5fe3ae2bb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -409,6 +409,7 @@ <Link>Tango.ColorLib.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> + <Resource Include="Images\time-zone.png" /> <Resource Include="Images\no-permissions.png" /> <Resource Include="Images\GlobalStatus\machine-off.png" /> <Resource Include="Images\machine-update-firmware.png" /> @@ -485,7 +486,7 @@ del "$(TargetDir)firmware_package.tfp"</PostBuildEvent> </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index 80154bc3f..444fd70b9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -68,7 +68,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Unregister<IRemoteAssistanceProvider>(); TangoIOC.Default.Unregister<IStorageProvider>(); TangoIOC.Default.Unregister<IUnifiedWriteFilterManager>(); - TangoIOC.Default.Unregister<IWindowsActivationManager>(); + TangoIOC.Default.Unregister<IOperationSystemManager>(); TangoIOC.Default.Register<IDispatcherProvider, DefaultDispatcherProvider>(new DefaultDispatcherProvider(Application.Current.Dispatcher)); TangoIOC.Default.Register<INotificationProvider, DefaultNotificationProvider>(); @@ -89,7 +89,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register<IHotSpotProvider, DefaultHotSpotProvider>(); TangoIOC.Default.Register<IStorageProvider, DefaultStorageProvider>(); TangoIOC.Default.Register<IUnifiedWriteFilterManager, DefaultUnifiedWriteFilterManager>(); - TangoIOC.Default.Register<IWindowsActivationManager, DefaultWindowsActivationManager>(); + TangoIOC.Default.Register<IOperationSystemManager, DefaultOperationSystemManager>(); //TangoIOC.Default.Register<TeamFoundationServiceExtendedClient>(new TeamFoundationServiceExtendedClient("https://twinetfs.visualstudio.com", String.Empty, "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa")); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs index 84987d705..7b8d4dbe6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs @@ -17,6 +17,7 @@ using Tango.PPC.Common.Application; using Tango.PPC.Common.Connection; using Tango.PPC.Common.MachineSetup; using Tango.PPC.Common.Navigation; +using Tango.PPC.Common.OS; using Tango.PPC.UI.ViewsContracts; using Tango.Settings; using Tango.SharedUI.Helpers; @@ -47,6 +48,7 @@ namespace Tango.PPC.UI.ViewModels WelcomeView, WiFiSelectionView, WiFiTestView, + TimeZoneView, SetupWelcomeView, SetupProgressView, SetupCompletedView, @@ -54,6 +56,7 @@ namespace Tango.PPC.UI.ViewModels } private MachineSetupResult _setup_result; + private IOperationSystemManager _operationSystemManager; #region Properties @@ -112,6 +115,21 @@ namespace Tango.PPC.UI.ViewModels set { _failedError = value; RaisePropertyChangedAuto(); } } + /// <summary> + /// Gets or sets the available time zones. + /// </summary> + public List<TimeZoneInfo> TimeZones { get; set; } + + private TimeZoneInfo _selectedTimeZone; + /// <summary> + /// Gets or sets the selected time zone. + /// </summary> + public TimeZoneInfo SelectedTimeZone + { + get { return _selectedTimeZone; } + set { _selectedTimeZone = value; RaisePropertyChangedAuto(); } + } + #endregion @@ -137,6 +155,10 @@ namespace Tango.PPC.UI.ViewModels /// </summary> public RelayCommand RestartCommand { get; set; } + /// <summary> + /// Gets or sets the time zone selected command. + /// </summary> + public RelayCommand TimeZoneSelectedCommand { get; set; } #endregion #region Constructors @@ -146,7 +168,7 @@ namespace Tango.PPC.UI.ViewModels /// </summary> /// <param name="applicationManager">The application manager.</param> /// <param name="machineSetupManager">The machine setup manager.</param> - public MachineSetupViewVM(IPPCApplicationManager applicationManager, IMachineSetupManager machineSetupManager) + public MachineSetupViewVM(IPPCApplicationManager applicationManager, IMachineSetupManager machineSetupManager, IOperationSystemManager operationSystemManager) { MachineSetupManager = machineSetupManager; @@ -161,6 +183,12 @@ namespace Tango.PPC.UI.ViewModels InstallCommand = new RelayCommand(Install); RestartCommand = new RelayCommand(() => { NavigateTo(MachineSetupView.WelcomeView); }); + TimeZoneSelectedCommand = new RelayCommand(() => { NavigateTo(MachineSetupView.SetupWelcomeView); }); + + _operationSystemManager = operationSystemManager; + + TimeZones = _operationSystemManager.GetAvailableTimeZones().ToList(); + SelectedTimeZone = TimeZones.SingleOrDefault(x => x.ToString() == "(UTC+02:00) Jerusalem"); } #endregion @@ -250,7 +278,7 @@ namespace Tango.PPC.UI.ViewModels if (connected) { - await NavigateTo(MachineSetupView.SetupWelcomeView); + await NavigateTo(MachineSetupView.TimeZoneView); } else { @@ -284,6 +312,7 @@ namespace Tango.PPC.UI.ViewModels try { + await _operationSystemManager.ChangeTimeZone(SelectedTimeZone); _setup_result = await MachineSetupManager.Setup(SerialNumber, HostAddress); State = MachineSetupStates.Completed; LogManager.Log("Machine setup completed."); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml index dc30cfa93..4832eea01 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml @@ -67,6 +67,19 @@ </StackPanel> </Grid> + <Grid controls:NavigationControl.NavigationName="TimeZoneView"> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="500"> + + <Image Source="/Images/time-zone.png" Width="128" /> + <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}">Please select the machine time zone</TextBlock> + <touch:TouchComboBox Margin="0 80 0 0" ItemsSource="{Binding TimeZones}" SelectedItem="{Binding SelectedTimeZone,Mode=TwoWay}"> + + </touch:TouchComboBox> + + <touch:TouchButton Margin="0 200 0 0" Padding="20" Width="300" CornerRadius="35" Command="{Binding TimeZoneSelectedCommand}">CONTINUE</touch:TouchButton> + </StackPanel> + </Grid> + <Grid controls:NavigationControl.NavigationName="SetupWelcomeView"> <StackPanel> <TextBlock TextAlignment="Center" LineHeight="40" FontSize="{StaticResource TangoTitleFontSize}" Margin="40 0" TextWrapping="Wrap"> |
