diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2022-07-28 18:33:11 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2022-07-28 18:33:11 +0300 |
| commit | 516ee0b585d84bda4fcc3c31aa44d1e3b7da5e93 (patch) | |
| tree | 053fbe2319447bc13bcf188cc369d7f2dc2df809 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels | |
| parent | 8c5f88c83e1c81202aeafe64b9a9381e3ebf852d (diff) | |
| download | Tango-516ee0b585d84bda4fcc3c31aa44d1e3b7da5e93.tar.gz Tango-516ee0b585d84bda4fcc3c31aa44d1e3b7da5e93.zip | |
MS. RML extension. Added table washing test results , GUI and database.
Related Work Items: #6660
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels')
2 files changed, 69 insertions, 9 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultViewVM.cs index 68a886f99..624ee7216 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultViewVM.cs @@ -18,6 +18,7 @@ using Tango.Core.Commands; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.ThreadExtensions.Models; using Tango.SharedUI; +using System.Collections.ObjectModel; namespace Tango.MachineStudio.ThreadExtensions.ViewModels { @@ -66,6 +67,18 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels RaisePropertyChanged(nameof(TestResultsFiles)); } } + + private ObservableCollection<WashingMaterialColorModel> _colorsToMaterialCollection; + + public ObservableCollection<WashingMaterialColorModel> ColorsToMaterialCollection + { + get { return _colorsToMaterialCollection; } + set { _colorsToMaterialCollection = value; + RaisePropertyChangedAuto(); + } + } + + public List<RmlExtensionTestResultsFile> TestResultsFiles { @@ -91,6 +104,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels DownLoadFileCommand = new RelayCommand<RmlExtensionTestResultsFile>(DownLoadFile); DeleteCommand = new RelayCommand<RmlExtensionTestResultsFile>(DeleteFile); DownLoadAllCommand = new RelayCommand(DownLoadAllFiles); + } #region TestResultsFiles diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs index cc1bba0e7..2dd444f0f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs @@ -275,7 +275,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels ResultTabs.Clear(); if(WashingTestMaterials == null) - WashingTestMaterials = _active_context.WashingTestMaterials.ToList(); + WashingTestMaterials = _active_context.WashingTestMaterials.OrderBy(x=> x.Name).ToList(); LogManager.Log("Loading selected test results..."); @@ -336,25 +336,54 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels CreateWashingResult(newtab); + return newtab; } private void CreateWashingResult(TestResultViewVM testresultViewVM) { - if(testresultViewVM.TestResult.RmlExtensionTestWashingResults != null) - return; - - var whashingresults = new SynchronizedObservableCollection<RmlExtensionTestWashingResult>(); - foreach (var material in WashingTestMaterials) + if(testresultViewVM.TestResult.RmlExtensionTestWashingResults != null && testresultViewVM.TestResult.RmlExtensionTestWashingResults.Count > 0 ) { - foreach (WashingResultColor color in Enum.GetValues(typeof(WashingResultColor))) + var collection = new ObservableCollection<WashingMaterialColorModel>(); + Dictionary<int, WashingMaterialColorModel> colorDictionary = new Dictionary<int, WashingMaterialColorModel>(); + List< RmlExtensionTestWashingResult > washingResultsOrdersByColor = testresultViewVM.TestResult.RmlExtensionTestWashingResults.OrderBy(x=>x.IndexRow).ThenBy(c => c.WashingTestMaterials != null ? c.WashingTestMaterials.Name : c.WashingTestMaterialsGuid).ToList(); + foreach (var res in washingResultsOrdersByColor) { - whashingresults.Add(new RmlExtensionTestWashingResult() { RmlExtensionTestResultsGuid = testresultViewVM.TestResult.Guid, WashingTestMaterialsGuid = material.Guid, Color = (int)color }); + WashingMaterialColorModel wmodel = null; + if(false == colorDictionary.TryGetValue(res.IndexRow, out wmodel)) + { + wmodel = new WashingMaterialColorModel() { Color = res.Color }; + colorDictionary.Add(res.IndexRow, wmodel); + collection.Add(wmodel); + } + wmodel.AddMaterial(res.Guid, res.GetMaterialName, res.WashingValue); } + testresultViewVM.ColorsToMaterialCollection = collection; } - testresultViewVM.TestResult.RmlExtensionTestWashingResults = whashingresults; + else + { + var whashingresults = new SynchronizedObservableCollection<RmlExtensionTestWashingResult>(); + var collecction = new ObservableCollection<WashingMaterialColorModel>(); + for (int index_row = 0; index_row < 6; index_row++) + { + var model = new WashingMaterialColorModel() { Color = -1 }; + + foreach (var material in WashingTestMaterials) + { + var rmlExtensionTestWashingResult = new RmlExtensionTestWashingResult() { RmlExtensionTestResultsGuid = testresultViewVM.TestResult.Guid, WashingTestMaterialsGuid = material.Guid, Color = -1, IndexRow = index_row }; + model.AddMaterial(rmlExtensionTestWashingResult.Guid, material.Name, null); + rmlExtensionTestWashingResult.WashingTestMaterials = material; + whashingresults.Add(rmlExtensionTestWashingResult); + + } + collecction.Add( model); + } + testresultViewVM.ColorsToMaterialCollection = collecction; + testresultViewVM.TestResult.RmlExtensionTestWashingResults = whashingresults; + } } + #endregion #region Save @@ -398,6 +427,22 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } } + public void ApplyToWashingResults(TestResultViewVM testresultViewVM) + { + foreach ( var model in testresultViewVM.ColorsToMaterialCollection) + { + foreach( var colormodel in model.ColorValues) + { + var result = testresultViewVM.TestResult.RmlExtensionTestWashingResults.FirstOrDefault(x=> x.Guid == colormodel.RmlExtensionTestWashingResultGUID); + if( result != null) + { + result.Color = model.Color; + result.WashingValue = colormodel.ColorValue; + } + } + } + } + public async void Save() { if (String.IsNullOrEmpty(SelectedMachineGUID)) @@ -412,6 +457,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { foreach (var tab in ResultTabs) { + ApplyToWashingResults(tab); tab.TestResult.LastUpdated = DateTime.UtcNow; } _active_context.SaveChanges(); |
