From b6b16143304b50744e974ddaa9c71c49766be4dc Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 9 Jan 2022 16:17:15 +0200 Subject: #5821 RML extension - Color calibration window --- .../Tango.MachineStudio.ThreadExtensions.csproj | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj index 9ea43ad0b..4af5d899b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj @@ -97,6 +97,8 @@ + + @@ -105,6 +107,9 @@ + + + @@ -112,6 +117,9 @@ AddItemDialog.xaml + + ColorCalibrationView.xaml + ColorParametersView.xaml @@ -145,6 +153,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -208,6 +220,10 @@ + + {37E4CEAB-B54B-451F-B535-04CF7DA9C459} + ColorMine + {bb2abb74-ba58-4812-83aa-ec8171f42df4} Tango.AutoComplete @@ -216,6 +232,10 @@ {f441feee-322a-4943-b566-110e12fd3b72} Tango.BL + + {b60c695c-61e8-4091-b506-4c45349c04aa} + Tango.ColorCalibration + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core @@ -228,6 +248,10 @@ {bc932dbd-7cdb-488c-99e4-f02cf441f55e} Tango.Logging + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} Tango.Settings -- cgit v1.3.1 From afdaadac0ddb76b5e905ef5eeda581ade4324f9b Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 19 Jan 2022 16:00:37 +0200 Subject: #5831 RML extension- Color shade window --- .../Models/ColorShadesModel.cs | 42 +++ .../Tango.MachineStudio.ThreadExtensions.csproj | 10 + .../ViewModels/ColorCalibrationTabVM.cs | 12 - .../ViewModels/ColorShadeTabVM.cs | 121 ++++++ .../ViewModels/ColorShadeViewVM.cs | 406 +++++++++++++++++++++ .../ViewModels/MainViewVM.cs | 22 +- .../Views/ColorShadeView.xaml | 162 ++++++++ .../Views/ColorShadeView.xaml.cs | 28 ++ .../Resources/ColorShadesTemplate.xlsx | Bin 0 -> 10366 bytes .../Builders/RMLExtensionColorShadeBuilder.cs | 61 ++++ .../Tango.BL/Calibration/CalibrationHelper.cs | 11 + .../Tango.BL/Calibration/ColorShadesTemplate.xlsx | Bin 0 -> 10366 bytes .../Entities/RmlExtensionColorShadesTestsData.cs | 22 ++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 4 +- 14 files changed, 887 insertions(+), 14 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml.cs create mode 100644 Software/Visual_Studio/Resources/ColorShadesTemplate.xlsx create mode 100644 Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorShadeBuilder.cs create mode 100644 Software/Visual_Studio/Tango.BL/Calibration/ColorShadesTemplate.xlsx (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs new file mode 100644 index 000000000..cc4351891 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Documents; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + public class ColorShadesModel + { + public class ColorShadesDataItem + { + public double ColorNumber { get; set; } + public double L { get; set; } + public double A { get; set; } + public double B { get; set; } + public double C { get; set; } + public double M { get; set; } + public double Y { get; set; } + public double L2 { get; set; } + public double A2 { get; set; } + public double B2 { get; set; } + } + + public void GetDataFromFile(string fileName, out List items, ref string errors) + { + items = null; + try + { + using (ExcelReader reader = new ExcelReader(fileName)) + { + items = reader.GetDataByIndex("Sheet1", 2); + } + } + catch (Exception ex) + { + errors = ex.Message; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj index 4af5d899b..065dec29e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj @@ -99,6 +99,7 @@ + @@ -111,6 +112,7 @@ + @@ -123,6 +125,10 @@ ColorParametersView.xaml + + ColorShadeView.xaml + + ComboboxEditable.xaml @@ -161,6 +167,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs index 0a27281ca..a2a119e29 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs @@ -314,18 +314,6 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels var points = liquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.OrderBy(y => y.Ink).ToList(); LoadDataPlots(points, GetPlot(liquidType), GetCalibrationDataVM(liquidType)); - //if (points.Count > 0) - //{ - // List items = new List(); - // points.ForEach(x => items.Add(new ColorLinearizationModel.LinearizationDataItem() { InkPercentage = x.Ink, L = x.L, A = x.A, B = x.B })); - // items.OrderBy(y => y.InkPercentage).ToList(); - // var index = 1; - // List calibrationPoints = new List(); - // points.ForEach(x => calibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = x.Ink, Y = x.CalculatedPoint })); - - - // CreatePlots(ConvertLiquidTypeToPMR(liquidType), GetPlot(liquidType), items, GetCalibrationDataVM(liquidType)); - //} } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs new file mode 100644 index 000000000..df0ba521c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; +using Tango.MachineStudio.ThreadExtensions.Models; +using Tango.BL.Enumerations; +using Tango.Core.Commands; +using Microsoft.Win32; +using Tango.MachineStudio.Common.Notifications; +using Tango.BL.ActionLogs; +using Tango.BL.Entities; +using Tango.Core; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class ColorShadeTabVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + + #region Properties + + private string _name; + /// + /// Gets or sets the name of the thread. Using in print + /// + public string Name + { + get { return _name; } + set + { + _name = value; + if (RmlExtensionColorShadesTest != null) + RmlExtensionColorShadesTest.Name = _name; + RaisePropertyChangedAuto(); + } + } + + private int _tabIndex; + + public int TabIndex + { + get { return _tabIndex; } + set + { + _tabIndex = value; + RaisePropertyChangedAuto(); + } + } + + + private bool _isSelected; + /// + /// Gets or sets a value indicating whether this instance is selected. + /// + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); } + } + + private RmlExtensionColorShadesTest _rmlExtensionColorShadesTest; + + public RmlExtensionColorShadesTest RmlExtensionColorShadesTest + { + get { return _rmlExtensionColorShadesTest; } + set + { + _rmlExtensionColorShadesTest = value; + RaisePropertyChangedAuto(); + } + } + + /// + /// Gets or sets last points before save. Used in Save to remove points before save new. + /// + /// + /// The removed points. + /// + public List RemovedDataList { get; set; } + + #endregion + + RelayCommand ImportColorsCommand { get; set; } + + public ColorShadeTabVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + ImportColorsCommand = new RelayCommand(ImportColors); + } + + private void ImportColors(object obj) + { + List items; + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select data file"; + dlg.Filter = "Excel |*.xlsx"; + items = null; + if (dlg.ShowDialogCenter() && dlg.FileName.IsNotNullOrEmpty()) + { + ColorShadesModel model = new ColorShadesModel(); + string errors = ""; + model.GetDataFromFile(dlg.FileName, out items, ref errors); + if (false == String.IsNullOrEmpty(errors) || items == null || items.Count == 0) + { + _notification.ShowError("An error occurred while trying to import data form the selected excel file. Please check the file format if valid and is available to read."); + + } + else + { + //Settings data to object + } + + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs new file mode 100644 index 000000000..b1dac5ce9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs @@ -0,0 +1,406 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.ActionLogs; +using Tango.BL.Builders; +using Tango.BL.Entities; +using Tango.Core; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; +using Tango.AutoComplete.Editors; +using Tango.MachineStudio.ThreadExtensions.Models; +using Tango.Core.Commands; +using Microsoft.Win32; +using Tango.Logging; +using Tango.MachineStudio.ThreadExtensions.ViewModels; +using System.Collections.ObjectModel; +using Tango.BL.Calibration; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class ColorShadeViewVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + + private ObservablesContext _active_context; + public event EventHandler SaveColorShadesEvent; + + #region Properties + + + private RmlExtensionColorShade _colorShade; + + public RmlExtensionColorShade RmlExtensionColorShade + { + get { return _colorShade; } + set { _colorShade = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection _colorShadeTabs; + + public ObservableCollection ColorShadeTabs + { + get { return _colorShadeTabs; } + set { _colorShadeTabs = value; } + } + + private ColorShadeTabVM _selectedTab; + + public ColorShadeTabVM SelectedTab + { + get { return _selectedTab; } + set + { + _selectedTab = value; + RaisePropertyChangedAuto(); + + foreach (var tab in _colorShadeTabs.Where(x => x != _selectedTab)) + { + tab.IsSelected = false; + } + + if (_selectedTab != null) + { + _selectedTab.IsSelected = true; + } + } + } + + private string _RMLExtentionGUID; + + public string RMLExtentionGUID + { + get { return _RMLExtentionGUID; } + set + { + _RMLExtentionGUID = value; + } + } + + private string _RMLGUID; + + public string RMLGUID + { + get { return _RMLGUID; } + set + { + _RMLGUID = value; + } + } + + protected string _selectedMachineGuid; + /// + /// Gets or sets the selected machine. + /// + public String SelectedMachineGUID + { + get { return _selectedMachineGuid; } + set + { + if (value != null && _selectedMachineGuid != value) + { + _selectedMachineGuid = value; + SelectedMachineChanged(); + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + } + } + } + + + private bool _isViewLoaded; + /// + /// Gets or sets a value indicating whether this instance is view loaded. Used to update charts. + /// + public bool IsViewLoaded + { + get { return _isViewLoaded; } + set + { + if (_isViewLoaded != value) + { + _isViewLoaded = value; + } + } + } + + #endregion + + #region commands + public RelayCommand CreateColorDataImportExcelTemplateCommand { get; set; } + + public RelayCommand SaveCommand { get; set; } + + public RelayCommand AddTabCommand { get; set; } + + public RelayCommand RemoveTabCommand { get; set; } + + public RelayCommand RenameTabCommand { get; set; } + + #endregion + + public ColorShadeViewVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + ColorShadeTabs = new ObservableCollection(); + + SaveCommand = new RelayCommand(Save, () => IsFree); + + AddTabCommand = new RelayCommand(() => AddNewTab()); + RemoveTabCommand = new RelayCommand(RemoveTab); + RenameTabCommand = new RelayCommand(RenameTab); + + CreateColorDataImportExcelTemplateCommand = new RelayCommand(CreateColorDataImportExcelTemplate); + } + + #region Loading + public async void LoadColorShades() + { + if (SelectedMachineGUID == null) + { + _notification.ShowWarning(LogManager.Log($"Please, select machine.", LogCategory.Warning)); + IsFree = false; + return; + } + if (RMLGUID == null) + { + IsFree = false; + return; + } + try + { + IsFree = false; + if (_active_context != null) + { + _active_context.Dispose(); + } + + _active_context = ObservablesContext.CreateDefault(); + + ColorShadeTabs.Clear(); + LogManager.Log("Loading color shade view ..."); + using (_notification.PushTaskItem("Loading Color Shade View ...")) + { + var testResults = await new RMLExtensionColorShadeBuilder(_active_context).SetAll().ForRMLExtension(RMLExtentionGUID).ForMachine(SelectedMachineGUID).WithTests().BuildAsync(); + RmlExtensionColorShade = testResults.OrderBy(x => x.ID).ToList().FirstOrDefault(); + if (RmlExtensionColorShade == null) + { + RmlExtensionColorShade = new RmlExtensionColorShade() { RmlsExtensionsGuid = RMLExtentionGUID, MachineGuid = SelectedMachineGUID }; + _active_context.RmlExtensionColorShades.Add(RmlExtensionColorShade); + _active_context.SaveChanges(); + } + + foreach (var test in RmlExtensionColorShade.RmlExtensionColorShadesTests) + { + ColorShadeTabs.Add(new ColorShadeTabVM(_notification, _actionLogManager) { RmlExtensionColorShadesTest = test, Name = test.Name }); + if (ColorShadeTabs.Count == 1) + SelectedTab = ColorShadeTabs[0]; + } + if (ColorShadeTabs.Count == 0) + { + SelectedTab = CreateNewColorShadeTabVM("Untitled", 1); + ColorShadeTabs.Add(SelectedTab); + _active_context.SaveChanges(); + } + if (IsViewLoaded) + { + // ColorShadeTabs.ToList().ForEach(x => x.InitData()); + } + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error loading Color Calibration tests.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + + private ColorShadeTabVM CreateNewColorShadeTabVM(string name, int index) + { + ColorShadeTabVM newtab = new ColorShadeTabVM(_notification, _actionLogManager) { Name = name, TabIndex = index }; + + newtab.RmlExtensionColorShadesTest = new RmlExtensionColorShadesTest() + { + RmlExtensionColorShadesGuid = RMLExtentionGUID, + Name = name + }; + if (RmlExtensionColorShade != null) + { + RmlExtensionColorShade.RmlExtensionColorShadesTests.Add(newtab.RmlExtensionColorShadesTest); + } + + return newtab; + } + #endregion + + #region Methods + + private void OnRMLExtensionGUIDChanged() + { + } + + private void SelectedMachineChanged() + { + SelectedTab = null; + LoadColorShades(); + } + + private void CreateColorDataImportExcelTemplate() + { + SaveFileDialog dlg = new SaveFileDialog(); + try + { + dlg.Title = $"Create excel template file"; + dlg.Filter = "Excel Files|*.xlsx"; + dlg.DefaultExt = ".xlsx"; + dlg.FileName = "Color Shades File Template"; + if (dlg.ShowDialog().Value) + { + CalibrationHelper.CreateColorShadesInputExcelTemplate(dlg.FileName); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error generating excel color shades template file " + dlg.FileName); + _notification.ShowError("An error occurred while trying to generate the color shades file."); + } + } + + #endregion + + #region Tabs modification + + /// + /// Removes the specified tab. + /// + /// The tab. + private void RemoveTab(ColorShadeTabVM tab) + { + if (ColorShadeTabs.Count == 1) + return; + if (_notification.ShowQuestion("Are you sure you want to delete the selected tab?")) + { + _active_context.RmlExtensionColorShadesTestsData.RemoveRange(tab.RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData.ToList()); + + //_active_context.RmlExtensionColorCalibrationsTestsLiquidData.RemoveRange(tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData); + tab.RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData = null; + + RmlExtensionColorShade.RmlExtensionColorShadesTests.Remove(tab.RmlExtensionColorShadesTest); + _active_context.RmlExtensionColorShadesTests.Remove(tab.RmlExtensionColorShadesTest); + + ColorShadeTabs.Remove(tab); + SelectedTab = ColorShadeTabs.LastOrDefault(); + _active_context.SaveChanges(); + } + } + + /// + /// Adds a new tab. + /// + private bool AddNewTab(String name = null) + { + if (ColorShadeTabs.Count > 7) + { + //_notification.ShowError("Cannot exceed the maximum number of 8 tabs. You can remove a tab, or create a new project."); + return false; + } + + if (name == null) + { + name = _notification.ShowTextInput("Enter tab name", "Tab Name", "Test"); + } + + if (!String.IsNullOrWhiteSpace(name)) + { + var tab = CreateNewColorShadeTabVM(name, (ColorShadeTabs.Count + 1)); + _active_context.SaveChanges(); + ColorShadeTabs.Add(tab); + SelectedTab = tab; + return true; + } + else + { + return false; + } + } + + /// + /// Renames the tab. + /// + /// The tab. + private void RenameTab() + { + if (SelectedTab != null) + { + var name = _notification.ShowTextInput("Enter tab name", "Tab Name", SelectedTab.Name); + + if (!String.IsNullOrWhiteSpace(name)) + { + SelectedTab.Name = name; + } + } + } + + #endregion + + #region Save + + public async void Save() + { + if (SelectedMachineGUID == null) + { + _notification.ShowWarning(LogManager.Log($"Could not save Color Shades. Please, select machine before save.", LogCategory.Warning)); + return; + } + + try + { + IsFree = false; + DateTime lastUpdated = DateTime.UtcNow; + RmlExtensionColorShade.LastUpdated = lastUpdated; + + foreach (var tab in ColorShadeTabs) + { + tab.RmlExtensionColorShadesTest.LastUpdated = lastUpdated; + //var removedPoints = tab.RemovedPoints; + //foreach (var liquidData in tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData) + //{ + // var liquidtype = _liquids.Where(l => l.Guid == liquidData.LiquidTypeGuid).FirstOrDefault(); + // if (liquidtype != null && removedPoints.ContainsKey(liquidtype.Type)) + // { + // _active_context.RmlExtensionColorCalibrationsTestsLiquidDataPoints.RemoveRange(removedPoints[liquidtype.Type]); + // } + // liquidData.LastUpdated = lastUpdated; + //} + //tab.RemovedPoints.Clear(); + } + await _active_context.SaveChangesAsync(); + + // LoadColorParameters(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not update color shades."); + _notification.ShowError($"An error occurred while trying to save color shades.\n{ex.Message}"); + } + finally + { + IsFree = true; + EventHandler handler = SaveColorShadesEvent; + handler?.Invoke(this, new EventArgs()); + } + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs index 1cc6e1dcc..47965deb4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs @@ -264,6 +264,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels set { _colorCalibrationViewVM = value; RaisePropertyChangedAuto(); } } + private ColorShadeViewVM _solorShadeViewVM; + public ColorShadeViewVM ColorShadeViewVM + { + get { return _solorShadeViewVM; } + set { _solorShadeViewVM = value; RaisePropertyChangedAuto(); } + } + + protected MachineModel _selectedMachine; /// /// Gets or sets the selected machine. @@ -1051,7 +1059,12 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels ColorCalibrationViewVM.ActiveRML = ActiveRML; ColorCalibrationViewVM.RMLGUID = ActiveRML.Guid; ColorCalibrationViewVM.Machine = SelectedMachine; - + + ColorShadeViewVM = new ColorShadeViewVM(_notification, _actionLogManager); + ColorShadeViewVM.RMLExtentionGUID = guid; + ColorShadeViewVM.RMLGUID = ActiveRML.Guid; + ColorShadeViewVM.SelectedMachineGUID = SelectedMachine != null ? SelectedMachine.Guid : null; ; + if (ActiveRMLExtension.RMLStatus == RMLExtensionStatus.New) { ColorParametersVewVM.SaveColorParameters -= UpdateStatus; @@ -1060,6 +1073,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels TestResultsViewVM.SaveTestResults += UpdateStatus; ColorCalibrationViewVM.SaveColorCalibration -= UpdateStatus; ColorCalibrationViewVM.SaveColorCalibration += UpdateStatus; + ColorShadeViewVM.SaveColorShadesEvent -= UpdateStatus; + ColorShadeViewVM.SaveColorShadesEvent += UpdateStatus; } View.NavigateTo(RMLExtensionNavigationView.RMLExtentionView); @@ -1123,6 +1138,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels ColorParametersVewVM.SaveColorParameters -= UpdateStatus; TestResultsViewVM.SaveTestResults -= UpdateStatus; ColorCalibrationViewVM.SaveColorCalibration -= UpdateStatus; + ColorShadeViewVM.SaveColorShadesEvent -= UpdateStatus; ActiveRMLExtension.RMLStatus = RMLExtensionStatus.InProgress; ActiveRMLExtension.LastUpdated = DateTime.UtcNow; @@ -1153,6 +1169,10 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { ColorCalibrationViewVM.Machine = SelectedMachine; } + if(ColorShadeViewVM != null) + { + ColorShadeViewVM.SelectedMachineGUID = SelectedMachine.Guid; + } } #endregion diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml new file mode 100644 index 000000000..70df4d6bf --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml.cs new file mode 100644 index 000000000..2a8079cfe --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.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.MachineStudio.ThreadExtensions.Views +{ + /// + /// Interaction logic for ColorShadeView.xaml + /// + public partial class ColorShadeView : UserControl + { + public ColorShadeView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/Resources/ColorShadesTemplate.xlsx b/Software/Visual_Studio/Resources/ColorShadesTemplate.xlsx new file mode 100644 index 000000000..cf98c2b1b Binary files /dev/null and b/Software/Visual_Studio/Resources/ColorShadesTemplate.xlsx differ diff --git a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorShadeBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorShadeBuilder.cs new file mode 100644 index 000000000..0f1894b4a --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorShadeBuilder.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using System.Data.Entity; + +namespace Tango.BL.Builders +{ + public class RMLExtensionColorShadeBuilder : EntityCollectionBuilderBase + { + public RMLExtensionColorShadeBuilder(ObservablesContext context) : base(context) + { + } + + public virtual RMLExtensionColorShadeBuilder ForRMLExtension(String rmlExtensionGUID) + { + return AddQueryStep(0, (query) => + { + if (rmlExtensionGUID != null) + { + return query.Where(x => x.RmlsExtensionsGuid == rmlExtensionGUID); + } + else + { + return query; + } + }); + } + public virtual RMLExtensionColorShadeBuilder ForMachine(String machineGUID) + { + return AddQueryStep(1, (query) => + { + if (machineGUID != null) + { + return query.Where(x => x.MachineGuid == machineGUID); + } + else + { + return query; + } + }); + } + public virtual RMLExtensionColorShadeBuilder WithTests() + { + return AddStep(2, () => + { + foreach (var result in Entities.ToList()) + { + var testsList = Context.RmlExtensionColorShadesTests.Where(x => x.RmlExtensionColorShadesGuid == result.Guid).Include(y => y.RmlExtensionColorShadesTestsData).OrderBy(z => z.ID).ToList(); + + //foreach (var test in testsList) + //{ + // var b = Context.RmlExtensionColorShadesTestsData.Where(x => x.RmlExtensionColorShadesTestsGuid == test.Guid).ToList(); + //} + } + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Calibration/CalibrationHelper.cs b/Software/Visual_Studio/Tango.BL/Calibration/CalibrationHelper.cs index b75a9751d..ced98dbff 100644 --- a/Software/Visual_Studio/Tango.BL/Calibration/CalibrationHelper.cs +++ b/Software/Visual_Studio/Tango.BL/Calibration/CalibrationHelper.cs @@ -72,5 +72,16 @@ namespace Tango.BL.Calibration stream.CopyTo(fs); } } + + public static void CreateColorShadesInputExcelTemplate(String fileName) + { + var stream = EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.BL.Calibration.ColorShadesTemplate.xlsx"); + + using (FileStream fs = new FileStream(fileName, FileMode.Create)) + { + stream.Seek(0, SeekOrigin.Begin); + stream.CopyTo(fs); + } + } } } diff --git a/Software/Visual_Studio/Tango.BL/Calibration/ColorShadesTemplate.xlsx b/Software/Visual_Studio/Tango.BL/Calibration/ColorShadesTemplate.xlsx new file mode 100644 index 000000000..cf98c2b1b Binary files /dev/null and b/Software/Visual_Studio/Tango.BL/Calibration/ColorShadesTemplate.xlsx differ diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs index 3d9c77b11..ac2c44f15 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs @@ -7,10 +7,32 @@ // the code is regenerated. Do not modify! // //------------------------------------------------------------------------------ +using ColorMine.ColorSpaces; +using Newtonsoft.Json; +using System.Windows.Media; +using System.ComponentModel.DataAnnotations.Schema; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; namespace Tango.BL.Entities { public class RmlExtensionColorShadesTestsData : RmlExtensionColorShadesTestsDataBase { + public RmlExtensionColorShadesTestsData() : base() + { + } + + + [NotMapped] + [JsonIgnore] + public SolidColorBrush ColorBrush + { + get { + Lab lab = new Lab(L, A, B); + Rgb rgb = (Rgb)lab.ToRgb(); + return new SolidColorBrush(Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B)); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index e76aff050..bcc6e303e 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -117,6 +117,7 @@ + @@ -736,6 +737,7 @@ Designer + Designer @@ -801,7 +803,7 @@ - + \ No newline at end of file -- cgit v1.3.1 From bfc9623f1b20c0a17e54bfbcdc59c43104afec78 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 30 Jan 2022 14:50:12 +0200 Subject: Added Data grid displaying all available recorded files for download. Related Work Items: #5820 --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Tango.MachineStudio.ThreadExtensions.csproj | 9 + .../ViewModels/TestResultViewVM.cs | 119 ++++++++++++- .../ViewModels/TestResultsViewVM.cs | 11 +- .../Views/TestResultsView.xaml | 121 +++++++++---- .../packages.config | 2 + .../RMLExtensionTestResultsCollectionBuilder.cs | 10 ++ .../Tango.BL/DTO/RmlExtensionTestResultsFileDTO.cs | 14 ++ .../DTO/RmlExtensionTestResultsFileDTOBase.cs | 49 +++++ .../Entities/RmlExtensionTestResultBase.cs | 38 ++++ .../Entities/RmlExtensionTestResultsFile.cs | 16 ++ .../Entities/RmlExtensionTestResultsFileBase.cs | 182 +++++++++++++++++++ .../Visual_Studio/Tango.BL/ObservablesContext.cs | 8 + .../ObservablesEntitiesAdapterExtension.cs | 38 ++++ .../ObservablesStaticCollectionsExtension.cs | 38 ++++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 6 +- .../DB/RML_EXTENSION_TEST_RESULTS.cs | 3 + .../DB/RML_EXTENSION_TEST_RESULTS_FILES.cs | 26 +++ .../Tango.DAL.Remote/DB/RemoteADO.Context.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 74 ++++++++ .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 197 +++++++++++---------- .../Tango.DAL.Remote/Tango.DAL.Remote.csproj | 5 +- 23 files changed, 822 insertions(+), 145 deletions(-) create mode 100644 Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTO.cs create mode 100644 Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTOBase.cs create mode 100644 Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFile.cs create mode 100644 Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFileBase.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS_FILES.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 0035ae1d8..a4a0facae 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 5ec2e2d21..e542c9bc0 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj index 065dec29e..ae05ca02c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj @@ -53,6 +53,15 @@ ..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll + + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll + + + ..\..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll + ..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll 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 41be789ed..68a886f99 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 @@ -1,8 +1,11 @@ using Microsoft.Win32; +using Microsoft.WindowsAPICodePack.Dialogs; using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Data.Entity; +using System.Diagnostics; using System.Text; using System.Threading.Tasks; using Tango.BL; @@ -10,6 +13,7 @@ using Tango.BL.ActionLogs; using Tango.BL.DTO; using Tango.BL.Entities; using Tango.BL.Enumerations; +using Tango.BL.ValueObjects; using Tango.Core.Commands; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.ThreadExtensions.Models; @@ -21,9 +25,9 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { private INotificationProvider _notification; private IActionLogManager _actionLogManager; - + #region Properties - + private string _threadName; /// /// Gets or sets the name of the thread. Using in print @@ -51,7 +55,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels get { return _isSelected; } set { _isSelected = value; RaisePropertyChangedAuto(); } } - + private RmlExtensionTestResult _testResult; public RmlExtensionTestResult TestResult @@ -59,19 +63,124 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels get { return _testResult; } set { _testResult = value; RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(TestResultsFiles)); } } - - #endregion + public List TestResultsFiles + { + get + { + return TestResult.RmlExtensionTestResultsFiles.ToList(); + } + } + public RelayCommand DeleteCommand { get; set; } + public RelayCommand DownLoadFileCommand { get; set; } + public RelayCommand UploadCommand { get; set; } + public RelayCommand DownLoadAllCommand { get; set; } + #endregion + public TestResultViewVM(INotificationProvider notification, IActionLogManager actionLogManager) { _notification = notification; _actionLogManager = actionLogManager; + + UploadCommand = new RelayCommand(UploadFiles); + DownLoadFileCommand = new RelayCommand(DownLoadFile); + DeleteCommand = new RelayCommand(DeleteFile); + DownLoadAllCommand = new RelayCommand(DownLoadAllFiles); } + + #region TestResultsFiles + private async void UploadFiles(object obj) + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select data file"; + dlg.Filter = "CSV Files|*.csv"; + dlg.Multiselect = true; + if (dlg.ShowDialog().Value) + { + try + { + var files = dlg.FileNames.ToList(); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var testResult = await db.RmlExtensionTestResults.Where(x => x.Guid == TestResult.Guid).Include(t1 => t1.RmlExtensionTestResultsFiles).FirstOrDefaultAsync(); + foreach (var strpath in files) + { + var testResultfile = new RmlExtensionTestResultsFile(); + testResultfile.FileName = Path.GetFileName(strpath); + //temporary!!! + testResultfile.FilePath = strpath; + + // TestResult.RmlExtensionTestResultsFiles.Add(testResultfile); + testResult.RmlExtensionTestResultsFiles.Add(testResultfile); + } + if (testResult != null) + { + await db.SaveChangesAsync(); + } + TestResult.RmlExtensionTestResultsFiles = testResult.RmlExtensionTestResultsFiles;///????? + RaisePropertyChanged(nameof(TestResultsFiles)); + } + _notification.ShowInfo("File successfully loaded."); + } + catch (Exception ex) + { + _notification.ShowError($"An error occurred while trying to import the file.\n{ex.FlattenMessage()}"); + } + } + + } + + private void DownLoadFile(RmlExtensionTestResultsFile file) + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Title = "Save the csv file"; + dlg.Filter = "CSV Files|*.csv"; + dlg.DefaultExt = ".csv"; + dlg.FileName = file.FileName; + if (dlg.ShowDialog().Value) + { + /// + } + } + + private void DownLoadAllFiles() + { + CommonOpenFileDialog dlg = new CommonOpenFileDialog(); + dlg.Title = "Select folder."; + dlg.IsFolderPicker = true; + if (dlg.ShowDialog() == CommonFileDialogResult.Ok) + { + var filesPath = TestResult.RmlExtensionTestResultsFiles.Select( x=>x.FilePath).ToList(); + ///// + } + } + + private async void DeleteFile(RmlExtensionTestResultsFile file) + { + if (_notification.ShowQuestion("Are you sure you want to delete the selected file?")) + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var deletefile = db.RmlExtensionTestResultsFiles.FirstOrDefault(x => x.Guid == file.Guid); + if(deletefile != null) + { + db.RmlExtensionTestResultsFiles.Remove(deletefile); + await db.SaveChangesAsync(); + } + } + TestResult.RmlExtensionTestResultsFiles.Remove(file); + RaisePropertyChanged(nameof(TestResultsFiles)); + } + } + #endregion + } } 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 c1fb4497f..f639eb6e7 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 @@ -1,6 +1,8 @@ -using System; +using Microsoft.Win32; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -271,7 +273,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels using (_notification.PushTaskItem("Loading Test Results Parameters ...")) { - var testResults = await new RMLExtensionTestResultsCollectionBuilder(_active_context).SetAll().ForRMLExtension(RMLExtemtionGUID).ForMachine(SelectedMachineGUID).WithRubbingAndTensileResults().BuildAsync(); + var testResults = await new RMLExtensionTestResultsCollectionBuilder(_active_context).SetAll().ForRMLExtension(RMLExtemtionGUID).ForMachine(SelectedMachineGUID).WithRubbingAndTensileResults().WithTestResultsFiles().BuildAsync(); SelectedTestResults = testResults.OrderBy(x => x.ResultIndex).ToSynchronizedObservableCollection(); foreach (var result in SelectedTestResults) { @@ -403,6 +405,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels #endregion + #region Excel + public async void LoadTestResultsExcel(List testResultsExcelModelList, string machineGUID, string machineSerialNumber) { try @@ -556,5 +560,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels IsFree = true; } } + + #endregion + } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml index b8a4b7f28..f6262b52d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml @@ -158,33 +158,12 @@ - + - - + --> + + @@ -266,17 +245,16 @@ + - - - - - + + + @@ -289,8 +267,8 @@ - - Process Parameters @@ -386,7 +364,7 @@ - + Tension through the thread path @@ -627,7 +605,7 @@ - + @@ -637,16 +615,83 @@ - Conclusion: + Conclusion: - Comments: - + Comments: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/packages.config index da5ed8abc..f9bce0fbf 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/packages.config @@ -6,6 +6,8 @@ + + diff --git a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionTestResultsCollectionBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionTestResultsCollectionBuilder.cs index 574439852..2b962d56b 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionTestResultsCollectionBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionTestResultsCollectionBuilder.cs @@ -26,6 +26,16 @@ namespace Tango.BL.Builders } }); } + public virtual RMLExtensionTestResultsCollectionBuilder WithTestResultsFiles() + { + return AddStep(3, () => + { + foreach (var result in Entities.ToList()) + { + Context.RmlExtensionTestResultsFiles.Where(x => x.RmlExtensionTestResultsGuid == result.Guid).OrderBy(x => x.FileName).ToList(); + } + }); + } public virtual RMLExtensionTestResultsCollectionBuilder ForRMLExtension(String rmlExtensionGUID) { return AddQueryStep(0, (query) => diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTO.cs new file mode 100644 index 000000000..0e06e750e --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTO.cs @@ -0,0 +1,14 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.BL.DTO +{ + public class RmlExtensionTestResultsFileDTO : RmlExtensionTestResultsFileDTOBase + { + + } +} diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTOBase.cs new file mode 100644 index 000000000..f06cdb159 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionTestResultsFileDTOBase.cs @@ -0,0 +1,49 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.BL.DTO +{ + public abstract class RmlExtensionTestResultsFileDTOBase : ObservableEntityDTO + { + + /// + /// rml extension test results guid + /// + public String RmlExtensionTestResultsGuid + { + get; set; + } + + /// + /// file name + /// + public String FileName + { + get; set; + } + + /// + /// file path + /// + public String FilePath + { + get; set; + } + + } +} diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultBase.cs index 561b311d7..7f6804039 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultBase.cs @@ -93,6 +93,8 @@ namespace Tango.BL.Entities public event EventHandler MachineChanged; + public event EventHandler> RmlExtensionTestResultsFilesChanged; + public event EventHandler> RubbingResultsChanged; protected String _rmlsextensionsguid; @@ -1046,6 +1048,31 @@ namespace Tango.BL.Entities } } + protected SynchronizedObservableCollection _rmlextensiontestresultsfiles; + + /// + /// Gets or sets the rmlextensiontestresultbase rml extension test results files. + /// + + public virtual SynchronizedObservableCollection RmlExtensionTestResultsFiles + { + get + { + return _rmlextensiontestresultsfiles; + } + + set + { + if (_rmlextensiontestresultsfiles != value) + { + _rmlextensiontestresultsfiles = value; + + OnRmlExtensionTestResultsFilesChanged(value); + + } + } + } + protected SynchronizedObservableCollection _rubbingresults; /// @@ -1368,6 +1395,15 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(Machine)); } + /// + /// Called when the RmlExtensionTestResultsFiles has changed. + /// + protected virtual void OnRmlExtensionTestResultsFilesChanged(SynchronizedObservableCollection rmlextensiontestresultsfiles) + { + RmlExtensionTestResultsFilesChanged?.Invoke(this, rmlextensiontestresultsfiles); + RaisePropertyChanged(nameof(RmlExtensionTestResultsFiles)); + } + /// /// Called when the RubbingResults has changed. /// @@ -1385,6 +1421,8 @@ namespace Tango.BL.Entities TensileResults = new SynchronizedObservableCollection(); + RmlExtensionTestResultsFiles = new SynchronizedObservableCollection(); + RubbingResults = new SynchronizedObservableCollection(); } diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFile.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFile.cs new file mode 100644 index 000000000..5ae38f7f5 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFile.cs @@ -0,0 +1,16 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +namespace Tango.BL.Entities +{ + public class RmlExtensionTestResultsFile : RmlExtensionTestResultsFileBase + { + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFileBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFileBase.cs new file mode 100644 index 000000000..37cc8fd4a --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionTestResultsFileBase.cs @@ -0,0 +1,182 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Xml.Serialization; +using Newtonsoft.Json; +using System.Linq; +using Tango.DAL.Remote.DB; +using Tango.Core; +using System.ComponentModel; +using Tango.Core.CustomAttributes; + +namespace Tango.BL.Entities +{ + [Table("RML_EXTENSION_TEST_RESULTS_FILES")] + public abstract class RmlExtensionTestResultsFileBase : ObservableEntity + { + + public event EventHandler FileNameChanged; + + public event EventHandler FilePathChanged; + + public event EventHandler RmlExtensionTestResultsChanged; + + protected String _rmlextensiontestresultsguid; + + /// + /// Gets or sets the rmlextensiontestresultsfilebase rml extension test results guid. + /// + + [Column("RML_EXTENSION_TEST_RESULTS_GUID")] + [ForeignKey("RmlExtensionTestResults")] + + public String RmlExtensionTestResultsGuid + { + get + { + return _rmlextensiontestresultsguid; + } + + set + { + if (_rmlextensiontestresultsguid != value) + { + _rmlextensiontestresultsguid = value; + + } + } + } + + protected String _filename; + + /// + /// Gets or sets the rmlextensiontestresultsfilebase file name. + /// + + [Column("FILE_NAME")] + + public String FileName + { + get + { + return _filename; + } + + set + { + if (_filename != value) + { + _filename = value; + + OnFileNameChanged(value); + + } + } + } + + protected String _filepath; + + /// + /// Gets or sets the rmlextensiontestresultsfilebase file path. + /// + + [Column("FILE_PATH")] + + public String FilePath + { + get + { + return _filepath; + } + + set + { + if (_filepath != value) + { + _filepath = value; + + OnFilePathChanged(value); + + } + } + } + + protected RmlExtensionTestResult _rmlextensiontestresults; + + /// + /// Gets or sets the rmlextensiontestresultsfilebase rml extension test results. + /// + + [XmlIgnore] + [JsonIgnore] + public virtual RmlExtensionTestResult RmlExtensionTestResults + { + get + { + return _rmlextensiontestresults; + } + + set + { + if (_rmlextensiontestresults != value) + { + _rmlextensiontestresults = value; + + if (RmlExtensionTestResults != null) + { + RmlExtensionTestResultsGuid = RmlExtensionTestResults.Guid; + } + + OnRmlExtensionTestResultsChanged(value); + + } + } + } + + /// + /// Called when the FileName has changed. + /// + protected virtual void OnFileNameChanged(String filename) + { + FileNameChanged?.Invoke(this, filename); + RaisePropertyChanged(nameof(FileName)); + } + + /// + /// Called when the FilePath has changed. + /// + protected virtual void OnFilePathChanged(String filepath) + { + FilePathChanged?.Invoke(this, filepath); + RaisePropertyChanged(nameof(FilePath)); + } + + /// + /// Called when the RmlExtensionTestResults has changed. + /// + protected virtual void OnRmlExtensionTestResultsChanged(RmlExtensionTestResult rmlextensiontestresults) + { + RmlExtensionTestResultsChanged?.Invoke(this, rmlextensiontestresults); + RaisePropertyChanged(nameof(RmlExtensionTestResults)); + } + + /// + /// Initializes a new instance of the class. + /// + public RmlExtensionTestResultsFileBase() : base() + { + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/ObservablesContext.cs b/Software/Visual_Studio/Tango.BL/ObservablesContext.cs index 382bb0dca..16e44759b 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesContext.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesContext.cs @@ -758,6 +758,14 @@ namespace Tango.BL get; set; } + /// + /// Gets or sets the RmlExtensionTestResultsFiles. + /// + public DbSet RmlExtensionTestResultsFiles + { + get; set; + } + /// /// Gets or sets the Rmls. /// diff --git a/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs index a95bbd787..b18a39cb6 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs @@ -3329,6 +3329,42 @@ namespace Tango.BL } + private ObservableCollection _rmlextensiontestresultsfiles; + /// + /// Gets or sets the RmlExtensionTestResultsFiles. + /// + public ObservableCollection RmlExtensionTestResultsFiles + { + get + { + return _rmlextensiontestresultsfiles; + } + + set + { + _rmlextensiontestresultsfiles = value; RaisePropertyChanged(nameof(RmlExtensionTestResultsFiles)); + } + + } + + private ICollectionView _rmlextensiontestresultsfilesViewSource; + /// + /// Gets or sets the RmlExtensionTestResultsFiles View Source. + /// + public ICollectionView RmlExtensionTestResultsFilesViewSource + { + get + { + return _rmlextensiontestresultsfilesViewSource; + } + + set + { + _rmlextensiontestresultsfilesViewSource = value; RaisePropertyChanged(nameof(RmlExtensionTestResultsFilesViewSource)); + } + + } + private ObservableCollection _rmls; /// /// Gets or sets the Rmls. @@ -4383,6 +4419,8 @@ namespace Tango.BL RmlExtensionColorShadesTestsDataViewSource = CreateCollectionView(RmlExtensionColorShadesTestsData); + RmlExtensionTestResultsFilesViewSource = CreateCollectionView(RmlExtensionTestResultsFiles); + RmlsViewSource = CreateCollectionView(Rmls); RmlsSpoolsViewSource = CreateCollectionView(RmlsSpools); diff --git a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs index f4ccd1d88..d5f9c0bb9 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs @@ -3329,6 +3329,42 @@ namespace Tango.BL } + private ObservableCollection _rmlextensiontestresultsfiles; + /// + /// Gets or sets the RmlExtensionTestResultsFiles. + /// + public ObservableCollection RmlExtensionTestResultsFiles + { + get + { + return _rmlextensiontestresultsfiles; + } + + set + { + _rmlextensiontestresultsfiles = value; RaisePropertyChanged(nameof(RmlExtensionTestResultsFiles)); + } + + } + + private ICollectionView _rmlextensiontestresultsfilesViewSource; + /// + /// Gets or sets the RmlExtensionTestResultsFiles View Source. + /// + public ICollectionView RmlExtensionTestResultsFilesViewSource + { + get + { + return _rmlextensiontestresultsfilesViewSource; + } + + set + { + _rmlextensiontestresultsfilesViewSource = value; RaisePropertyChanged(nameof(RmlExtensionTestResultsFilesViewSource)); + } + + } + private ObservableCollection _rmls; /// /// Gets or sets the Rmls. @@ -4383,6 +4419,8 @@ namespace Tango.BL RmlExtensionColorShadesTestsDataViewSource = CreateCollectionView(RmlExtensionColorShadesTestsData); + RmlExtensionTestResultsFilesViewSource = CreateCollectionView(RmlExtensionTestResultsFiles); + RmlsViewSource = CreateCollectionView(Rmls); RmlsSpoolsViewSource = CreateCollectionView(RmlsSpools); diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index bcc6e303e..76f521843 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -305,6 +305,8 @@ + + @@ -489,6 +491,8 @@ + + @@ -803,7 +807,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS.cs index b1a5ae94f..c530978d8 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS.cs @@ -18,6 +18,7 @@ namespace Tango.DAL.Remote.DB public RML_EXTENSION_TEST_RESULTS() { this.TENSILE_RESULTS = new HashSet(); + this.RML_EXTENSION_TEST_RESULTS_FILES = new HashSet(); this.RUBBING_RESULTS = new HashSet(); } @@ -62,6 +63,8 @@ namespace Tango.DAL.Remote.DB public virtual ICollection TENSILE_RESULTS { get; set; } public virtual MACHINE MACHINE { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection RML_EXTENSION_TEST_RESULTS_FILES { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection RUBBING_RESULTS { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS_FILES.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS_FILES.cs new file mode 100644 index 000000000..5d51a4c8a --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_TEST_RESULTS_FILES.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.DAL.Remote.DB +{ + using System; + using System.Collections.Generic; + + public partial class RML_EXTENSION_TEST_RESULTS_FILES + { + public int ID { get; set; } + public string GUID { get; set; } + public System.DateTime LAST_UPDATED { get; set; } + public string RML_EXTENSION_TEST_RESULTS_GUID { get; set; } + public string FILE_NAME { get; set; } + public string FILE_PATH { get; set; } + + public virtual RML_EXTENSION_TEST_RESULTS RML_EXTENSION_TEST_RESULTS { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs index c89fc2a1f..17f6c87f0 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs @@ -117,6 +117,7 @@ namespace Tango.DAL.Remote.DB public virtual DbSet RML_EXTENSION_COLOR_SHADES { get; set; } public virtual DbSet RML_EXTENSION_COLOR_SHADES_TESTS { get; set; } public virtual DbSet RML_EXTENSION_COLOR_SHADES_TESTS_DATA { get; set; } + public virtual DbSet RML_EXTENSION_TEST_RESULTS_FILES { get; set; } public virtual DbSet RMLS { get; set; } public virtual DbSet RMLS_SPOOLS { get; set; } public virtual DbSet ROLES { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index ae70f1ed6..09dded898 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -1219,6 +1219,17 @@ + + + + + + + + + + + @@ -2776,6 +2787,20 @@ + + + + + + + + + + + + + + @@ -3435,6 +3460,7 @@ + @@ -3785,6 +3811,10 @@ + + + + @@ -4123,6 +4153,7 @@ + @@ -4523,6 +4554,10 @@ + + + + @@ -4679,6 +4714,7 @@ + @@ -6333,6 +6369,18 @@ + + + + + + + + + + + + @@ -7983,6 +8031,20 @@ + + + + + + + + + + + + + + @@ -9649,6 +9711,18 @@ + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index a72a68e1f..859ff927d 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,104 +5,105 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj index 10f151494..da4624d61 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj +++ b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj @@ -324,6 +324,9 @@ RemoteADO.tt + + RemoteADO.tt + RemoteADO.tt @@ -479,7 +482,7 @@ - + \ No newline at end of file -- cgit v1.3.1