diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2021-11-25 10:17:16 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2021-11-25 10:17:16 +0200 |
| commit | 62d65c64a9a1e44aca6421ddc7a385a6d4b7361e (patch) | |
| tree | c1541168c59b130526bfc3459dea0c592a5c2e3e /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels | |
| parent | b88f12398df6b1d3126369a4016eceecdfa4dbc8 (diff) | |
| download | Tango-62d65c64a9a1e44aca6421ddc7a385a6d4b7361e.tar.gz Tango-62d65c64a9a1e44aca6421ddc7a385a6d4b7361e.zip | |
#5818 -Export to Excel file
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels')
4 files changed, 279 insertions, 139 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorParametersVewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorParametersVewVM.cs index c60c65216..e13e016c5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorParametersVewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorParametersVewVM.cs @@ -782,6 +782,104 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } #endregion + + #region export to excel + + public void WritetoExcel(ColorParametrsExcelModel colorParametrsExcelModel, string machineGuid) + { + if (_active_context == null) + { + _active_context = ObservablesContext.CreateDefault(); + } + var colorProcessParametercur = _active_context.ColorProcessParameters.Where(x => x.RmlsExtensionsGuid == RMLExtemtionGUID && x.MachineGuid == machineGuid).FirstOrDefault(); + if (colorProcessParametercur == null) + return; + var colorProcessParameter = new ColorProcessParametersBuilder(_active_context).Set(colorProcessParametercur.Guid).WithColorProcessData().WithColorProcessFactor().WithColorProcessInkUptake().Build(); + var factor_cyan100 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.CYAN && x.FactorPercent == 100).FirstOrDefault(); + if (factor_cyan100 != null) + { + colorParametrsExcelModel.Factor_100__C = factor_cyan100.InkNlCm; + colorParametrsExcelModel.Factor_100__Cyan_L = factor_cyan100.L; + colorParametrsExcelModel.Factor_100__Cyan_A = factor_cyan100.A; + colorParametrsExcelModel.Factor_100__Cyan_B = factor_cyan100.B; + } + + var factor_magenta100 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.MAGENTA && x.FactorPercent == 100).FirstOrDefault(); + if (factor_magenta100 != null) + { + colorParametrsExcelModel.Factor_100__M = factor_magenta100.InkNlCm; + colorParametrsExcelModel.Factor_100__Magenta_L = factor_magenta100.L; + colorParametrsExcelModel.Factor_100__Magenta_A = factor_magenta100.A; + colorParametrsExcelModel.Factor_100__Magenta_B = factor_magenta100.B; + } + + var factor_yellow100 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.YELLOW && x.FactorPercent == 100).FirstOrDefault(); + if (factor_yellow100 != null) + { + colorParametrsExcelModel.Factor_100__Y = factor_yellow100.InkNlCm; + colorParametrsExcelModel.Factor_100__Yellow_L = factor_yellow100.L; + colorParametrsExcelModel.Factor_100__Yellow_A = factor_yellow100.A; + colorParametrsExcelModel.Factor_100__Yellow_B = factor_yellow100.B; + } + + var factor_key100 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.BLACK && x.FactorPercent == 100).FirstOrDefault(); + if (factor_key100 != null) + { + colorParametrsExcelModel.Factor_100_K = factor_key100.InkNlCm; + colorParametrsExcelModel.Factor_100__Key_L = factor_key100.L; + colorParametrsExcelModel.Factor_100__Key_A = factor_key100.A; + colorParametrsExcelModel.Factor_100__Key_B = factor_key100.B; + } + + var factor_cyan200 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.CYAN && x.FactorPercent == 200).FirstOrDefault(); + if (factor_cyan200 != null) + { + colorParametrsExcelModel.Factor_200_C = factor_cyan200.InkNlCm; + colorParametrsExcelModel.Factor_200__Cyan_L = factor_cyan200.L; + colorParametrsExcelModel.Factor_200__Cyan_A = factor_cyan200.A; + colorParametrsExcelModel.Factor_200__Cyan_B = factor_cyan200.B; + } + + var factor_magenta200 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.MAGENTA && x.FactorPercent == 200).FirstOrDefault(); + if (factor_magenta200 != null) + { + colorParametrsExcelModel.Factor_200__Magenta = factor_magenta200.InkNlCm; + colorParametrsExcelModel.Factor_200__Magenta_L = factor_magenta200.L; + colorParametrsExcelModel.Factor_200__Magenta_A = factor_magenta200.A; + colorParametrsExcelModel.Factor_200__Magenta_B = factor_magenta200.B; + } + + var factor_yellow200 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.YELLOW && x.FactorPercent == 200).FirstOrDefault(); + if (factor_yellow200 != null) + { + colorParametrsExcelModel.Factor_200__Yellow = factor_yellow200.InkNlCm; + colorParametrsExcelModel.Factor_200__Yellow_L = factor_yellow200.L; + colorParametrsExcelModel.Factor_200__Yellow_A = factor_yellow200.A; + colorParametrsExcelModel.Factor_200__Yellow_B = factor_yellow200.B; + } + + var factor_key200 = colorProcessParameter.ColorProcessFactors.Where(x => x.FactorColor == FactorColors.BLACK && x.FactorPercent == 200).FirstOrDefault(); + if (factor_key200 != null) + { + colorParametrsExcelModel.Factor_200__Key = factor_key200.InkNlCm; + colorParametrsExcelModel.Factor_200__Key_L = factor_key200.L; + colorParametrsExcelModel.Factor_200__Key_A = factor_key200.A; + colorParametrsExcelModel.Factor_200__Key_B = factor_key200.B; + } + + foreach (var inkUptakeZone in colorProcessParameter.ColorProcessInkUptake) + { + if (inkUptakeZone.InkUptakeZoneType == InkUptakeZoneTypes.MININKUPTAKEZONE1) + colorParametrsExcelModel.Min_Ink_Uptake_Zone1 = (inkUptakeZone.InkValue == null) ? 0 : (int)inkUptakeZone.InkValue; + else if (inkUptakeZone.InkUptakeZoneType == InkUptakeZoneTypes.MININKUPTAKEZONE2) + colorParametrsExcelModel.Min_Ink_Uptake_Zone2 = (inkUptakeZone.InkValue == null) ? 0 : (int)inkUptakeZone.InkValue; + else if (inkUptakeZone.InkUptakeZoneType == InkUptakeZoneTypes.MAXINKUPTAKEZONE1) + colorParametrsExcelModel.Max_Ink_Uptake_Zone1 = (inkUptakeZone.InkValue == null) ? 0 : (int)inkUptakeZone.InkValue; + else if (inkUptakeZone.InkUptakeZoneType == InkUptakeZoneTypes.MAXINKUPTAKEZONE2) + colorParametrsExcelModel.Max_ink_uptake__Zone2 = (inkUptakeZone.InkValue == null) ? 0 : (int)inkUptakeZone.InkValue; + } + } + #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 954500b60..6b95cf190 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 @@ -1255,8 +1255,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels // .Set(SelectedRMLExtension.RMLGuid) // .Build(); - List<ThreadCharacteristicsExelModel> threadCharacteristicsExelModels = new List<ThreadCharacteristicsExelModel>(); - ThreadCharacteristicsExelModel model = new ThreadCharacteristicsExelModel(); + List<ThreadCharacteristicsExcelModel> threadCharacteristicsExelModels = new List<ThreadCharacteristicsExcelModel>(); + ThreadCharacteristicsExcelModel model = new ThreadCharacteristicsExcelModel(); model.ThreadName = ActiveRML.Name; model.Manufacturer = ActiveRML.Manufacturer == null? "": ActiveRML.Manufacturer; model.Brand = ActiveRMLExtension.YarnBrand == null ? "": ActiveRMLExtension.YarnBrand.Name; @@ -1283,18 +1283,33 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels model.Twist = ActiveRMLExtension.TwistTpm; model.TwistDirection = ActiveRMLExtension.YarnTwistDirections.ToDescription(); threadCharacteristicsExelModels.Add(model); - writer.WriteData(threadCharacteristicsExelModels, "Thread characteristics"); - //List<ColorGroup> groups = ActiveCatalog.ColorCatalogsGroups.Select(x => new ColorGroup() - //{ - // GroupColor = x.Color, - // GroupName = x.Name, - // GroupIndex = x.GroupIndex, - //}).ToList(); + writer.WriteData(threadCharacteristicsExelModels, "Thread characteristics", 2); - //writer.WriteData(groups, "Groups"); + List<ColorParametrsExcelModel> colorParametrsExcelList = new List<ColorParametrsExcelModel>(); - //ActiveRMLExtension. + List<TestResultsExcelModel> testResultsExcelModelList = new List<TestResultsExcelModel>(); + foreach(var machine in Machines) + { + if (machine.HasRMLTest) + { + ColorParametrsExcelModel colorParametrsExcelModel = new ColorParametrsExcelModel(); + colorParametrsExcelModel.Thread_name = ActiveRML.Name; + colorParametrsExcelModel.MachineNumber = machine.SerialNumber; + colorParametrsExcelModel.White_point_L = ActiveRML.WhitePointL; + colorParametrsExcelModel.White_point_a = ActiveRML.WhitePointA; + colorParametrsExcelModel.White_point_B = ActiveRML.WhitePointB; + ColorParametersVewVM.WritetoExcel(colorParametrsExcelModel, machine.Guid); + + colorParametrsExcelList.Add(colorParametrsExcelModel); + + TestResultsViewVM.LoadTestResultsExcel(testResultsExcelModelList, machine.Guid, machine.SerialNumber); + } + + } + writer.WriteData(colorParametrsExcelList, "Color parameters",2); + writer.WriteData(testResultsExcelModelList, "Machine tests results", 2); + writer.Dispose(); InvokeUI(() => 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 52182cdd7..41be789ed 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 @@ -12,6 +12,7 @@ using Tango.BL.Entities; using Tango.BL.Enumerations; using Tango.Core.Commands; using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.ThreadExtensions.Models; using Tango.SharedUI; namespace Tango.MachineStudio.ThreadExtensions.ViewModels @@ -63,139 +64,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels #endregion - public RelayCommand ExportToFileCommand { get; set; } + public TestResultViewVM(INotificationProvider notification, IActionLogManager actionLogManager) { _notification = notification; _actionLogManager = actionLogManager; - ExportToFileCommand = new RelayCommand(ExportToFile); - } - - #region save - // public void Save(ObservablesContext active_context) - //{ - // try - // { - // IsFree = false; - - // TestResult.LastUpdated = DateTime.UtcNow; - - // var RmlExtensionTestResultAfterChange = RmlExtensionTestResultDTO.FromObservable(TestResult); - - // active_context.SaveChanges(); - // } - // catch (Exception ex) - // { - // LogManager.Log(ex, "Could not update RmlExtension TestResult."); - // _notification.ShowError($"An error occurred while trying to save RmlExtension TestResult.\n{ex.Message}"); - // } - // finally - // { - // IsFree = true; - // } - //} - #endregion - - private void ExportToFile() - { - SaveFileDialog dlg = new SaveFileDialog(); - try - { - dlg.Title = $"Export excel calibration file for {TestResult.Name}"; - dlg.Filter = "Text Files|*.txt"; - dlg.DefaultExt = ".txt"; - dlg.FileName = $"RML_EXTENSION_{TestResult.Name}.txt"; - if (dlg.ShowDialog().Value) - { - using (StreamWriter outputFile = new StreamWriter(dlg.FileName)) - { - outputFile.WriteLine(String.Format($" {TestResult.Name.ToUpper()} ")); - outputFile.WriteLine(""); - outputFile.WriteLine(""); - outputFile.WriteLine(" Dryer temperature"); - outputFile.WriteLine(""); - outputFile.WriteLine(String.Format($" Dryer temperature : {TestResult.DryerTemperature.ToString()}")); - outputFile.WriteLine(String.Format($" Tunnel temperature : {TestResult.TunnelTemperature.ToString()}")); - outputFile.WriteLine(String.Format($" Tunnel flow : {TestResult.TunnelFlow.ToString()}")); - outputFile.WriteLine(String.Format($" Tunnel AVG temperature : {TestResult.TunnelAvgTemperature.ToString()}")); - outputFile.WriteLine(""); - outputFile.WriteLine(""); - outputFile.WriteLine(" Tension through the thread path"); - outputFile.WriteLine(""); - outputFile.WriteLine(String.Format($" Head : {TestResult.TensionHeadMin.ToString()} - {TestResult.TensionHeadMax.ToString()}")); - outputFile.WriteLine(String.Format($" After dryer : {TestResult.TensionAfterDryerMin.ToString()} - {TestResult.TensioinAfterDryerMax.ToString()}")); - outputFile.WriteLine(String.Format($" Winder : {TestResult.BtsrMin.ToString()} - {TestResult.BtsrMax.ToString()}")); - outputFile.WriteLine(String.Format($" BTSR : {TestResult.TensionHeadMin.ToString()} - {TestResult.TensionHeadMax.ToString()}")); - outputFile.WriteLine(String.Format($" Puller tension : {TestResult.PullerTensionMin.ToString()} - {TestResult.PullerTensionMax.ToString()}")); - outputFile.WriteLine(String.Format($" Winder exit tension: {TestResult.ExitTensionMin.ToString()} - {TestResult.ExitTensionMax.ToString()}")); - - outputFile.WriteLine(""); - outputFile.WriteLine(" Rubbing results"); - outputFile.WriteLine(""); - outputFile.WriteLine(" Color DeltaE CIE 100 % GS 100% DeltaETestResult CIE 200 % GS 200% "); - foreach (var rubbingResult in TestResult.RubbingResults) - { - StringBuilder sb = new StringBuilder(); - //sb.Append(" Color: "); - sb.Append($" { rubbingResult.TestResultColor.ToString()} "); - //sb.Append(" DeltaE CIE 100 % : "); - sb.Append($" { rubbingResult.DeltaeCie100.ToString()} "); - //sb.Append(" GS 100% : "); - sb.Append($" { rubbingResult.Gs100.ToString()} "); - //sb.Append(" DeltaE CIE 200 % : "); - sb.Append($" { rubbingResult.DeltaeCie200.ToString()} "); - //sb.Append(" GS 200% : "); - sb.Append($" { rubbingResult.Gs200.ToString()} "); - outputFile.WriteLine(sb); - } - outputFile.WriteLine(""); - outputFile.WriteLine(" Mechanical properties"); - outputFile.WriteLine(""); - outputFile.WriteLine(" %Color Color Load at Maximum Load(N) STDEV Percentage Strain at Maximum Load STDEV "); - foreach (var result in TestResult.TensileResults) - { - StringBuilder sb = new StringBuilder(); - //sb.Append(" % Color: "); - sb.Append($" { result.ColorPercent.ToString()}"); - //sb.Append(" Color : "); - sb.Append($" { result.TestResultColor.ToString()}"); - //sb.Append(" Load at Maximum Load(N) : "); - sb.Append($" { result.MaxLoad.ToString()}"); - //sb.Append(" STDEV : "); - sb.Append($" { result.StdevMaxLoad.ToString()}"); - //sb.Append(" Percentage Strain at Maximum Load: "); - sb.Append($" {result.StrainMaxLoad.ToString()}"); - //sb.Append(" STDEV : "); - sb.Append($" { result.StdevStrainMaxLoad.ToString()}"); - outputFile.WriteLine(sb); - } - outputFile.WriteLine(""); - outputFile.WriteLine(" Uniformity"); - outputFile.WriteLine(""); - outputFile.WriteLine(String.Format($" Zone1 : {TestResult.SeverityZone1Min.ToString()} - {TestResult.SeverityZone1Max.ToString()}")); - outputFile.WriteLine(String.Format($" Zone2 : {TestResult.SeverityZone2Min.ToString()} - {TestResult.SeverityZone2Max.ToString()}")); - outputFile.WriteLine(""); - outputFile.WriteLine(" COF"); - outputFile.WriteLine(""); - outputFile.WriteLine(" Thread name Lub Version COF Lub amount "); - outputFile.WriteLine(String.Format($" REF {TestResult.RefLubVersion} {TestResult.RefCof.ToString()} {TestResult.RefLub.ToString()}")); - outputFile.WriteLine(String.Format($" {ThreadName} {TestResult.ThreadLubVersion} {TestResult.ThreadCof.ToString()} {TestResult.ThreadLub.ToString()}")); - - outputFile.WriteLine(""); - outputFile.WriteLine(String.Format($" Comments: {TestResult.Comment}")); - outputFile.WriteLine(String.Format($" Conclusion: {TestResult.Conclusions}")); - outputFile.WriteLine(""); - outputFile.Flush(); - } - - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error exporting excel file " + dlg.FileName); - _notification.ShowError("An error occurred while trying to export the test result data."); - } } + + } } 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 eea7eb9fc..f7823a77c 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 @@ -402,5 +402,156 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } #endregion + + public async void LoadTestResultsExcel(List<TestResultsExcelModel> testResultsExcelModelList, string machineGUID, string machineSerialNumber) + { + try + { + IsFree = false; + if (_active_context == null) + { + _active_context = ObservablesContext.CreateDefault(); + } + + using (_notification.PushTaskItem("Loading Test Results Parameters for save in Excel file ...")) + { + SynchronizedObservableCollection<RmlExtensionTestResult> testResults = SelectedTestResults; + if (SelectedMachineGUID != machineGUID) + { + var loadedtestResults = await new RMLExtensionTestResultsCollectionBuilder(_active_context).SetAll().ForRMLExtension(RMLExtemtionGUID).ForMachine(machineGUID).WithRubbingAndTensileResults().BuildAsync(); + testResults = loadedtestResults.OrderBy(x => x.ResultIndex).ToSynchronizedObservableCollection(); + + } + foreach (var testresult in testResults) + { + TestResultsExcelModel testResultsExcelModel = new TestResultsExcelModel(); + testResultsExcelModel.Thread_name_test_results = ThreadName; + testResultsExcelModel.Machine_number = machineSerialNumber; + testResultsExcelModel.Test_results_name__tab = testresult.Name; + + testResultsExcelModel.Dryer_temp = testresult.DryerTemperature == null ? 0 : (int)testresult.DryerTemperature; + testResultsExcelModel.Dryer_flow = 0; + testResultsExcelModel.Tunnel_temp = testresult.TunnelTemperature == null ? 0 : (int)testresult.TunnelTemperature; + testResultsExcelModel.Tunnel_flow = testresult.TunnelFlow == null ? 0 : (int)testresult.TunnelFlow; + + testResultsExcelModel.Tension_in_head = testresult.TensionHeadMin == null ? "" : testresult.TensionHeadMin.ToString(); + testResultsExcelModel.Tension_after_dryer = testresult.TensionAfterDryerMin == null ? "" : testresult.TensionAfterDryerMin.ToString(); + testResultsExcelModel.Tension_in_winder = testresult.TensionWinderMin == null ? "" : testresult.TensionWinderMin.ToString(); + testResultsExcelModel.BTSR = testresult.BtsrMin == null ? "" : testresult.BtsrMin.ToString(); + testResultsExcelModel.Puller_tension = testresult.PullerTensionMin == null ? "" : testresult.PullerTensionMin.ToString(); + testResultsExcelModel.Winder_tension = testresult.ExitTensionMin == null ? "" : testresult.ExitTensionMin.ToString(); + + foreach( var tensileResult in testresult.TensileResults) + { + if(tensileResult.TestResultColor == TestResultColors.CYAN) + { + if(tensileResult.ColorPercent == 100) + { + testResultsExcelModel.Load_N_100_C = tensileResult.MaxLoad == null ? 0 : (double)tensileResult.MaxLoad; + testResultsExcelModel.STDEV_100_C = tensileResult.StdevMaxLoad == null ? 0 : (double)tensileResult.StdevMaxLoad; + testResultsExcelModel.Change_100_C = tensileResult.PercentChangeLoad == null ? 0 : (double)tensileResult.PercentChangeLoad; + testResultsExcelModel.Strain_100_C = tensileResult.StrainMaxLoad == null ? 0 : (double)tensileResult.StrainMaxLoad; + testResultsExcelModel.STDEV_100_C_2 = tensileResult.StdevStrainMaxLoad == null ? 0 : (double)tensileResult.StdevStrainMaxLoad; + testResultsExcelModel.Change_100_C_2 = tensileResult.PercentChangeStrain == null ? 0 : (double)tensileResult.PercentChangeStrain; + } + else if(tensileResult.ColorPercent == 200) + { + testResultsExcelModel.Load__N_200_C = tensileResult.MaxLoad == null ? 0 : (double)tensileResult.MaxLoad; + testResultsExcelModel.STDEV_200_C = tensileResult.StdevMaxLoad == null ? 0 : (double)tensileResult.StdevMaxLoad; + testResultsExcelModel.Change_200_C = tensileResult.PercentChangeLoad == null ? 0 : (double)tensileResult.PercentChangeLoad; + testResultsExcelModel.Strain_200_C = tensileResult.StrainMaxLoad == null ? 0 : (double)tensileResult.StrainMaxLoad; + testResultsExcelModel.STDEV_200_C_2 = tensileResult.StdevStrainMaxLoad == null ? 0 : (double)tensileResult.StdevStrainMaxLoad; + testResultsExcelModel.Change_200_C_2 = tensileResult.PercentChangeStrain == null ? 0 : (double)tensileResult.PercentChangeStrain; + } + } + else if(tensileResult.TestResultColor == TestResultColors.BLACK) + { + if (tensileResult.ColorPercent == 100) + { + testResultsExcelModel.Load__N_100_K = tensileResult.MaxLoad == null ? 0 : (double)tensileResult.MaxLoad; + testResultsExcelModel.STDEV_100_K = tensileResult.StdevMaxLoad == null ? 0 : (double)tensileResult.StdevMaxLoad; + testResultsExcelModel.Change__100_K = tensileResult.PercentChangeLoad == null ? 0 : (double)tensileResult.PercentChangeLoad; + testResultsExcelModel.Strain_100_K = tensileResult.StrainMaxLoad == null ? 0 : (double)tensileResult.StrainMaxLoad; + testResultsExcelModel.STDEV_100_K_2 = tensileResult.StdevStrainMaxLoad == null ? 0 : (double)tensileResult.StdevStrainMaxLoad; + testResultsExcelModel.Change_100_K_2 = tensileResult.PercentChangeStrain == null ? 0 : (double)tensileResult.PercentChangeStrain; + } + else if (tensileResult.ColorPercent == 200) + { + testResultsExcelModel.Load__N_200_K = tensileResult.MaxLoad == null ? 0 : (double)tensileResult.MaxLoad; + testResultsExcelModel.STDEV_200_K = tensileResult.StdevMaxLoad == null ? 0 : (double)tensileResult.StdevMaxLoad; + testResultsExcelModel.Change_200_K = tensileResult.PercentChangeLoad == null ? 0 : (double)tensileResult.PercentChangeLoad; + testResultsExcelModel.Strain_200_K = tensileResult.StrainMaxLoad == null ? 0 : (double)tensileResult.StrainMaxLoad; + testResultsExcelModel.STDEV_200_K_2 = tensileResult.StdevStrainMaxLoad == null ? 0 : (double)tensileResult.StdevStrainMaxLoad; + testResultsExcelModel.Change_200_K_2 = tensileResult.PercentChangeStrain == null ? 0 : (double)tensileResult.PercentChangeStrain; + } + + } + else if (tensileResult.IsWhiteColor) + { + testResultsExcelModel.Load__N_REF = tensileResult.MaxLoad == null ? 0 : (double)tensileResult.MaxLoad; + testResultsExcelModel.STDEV_REF = tensileResult.StdevMaxLoad == null ? 0 : (double)tensileResult.StdevMaxLoad; + testResultsExcelModel.REF_Strain = tensileResult.StdevStrainMaxLoad == null ? 0 : (double)tensileResult.StdevStrainMaxLoad; + testResultsExcelModel.STDEV_Strain_REF = tensileResult.PercentChangeStrain == null ? 0 : (double)tensileResult.PercentChangeStrain; + } + + } + + foreach (var rubbingresult in testresult.RubbingResults) + { + if (rubbingresult.TestResultColor == TestResultColors.CYAN) + { + testResultsExcelModel.Rubbing_C_100___DE = rubbingresult.DeltaeCie100 == null ? 0.0 : (double)rubbingresult.DeltaeCie100; + testResultsExcelModel.Rubbing_C_100___GS = rubbingresult.Gs100 == null ? 0.0 : (double)rubbingresult.Gs100; + testResultsExcelModel.Rubbing_C_200___DE = rubbingresult.DeltaeCie200 == null ? 0.0 : (double)rubbingresult.DeltaeCie200; + testResultsExcelModel.Rubbing_C_200___GS = rubbingresult.Gs200 == null ? 0.0 : (double)rubbingresult.Gs200; + } + else if (rubbingresult.TestResultColor == TestResultColors.MAGENTA) + { + testResultsExcelModel.Rubbing_M_100___DE = rubbingresult.DeltaeCie100 == null ? 0.0 : (double)rubbingresult.DeltaeCie100; + testResultsExcelModel.Rubbing_M_100___GS = rubbingresult.Gs100 == null ? 0.0 : (double)rubbingresult.Gs100; + testResultsExcelModel.Rubbing_M_200___DE = rubbingresult.DeltaeCie200 == null ? 0.0 : (double)rubbingresult.DeltaeCie200; + testResultsExcelModel.Rubbing_M_200___GS = rubbingresult.Gs200 == null ? 0.0 : (double)rubbingresult.Gs200; + } + else if (rubbingresult.TestResultColor == TestResultColors.YELLOW) + { + testResultsExcelModel.Rubbing_Y_100___DE = rubbingresult.DeltaeCie100 == null ? 0.0 : (double)rubbingresult.DeltaeCie100; + testResultsExcelModel.Rubbing_Y_100___GS = rubbingresult.Gs100 == null ? 0.0 : (double)rubbingresult.Gs100; + testResultsExcelModel.Rubbing_Y_200___DE = rubbingresult.DeltaeCie200 == null ? 0.0 : (double)rubbingresult.DeltaeCie200; + testResultsExcelModel.Rubbing_Y_200___GS = rubbingresult.Gs200 == null ? 0.0 : (double)rubbingresult.Gs200; + } + else if (rubbingresult.TestResultColor == TestResultColors.BLACK) + { + testResultsExcelModel.Rubbing_K_100___DE = rubbingresult.DeltaeCie100 == null ? 0.0 : (double)rubbingresult.DeltaeCie100; + testResultsExcelModel.Rubbing_K_100___GS = rubbingresult.Gs100 == null ? 0.0 : (double)rubbingresult.Gs100; + testResultsExcelModel.Rubbing_K_200___DE = rubbingresult.DeltaeCie200 == null ? 0.0 : (double)rubbingresult.DeltaeCie200; + testResultsExcelModel.Rubbing_K_200___GS = rubbingresult.Gs200 == null ? 0.0 : (double)rubbingresult.Gs200; + } + } + + testResultsExcelModel.Uniformity_Zone_1 = testresult.SeverityZone1Min == null ? "" : testresult.SeverityZone1Min.ToString() + "-" + testresult.SeverityZone1Max == null ? "" : testresult.SeverityZone1Max.ToString(); + testResultsExcelModel.Uniformity_Zone_2 = testresult.SeverityZone2Min == null ? "" : testresult.SeverityZone2Min.ToString() + "-" + testresult.SeverityZone2Max == null ? "" : testresult.SeverityZone2Max.ToString(); + + testResultsExcelModel.COF_REF = testresult.RefCof == null ? 0.0 : (double)testresult.RefCof; + testResultsExcelModel.CV_REF = 0.0; + testResultsExcelModel.COF_Black = testresult.ThreadCof == null ? 0.0 : (double)testresult.ThreadCof; + testResultsExcelModel.CV_Black = 0.0; + testResultsExcelModel.lub_amount = testresult.ThreadLub == null ? 0.0 : (double)testresult.ThreadLub; + + testResultsExcelModel.Comments = testresult.Comment; + testResultsExcelModel.Conclusion = testresult.Conclusions; + testResultsExcelModelList.Add(testResultsExcelModel); + } + } + IsFree = true; + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error loading TestResults for saving in Excel file.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } } } |
