diff options
| author | Roy Ben Shabat <roy.mail.net@gmail.com> | 2025-09-09 06:51:14 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <roy.mail.net@gmail.com> | 2025-09-09 06:51:14 +0300 |
| commit | 1cbef6c4d79a1db8c8d3923edfec2e50277caa51 (patch) | |
| tree | 6487fb1a2e4c85327bc74348018ad1621cc28fba /Software/Visual_Studio/Tango.Integration | |
| parent | 987e4992d01a0bc84170498c40dad0621542f46c (diff) | |
| download | Tango-1cbef6c4d79a1db8c8d3923edfec2e50277caa51.tar.gz Tango-1cbef6c4d79a1db8c8d3923edfec2e50277caa51.zip | |
RMl Default Liquid Factor + Machine Type + Improved RML Filter Loading.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration')
| -rw-r--r-- | Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs index e128a5949..4f442152d 100644 --- a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs +++ b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs @@ -15,6 +15,7 @@ using Tango.BL.Enumerations; using Tango.Core; using Tango.Core.ExtensionMethods; using Tango.Integration.Operation; +using Tango.Logging; using Tango.PMR.MachineStatus; using Tango.PMR.Printing; @@ -399,44 +400,32 @@ namespace Tango.Integration.JobRuns } } - private void SetJobRunLiquidQuantities(JobRun run, List<BL.ValueObjects.JobRunLiquidQuantity> quantities, bool update = false) + + public void SetJobRunLiquidQuantities(JobRun run, IEnumerable<BL.ValueObjects.JobRunLiquidQuantity> quantities, bool update = false) { - if (run == null || quantities == null) - return; + if (run == null || quantities == null) return; - // Map each LiquidType to the corresponding JobRun property updater - var setters = new Dictionary<LiquidTypes, Action<long>> - { - { LiquidTypes.Cyan, q => run.CyanQuantity = update ? run.CyanQuantity + q : q }, - { LiquidTypes.Magenta, q => run.MagentaQuantity = update ? run.MagentaQuantity + q : q }, - { LiquidTypes.Yellow, q => run.YellowQuantity = update ? run.YellowQuantity + q : q }, - { LiquidTypes.Black, q => run.BlackQuantity = update ? run.BlackQuantity + q : q }, - { LiquidTypes.Transparent, q => run.TransparentQuantity = update ? run.TransparentQuantity + q : q }, - { LiquidTypes.Lubricant, q => run.LubricantQuantity = update ? run.LubricantQuantity + q : q }, - { LiquidTypes.Cleaner, q => run.CleanerQuantity = update ? run.CleanerQuantity + q : q }, - { LiquidTypes.LightCyan, q => run.LightCyanQuantity = update ? run.LightCyanQuantity + q : q }, - { LiquidTypes.LightMagenta, q => run.LightMagentaQuantity = update ? run.LightMagentaQuantity + q : q }, - { LiquidTypes.LightYellow, q => run.LightYellowQuantity = update ? run.LightYellowQuantity + q : q }, - { LiquidTypes.Blue, q => run.BlueQuantity = update ? run.BlueQuantity + q : q }, - { LiquidTypes.LightBlue, q => run.LightBlueQuantity = update ? run.LightBlueQuantity + q : q }, - { LiquidTypes.Orange, q => run.OrangeQuantity = update ? run.OrangeQuantity + q : q }, - { LiquidTypes.LightOrange, q => run.LightOrangeQuantity = update ? run.LightOrangeQuantity + q : q }, - { LiquidTypes.Rubine, q => run.RubineQuantity = update ? run.RubineQuantity + q : q }, - { LiquidTypes.LightRubine, q => run.LightRubineQuantity = update ? run.LightRubineQuantity + q : q }, - { LiquidTypes.Navy, q => run.NavyQuantity = update ? run.NavyQuantity + q : q }, - { LiquidTypes.Violet, q => run.VioletQuantity = update ? run.VioletQuantity + q : q }, - { LiquidTypes.TWCyan, q => run.TwCyanQuantity = update ? run.VioletQuantity + q : q } - }; + var props = run.GetType() + .GetProperties(BindingFlags.Instance | BindingFlags.Public) + .Where(p => p.CanRead && p.CanWrite && p.PropertyType == typeof(long)) + .Where(p => p.Name.EndsWith("Quantity", StringComparison.OrdinalIgnoreCase)) + .ToDictionary(p => p.Name.ToLower(), p => p); - foreach (var liquidType in setters.Keys) + foreach (var q in quantities) { - var quantityObj = quantities.SingleOrDefault(x => x.LiquidType == liquidType); - var quantity = quantityObj?.Quantity ?? 0; - setters[liquidType](quantity); + var key = (q.LiquidType.ToString() + "Quantity").ToLower(); + if (!props.TryGetValue(key, out var prop)) + { + LogManager.Log($"Could not locate liquid quantity field for {q.LiquidType} on JobRun object.", LogCategory.Error); + continue; + } + + var currentVal = (long)(prop.GetValue(run) ?? 0L); + var newVal = update ? currentVal + q.Quantity : q.Quantity; + prop.SetValue(run, newVal); } } - #endregion #region Public Methods |
