diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-12-05 11:30:45 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-12-05 11:30:45 +0200 |
| commit | cd467ed8a6afec8dcf50d8dc71c75d9d445f7489 (patch) | |
| tree | 0adc1655c1d11c434061993d47ef77e461284f7f /Software/Visual_Studio/PPC/Tango.PPC.UI | |
| parent | e8c9c0b649f31bf5170be409cdf6925aa9fc11b6 (diff) | |
| download | Tango-cd467ed8a6afec8dcf50d8dc71c75d9d445f7489.tar.gz Tango-cd467ed8a6afec8dcf50d8dc71c75d9d445f7489.zip | |
Working on PPC packages...
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
8 files changed, 209 insertions, 2 deletions
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 ed5ea2629..95c4ccdac 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -32,6 +32,7 @@ using Tango.PPC.UI.Dialogs; using Tango.Core.Threading; using Tango.PPC.Common.Messages; using Tango.Core.ExtensionMethods; +using Tango.PPC.Common.Navigation; namespace Tango.PPC.UI.PPCApplication { @@ -130,6 +131,11 @@ namespace Tango.PPC.UI.PPCApplication /// </summary> public DateTime StartUpDate { get; private set; } + /// <summary> + /// Gets a value indicating whether an update has occurred before the application started. + /// </summary> + public bool IsAfterUpdate { get; private set; } + private bool _isScreenLocked; /// <summary> /// Gets or sets a value indicating whether the screen is currently locked. @@ -220,6 +226,10 @@ namespace Tango.PPC.UI.PPCApplication isAfterSetup = true; LogManager.Log("System restart is required."); } + else + { + IsAfterUpdate = true; + } settings.ApplicationState = ApplicationStates.Ready; settings.Save(); @@ -419,7 +429,7 @@ namespace Tango.PPC.UI.PPCApplication /// <summary> /// Restarts the application. /// </summary> - public void Restart() + public async void Restart() { if (IsShuttingDown) return; @@ -427,8 +437,19 @@ namespace Tango.PPC.UI.PPCApplication try { + _dispatcher.Invoke(() => + { + var nav = TangoIOC.Default.GetInstance<INavigationManager>(); + if (nav != null) + { + nav.NavigateTo(NavigationView.RestartingView); + } + }); + LogManager.Log("Restarting the application..."); + await Task.Delay(8000); + _watchdogServer.Dispose(); foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>()) 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 e71e5794d..9691987c2 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 @@ -165,6 +165,7 @@ <Compile Include="ViewModels\MachineUpdateViewVM.cs" /> <Compile Include="ViewModels\NoPermissionsViewVM.cs" /> <Compile Include="ViewModels\RestartingSystemViewVM.cs" /> + <Compile Include="ViewModels\RestartingViewVM.cs" /> <Compile Include="ViewsContracts\ILayoutView.cs" /> <Compile Include="ViewsContracts\IMachineSetupView.cs" /> <Compile Include="ViewsContracts\IMachineUpdateView.cs" /> @@ -180,6 +181,9 @@ <Compile Include="Views\LoadingErrorView.xaml.cs"> <DependentUpon>LoadingErrorView.xaml</DependentUpon> </Compile> + <Compile Include="Views\RestartingView.xaml.cs"> + <DependentUpon>RestartingView.xaml</DependentUpon> + </Compile> <Compile Include="Views\LoadingView.xaml.cs"> <DependentUpon>LoadingView.xaml</DependentUpon> </Compile> @@ -269,6 +273,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\RestartingView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\LoadingView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -608,7 +616,7 @@ if $(ConfigurationName) == Release del *.xml</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 ed56f8a08..60bce4e20 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -74,6 +74,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Unregister<IOperationSystemManager>(); TangoIOC.Default.Unregister<PPCWebClient>(); TangoIOC.Default.Unregister<IBackupManager>(); + TangoIOC.Default.Unregister<IPackageRunner>(); TangoIOC.Default.Register<PPCWebClient, PPCWebClient>(new PPCWebClient()); TangoIOC.Default.Register<IDispatcherProvider, DefaultDispatcherProvider>(new DefaultDispatcherProvider(Application.Current.Dispatcher)); @@ -110,6 +111,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register<NoPermissionsViewVM>(); TangoIOC.Default.Register<RestartingSystemViewVM>(); TangoIOC.Default.Register<EmergencyViewVM>(); + TangoIOC.Default.Register<RestartingViewVM>(); TangoIOC.Default.GetInstance<IPPCApplicationManager>().ContentRendered += (_, __) => @@ -215,5 +217,13 @@ namespace Tango.PPC.UI return TangoIOC.Default.GetInstance<EmergencyViewVM>(); } } + + public static RestartingViewVM RestartingViewVM + { + get + { + return TangoIOC.Default.GetInstance<RestartingViewVM>(); + } + } } }
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs index 01e67d3ce..4cc4ee46f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -275,6 +275,66 @@ namespace Tango.PPC.UI.ViewModels base.OnApplicationReady(); StorageProvider.RegisterFileHandler(ExplorerFileDefinition.Update.Extension, HandleSoftwareUpdatePackageLoaded); + + if (ApplicationManager.IsAfterUpdate) + { + RunPostUpdatePackages(); + } + } + + #endregion + + #region Post Update Packages + + private async void RunPostUpdatePackages() + { + await Task.Delay(1000); + + LogManager.Log("Application was loaded after an update. Checking for required post-update packages..."); + + bool required = false; + + try + { + required = await MachineUpdateManager.PostUpdatePackagesRequired(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error checking for post-update packages."); + } + + if (required) + { + LogManager.Log("Post-update packages found and needs to be installed. Navigating to machine update and running post-update packages..."); + await NavigationManager.NavigateTo(Common.Navigation.NavigationView.MachineUpdateView); + await NavigateTo(MachineUpdateView.UpdateProgressView); + try + { + var result = await MachineUpdateManager.RunPostUpdatePackages(); + + LogManager.Log("Post-update packages installed successfully."); + + await Task.Delay(2000); + + if (result.RestartRequired) + { + LogManager.Log("Restart required. Restarting..."); + ApplicationManager.Restart(); + } + else + { + await NavigationManager.NavigateTo(Common.Navigation.NavigationView.LayoutView); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error occurred while running post-update packages."); + } + } + else + { + LogManager.Log("No post-update packages installation required."); + } } #endregion diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/RestartingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/RestartingViewVM.cs new file mode 100644 index 000000000..46111031b --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/RestartingViewVM.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common; + +namespace Tango.PPC.UI.ViewModels +{ + public class RestartingViewVM : PPCViewModel + { + public override void OnApplicationStarted() + { + + } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + } + + public override void OnNavigatedFrom() + { + base.OnNavigatedFrom(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index d139ad5ed..5be95ded4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -124,6 +124,7 @@ <local:MachineUpdateView></local:MachineUpdateView> <local:RestartingSystemView></local:RestartingSystemView> <local:EmergencyView></local:EmergencyView> + <local:RestartingView></local:RestartingView> </controls:NavigationControl> </touch:TouchPanel> </Grid> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingView.xaml new file mode 100644 index 000000000..41017f629 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingView.xaml @@ -0,0 +1,52 @@ +<UserControl x:Class="Tango.PPC.UI.Views.RestartingView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels" + xmlns:fx="clr-namespace:Tango.SharedUI.Effects;assembly=Tango.SharedUI" + xmlns:gif="clr-namespace:Tango.AnimatedGif;assembly=Tango.AnimatedGif" + xmlns:global="clr-namespace:Tango.PPC.UI" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:local="clr-namespace:Tango.PPC.UI.Views" + mc:Ignorable="d" + d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:RestartingViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.RestartingViewVM}"> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <Grid Margin="0 100 0 0"> + <Image Source="/Images/machine.png" Stretch="Uniform" Width="250" RenderOptions.BitmapScalingMode="Fant"></Image> + <touch:TouchBusyIndicator Foreground="{StaticResource TangoGrayBrush}" Width="350" Height="350" IsIndeterminate="{Binding IsVisible}" /> + </Grid> + + <TextBlock Margin="0 40 0 0" HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoGrayTextBrush}"> + <Run>v</Run><Run Text="{Binding ApplicationManager.Version,Mode=OneWay}"></Run> + </TextBlock> + <TextBlock FontSize="{StaticResource TangoHeaderFontSize}" Margin="0 100 0 0" HorizontalAlignment="Center" Width="170"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="Text" Value="Restarting"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsVisible}" Value="True"> + <DataTrigger.EnterActions> + <BeginStoryboard x:Name="storyRes"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Text" RepeatBehavior="5x"> + <DiscreteObjectKeyFrame KeyTime="00:00:0.2" Value="Restarting." /> + <DiscreteObjectKeyFrame KeyTime="00:00:0.6" Value="Restarting.." /> + <DiscreteObjectKeyFrame KeyTime="00:00:0.9" Value="Restarting..." /> + <DiscreteObjectKeyFrame KeyTime="00:00:1.4" Value="Restarting..." /> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + <DataTrigger.ExitActions> + <RemoveStoryboard BeginStoryboardName="storyRes" /> + </DataTrigger.ExitActions> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingView.xaml.cs new file mode 100644 index 000000000..fabd7b47b --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingView.xaml.cs @@ -0,0 +1,28 @@ +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.PPC.UI.Views +{ + /// <summary> + /// Interaction logic for LoadingView.xaml + /// </summary> + public partial class RestartingView : UserControl + { + public RestartingView() + { + InitializeComponent(); + } + } +} |
