Beispiel #1
0
        public static DataForEnergy GetEnergyBarData(string fromDate, string selectedShift)
        {
            DateTime fromdateTime = DateTime.ParseExact(fromDate, "dd-MM-yyyy", CultureInfo.InvariantCulture);

            fromDate = fromdateTime.ToString("yyyy-MM-dd");
            DataTable     dt             = DataBaseAccess.GetDataForDateShift(fromDate, selectedShift, true);
            DataForEnergy chartForEnergy = new DataForEnergy();

            try
            {
                chartForEnergy.TitleEnergy      = "Energy Graph";
                chartForEnergy.xAxisTitleEnergy = "Machine";
                chartForEnergy.yAxisTitleEnergy = "Energy(KwH)";

                chartForEnergy.EnergyCategories = new List <string>();
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow dataRow in dt.Rows)
                    {
                        chartForEnergy.EnergyCategories.Add(dataRow[0].ToString());
                    }
                    chartForEnergy.seriesEnergy = new List <ChartSeries>();
                    ChartSeries series1 = new ChartSeries();
                    ChartSeries series2 = new ChartSeries();
                    series1.name = dt.Columns["Energy"].ColumnName;
                    series2.name = dt.Columns["Target"].ColumnName;
                    series1.data = new List <double>();
                    series2.data = new List <double>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        series1.data.Add(Convert.ToDouble(dt.Rows[i]["Energy"].ToString()));
                        series2.data.Add(Convert.ToDouble(dt.Rows[i]["Target"].ToString()));
                    }
                    chartForEnergy.seriesEnergy.Add(series1);
                    chartForEnergy.seriesEnergy.Add(series2);
                }
                else
                {
                    chartForEnergy.seriesEnergy = new List <ChartSeries>
                    {
                        new ChartSeries {
                            name = "Energy", data = new List <double> {
                                34, 54, 35, 23, 53, 23, 32, 35, 75, 76, 56, 36, 76, 86, 34, 54, 35, 23, 53, 23, 32, 35, 75, 76, 89
                            }
                        },
                    };
                    for (int i = 0; i <= 24; i++)
                    {
                        chartForEnergy.EnergyCategories.Add("FANUC");
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex.Message);
            }

            return(chartForEnergy);
        }
Beispiel #2
0
        public static DataForEnergy GetHourwiseEnergy(string machine, string date, string shift)
        {
            List <HourwiseMonitoringData> hourwiseMonitoringDatas = new List <HourwiseMonitoringData>();
            DateTime fromdateTime = DateTime.ParseExact(date, "dd-MM-yyyy", CultureInfo.InvariantCulture);

            date = fromdateTime.ToString("yyyy-MM-dd");
            hourwiseMonitoringDatas = DataBaseAccess.GetHourWiseEnergyData(machine, date, shift, true);
            DataForEnergy chartForEnergy = new DataForEnergy();

            try
            {
                chartForEnergy.TitleEnergy      = "Energy Graph";
                chartForEnergy.xAxisTitleEnergy = "Hours";
                chartForEnergy.yAxisTitleEnergy = "Energy(KwH)";

                chartForEnergy.EnergyCategories = new List <string>();
                ChartSeries series1 = new ChartSeries();
                ChartSeries series2 = new ChartSeries();

                if (hourwiseMonitoringDatas != null && hourwiseMonitoringDatas.Count > 0)
                {
                    series1.name = "Energy";
                    series2.name = "Target";
                    series1.data = new List <double>();
                    series2.data = new List <double>();
                    foreach (HourwiseMonitoringData data in hourwiseMonitoringDatas)
                    {
                        chartForEnergy.EnergyCategories.Add(data.ShiftHourID);
                        series1.data.Add(Convert.ToDouble(data.Energy));
                        series2.data.Add(Convert.ToDouble(data.Target));
                    }
                    chartForEnergy.seriesEnergy = new List <ChartSeries>();
                    chartForEnergy.seriesEnergy.Add(series1);
                    chartForEnergy.seriesEnergy.Add(series2);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex.Message);
            }

            return(chartForEnergy);
        }