Пример #1
0
        public static DataForSummery GetSummeryPieData(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);
            DataForSummery chartForSummery = new DataForSummery();

            chartForSummery.data = new List <pieData>();

            try
            {
                if (dt != null && dt.Rows.Count > 0)
                {
                    chartForSummery.name = dt.Columns["Energy"].ColumnName;
                    foreach (DataRow dataRow in dt.Rows)
                    {
                        pieData pData = new pieData();
                        pData.name = dataRow["MachineID"].ToString();
                        if (Convert.ToDouble(dataRow["Energy"].ToString()) < 0)
                        {
                            pData.y        = Convert.ToDouble(dataRow["Energy"].ToString()) * -1;
                            pData.positive = false;
                        }

                        else
                        {
                            pData.y        = Convert.ToDouble(dataRow["Energy"].ToString());
                            pData.positive = true;
                        }

                        chartForSummery.data.Add(pData);
                    }
                }
                else
                {
                    chartForSummery.name = "Machine";
                    chartForSummery.data = new List <pieData>
                    {
                        new pieData {
                            name = "FANUC", y = 286
                        }
                    };
                }
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex.Message);
            }

            return(chartForSummery);
        }
Пример #2
0
        public static DataForSummery GetHourwiseSummary(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);
            DataForSummery chartForSummery = new DataForSummery();

            chartForSummery.data = new List <pieData>();

            try
            {
                if (hourwiseMonitoringDatas != null && hourwiseMonitoringDatas.Count > 0)
                {
                    chartForSummery.name = "Energy";
                    foreach (HourwiseMonitoringData data in hourwiseMonitoringDatas)
                    {
                        pieData pData = new pieData();
                        pData.name = data.ShiftHourID;
                        if (Convert.ToDouble(data.Energy) < 0)
                        {
                            pData.y        = Convert.ToDouble(data.Energy) * -1;
                            pData.positive = false;
                        }

                        else
                        {
                            pData.y        = Convert.ToDouble(data.Energy);
                            pData.positive = true;
                        }

                        chartForSummery.data.Add(pData);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex.Message);
            }

            return(chartForSummery);
        }