aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-02-13 20:02:59 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-02-13 20:02:59 +0200
commit69c55f54ee7217f16419049a311ce437d3c19157 (patch)
tree2c0c25115e07ad4eba5dd4bb4c150fe6d1f0c702
parent7b371c15dfb48c5182bbb704b5ea1ff1385b1d30 (diff)
downloadTango-69c55f54ee7217f16419049a311ce437d3c19157.tar.gz
Tango-69c55f54ee7217f16419049a311ce437d3c19157.zip
Fixed issue with PPC WIFI connection profiles.
Implemented OS restart after first setup. Prevented PPC updater crashes without restarting PPC. Implemented restarting system view on PPC.
-rw-r--r--Software/DB/PPC/Tango.mdfbin75497472 -> 75497472 bytes
-rw-r--r--Software/DB/PPC/Tango_log.ldfbin53673984 -> 53673984 bytes
-rw-r--r--Software/DB/Tango.mdfbin75497472 -> 75497472 bytes
-rw-r--r--Software/DB/Tango_log.ldfbin22675456 -> 22675456 bytes
-rw-r--r--Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnkbin1532 -> 1516 bytes
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs5
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiNetwork.cs19
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs1
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs10
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs6
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml1
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs11
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs19
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj8
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs9
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/RestartingSystemViewVM.cs45
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml1
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml27
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml.cs28
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml.cs85
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Converters/EnumToBooleanConverter.cs43
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj3
24 files changed, 282 insertions, 43 deletions
diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf
index cb9117cd5..1780c8e20 100644
--- a/Software/DB/PPC/Tango.mdf
+++ b/Software/DB/PPC/Tango.mdf
Binary files differ
diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf
index fe9d3427d..804f5dce4 100644
--- a/Software/DB/PPC/Tango_log.ldf
+++ b/Software/DB/PPC/Tango_log.ldf
Binary files differ
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf
index 3fc4027c5..45ae37b64 100644
--- a/Software/DB/Tango.mdf
+++ b/Software/DB/Tango.mdf
Binary files differ
diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf
index 9f060f952..c61fb1004 100644
--- a/Software/DB/Tango_log.ldf
+++ b/Software/DB/Tango_log.ldf
Binary files differ
diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk
index ec95c71d3..ff1ca4297 100644
--- a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk
+++ b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk
Binary files differ
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs
index 5f0b35ce2..f07ba39a9 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs
@@ -41,6 +41,11 @@ namespace Tango.PPC.Common.Application
event EventHandler SetupRequired;
/// <summary>
+ /// Occurs when a system restart is required.
+ /// </summary>
+ event EventHandler SystemRestartRequired;
+
+ /// <summary>
/// Occurs when the application has encountered an error when initializing.
/// </summary>
event EventHandler<Exception> ApplicationInitializationError;
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiNetwork.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiNetwork.cs
index 766e25e40..46a1e2355 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiNetwork.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiNetwork.cs
@@ -86,14 +86,14 @@ namespace Tango.PPC.Common.Connectivity
return new WiFiAuthentication(new AuthRequest(AccessPoint));
}
- public Task<bool> Connect(WiFiAuthentication request)
+ public Task<bool> Connect(WiFiAuthentication request, bool overwriteProfile)
{
return Task.Factory.StartNew<bool>(() =>
{
try
{
Connecting = true;
- return AccessPoint.Connect(request.AuthRequest, false);
+ return AccessPoint.Connect(request.AuthRequest, overwriteProfile);
}
catch (Exception)
{
@@ -126,5 +126,20 @@ namespace Tango.PPC.Common.Connectivity
}
});
}
+
+ public Task Forget()
+ {
+ return Task.Factory.StartNew(() =>
+ {
+ try
+ {
+ AccessPoint.DeleteProfile();
+ }
+ catch
+ {
+
+ }
+ });
+ }
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs
index ac02422c0..e3129b970 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs
@@ -21,5 +21,6 @@ namespace Tango.PPC.Common.Navigation
ExternalBridgeView,
HomeModule,
ShutdownView,
+ RestartingSystemView
}
}
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 a073c1c5e..75e8d40dc 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs
@@ -10,6 +10,7 @@ using Tango.PPC.Common.Scripting;
namespace Tango.PPC.Common.OS
{
using System.Collections.ObjectModel;
+ using System.Diagnostics;
using Tango.Core;
using SLID = Guid; //SLID id declaration as typedef GUID SLID; in slpublic.h
@@ -124,5 +125,14 @@ namespace Tango.PPC.Common.OS
CmdCommand cmd = new CmdCommand("tzutil", $"/s \"{timeZone.Id}\"");
await cmd.Run();
}
+
+ /// <summary>
+ /// Restarts the system.
+ /// </summary>
+ /// <returns></returns>
+ public void Restart()
+ {
+ Process.Start("shutdown.exe", "-r -t 0");
+ }
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs
index d7898d174..0cdf85927 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs
@@ -43,5 +43,11 @@ namespace Tango.PPC.Common.OS
/// <param name="timeZone">The time zone.</param>
/// <returns></returns>
Task ChangeTimeZone(TimeZoneInfo timeZone);
+
+ /// <summary>
+ /// Restarts the system.
+ /// </summary>
+ /// <returns></returns>
+ void Restart();
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml
index 266bef3eb..05cd998e6 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml
@@ -43,6 +43,7 @@
<converters:GreaterThanToBooleanConverter x:Key="GreaterThanToBooleanConverter" />
<converters:ByteArrayToFileSizeConverter x:Key="ByteArrayToFileSizeConverter" />
<converters:EnumToVisibilityConverter x:Key="EnumToVisibilityConverter" />
+ <converters:EnumToBooleanConverter x:Key="EnumToBooleanConverter" />
<converters:DateTimeUTCToStringConverter x:Key="DateTimeUTCToStringConverter" />
<converters:NullObjectToBooleanConverter x:Key="NullObjectToBooleanConverter" />
<converters:IsNullToVisibilityConverter x:Key="IsNullToVisibilityConverter" />
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs
index a05e66f10..5fc7f00df 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs
@@ -224,7 +224,14 @@ namespace Tango.PPC.UI.Connectivity
if (vm.DialogResult)
{
- result = await network.Connect(auth);
+ result = await network.Connect(auth, true);
+
+ if (!result)
+ {
+ await _notification.ShowError("Could not connect to the specified network. Please check your password.");
+ await network.Forget();
+ }
+
await RefreshAvailableWiFiNetworks();
}
else
@@ -234,7 +241,7 @@ namespace Tango.PPC.UI.Connectivity
}
else
{
- result = await network.Connect(auth);
+ result = await network.Connect(auth, false);
await RefreshAvailableWiFiNetworks();
}
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 2929908cc..39ce8cd30 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
@@ -46,6 +46,11 @@ namespace Tango.PPC.UI.PPCApplication
private INotificationProvider _notificationProvider;
/// <summary>
+ /// Occurs when a system restart is required.
+ /// </summary>
+ public event EventHandler SystemRestartRequired;
+
+ /// <summary>
/// Occurs when the application has started.
/// </summary>
public event EventHandler ApplicationStarted;
@@ -141,6 +146,7 @@ namespace Tango.PPC.UI.PPCApplication
PPCSettings settings = null;
bool initialized = false;
+ bool isAfterSetup = false;
await Task.Factory.StartNew(() =>
{
@@ -163,8 +169,21 @@ namespace Tango.PPC.UI.PPCApplication
if (App.StartupArgs.Contains("-update_ok"))
{
LogManager.Log("Application started with '-update_ok' startup arguments. The application has been successfully updated.");
+
+ if (settings.ApplicationState == ApplicationStates.PreSetup)
+ {
+ isAfterSetup = true;
+ LogManager.Log("System restart is required.");
+ }
+
settings.ApplicationState = ApplicationStates.Ready;
settings.Save();
+
+ if (isAfterSetup)
+ {
+ SystemRestartRequired?.Invoke(this, new EventArgs());
+ return;
+ }
}
if (settings.ApplicationState == ApplicationStates.Ready)
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 17598c085..f40bfa7de 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
@@ -144,6 +144,7 @@
<Compile Include="ViewModels\MainViewVM.cs" />
<Compile Include="ViewModels\MachineUpdateViewVM.cs" />
<Compile Include="ViewModels\NoPermissionsViewVM.cs" />
+ <Compile Include="ViewModels\RestartingSystemViewVM.cs" />
<Compile Include="ViewsContracts\ILayoutView.cs" />
<Compile Include="ViewsContracts\IMachineSetupView.cs" />
<Compile Include="ViewsContracts\IMachineUpdateView.cs" />
@@ -174,6 +175,9 @@
<Compile Include="Views\NoPermissionsView.xaml.cs">
<DependentUpon>NoPermissionsView.xaml</DependentUpon>
</Compile>
+ <Compile Include="Views\RestartingSystemView.xaml.cs">
+ <DependentUpon>RestartingSystemView.xaml</DependentUpon>
+ </Compile>
<Page Include="Connectivity\WiFiAuthenticationView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -242,6 +246,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Views\RestartingSystemView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
index 444fd70b9..4eb5475f0 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
@@ -102,6 +102,7 @@ namespace Tango.PPC.UI
TangoIOC.Default.Register<MachineUpdateViewVM>();
TangoIOC.Default.Register<LoadingErrorViewVM>();
TangoIOC.Default.Register<NoPermissionsViewVM>();
+ TangoIOC.Default.Register<RestartingSystemViewVM>();
TangoIOC.Default.GetInstance<IPPCApplicationManager>().ContentRendered += (_, __) =>
@@ -191,5 +192,13 @@ namespace Tango.PPC.UI
return TangoIOC.Default.GetInstance<NoPermissionsViewVM>();
}
}
+
+ public static RestartingSystemViewVM RestartingSystemViewVM
+ {
+ get
+ {
+ return TangoIOC.Default.GetInstance<RestartingSystemViewVM>();
+ }
+ }
}
} \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/RestartingSystemViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/RestartingSystemViewVM.cs
new file mode 100644
index 000000000..b1cb57fce
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/RestartingSystemViewVM.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.PPC.Common;
+using Tango.PPC.Common.Application;
+using Tango.PPC.Common.Navigation;
+using Tango.PPC.Common.OS;
+
+namespace Tango.PPC.UI.ViewModels
+{
+ public class RestartingSystemViewVM : PPCViewModel
+ {
+ private IOperationSystemManager _os;
+ private INavigationManager _navigationManager;
+
+ public RestartingSystemViewVM(IPPCApplicationManager applicationManager, IOperationSystemManager operationSystemManager, INavigationManager navigationManager)
+ {
+ _navigationManager = navigationManager;
+ _os = operationSystemManager;
+ applicationManager.SystemRestartRequired += ApplicationManager_SystemRestartRequired;
+ }
+
+ private void ApplicationManager_SystemRestartRequired(object sender, EventArgs e)
+ {
+ InvokeUI(() =>
+ {
+ _navigationManager.NavigateTo(NavigationView.RestartingSystemView);
+ });
+ }
+
+ public async override void OnNavigatedTo()
+ {
+ base.OnNavigatedTo();
+ await Task.Delay(2000);
+ _os.Restart();
+ }
+
+ public override void OnApplicationStarted()
+ {
+
+ }
+ }
+}
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 30b99dbbf..9437caac9 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml
@@ -65,7 +65,7 @@
<TextBlock DockPanel.Dock="Top" Margin="20 0" FontSize="{StaticResource TangoTitleFontSize}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center">
Checking internet connection, please wait...
</TextBlock>
- <touch:TouchBusyIndicator Width="250" Margin="0 100 0 0" Height="250" IsIndeterminate="{Binding CurrentView,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter='WiFiTestView'}" />
+ <touch:TouchBusyIndicator Width="250" Margin="0 100 0 0" Height="250" IsIndeterminate="{Binding CurrentView,Converter={StaticResource EnumToBooleanConverter},ConverterParameter='WiFiTestView'}" />
</StackPanel>
</Grid>
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 6d1bde59d..c6e3fa6ea 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml
@@ -89,6 +89,7 @@
<local:ExternalBridgeView></local:ExternalBridgeView>
<local:MachineSetupView></local:MachineSetupView>
<local:MachineUpdateView></local:MachineUpdateView>
+ <local:RestartingSystemView></local:RestartingSystemView>
</controls:NavigationControl>
</touch:TouchPanel>
</Grid>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml
new file mode 100644
index 000000000..996b1788d
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml
@@ -0,0 +1,27 @@
+<UserControl x:Class="Tango.PPC.UI.Views.RestartingSystemView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:global="clr-namespace:Tango.PPC.UI"
+ xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels"
+ xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:local="clr-namespace:Tango.PPC.UI.Views"
+ mc:Ignorable="d"
+ d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:RestartingSystemViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.RestartingSystemViewVM}" Background="{StaticResource TangoPrimaryBackgroundBrush}">
+ <Grid>
+
+ <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
+ <touch:TouchBusyIndicator Width="350" Height="350" IsIndeterminate="{Binding IsVisible}" Foreground="{StaticResource TangoGrayBrush}" />
+ <TextBlock Margin="0 40 0 0" TextAlignment="Center" HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoGrayTextBrush}">
+ <Run>
+ Setup completed.
+ </Run>
+ <LineBreak/>
+ <Run>
+ Restarting the system for the last time...
+ </Run>
+ </TextBlock>
+ </StackPanel>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml.cs
new file mode 100644
index 000000000..1b426192e
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.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 RestartingSystemView.xaml
+ /// </summary>
+ public partial class RestartingSystemView : UserControl
+ {
+ public RestartingSystemView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
index d72e75011..efc5f8179 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.
-->
- <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
+ <!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />-->
</requestedPrivileges>
</security>
</trustInfo>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml.cs
index eb8d61a6b..ae4f22420 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Updater/MainWindow.xaml.cs
@@ -25,23 +25,17 @@ namespace Tango.PPC.Updater
{
private String _sourceFolder = AppDomain.CurrentDomain.BaseDirectory;
private String _msProcessName = "Tango.PPC.UI";
- private String _appPath = String.Join(" ", App.StartupArgs);
+ private String _appPath;
public MainWindow()
{
//Launch debugger..
-//#if DEBUG
-// if (!Debugger.IsAttached)
-// {
-// Debugger.Launch();
-// }
-//#endif
-
- if (!Directory.Exists(_appPath))
- {
- ShowError("This update utility can only be executed by the main Tango.");
- Environment.Exit(0);
- }
+ //#if DEBUG
+ // if (!Debugger.IsAttached)
+ // {
+ // Debugger.Launch();
+ // }
+ //#endif
InitializeComponent();
@@ -68,43 +62,63 @@ namespace Tango.PPC.Updater
private void MainWindow_ContentRendered(object sender, EventArgs e)
{
+ Update();
+ }
+
+ private void Update()
+ {
try
{
- Update();
+ Init();
+ EnsureTangoIsDown();
+ RemoveOldDLLFiles();
+ ReplaceFiles();
+
+ txtStatus.Text = "Update completed. Starting application...";
+ DoEvents();
+ Thread.Sleep(1000);
+ StartTango(true);
}
catch (Exception ex)
{
- Debug.WriteLine(ex.ToString());
- ShowError(ex.Message);
- Process p = new Process();
- p.StartInfo.FileName = _appPath + "\\" + _msProcessName + ".exe";
- p.StartInfo.LoadUserProfile = true;
- p.StartInfo.UseShellExecute = true;
- p.Start();
+ ShowError($"Update failed.\n{ex.Message}");
+ StartTango(false);
+ }
+ finally
+ {
Environment.Exit(0);
}
}
- private void Update()
+ private void Init()
{
- EnsureTangoIsDown();
- RemoveOldDLLFiles();
- ReplaceFiles();
- StartTango();
- Environment.Exit(0);
+ try
+ {
+ _appPath = String.Join(" ", App.StartupArgs);
+ }
+ catch
+ {
+ throw new ArgumentException("Error parsing startup arguments.");
+ }
+
+ if (!Directory.Exists(_appPath))
+ {
+ throw new InvalidOperationException("This update utility can only be executed by the main Tango application.");
+ }
}
- private void StartTango()
+ private void StartTango(bool success)
{
- txtStatus.Text = "Update completed. Starting application...";
- DoEvents();
- Thread.Sleep(1000);
-
Process p = new Process();
p.StartInfo.FileName = _appPath + "\\" + _msProcessName + ".exe";
p.StartInfo.LoadUserProfile = true;
p.StartInfo.UseShellExecute = true;
- p.StartInfo.Arguments = "-update_ok";
+
+ if (success)
+ {
+ p.StartInfo.Arguments = "-update_ok";
+ }
+
p.Start();
}
@@ -138,7 +152,7 @@ namespace Tango.PPC.Updater
prog.Value = progress++;
DoEvents();
- Thread.Sleep(30);
+ Thread.Sleep(10);
}
catch (Exception ex)
{
@@ -198,8 +212,7 @@ namespace Tango.PPC.Updater
if (tries > 10)
{
- ShowError("The main Tango process seems to in a frozen state. Please restart your computer and try again.");
- Environment.Exit(0);
+ throw new IOException("The main Tango process seems to in a frozen state. Please restart your computer and try again.");
}
} while (appProcess != null);
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToBooleanConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToBooleanConverter.cs
new file mode 100644
index 000000000..567d79c5a
--- /dev/null
+++ b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToBooleanConverter.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace Tango.SharedUI.Converters
+{
+ public class EnumToBooleanConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (parameter != null)
+ {
+ if (parameter is String)
+ {
+ if (parameter.ToString().Contains(","))
+ {
+ String[] values = parameter.ToString().Split(',');
+ return values.Contains(value.ToString()) ? true : false;
+ }
+ else
+ {
+ return value.ToString() == parameter.ToString() ? true : false;
+ }
+ }
+ else
+ {
+ return value == parameter ? true : false;
+ }
+ }
+
+ return false;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj
index be03e3a60..048edca82 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj
+++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj
@@ -96,6 +96,7 @@
<Compile Include="Converters\DateTimeUTCToStringConverter.cs" />
<Compile Include="Converters\DisplayMemberPathConverter.cs" />
<Compile Include="Converters\DoubleToIntConverter.cs" />
+ <Compile Include="Converters\EnumToBooleanConverter.cs" />
<Compile Include="Converters\EnumToDescriptionConverter.cs" />
<Compile Include="Converters\EnumToItemsSourceConverter.cs" />
<Compile Include="Converters\EnumToVisibilityConverter.cs" />
@@ -232,7 +233,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<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