diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2019-07-28 13:24:28 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2019-07-28 13:24:28 +0300 |
| commit | 230ea9b597a2932f5d16572d94ee14c862d5b419 (patch) | |
| tree | 7e260db879dd815f5350e11a4a85ca04514237b7 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels | |
| parent | 16cc209e80498a0b39c1ad57d4f36be906cbb313 (diff) | |
| parent | 30759321e22e22363eda9387e178b4d48b7d9088 (diff) | |
| download | Tango-230ea9b597a2932f5d16572d94ee14c862d5b419.tar.gz Tango-230ea9b597a2932f5d16572d94ee14c862d5b419.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels')
2 files changed, 47 insertions, 1 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs index 5467c53a0..16f6938a0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs @@ -3,12 +3,14 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; using Tango.BL.Entities; using Tango.Core.Commands; using Tango.MachineStudio.Common.Diagnostics; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.StudioApplication; using Tango.SharedUI; +using System.Data.Entity; namespace Tango.MachineStudio.UI.ViewModels { @@ -39,6 +41,19 @@ namespace Tango.MachineStudio.UI.ViewModels set { _diagnosticsFrameProvider = value; RaisePropertyChangedAuto(); } } + private String _totalMachineWorkTime; + public String TotalMachineWorkTime + { + get { return _totalMachineWorkTime; } + set { _totalMachineWorkTime = value; RaisePropertyChangedAuto(); } + } + + private String _totalMachineMeters; + public String TotalMachineMeters + { + get { return _totalMachineMeters; } + set { _totalMachineMeters = value; RaisePropertyChangedAuto(); } + } public RelayCommand DisconnectCommand { get; set; } @@ -64,5 +79,36 @@ namespace Tango.MachineStudio.UI.ViewModels Result = result; Accept(); } + + public override void OnShow() + { + base.OnShow(); + LoadMachineCounters(); + } + + private async void LoadMachineCounters() + { + try + { + TotalMachineMeters = "loading..."; + TotalMachineWorkTime = "loading..."; + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var jobs = await db.Jobs.Include(x => x.JobRuns).Where(x => x.MachineGuid == ApplicationManager.Machine.Guid).ToListAsync(); + + TotalMachineWorkTime = TimeSpan.FromHours(jobs.SelectMany(x => x.JobRuns).Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours)).ToString(@"hh\:mm\:ss"); + + int meters = (int)jobs.SelectMany(x => x.JobRuns).Select(x => x.EndPosition).Sum(); + TotalMachineMeters = $"{meters.ToString("N0")} meters"; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error loading machine counters."); + TotalMachineMeters = "error!"; + TotalMachineWorkTime = "error!"; + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs index 1165c0920..b9cd82979 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -193,7 +193,7 @@ namespace Tango.MachineStudio.UI.ViewModels catch (Exception ex) { LogManager.Log(ex, "Login Error."); - _notificationProvider.ShowError($"The specified email or password was incorrect, or you don't have a permission to run this application.\nError: {ex.FlattenMessage()}"); + _notificationProvider.ShowError($"An error occurred while trying to perform the logging operation.\n{ex.FlattenMessage()}"); } finally { |
