aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs
diff options
context:
space:
mode:
authorMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
committerMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
commit00a491d93733d4625ad329b2ba8237f445364b3f (patch)
tree4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs
parent124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff)
downloadTango-00a491d9.tar.gz
Tango-00a491d9.zip
merge
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs87
1 files changed, 16 insertions, 71 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs
index 452907366..444c1d09e 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs
@@ -8,20 +8,16 @@ using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
-using Tango.BL;
using Tango.Core.Commands;
using Tango.PPC.Common;
using Tango.PPC.Common.OS;
using Tango.Settings;
-using System.Data.Entity;
-using Tango.PPC.Common.UWF;
namespace Tango.PPC.Technician.ViewModels
{
public class SystemViewVM : PPCViewModel
{
private IOperationSystemManager _os;
- private IUnifiedWriteFilterManager _uwf;
private Timer _statsTimer;
private bool _resettingDevice;
@@ -60,20 +56,6 @@ namespace Tango.PPC.Technician.ViewModels
set { _ipAddress = value; RaisePropertyChangedAuto(); }
}
- private String _totalDyeTime;
- public String TotalDyeTime
- {
- get { return _totalDyeTime; }
- set { _totalDyeTime = value; RaisePropertyChangedAuto(); }
- }
-
- private String _totalDyeMeters;
- public String TotalDyeMeters
- {
- get { return _totalDyeMeters; }
- set { _totalDyeMeters = value; RaisePropertyChangedAuto(); }
- }
-
public RelayCommand ResetDeviceCommand { get; set; }
public RelayCommand RestartCommand { get; set; }
@@ -84,10 +66,9 @@ namespace Tango.PPC.Technician.ViewModels
public RelayCommand ExitToExplorerCommand { get; set; }
- public SystemViewVM(IOperationSystemManager os, IUnifiedWriteFilterManager uwf)
+ public SystemViewVM(IOperationSystemManager os)
{
_os = os;
- _uwf = uwf;
CPU = 0;
RAM = 0;
@@ -105,7 +86,7 @@ namespace Tango.PPC.Technician.ViewModels
{
_resettingDevice = true;
ResetDeviceCommand.RaiseCanExecuteChanged();
- await MachineProvider.MachineOperator.Reset();
+ await MachineProvider.MachineOperator.ResetDFU();
await NotificationProvider.ShowInfo("Embedded device has been reset successfully.");
}
catch (Exception ex)
@@ -121,30 +102,11 @@ namespace Tango.PPC.Technician.ViewModels
private async void FactoryReset()
{
- if (await NotificationProvider.ShowQuestion("Are you sure you want to reset this device back to factory settings?"))
+ if (await NotificationProvider.ShowQuestion("Are you sure you want to reset this device and back to factory settings?"))
{
Settings.ApplicationState = ApplicationStates.FactoryRestore;
Settings.Save();
- try
- {
- NotificationProvider.SetGlobalBusyMessage("Disabling write filter protection...");
- await _uwf.Disable();
- await Task.Delay(2000);
- NotificationProvider.ReleaseGlobalBusyMessage();
- await NavigationManager.NavigateTo(Common.Navigation.NavigationView.RestartingSystemView);
- await Task.Delay(4000);
- _os.Restart();
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, "Error executing factory reset.");
- NotificationProvider.ReleaseGlobalBusyMessage();
- await NotificationProvider.ShowError($"Error executing factory reset.\n{ex.FlattenMessage()}");
- }
- finally
- {
- NotificationProvider.ReleaseGlobalBusyMessage();
- }
+ ApplicationManager.Restart();
}
}
@@ -160,8 +122,6 @@ namespace Tango.PPC.Technician.ViewModels
{
if (await NotificationProvider.ShowQuestion("Are you sure you want to restart the device?"))
{
- await NavigationManager.NavigateTo(Common.Navigation.NavigationView.RestartingSystemView);
- await Task.Delay(4000);
_os.Restart();
}
}
@@ -170,7 +130,12 @@ namespace Tango.PPC.Technician.ViewModels
{
if (await NotificationProvider.ShowQuestion("Close the application and start OS shell?"))
{
- _os.OpenShell();
+ Process.Start(new ProcessStartInfo()
+ {
+ UseShellExecute = true,
+ FileName = "explorer.exe",
+ });
+
ApplicationManager.ShutDown();
}
}
@@ -183,6 +148,12 @@ namespace Tango.PPC.Technician.ViewModels
_statsTimer.Start();
}
+ public override void OnApplicationReady()
+ {
+ base.OnApplicationReady();
+ IPAddress = GetIpv4Address();
+ }
+
private void _statsTimer_Elapsed(object sender, ElapsedEventArgs e)
{
if (IsVisible)
@@ -273,31 +244,5 @@ namespace Tango.PPC.Technician.ViewModels
return "N/A";
}
}
-
- public async override void OnNavigatedTo()
- {
- base.OnNavigatedTo();
-
- IPAddress = GetIpv4Address();
-
- try
- {
- using (ObservablesContext db = ObservablesContext.CreateDefault())
- {
- var jobRuns = await db.JobRuns.Select(x => new { x.StartDate, x.EndDate, x.EndPosition }).ToListAsync();
-
- TotalDyeTime = TimeSpan.FromHours(jobRuns.Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours)).ToStringUnlimitedHours();
-
- int meters = (int)jobRuns.Select(x => x.EndPosition).Sum();
- TotalDyeMeters = $"{meters.ToString("N0")} meters";
- }
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, "Error loading machine counters.");
- TotalDyeTime = "error!";
- TotalDyeMeters = "error!";
- }
- }
}
}