diff options
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs index a98641b25..d05b4c6bf 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Statistics/DefaultStatisticsService.cs @@ -29,6 +29,7 @@ namespace Tango.PPC.Common.Statistics private List<ColorCatalog> _catalogs; private List<ColorCatalogsItem> _color_catalog_Items; private List<ColorSpace> _colorSpaces; + private Dictionary<String, LiquidType> _liquidTypes; public bool Enabled { get; set; } = true; @@ -107,6 +108,8 @@ namespace Tango.PPC.Common.Statistics using (ObservablesContext db = ObservablesContext.CreateDefault()) { + response.Result.LiquidTypes = db.LiquidTypes.ToList().Select(x => LiquidTypeDTO.FromObservable(x)).ToList(); + var filters = request.Filters; var db_JobRuns = db.JobRuns.Where(x => (x.StartDate <= filters.EndDateUTC && x.StartDate >= filters.StartDateUTC)); @@ -173,6 +176,19 @@ namespace Tango.PPC.Common.Statistics } } + if (_liquidTypes == null) + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var types = await db.LiquidTypes.ToListAsync(); + _liquidTypes = new Dictionary<string, LiquidType>(); + foreach (var t in types) + { + _liquidTypes.Add(t.Name, t); + } + } + } + JobRunComposition jobRunComposition = new JobRunComposition(); jobRunComposition.JobRun = JobRunDTO.FromObservable(jobRun); @@ -197,11 +213,17 @@ namespace Tango.PPC.Common.Statistics foreach (var liquidType in stop.LiquidVolumes) { PresentationLiquidVolume plt = new PresentationLiquidVolume(); - plt.LiquidType = (LiquidTypes)Enum.Parse(typeof(LiquidTypes), liquidType.LiquidTypeName.Replace(" ", "")); - plt.Volume = liquidType.Volume; - pbs.LiquidVolumes.Add(plt); + + if (_liquidTypes.ContainsKey(liquidType.LiquidTypeName)) + { + plt.LiquidType = _liquidTypes[liquidType.LiquidTypeName]; + plt.Volume = liquidType.Volume; + pbs.LiquidVolumes.Add(plt); + } } + pbs.LiquidVolumes = pbs.LiquidVolumes.OrderBy(x => x.LiquidType.PreferredIndex).ToList(); + switch (pbs.ColorSpace) { case ColorSpaces.RGB: @@ -215,29 +237,16 @@ namespace Tango.PPC.Common.Statistics pbs.B = stop.B; break; case ColorSpaces.Volume: - pbs.Cyan = pbs.LiquidVolumes.First(x => x.LiquidType == LiquidTypes.Cyan).Volume; - pbs.Magenta = pbs.LiquidVolumes.First(x => x.LiquidType == LiquidTypes.Magenta).Volume; - pbs.Yellow = pbs.LiquidVolumes.First(x => x.LiquidType == LiquidTypes.Yellow).Volume; - pbs.Black = pbs.LiquidVolumes.First(x => x.LiquidType == LiquidTypes.Black).Volume; - - var lightCyan = pbs.LiquidVolumes.FirstOrDefault(x => x.LiquidType == LiquidTypes.LightCyan); - var lightMagenta = pbs.LiquidVolumes.FirstOrDefault(x => x.LiquidType == LiquidTypes.LightMagenta); - var lightYellow = pbs.LiquidVolumes.FirstOrDefault(x => x.LiquidType == LiquidTypes.LightYellow); - - if (lightCyan != null && lightCyan.Volume > 0) - { - pbs.Cyan = lightCyan.Volume / 10d; - } - - if (lightMagenta != null && lightMagenta.Volume > 0) - { - pbs.Magenta = lightMagenta.Volume / 10d; - } - if (lightYellow != null && lightYellow.Volume > 0) - { - pbs.Yellow = lightYellow.Volume / 10d; - } + //foreach (var lightInk in pbs.LiquidVolumes.Where(x => x.LiquidType.IsLightInk && x.Volume > 0)) + //{ + // var darkInk = pbs.LiquidVolumes.FirstOrDefault(x => x.LiquidType.Code == lightInk.LiquidType.DarkInkCode); + // if (darkInk != null) + // { + // darkInk.Volume = (double)((decimal)lightInk.Volume / 10m); + // lightInk.Volume = 0; + // } + //} break; case ColorSpaces.Catalog: |
