private List <ControlChartData> GetStenolDropChartData(List <BatchReport> reports)
        {
            List <ControlChartData> output      = new List <ControlChartData>();
            List <BatchReport>      regBatches  = reports.Where(x => x.RecipeType == RecipeTypes.Reg).ToList();
            List <decimal>          values      = new List <decimal>();
            List <string>           xAxisLabels = new List <string>();

            string stenolName = _applicationData.ApplicationMode == "demo" ? "Material 21" : "FATTY ALC";

            foreach (var report in regBatches)
            {
                decimal stenol = Convert.ToDecimal(BatchHelperMethods.GetSingleMaterialFromVessel(report, stenolName).ActualWeight);
                values.Add(stenol);
                xAxisLabels.Add(report.Campaign.ToString() + "-" + report.BatchNo.ToString());
            }

            ControlChartData data = new ControlChartData
            {
                Target      = 58.5M,
                Max         = 58.5M + (0.05M * 58.5M),
                Min         = 58.5M - (0.05M * 58.5M),
                Values      = values,
                XAxisLabels = xAxisLabels,
                SeriesName  = $"{stenolName} Quantity Kg",
                Title       = $"{stenolName} Quantity Of Reg Batches",
                YAxisSuffix = "Kg",
                ChartId     = "Reg"
            };

            data.ProcessCpkValues();
            output.Add(data);
            _xLCreator.AddToWorkBook <decimal>($"{stenolName}-Regs", values, data.Min, data.Max);

            return(output);
        }
        private List <ControlChartData> GetPhChartData(List <BatchReport> reports)
        {
            List <ControlChartData> output            = new List <ControlChartData>();
            var            BatchesGroupedByRecipeType = BatchHelperMethods.GroupBatchesByRecipeType(reports);
            List <decimal> values      = new List <decimal>();
            List <string>  xAxisLabels = new List <string>();

            foreach (var report in reports.OrderBy(x => x.StartTime.Date).ThenBy(x => x.StartTime.TimeOfDay))
            {
                values.Add(Convert.ToDecimal(report.Ph));
                xAxisLabels.Add($"{report.Campaign}-{report.BatchNo}");
            }
            ControlChartData data = new ControlChartData
            {
                Target      = 2.6M,
                Max         = 2.9M,
                Min         = 2.3M,
                Values      = values,
                XAxisLabels = xAxisLabels,
                SeriesName  = "Ph",
                Title       = $"pH Of all Batches",
                YAxisSuffix = "pH",
                ChartId     = "phchart"
            };

            data.ProcessCpkValues();
            output.Add(data);

            _xLCreator.AddToWorkBook <decimal>("PH", values, data.Min, data.Max);


            return(output);
        }
        private List <ControlChartData> GetViscoChartData(List <BatchReport> reports)
        {
            List <ControlChartData> output = new List <ControlChartData>();
            var BatchesGroupedByRecipeType = BatchHelperMethods.GroupBatchesByRecipeType(reports);

            foreach (var recipeType in BatchesGroupedByRecipeType.Keys)
            {
                List <decimal> values      = new List <decimal>();
                List <string>  xAxisLabels = new List <string>();

                foreach (var report in BatchesGroupedByRecipeType[recipeType].OrderBy(x => x.StartTime.Date).ThenBy(x => x.StartTime.TimeOfDay))
                {
                    values.Add(Convert.ToDecimal(report.Visco));
                    xAxisLabels.Add($"{report.Campaign}-{report.BatchNo}");
                }
                RecipeLimits limits = _recipeLimitRepository.GetLimitInfo(recipeType, LimitType.Visco);

                ControlChartData data = new ControlChartData
                {
                    Target      = limits.Target,
                    Max         = limits.Max,
                    Min         = limits.Min,
                    Values      = values,
                    XAxisLabels = xAxisLabels,
                    SeriesName  = "Visco cP",
                    Title       = $"Viscos Of {ChangeRecipeTypeNameForDemo(recipeType)} batches",
                    YAxisSuffix = "cP",
                    ChartId     = recipeType.ToString()
                };
                data.ProcessCpkValues();
                output.Add(data);
                _xLCreator.AddToWorkBook <decimal>($"Visco-{recipeType}", values, data.Min, data.Max);
            }
            return(output);
        }
        private List <ControlChartData> GetSoftquatChartData(List <BatchReport> reports)
        {
            List <ControlChartData> output = new List <ControlChartData>();
            var BatchesGroupedByRecipeType = BatchHelperMethods.GroupBatchesByRecipeType(reports);


            foreach (var recipeType in BatchesGroupedByRecipeType.Keys)
            {
                List <decimal> values      = new List <decimal>();
                List <string>  xAxisLabels = new List <string>();

                string quatName = _applicationData.ApplicationMode == "demo" ? "Material 51" : "SOFTQUAT";

                foreach (var report in BatchesGroupedByRecipeType[recipeType].OrderBy(x => x.StartTime.Date).ThenBy(x => x.StartTime.TimeOfDay))
                {
                    double softquatWeight = BatchHelperMethods.GetSingleMaterialFromVessel(report, quatName).ActualWeight;
                    values.Add(Convert.ToDecimal(softquatWeight));
                    xAxisLabels.Add($"{report.Campaign}-{report.BatchNo}");
                }
                RecipeLimits limits = _recipeLimitRepository.GetLimitInfo(recipeType, LimitType.Softquat);

                ControlChartData data = new ControlChartData
                {
                    Target      = limits.Target,
                    Max         = limits.Target + (0.05M * limits.Target),
                    Min         = limits.Target - (0.05M * limits.Target),
                    Values      = values,
                    XAxisLabels = xAxisLabels,
                    SeriesName  = quatName + " Quantity Kg",
                    Title       = $"{quatName} Quantity Of {recipeType} Batches",
                    YAxisSuffix = "Kg",
                    ChartId     = recipeType.ToString()
                };
                data.ProcessCpkValues();
                output.Add(data);
                _xLCreator.AddToWorkBook <decimal>($"{quatName}-{recipeType}", values, data.Min, data.Max);
            }

            return(output);
        }
        private List <ControlChartData> GetActiveDropChartData(List <BatchReport> reports)
        {
            List <ControlChartData> output         = new List <ControlChartData>();
            List <BatchReport>      reportsToCheck = new List <BatchReport>();
            var batchesGroupedByRecipeType         = BatchHelperMethods.GroupBatchesByRecipeType(reports);

            foreach (var recipeType in batchesGroupedByRecipeType.Keys)
            {
                List <decimal> values       = new List <decimal>();
                List <string>  xAxisLabels  = new List <string>();
                PcsTempTargets limits       = new PcsTempTargets();
                string         nameOfRecipe = "";

                foreach (var report in batchesGroupedByRecipeType[recipeType].OrderBy(x => x.StartTime.Date).ThenBy(x => x.StartTime.TimeOfDay))
                {
                    if (recipeType == RecipeTypes.Conc)
                    {
                        if (report.Recipe == "WHTCON" || report.Recipe == "Recipe 38")
                        {
                            limits            = _pcsActiveTempParameters.GetTargetsFor(report.Recipe);
                            limits.UpperLimit = limits.Target + 1.5M;
                            limits.LowerLimit = limits.Target - 1.5M;
                            decimal tempValue = Convert.ToDecimal(_helperMethods.GetTemperatureOfActiveDrop(report.AllVessels.Where(x => x.VesselType == Vessel.VesselTypes.MainMixer).First()));
                            values.Add(CheckTemperatureForAdjustments(tempValue, limits.UpperLimit, limits.LowerLimit));
                            xAxisLabels.Add($"{report.Campaign}-{report.BatchNo}");
                            nameOfRecipe = report.Recipe;
                        }
                    }
                    if (recipeType == RecipeTypes.Reg)
                    {
                        if (report.Recipe == "WHTREG" || report.Recipe == "RE-Recipe 39")
                        {
                            limits            = _pcsActiveTempParameters.GetTargetsFor(report.Recipe);
                            limits.UpperLimit = limits.Target + 1M;
                            limits.LowerLimit = limits.Target - 1M;
                            decimal tempValue = Convert.ToDecimal(_helperMethods.GetTemperatureOfActiveDrop(report.AllVessels.Where(x => x.VesselType == Vessel.VesselTypes.MainMixer).First()));
                            values.Add(CheckTemperatureForAdjustments(tempValue, limits.UpperLimit, limits.LowerLimit));
                            xAxisLabels.Add($"{report.Campaign}-{report.BatchNo}");
                            nameOfRecipe = report.Recipe;
                        }
                    }
                    if (recipeType == RecipeTypes.BigBang)
                    {
                        if (report.Recipe == "BB-SKY" || report.Recipe == "BB-Recipe 15")
                        {
                            limits            = _pcsActiveTempParameters.GetTargetsFor(report.Recipe);
                            limits.UpperLimit = limits.Target + 1.5M;
                            limits.LowerLimit = limits.Target - 1.5M;
                            decimal tempValue = Convert.ToDecimal(_helperMethods.GetTemperatureOfActiveDrop(report.AllVessels.Where(x => x.VesselType == Vessel.VesselTypes.MainMixer).First()));
                            values.Add(CheckTemperatureForAdjustments(tempValue, limits.UpperLimit, limits.LowerLimit));
                            xAxisLabels.Add($"{report.Campaign}-{report.BatchNo}");
                            nameOfRecipe = report.Recipe;
                        }
                    }
                }

                ControlChartData data = new ControlChartData
                {
                    Target      = limits.Target,
                    Max         = limits.UpperLimit,
                    Min         = limits.LowerLimit,
                    Values      = values,
                    XAxisLabels = xAxisLabels,
                    SeriesName  = "Active Drop Temp",
                    Title       = $"Active Drop Temps Of {nameOfRecipe} Batches",
                    YAxisSuffix = " C",
                    ChartId     = recipeType.ToString()
                };
                data.ProcessCpkValues();
                output.Add(data);
                _xLCreator.AddToWorkBook <decimal>($"Active-temp-{nameOfRecipe}", values, data.Min, data.Max);
            }

            return(output);
        }