public Vehicles GetVinInfo(int VinID)
        {
            var connectionString = ConfigurationManager.ConnectionStrings["PCanRepository"].ConnectionString;
            string sql = "SELECT CustomerID,CustomerName, Bus, BusOwner,Vin,VinID from dbo.VehiclesVw with(nolock) where VinID=@VinID";
            Vehicles v = new Vehicles();

            using (SqlConnection con = new SqlConnection(connectionString))
            {

                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.Parameters.Add("@VinID", SqlDbType.Int);
                cmd.Parameters["@VinID"].Value = VinID;
                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {

                        v.VinID = int.Parse(reader["VinID"].ToString());
                        v.CustomerID = int.Parse(reader["CustomerID"].ToString());
                        v.Vin = reader["Vin"].ToString();
                        v.CustomerName = reader["CustomerName"].ToString();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                return v;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string VinID = Request.QueryString["VinID"].ToString();

            string ProcessDate = String.Empty;
            DateTime dtProcessDate = DateTime.Today;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ProcessDate"]))
            {
                ProcessDate = Request.QueryString["ProcessDate"].ToString();
                dtProcessDate = DateTime.Parse(ProcessDate);
            }

            string ReportType = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportType"]))
            {
                ReportType = Request.QueryString["ReportType"].ToString();
            }

            string WeekNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["WeekNumber"]))
            {
                WeekNumber = Request.QueryString["WeekNumber"].ToString();
            }

            string YearNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["YearNumber"]))
            {
                YearNumber = Request.QueryString["YearNumber"].ToString();
            }

            string ReportPeriod = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportPeriod"]))
            {
                ReportPeriod = Request.QueryString["ReportPeriod"].ToString();
            }

            int intWeekNumber = 0;
            int intYearNumber = 0;

            string DtRangeWeekly = String.Empty;
            if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
            {
                bool IsWeekNumeric = int.TryParse(WeekNumber, out intWeekNumber);
                if (IsWeekNumeric)
                {
                    intWeekNumber = int.Parse(WeekNumber);
                }

                bool IsYearNumeric = int.TryParse(YearNumber, out intYearNumber);
                if (IsYearNumeric)
                {
                    intYearNumber = int.Parse(YearNumber);
                }

                GetChartData gd = new GetChartData();
                DataTable DtRange = gd.GetDateRangeFromWeekNumber(intWeekNumber, intYearNumber);

                DtRangeWeekly = Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d") + " - " + Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d");
            }

            if (ReportPeriod == "Weekly")
            {
                lblHead.InnerText = "Weekly Vehicle Report";
            }
            else     if (ReportPeriod == "NREL")
            {
                lblHead.InnerText = "NREL Weekly Vehicle Report";
            }

            else
            {
                lblHead.InnerText = "Daily Vehicle Report";
            }

            //VinID = "221";
            //  ReportType = "GenVehicleData_VinSpeed";
            //ReportType = "GenVehicleData_CurrentVoltage";
            //ProcessDate = "04/13/2015";

            Vehicles Vehicle = new Vehicles();

            if (VinID != "")
            {
                int intVinID;
                bool IsVinNumeric = int.TryParse(VinID, out intVinID);

                if (IsVinNumeric)
                {
                    intVinID = int.Parse(VinID);

                    GetChartData gcd = new GetChartData();
                    Vehicle = gcd.GetVinInfo(intVinID);
                    GetChartData gd = new GetChartData();
                    ReportType = "OperationalData";

                    DataTable dataTable_OperationalData = new DataTable();

                    if (intWeekNumber > 0)
                    {
                         dataTable_OperationalData = gd.GetDashBoardData(intVinID, intWeekNumber,intYearNumber, ReportType);
                    }
                    else
                    {
                        dataTable_OperationalData = gd.GetDashBoardData(intVinID, dtProcessDate, ReportType);
                    }

                    ReportType = "HVACOperationMode";

                    DataTable dataTable_HVACOperationMode = new DataTable();
                    if (intWeekNumber > 0)
                    {
                         dataTable_HVACOperationMode = gd.GetDashBoardData(intVinID, intWeekNumber, intYearNumber, ReportType);
                    }
                    else
                    {
                         dataTable_HVACOperationMode = gd.GetDashBoardData(intVinID, dtProcessDate, ReportType);
                    }

                    ReportType = "AuxLoadsOnTime";
                    DataTable dataTable_AuxLoadsOnTime = new DataTable();
                    if (intWeekNumber > 0)
                    {
                         dataTable_AuxLoadsOnTime = gd.GetDashBoardData(intVinID, intWeekNumber, intYearNumber, ReportType);
                    }
                    else
                    {
                         dataTable_AuxLoadsOnTime = gd.GetDashBoardData(intVinID, dtProcessDate, ReportType);
                    }

                    ReportType = "PowerTrainData";
                    DataTable dataTable_PowerTrainData = new DataTable();
                    if (intWeekNumber > 0)
                    {
                         dataTable_PowerTrainData = gd.GetDashBoardData(intVinID, intWeekNumber, intYearNumber, ReportType);
                    }
                    else
                    {
                         dataTable_PowerTrainData = gd.GetDashBoardData(intVinID, dtProcessDate, ReportType);
                    }

                        ReportType = "DailyChargingData";
                        DataTable dataTable_DailyChargingData = new DataTable();
                        if (intWeekNumber > 0)
                        {
                            dataTable_DailyChargingData = gd.GetDashBoardDataTabular(intVinID, intWeekNumber, intYearNumber, ReportType);
                        }
                        else
                        {
                            // dataTable_OperationalData = gd.GetDashBoardDataTabular(intVinID, dtProcessDate, ReportType);
                        }

                            GV_DailyChargingData.Visible = true;
                            GV_DailyChargingData.DataSource = dataTable_DailyChargingData;
                            GV_DailyChargingData.DataBind();

                            ReportType = "DailyTempData";
                            DataTable dataTable_DailyTempData = new DataTable();
                            if (intWeekNumber > 0)
                            {
                                dataTable_DailyTempData = gd.GetDashBoardDataTabular(intVinID, intWeekNumber, intYearNumber, ReportType);
                            }
                            else
                            {
                                // dataTable_OperationalData = gd.GetDashBoardDataTabular(intVinID, dtProcessDate, ReportType);
                            }

                            GV_DailyTempData1.Visible = true;
                            GV_DailyTempData1.DataSource = dataTable_DailyTempData;
                           GV_DailyTempData1.DataBind();

                    GridView1.DataSource = dataTable_OperationalData;
                    GridView1.DataBind();

                    GridView3.DataSource = dataTable_HVACOperationMode;
                    GridView3.DataBind();

                    GridView4.DataSource = dataTable_AuxLoadsOnTime;
                    GridView4.DataBind();

                    GridView5.DataSource = dataTable_PowerTrainData;
                    GridView5.DataBind();

                    lblVin.InnerHtml = "<b>" + Vehicle.CustomerName + " - " + Vehicle.Vin;
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                     lblDate.InnerHtml = "<b>" + DtRangeWeekly;
                    }
                    else
                    {
                    lblDate.InnerHtml = "<b>" + dtProcessDate.ToShortDateString();
                     }

                }
                else
                {
                    Response.Write(" Vehicle does not exists!");
                    Response.End();
                }

            }
            else
            {
                Response.Write(" Vehicle does not exists!");
                Response.End();
            }

            //switch (ReportType)
            //{

            //    case "TempData":
            //        ReportServices_DailyGrab_VinDashBoard_OperationalData(Vehicle, dtProcessDate);
            //        break;

            //    default:
            //        Response.Write(" Chart Type does not exists!");
            //        break;
            //}
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //string VinID = Request.QueryString["VinID"].ToString();
            //string ProcessDate = Request.QueryString["ProcessDate"].ToString();
            //string ReportPeriod = Request.QueryString["ReportPeriod"].ToString();

            //string ReportType = Request.QueryString["ReportType"].ToString();

            //string WeekNumber = Request.QueryString["WeekNumber"].ToString();
            //string YearNumber = Request.QueryString["YearNumber"].ToString();

            string VinID = Request.QueryString["VinID"].ToString();

            string ProcessDate = String.Empty;
            DateTime dtProcessDate = DateTime.Today;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ProcessDate"]))
            {
                ProcessDate = Request.QueryString["ProcessDate"].ToString();
                dtProcessDate = DateTime.Parse(ProcessDate);
            }

            string ReportType = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportType"]))
            {
                ReportType = Request.QueryString["ReportType"].ToString();
            }

            string WeekNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["WeekNumber"]))
            {
                WeekNumber = Request.QueryString["WeekNumber"].ToString();
            }

            string YearNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["YearNumber"]))
            {
                YearNumber = Request.QueryString["YearNumber"].ToString();
            }

            string ReportPeriod = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportPeriod"]))
            {
                ReportPeriod = Request.QueryString["ReportPeriod"].ToString();
            }

            int intWeekNumber = 0;
            int intYearNumber = 0;

            string DtRangeWeekly = String.Empty;
            if (ReportPeriod == "Weekly")
            {
                bool IsWeekNumeric = int.TryParse(WeekNumber, out intWeekNumber);
                if (IsWeekNumeric)
                {
                    intWeekNumber = int.Parse(WeekNumber);
                }

                bool IsYearNumeric = int.TryParse(YearNumber, out intYearNumber);
                if (IsYearNumeric)
                {
                    intYearNumber = int.Parse(YearNumber);
                }

                GetChartData gd = new GetChartData();
                DataTable DtRange = gd.GetDateRangeFromWeekNumber(intWeekNumber, intYearNumber);

                DtRangeWeekly = Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d") + " - " + Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d");
            }

            Vehicles Vehicle = new Vehicles();

            if (VinID != "")
            {
                int intVinID;
                bool IsVinNumeric = int.TryParse(VinID, out intVinID);

                if (IsVinNumeric)
                {
                    intVinID = int.Parse(VinID);

                    GetChartData gcd = new GetChartData();
                    Vehicle = gcd.GetVinInfo(intVinID);
                    GetChartData gd = new GetChartData();

                    DataTable dataTable_TempData = new DataTable();

                    if (intWeekNumber > 0)
                    {
                        dataTable_TempData = gd.GetDashBoardDataTabular(intVinID, intWeekNumber, intYearNumber, ReportType);
                    }
                    else
                    {
                        dataTable_TempData = gd.GetDashBoardDataTabular(intVinID, dtProcessDate, ReportType);
                    }

                    if (ReportType == "DailyChargingData")
                    {
                        GV_DailyChargingData.Visible = true;
                        GV_DailyChargingData.DataSource = dataTable_TempData;
                        GV_DailyChargingData.DataBind();
                    }

                    if (ReportType == "DailyTempData")
                    {
                        GV_DailyTempData.Visible = true;
                        GV_DailyTempData.DataSource = dataTable_TempData;
                        GV_DailyTempData.DataBind();
                    }

                    if (ReportType == "DailyBatteryData")
                    {
                        GV_DailyBatteryData.Visible = true;
                        GV_DailyBatteryData.DataSource = dataTable_TempData;
                        GV_DailyBatteryData.DataBind();
                    }

                }
                else
                {
                    Response.Write(" Vehicle does not exists!");
                    Response.End();
                }

            }
            else
            {
                Response.Write(" Vehicle does not exists!");
                Response.End();
            }
        }
        private void ReportServices_DailyGrab_GenVehicleData_VinChargingHist(Vehicles v, int WeekNumber, int YearNumber)
        {
            GetChartData gd = new GetChartData();
            DataTable DtRange = gd.GetDateRangeFromWeekNumber(WeekNumber,YearNumber);
            DataTable dataTable = gd.Dt_DailyGrab_GetVenChargingHist(v.VinID, WeekNumber, YearNumber, Rounding);

            string mainTitle = string.Format("Vehicle Charging - {0} - {1}  ", Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d"), Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d"));

            string subTitle = string.Format("{0} - {1}", v.CustomerName, v.Vin);
               hcFrutas.Title = new Title(mainTitle);
               hcFrutas.SubTitle = new SubTitle(subTitle);

               hcFrutas.Theme = "grid";
               hcFrutas.Legend = new Legend { align = Align.right, layout = Layout.vertical, verticalAlign = VerticalAlign.top, x = -10, y = 70, borderWidth = 0 };
               hcFrutas.Appearance = new Appearance { renderTo = "container", animation = false };
               hcFrutas.YAxis.Add(new YAxisItem { title = new Title("Occurence") });

            //Get point collection
            var pointCollectionBrakePedal = new PointCollection();
            var pointCollectionCat = new PointCollection();
            //var pointCollectionSocMax = new PointCollection();
            //var pointCollectionSocDas = new PointCollection();

            List<string> buckets = new List<string>();

            // Add string using Add method

            foreach (DataRow row in dataTable.Rows)
            {
                pointCollectionBrakePedal.Add(new Point(Convert.ToDouble(row["TimeInMins"])));
                buckets.Add(row["BucketEnd"].ToString());
                //pointCollectionSocMax.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCes_usi_SoCmax_pct"])));
                //pointCollectionSocDas.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCbo_usi_DashSOC_pct"])));
                // pointCollection.Add(new Point(DateTime.Parse(row["Time_Occur"].ToString()), Convert.ToDouble(row["SocMin"])));
            }

            //Add data to serie
            //hcVendas.XAxis.Add(new XAxisItem { title = new Title("Time Buckets"), categories = pointCollectionCat.ToArray()  });
            //hcFrutas.XAxis.Add(new XAxisItem { type = AxisDataType.linear, categories = buckets.ToArray(), tickColor = "#ccc", tickLength = 50, labels = (new Labels() { rotation = -90, step = 1, y = 30 }) });
               hcFrutas.XAxis.Add(new XAxisItem { type = AxisDataType.linear, tickColor = "#ccc", categories = buckets.ToArray(), tickLength = 1, title = new Title("Charinging Time in Min") });

            var series = new Collection<Serie> { new Serie { name = "Counts", data = pointCollectionBrakePedal.ToArray(), type = RenderType.column, showInLegend = false } };

            //hcVendas.PlotOptions = new PlotOptionsLine { marker = new Marker { enabled = true }, dataLabels = new DataLabels { enabled = true } };
               hcFrutas.PlotOptions = new PlotOptionsColumn { groupPadding = 0, pointPadding = 0, shadow = true, borderWidth = 2, borderColor = "#666", dataLabels = new DataLabels { enabled = true } };

            //Bind the control
               hcFrutas.DataSource = series;
               hcFrutas.DataBind();
        }
        private void ReportServices_DailyGrab_GenVehicleData_VinChgEnergyHist(Vehicles v, int WeekNumber, int YearNumber)
        {
            GetChartData gd = new GetChartData();

            DataTable DtRange = gd.GetDateRangeFromWeekNumber(WeekNumber, YearNumber);
            DataTable dataTable = gd.Dt_DailyGrab_GetVenChgEnergyHist(v.VinID, WeekNumber, YearNumber, Rounding);

            string mainTitle = string.Format("Chrg Energy kWh - {0} - {1}  ", Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d"), Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d"));

            string subTitle = string.Format("{0} - {1}", v.CustomerName, v.Vin);
               hcFrutas.Title = new Title(mainTitle);
               hcFrutas.SubTitle = new SubTitle(subTitle);

               hcFrutas.Theme = "grid";
               hcFrutas.Legend = new Legend { align = Align.right, layout = Layout.vertical, verticalAlign = VerticalAlign.top, x = -10, y = 70, borderWidth = 0 };
               hcFrutas.Appearance = new Appearance { renderTo = "container", animation = false };
               hcFrutas.YAxis.Add(new YAxisItem { title = new Title("Chrg Energy kWh") });

            //Get point collection
            var pointCollectionChgEnergy = new PointCollection();
            var pointCollectionCat = new PointCollection();
            //var pointCollectionSocMax = new PointCollection();
            //var pointCollectionSocDas = new PointCollection();

            List<string> buckets = new List<string>();

            // Add string using Add method

            foreach (DataRow row in dataTable.Rows)
            {
                pointCollectionChgEnergy.Add(new Point(Convert.ToDouble(row["Chg_Energy_kwh"])));
                buckets.Add(row["ProcessDate"].ToString());

            }

            //Add data to serie
              hcFrutas.XAxis.Add(new XAxisItem { type = AxisDataType.linear, tickColor = "#ccc", categories = buckets.ToArray(), tickLength = 1, title = new Title("Date") });

               var series = new Collection<Serie> { new Serie { name = "Chrg Energy kWh", data = pointCollectionChgEnergy.ToArray(), type = RenderType.column, showInLegend = false } };

            //hcVendas.PlotOptions = new PlotOptionsLine { marker = new Marker { enabled = true }, dataLabels = new DataLabels { enabled = true } };
               hcFrutas.PlotOptions = new PlotOptionsColumn { groupPadding = 0, pointPadding = 0, shadow = true, borderWidth = 2, borderColor = "#666", dataLabels = new DataLabels { enabled = true } };

            //Bind the control
               hcFrutas.DataSource = series;
               hcFrutas.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string VinID = Request.QueryString["VinID"].ToString();

            string ProcessDate = String.Empty;
            DateTime dtProcessDate = DateTime.Today;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ProcessDate"]))
            {
                ProcessDate = Request.QueryString["ProcessDate"].ToString();
                dtProcessDate = DateTime.Parse(ProcessDate);
            }

            string ReportType = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportType"]))
            {
                ReportType = Request.QueryString["ReportType"].ToString();
            }

            string WeekNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["WeekNumber"]))
            {
                WeekNumber = Request.QueryString["WeekNumber"].ToString();
            }

            string YearNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["YearNumber"]))
            {
                YearNumber = Request.QueryString["YearNumber"].ToString();
            }

            string ReportPeriod = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportPeriod"]))
            {
                ReportPeriod = Request.QueryString["ReportPeriod"].ToString();
            }

            int intWeekNumber = 0;
            int intYearNumber = 0;

            string DtRangeWeekly = String.Empty;
            if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
            {
                bool IsWeekNumeric = int.TryParse(WeekNumber, out intWeekNumber);
                if (IsWeekNumeric)
                {
                    intWeekNumber = int.Parse(WeekNumber);
                }

                bool IsYearNumeric = int.TryParse(YearNumber, out intYearNumber);
                if (IsYearNumeric)
                {
                    intYearNumber = int.Parse(YearNumber);
                }

                GetChartData gd = new GetChartData();
                DataTable DtRange = gd.GetDateRangeFromWeekNumber(intWeekNumber, intYearNumber);

                DtRangeWeekly = Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d") + " - " + Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d");
            }

            if (ReportPeriod == "Weekly")
            {
                lblHead.InnerHtml = "<br/><br/><b>Weekly Vehicle Report";
            }
            else if (ReportPeriod == "NREL")
            {
                lblHead.InnerHtml = "<br/><br/><b>NREL Weekly Vehicle Report";
            }

            else if (ReportPeriod == "DailyBattery")
            {
                lblHead.InnerHtml = "<br/><br/><b>Daily Battery Report";
            }

            else if (ReportPeriod == "DailyBatteryAllCust")
            {
                lblHead.InnerHtml = "<br/><br/><b>Daily Battery Status Report";
            }

            else
            {
                lblHead.InnerHtml = "<br/><br/><b>Daily Vehicle Report";
            }

             Vehicles Vehicle = new Vehicles();

            if (VinID != "")
            {
                int intVinID;
                bool IsVinNumeric = int.TryParse(VinID, out intVinID);

                if (IsVinNumeric)
                {
                    intVinID = int.Parse(VinID);

                    GetChartData gcd = new GetChartData();
                    Vehicle = gcd.GetVinInfo(intVinID);

                    lblVin.InnerHtml = "<br/><br/><b>" + Vehicle.CustomerName + "  -  " + Vehicle.Vin;
                    if (ReportPeriod == "Weekly")
                    {
                     lblDate.InnerHtml = "<br/><br/><b>Report Dates: " + DtRangeWeekly;
                    }
                    else if (ReportPeriod == "NREL")
                    {
                        lblDate.InnerHtml = "<br/><br/><b>Report Dates: " + DtRangeWeekly;
                    }
                    else if (ReportPeriod == "DailyBattery")
                    {
                        lblDate.InnerHtml = "<br/><br/><b>Report Dates: " + dtProcessDate.ToShortDateString();
                    }
                    else if (ReportPeriod == "DailyBatteryAllCust")
                    {
                        lblDate.InnerHtml = "<br/><br/><b>Report Dates: " + dtProcessDate.ToShortDateString();
                        lblVin.Visible = false;
                        splashImg.Visible = false;
                    }

                    else
                    {
                        lblDate.InnerHtml = "<br/><br/><b>Report Date: " + dtProcessDate.ToShortDateString();
                    }

                }
                else
                {
                    lblVin.InnerHtml = "<br/><br/><b>" + " Vehicle does not exists!";
                    Response.End();
                }

            }
            else
            {
                lblVin.InnerHtml = "<b>" + " Vehicle does not exists!";
                Response.End();
            }

            //VinID = "221";
            //  ReportType = "GenVehicleData_VinSpeed";
            //ReportType = "GenVehicleData_CurrentVoltage";
            //ProcessDate = "04/13/2015";
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string VinID =string.Empty;

            if (!String.IsNullOrEmpty(Request.QueryString["VinID"]))
            {
                VinID = Request.QueryString["VinID"].ToString();

            }

            string ChargingStationID = string.Empty;

            if (!String.IsNullOrEmpty(Request.QueryString["ChargingStationID"]))
            {
                ChargingStationID = Request.QueryString["ChargingStationID"].ToString();

            }

            string ProcessDate = String.Empty;
            DateTime dtProcessDate = DateTime.Today;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ProcessDate"]))
            {
                ProcessDate = Request.QueryString["ProcessDate"].ToString();
                dtProcessDate = DateTime.Parse(ProcessDate);
            }

            string ReportType = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportType"]))
            {
                ReportType = Request.QueryString["ReportType"].ToString();
            }

            string WeekNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["WeekNumber"]))
            {
                WeekNumber = Request.QueryString["WeekNumber"].ToString();
            }

            string YearNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["YearNumber"]))
            {
                YearNumber = Request.QueryString["YearNumber"].ToString();
            }

            string ReportPeriod = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportPeriod"]))
            {
                ReportPeriod = Request.QueryString["ReportPeriod"].ToString();
            }

            int intWeekNumber = 0;
            int intYearNumber = 0;

            string DtRangeWeekly = String.Empty;
            if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
            {
                bool IsWeekNumeric = int.TryParse(WeekNumber, out intWeekNumber);
                if (IsWeekNumeric)
                {
                    intWeekNumber = int.Parse(WeekNumber);
                }

                bool IsYearNumeric = int.TryParse(YearNumber, out intYearNumber);
                if (IsYearNumeric)
                {
                    intYearNumber = int.Parse(YearNumber);
                }

                GetChartData gd = new GetChartData();
                DataTable DtRange = gd.GetDateRangeFromWeekNumber(intWeekNumber, intYearNumber);

                DtRangeWeekly = Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d") + " - " + Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d");
            }

            //string ReportType = Request.QueryString["ReportType"].ToString();
            //string ReportPeriod = Request.QueryString["ReportPeriod"].ToString();
            //string WeekNumber = Request.QueryString["WeekNumber"].ToString();
            //string YearNumber = Request.QueryString["YearNumber"].ToString();

            //VinID = "221";
            //  ReportType = "GenVehicleData_VinSpeed";
            //ReportType = "GenVehicleData_CurrentVoltage";
            //ProcessDate = "04/13/2015";
            //DateTime dtProcessDate = DateTime.Parse(ProcessDate);

            Vehicles Vehicle = new Vehicles();

            if (VinID != "")
            {
                int intVinID;
                bool IsVinNumeric = int.TryParse(VinID, out intVinID);

                if (IsVinNumeric)
                {
                    intVinID = int.Parse(VinID);

                    GetChartData gcd = new GetChartData();
                    Vehicle = gcd.GetVinInfo(intVinID);

                }
                else
                {
                    Response.Write(" Vehicle does not exists!");
                    Response.End();
                }

            }
            //else
            //{
            //    Response.Write(" Vehicle does not exists!");
            //    Response.End();
            //}

            Chargers Charger = new Chargers();
            int intChargingStationID = 0;

            if (ChargingStationID != "")
            {

                bool IsChargerNumeric = int.TryParse(ChargingStationID, out intChargingStationID);

                if (IsChargerNumeric)
                {
                    intChargingStationID = int.Parse(ChargingStationID);

                    GetChartData gcd = new GetChartData();
                    Charger = gcd.GetChargerInfo(intChargingStationID);

                }
                else
                {
                    Response.Write(" Charger does not exists!");
                    Response.End();
                }

            }
            //else
            //{
            //    Response.Write(" Charger does not exists!");
            //    Response.End();
            //}

            switch (ReportType)
            {

                case "GenVehicleData_VinSpeedHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinSpeedHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinSpeedHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinEfficiencyHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinEfficiencyHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinEfficiencyHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinAccelPedalHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinAccelPedalHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinAccelPedalHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinBrakePedalHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinBrakePedalHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinBrakePedalHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinChargingHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinChargingHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinChargingHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinVoltageHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinVoltageHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinVoltageHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinSocMinHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinSocMinHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinSocMinHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinBatteryTempMaxHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinBatteryTempMaxHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinBatteryTempMaxHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinPECoolantTempHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinPECoolantTempHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinPECoolantTempHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinDCDCConverterPowerHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinDCDCConverterPowerHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinDCDCConverterPowerHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinTractionMotorRotorTempHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTractionMotorRotorTempHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTractionMotorRotorTempHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinStatorTempHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinStatorTempHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinStatorTempHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinTractionMotorInverterTempHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTractionMotorInverterTempHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTractionMotorInverterTempHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinTractionMotorIGBTTempHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTractionMotorIGBTTempHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTractionMotorIGBTTempHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinRadiatorFanSpeedHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinRadiatorFanSpeedHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinRadiatorFanSpeedHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinBatteryCoolantPumpHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinBatteryCoolantPumpHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinBatteryCoolantPumpHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinMinAirPressureHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinMinAirPressureHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinMinAirPressureHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinTransTempHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTransTempHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTransTempHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinChgEnergyHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinChgEnergyHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        //do nothing
                    }

                    break;

                    case "GenVehicleData_ChargerStatusHist":
                    if (ReportPeriod == "Weekly")
                    {
                        ReportServices_DailyGrab_GenChargerData_ChargerHist(Charger, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        //do nothing
                    }

                    break;

                default:
                    Response.Write(" Chart Type does not exists!");
                    break;
            }
        }
        private void ReportServices_DailyGrab_GenVehicleData_CurrentByPacks(Vehicles v, DateTime dt)
        {
            GetChartData gd = new GetChartData();
            DataTable dataTable = gd.Dt_DailyGrab_GetCurrentbyPacks(v.VinID, dt, Rounding);

            string mainTitle = string.Format("Current  Daily - {0}", dt.ToString("MM/dd/yy"));
            string subTitle = string.Format("{0} - {1}", v.CustomerName, v.Vin);
            hcVendas.Title = new Title(mainTitle);
            hcVendas.SubTitle = new SubTitle(subTitle);

            hcVendas.Theme = "grid";
            hcVendas.Legend = new Legend { align = Align.right, layout = Layout.vertical, verticalAlign = VerticalAlign.top, x = -10, y = 70, borderWidth = 0 };
            hcVendas.Appearance = new Appearance { renderTo = "container", animation = false };
            hcVendas.YAxis.Add(new YAxisItem { title = new Title("Current Amps "), minorGridLineWidth = 0, gridLineWidth = 0 });

            hcVendas.XAxis.Add(new XAxisItem { type = AxisDataType.datetime, dateTimeLabelFormats = new DateTimeLabelFormats { hour = "%H" }, title = new Title("Time in Hours") });

            hcVendas.Tooltip = new ToolTip("Highcharts.dateFormat('%H:%M', this.x) +': '+ this.y");

            //Get point collection
            var pointCollectionCurrent = new PointCollection();
            var pointCollectionCurrentPack0 = new PointCollection();
            var pointCollectionCurrentPack1 = new PointCollection();
            var pointCollectionCurrentPack2 = new PointCollection();
            var pointCollectionCurrentPack3 = new PointCollection();
            var pointCollectionCurrentPack4 = new PointCollection();
            var pointCollectionCurrentPack5 = new PointCollection();
            var pointCollectionCurrentPack6 = new PointCollection();
            var pointCollectionCurrentPack7 = new PointCollection();

            foreach (DataRow row in dataTable.Rows)
            {

                // pointCollectionCurrent.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCes_usi_Current_pct"])));
                pointCollectionCurrentPack0.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm0_uin_PackI_a"])));
                pointCollectionCurrentPack1.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm1_uin_PackI_a"])));
                pointCollectionCurrentPack2.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm2_uin_PackI_a"])));
                pointCollectionCurrentPack3.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm3_uin_PackI_a"])));
                pointCollectionCurrentPack4.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm4_uin_PackI_a"])));
                pointCollectionCurrentPack5.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm5_uin_PackI_a"])));
                pointCollectionCurrentPack6.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm6_uin_PackI_a"])));
                pointCollectionCurrentPack7.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm7_uin_PackI_a"])));

            }

            //Add data to serie

            var series = new Collection<Serie> {
                   //  new Serie { name = "Current", data = pointCollectionCurrent.ToArray() },
                     new Serie { name = "P0", data = pointCollectionCurrentPack0.ToArray() },
                     new Serie { name = "P1", data = pointCollectionCurrentPack1.ToArray() },
                     new Serie { name = "P2", data = pointCollectionCurrentPack2.ToArray() },
                     new Serie { name = "P3", data = pointCollectionCurrentPack3.ToArray() },
                     new Serie { name = "P4", data = pointCollectionCurrentPack4.ToArray() },
                     new Serie { name = "P5", data = pointCollectionCurrentPack5.ToArray() },
                     new Serie { name = "P6", data = pointCollectionCurrentPack6.ToArray() },
                     new Serie { name = "P7", data = pointCollectionCurrentPack7.ToArray() }
                 };

            hcVendas.DataSource = series;

            hcVendas.PlotOptions = new PlotOptionsLine { marker = new Marker { enabled = false }, dataLabels = new DataLabels { enabled = false } };

            //Bind the control
            hcVendas.DataBind();
        }
        private void ReportServices_DailyGrab_GenVehicleData_VinSpeedHist(Vehicles v, DateTime dt)
        {
            GetChartData gd = new GetChartData();
            DataTable dataTable = gd.Dt_DailyGrab_GetVenSpeedHist(v.VinID, dt, Rounding);

            string mainTitle = string.Format("Vehicle Speed Band  - {0}", dt.ToString("MM/dd/yy"));
            string subTitle = string.Format("{0} - {1}", v.CustomerName, v.Vin);
            hcVendas.Title = new Title(mainTitle);
            hcVendas.SubTitle = new SubTitle(subTitle);

            hcVendas.Theme = "grid";
            hcVendas.Legend = new Legend { align = Align.right, layout = Layout.vertical, verticalAlign = VerticalAlign.top, x = -10, y = 70, borderWidth = 0 };
            hcVendas.Appearance = new Appearance { renderTo = "container", animation = false };
            hcVendas.YAxis.Add(new YAxisItem { title = new Title("Time in Mins") });

            //  hcVendas.XAxis.Add(new XAxisItem { title = new Title("Time Buckets"), categories = new[] { "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002" } });

            //   hcVendas.Tooltip = new ToolTip("Highcharts.dateFormat('%H:%M', this.x) +': '+ this.y");

            //Get point collection
            var pointCollectionVinSpeed = new PointCollection();
            var pointCollectionCat = new PointCollection();
            //var pointCollectionSocMax = new PointCollection();
            //var pointCollectionSocDas = new PointCollection();

            List<string> revenues = new List<string>();

            // Add string using Add method

            foreach (DataRow row in dataTable.Rows)
            {
                pointCollectionVinSpeed.Add(new Point(Convert.ToDouble(row["TimeInMins"])));
                revenues.Add(row["BucketName"].ToString());
                //pointCollectionSocMax.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCes_usi_SoCmax_pct"])));
                //pointCollectionSocDas.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCbo_usi_DashSOC_pct"])));
                // pointCollection.Add(new Point(DateTime.Parse(row["Time_Occur"].ToString()), Convert.ToDouble(row["SocMin"])));
            }

            //Add data to serie
            //hcVendas.XAxis.Add(new XAxisItem { title = new Title("Time Buckets"), categories = pointCollectionCat.ToArray()  });
            hcVendas.XAxis.Add(new XAxisItem { title = new Title("Time Buckets"), categories = revenues.ToArray(), labels = (new Labels() { rotation = -90, step = 1, y = 20 }) });

            var series = new Collection<Serie> { new Serie { name = "VinSpeed", data = pointCollectionVinSpeed.ToArray(), type = RenderType.column } };
            series.Add(new Serie { name = "VinSpeed2", data = pointCollectionVinSpeed.ToArray(), type = RenderType.spline });
            //hcVendas.PlotOptions = new PlotOptionsLine { marker = new Marker { enabled = true }, dataLabels = new DataLabels { enabled = true } };

            //Bind the control
            hcVendas.DataSource = series;
            hcVendas.DataBind();
        }
        private void ReportServices_DailyGrab_GenVehicleData_VinSpeed(Vehicles v, DateTime dt)
        {
            GetChartData gd = new GetChartData();
            DataTable dataTable = gd.Dt_DailyGrab_GetSoC(v.VinID, dt, Rounding);

            string mainTitle = string.Format("Vin Speed Daily - {0}", dt.ToString("MM/dd/yy"));
            string subTitle = string.Format("{0} - {1}", v.CustomerName, v.Vin);
            hcVendas.Title = new Title(mainTitle);
            hcVendas.SubTitle = new SubTitle(subTitle);

            hcVendas.Theme = "grid";
            hcVendas.Legend = new Legend { align = Align.right, layout = Layout.vertical, verticalAlign = VerticalAlign.top, x = -10, y = 70, borderWidth = 0 };
            hcVendas.Appearance = new Appearance { renderTo = "container", animation = false };
            hcVendas.YAxis.Add(new YAxisItem { title = new Title("Speed in MPH") });

            hcVendas.XAxis.Add(new XAxisItem { type = AxisDataType.datetime, dateTimeLabelFormats = new DateTimeLabelFormats { hour = "%H" }, title = new Title("Time in Hours") });

            hcVendas.Tooltip = new ToolTip("Highcharts.dateFormat('%H:%M', this.x) +': '+ this.y");

            //Get point collection
            var pointCollectionVinSpeed = new PointCollection();
            var pointCollectionCharging = new PointCollection();
            var pointCollectionScoopHeater = new PointCollection();

            foreach (DataRow row in dataTable.Rows)
            {
                pointCollectionVinSpeed.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpt_int_Spd_mph"])));
                pointCollectionCharging.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCes_usi_ChargeEnable_xx"])));
                pointCollectionScoopHeater.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCbo_bo_ScoopHeaterOn"])));
                // pointCollection.Add(new Point(DateTime.Parse(row["Time_Occur"].ToString()), Convert.ToDouble(row["SocMin"])));
            }

            //Add data to serie

            var series = new SerieCollection();

            series.Add(new Serie { id = "VinSpeed", name = "VinSpeed", type = RenderType.spline, data = pointCollectionVinSpeed.ToArray() });
            series.Add(new Serie { id = "Charging", name = "Charging", color = "red", type = RenderType.spline, data = pointCollectionCharging.ToArray() });
            series.Add(new Serie { id = "ScoopHeater", name = "ScoopHeater", type = RenderType.spline, data = pointCollectionScoopHeater.ToArray() });

            hcVendas.PlotOptions = new PlotOptionsLine { marker = new Marker { enabled = false }, dataLabels = new DataLabels { enabled = false } };

            // var series = new Collection<Serie> { new Serie { name = "VinSpeed", data = pointCollectionVinSpeed.ToArray(), type = RenderType.scatter }, new Serie { name = "Charging", type = RenderType.scatter, data = pointCollectionCharging.ToArray() }, new Serie { name = "ScoopHeater", type = RenderType.scatter, data = pointCollectionScoopHeater.ToArray() } };

            // hcVendas.PlotOptions = new PlotOptionsScatter { marker = new Marker { enabled = false }, dataLabels = new DataLabels { enabled = false } };

            //Bind the control
            hcVendas.DataSource = series;
            hcVendas.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string VinID = Request.QueryString["VinID"].ToString();
            string ProcessDate = Request.QueryString["ProcessDate"].ToString();
            string ReportType = Request.QueryString["ReportType"].ToString();

            //VinID = "221";
            //  ReportType = "GenVehicleData_VinSpeed";
            //ReportType = "GenVehicleData_CurrentVoltage";
            //ProcessDate = "04/13/2015";
            DateTime dtProcessDate = DateTime.Parse(ProcessDate);

            Vehicles Vehicle = new Vehicles();

            if (VinID != "")
            {
                int intVinID;
                bool IsVinNumeric = int.TryParse(VinID, out intVinID);

                if (IsVinNumeric)
                {
                    intVinID = int.Parse(VinID);

                    GetChartData gcd = new GetChartData();
                    Vehicle = gcd.GetVinInfo(intVinID);

                }
                else
                {
                    Response.Write(" Vehicle does not exists!");
                    Response.End();
                }

            }
            else
            {
                Response.Write(" Vehicle does not exists!");
                Response.End();
            }

            switch (ReportType)
            {
                case "GenVehicleData_SoC":
                    ReportServices_DailyGrab_GenVehicleData_SOC(Vehicle, dtProcessDate);
                    break;
                case "GenVehicleData_SoCByPacks_Min":
                    ReportServices_DailyGrab_GenVehicleData_SOCByPacks(Vehicle, dtProcessDate, "MinSoC");
                    break;
                case "GenVehicleData_SoCByPacks_Max":
                    ReportServices_DailyGrab_GenVehicleData_SOCByPacks(Vehicle, dtProcessDate, "MaxSoC");
                    break;
                case "GenVehicleData_TMaxByPacks":
                    ReportServices_DailyGrab_GenVehicleData_TMaxByPacks(Vehicle, dtProcessDate);
                    break;
                case "GenVehicleData_CurrentByPacks":
                    ReportServices_DailyGrab_GenVehicleData_CurrentByPacks(Vehicle, dtProcessDate);
                    break;
                case "GenVehicleData_VinSpeed":
                    ReportServices_DailyGrab_GenVehicleData_VinSpeed(Vehicle, dtProcessDate);
                    break;
                case "GenVehicleData_CurrentVoltage":
                    ReportServices_DailyGrab_GenVehicleData_CurrentVoltage(Vehicle, dtProcessDate);
                    break;
                case "GenVehicleData_SoCEnergy":
                    ReportServices_DailyGrab_GenVehicleData_SOCEnergy(Vehicle, dtProcessDate);
                    break;
                case "GenVehicleData_VinSpeedHist":
                    ReportServices_DailyGrab_GenVehicleData_VinSpeedHist(Vehicle, dtProcessDate);
                    break;

                default:
                    Response.Write(" Chart Type does not exists!");
                    break;
            }
        }
        private void ReportServices_DailyGrab_GenVehicleData_SOCByPacks(Vehicles v, DateTime dt, string dtype)
        {
            string dtypeLabel = string.Empty;

            if (dtype == "MinSoC")
            {
                dtypeLabel = " Min ";
            }
            else if (dtype == "MaxSoC")
            {
                dtypeLabel = " Max ";
            }

            GetChartData gd = new GetChartData();
            DataTable dataTable = gd.Dt_DailyGrab_GetSoCbyPacks(v.VinID, dt, Rounding);

            string mainTitle = string.Format("Soc {0}  Daily - {1}", dtypeLabel, dt.ToString("MM/dd/yy"));
            string subTitle = string.Format("{0} - {1}", v.CustomerName, v.Vin);
            hcVendas.Title = new Title(mainTitle);
            hcVendas.SubTitle = new SubTitle(subTitle);

            hcVendas.Theme = "grid";

            hcVendas.Legend = new Legend { align = Align.right, layout = Layout.vertical, verticalAlign = VerticalAlign.top, x = -10, y = 70, borderWidth = 0 };
            hcVendas.Appearance = new Appearance { renderTo = "container", animation = false };
            hcVendas.YAxis.Add(new YAxisItem { title = new Title(string.Format("Soc {0}  % ", dtypeLabel)), minorGridLineWidth = 0, gridLineWidth = 0 });

            hcVendas.XAxis.Add(new XAxisItem { type = AxisDataType.datetime, dateTimeLabelFormats = new DateTimeLabelFormats { hour = "%H" }, title = new Title("Time in Hours") });

            hcVendas.Tooltip = new ToolTip("Highcharts.dateFormat('%H:%M', this.x) +': '+ this.y");

            //Get point collection
            var pointCollectionSocMin = new PointCollection();
            var pointCollectionSocMinPack0 = new PointCollection();
            var pointCollectionSocMinPack1 = new PointCollection();
            var pointCollectionSocMinPack2 = new PointCollection();
            var pointCollectionSocMinPack3 = new PointCollection();
            var pointCollectionSocMinPack4 = new PointCollection();
            var pointCollectionSocMinPack5 = new PointCollection();
            var pointCollectionSocMinPack6 = new PointCollection();
            var pointCollectionSocMinPack7 = new PointCollection();

            var pointCollectionSocMax = new PointCollection();
            var pointCollectionSocMaxPack0 = new PointCollection();
            var pointCollectionSocMaxPack1 = new PointCollection();
            var pointCollectionSocMaxPack2 = new PointCollection();
            var pointCollectionSocMaxPack3 = new PointCollection();
            var pointCollectionSocMaxPack4 = new PointCollection();
            var pointCollectionSocMaxPack5 = new PointCollection();
            var pointCollectionSocMaxPack6 = new PointCollection();
            var pointCollectionSocMaxPack7 = new PointCollection();

            foreach (DataRow row in dataTable.Rows)
            {

                if (dtype == "MinSoC")
                {
                    // pointCollectionSocMin.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCes_usi_SoCMin_pct"])));
                         //.pointCollectionSocMin.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCes_usi_SoCmin_pct"])));
                    pointCollectionSocMinPack0.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm0_usi_SoCMin_pct"])));
                    pointCollectionSocMinPack1.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm1_usi_SoCMin_pct"])));
                    pointCollectionSocMinPack2.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm2_usi_SoCMin_pct"])));
                    pointCollectionSocMinPack3.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm3_usi_SoCMin_pct"])));
                    pointCollectionSocMinPack4.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm4_usi_SoCMin_pct"])));
                    pointCollectionSocMinPack5.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm5_usi_SoCMin_pct"])));
                    pointCollectionSocMinPack6.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm6_usi_SoCMin_pct"])));
                    pointCollectionSocMinPack7.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm7_usi_SoCMin_pct"]),System.Drawing.Color.Black));

                    //pointCollectionSocMinPack0.Add(new Point(Convert.ToInt64(1), Convert.ToDouble(row["PCpm0_usi_SoCMin_pct"])));
                    //pointCollectionSocMinPack1.Add(new Point(Convert.ToInt64(2), Convert.ToDouble(row["PCpm1_usi_SoCMin_pct"])));
                    //pointCollectionSocMinPack2.Add(new Point(Convert.ToInt64(3), Convert.ToDouble(row["PCpm2_usi_SoCMin_pct"])));
                    //pointCollectionSocMinPack3.Add(new Point(Convert.ToInt64(4), Convert.ToDouble(row["PCpm3_usi_SoCMin_pct"])));
                    //pointCollectionSocMinPack4.Add(new Point(Convert.ToInt64(5), Convert.ToDouble(row["PCpm4_usi_SoCMin_pct"])));
                    //pointCollectionSocMinPack5.Add(new Point(Convert.ToInt64(6), Convert.ToDouble(row["PCpm5_usi_SoCMin_pct"])));
                    //pointCollectionSocMinPack6.Add(new Point(Convert.ToInt64(7), Convert.ToDouble(row["PCpm6_usi_SoCMin_pct"])));
                    //pointCollectionSocMinPack7.Add(new Point(Convert.ToInt64(8), Convert.ToDouble(row["PCpm7_usi_SoCMin_pct"])));

                }

                else if (dtype == "MaxSoC")
                {

                    // pointCollectionSocMax.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCes_usi_SoCMax_pct"])));

                    pointCollectionSocMaxPack0.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm0_usi_SoCMax_pct"])));
                    pointCollectionSocMaxPack1.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm1_usi_SoCMax_pct"])));
                    pointCollectionSocMaxPack2.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm2_usi_SoCMax_pct"])));
                    pointCollectionSocMaxPack3.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm3_usi_SoCMax_pct"])));
                    pointCollectionSocMaxPack4.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm4_usi_SoCMax_pct"])));
                    pointCollectionSocMaxPack5.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm5_usi_SoCMax_pct"])));
                    pointCollectionSocMaxPack6.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm6_usi_SoCMax_pct"])));
                    pointCollectionSocMaxPack7.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpm7_usi_SoCMax_pct"])));

                }

            }

            //Add data to serie

            if (dtype == "MinSoC")
            {

                var seriesMin = new Collection<Serie> {
                   //  new Serie { name = "SocMin", data = pointCollectionSocMin.ToArray() },
                     new Serie { name = "P0", data = pointCollectionSocMinPack0.ToArray() },
                     new Serie { name = "P1", data = pointCollectionSocMinPack1.ToArray() },
                     new Serie { name = "P2", data = pointCollectionSocMinPack2.ToArray() },
                     new Serie { name = "P3", data = pointCollectionSocMinPack3.ToArray() },
                     new Serie { name = "P4", data = pointCollectionSocMinPack4.ToArray() },
                     new Serie { name = "P5", data = pointCollectionSocMinPack5.ToArray() },
                     new Serie { name = "P6", data = pointCollectionSocMinPack6.ToArray() },
                     new Serie { name = "P7", data = pointCollectionSocMinPack7.ToArray(),color="Grey" }
                 };

                hcVendas.DataSource = seriesMin;

            }
            else if (dtype == "MaxSoC")
            {

                var seriesMax = new Collection<Serie> {
                     //new Serie { name = "SocMax", data = pointCollectionSocMax.ToArray() },
                     new Serie { name = "P0", data = pointCollectionSocMaxPack0.ToArray() },
                     new Serie { name = "P1", data = pointCollectionSocMaxPack1.ToArray() },
                     new Serie { name = "P2", data = pointCollectionSocMaxPack2.ToArray() },
                     new Serie { name = "P3", data = pointCollectionSocMaxPack3.ToArray() },
                     new Serie { name = "P4", data = pointCollectionSocMaxPack4.ToArray() },
                     new Serie { name = "P5", data = pointCollectionSocMaxPack5.ToArray() },
                     new Serie { name = "P6", data = pointCollectionSocMaxPack6.ToArray() },
                     new Serie { name = "P7", data = pointCollectionSocMaxPack7.ToArray() ,color="Grey" }
                 };

                hcVendas.DataSource = seriesMax;
            }

            hcVendas.PlotOptions = new PlotOptionsLine { marker = new Marker { enabled = false }, dataLabels = new DataLabels { enabled = false }};

            //Bind the control
            hcVendas.DataBind();
        }