public ActionResult Index()
        {
            PowerUsageService      objService = new PowerUsageService();
            PowerUsageModel        objModel   = new PowerUsageModel();
            List <PowerUsageModel> objList    = new List <PowerUsageModel>();
            int cid = 0;

            if (Session["CompID"] != null)
            {
                cid = Convert.ToInt32(Session["CompID"].ToString());
            }
            objList = objService.getPUData(cid);
            objModel.ListPowerData = new List <PowerUsageModel>();
            objModel.ListPowerData.AddRange(objList);


            List <PowerUsageModel> lstAppData    = new List <PowerUsageModel>();
            PowerUsageModel        objAppoint    = new PowerUsageModel();
            PowerUsageService      objAppService = new PowerUsageService();


            lstAppData = objAppService.getPUData(cid);

            var powerDataList = from e in lstAppData
                                select new
            {
                //id = e.PUID,
                label = e.DataSuite + "(" + e.RackID + ")",
                //rackid=e.RackID,
                y = e.PowerContracted,
                //pu=e.PowerUsed,
                //ou=e.OverUnder,
                lastreading = e.LastReading.Value.ToString("MMMM-yyyy"),
            };
            var rows = powerDataList.ToArray();

            if (rows.Count() > 0)
            {
                ViewBag.last = rows[0].lastreading;
            }
            string pc  = JsonConvert.SerializeObject(rows);
            string pcf = pc.Replace("[", string.Empty).Replace("]", string.Empty);

            ViewBag.DataPointsPC = pcf;

            var powerDataListPU = from e in lstAppData
                                  select new
            {
                //id = e.PUID,
                label = e.DataSuite + "(" + e.RackID + ")",
                //rackid=e.RackID,
                y = e.PowerUsed,
                //pu=e.PowerUsed,
                //ou=e.OverUnder,
                //lastreading = e.LastReading.Value.ToString("yyyy-MM-dd") + " " + e.LastReading,
            };
            var    rowsPU = powerDataListPU.ToArray();
            string pu     = JsonConvert.SerializeObject(rowsPU);;
            string puf    = pu.Replace("[", string.Empty).Replace("]", string.Empty);

            ViewBag.DataPointsPU = puf;

            List <PowerUsageModel> lstTotalPU = new List <PowerUsageModel>();
            //string year = Convert.ToString(System.DateTime.Now.Year);
            string year = "";

            if (objList.Count > 0)
            {
                year = objList[0].LastReading.Value.ToString("yyyy");
            }
            lstTotalPU = objService.getTotalPU(year, cid);
            objModel.ListTotalTickets = new List <PowerUsageModel>();
            objModel.ListTotalTickets.AddRange(lstTotalPU);

            var TTPCList = from e in lstTotalPU
                           select new
            {
                //id = e.PUID,
                label = e.TTmonth,
                //rackid=e.RackID,
                y = e.TotalPC,
                //pu=e.PowerUsed,
                //ou=e.OverUnder,
                year = e.TTyear,
            };
            var rowTT = TTPCList.ToArray();

            if (rowTT.Count() > 0)
            {
                ViewBag.Year = rowTT[0].year;
            }
            string ttpc  = JsonConvert.SerializeObject(rowTT);
            string ttpcf = ttpc.Replace("[", string.Empty).Replace("]", string.Empty);

            ViewBag.TTPC = ttpcf;


            var TTPUList = from e in lstTotalPU
                           select new
            {
                //id = e.PUID,
                label = e.TTmonth,
                //rackid=e.RackID,
                y = e.TotalPU,
            };
            var    rowsTTPU = TTPUList.ToArray();
            string ttpu     = JsonConvert.SerializeObject(rowsTTPU);
            string ttpuf    = ttpu.Replace("[", string.Empty).Replace("]", string.Empty);

            ViewBag.TTPU = ttpuf;

            UserService         objServiceComp = new UserService();
            List <CompanyModel> ListComp       = new List <CompanyModel>();

            ListComp          = objServiceComp.getActiveComp();
            objModel.ListComp = new List <CompanyModel>();
            objModel.ListComp.AddRange(ListComp);

            return(View(objModel));
        }
        public ActionResult Index(HttpPostedFileBase[] file, PowerUsageModel model)
        {
            PowerUsageModel   objModel   = new PowerUsageModel();
            PowerUsageService objService = new PowerUsageService();
            int mm = model.month;
            int yy = model.year;
            List <PowerUsageModel> objListSC = new List <PowerUsageModel>();
            int cid = 0;

            if (Session["CompID"] != null)
            {
                cid = Convert.ToInt32(Session["CompID"].ToString());
            }

            objListSC = objService.getPUDataByMMYY(mm, yy, cid);
            objModel.ListPowerData = new List <PowerUsageModel>();
            objModel.ListPowerData.AddRange(objListSC);
            System.Threading.Thread.Sleep(5000);


            List <PowerUsageModel> lstAppData    = new List <PowerUsageModel>();
            PowerUsageModel        objAppoint    = new PowerUsageModel();
            PowerUsageService      objAppService = new PowerUsageService();


            lstAppData = objAppService.getPUDataByMMYY(mm, yy, cid);

            var powerDataList = from e in lstAppData
                                select new
            {
                //id = e.PUID,
                label = e.DataSuite + "(" + e.RackID + ")",
                //rackid=e.RackID,
                y = e.PowerContracted,
                //pu=e.PowerUsed,
                //ou=e.OverUnder,
                //lastreading = e.LastReading.Value.ToString("yyyy-MM-dd") + " " + e.LastReading,
            };
            var    rows = powerDataList.ToArray();
            string pc   = JsonConvert.SerializeObject(rows);
            string pcf  = pc.Replace("[", string.Empty).Replace("]", string.Empty);

            ViewBag.DataPointsPC = pcf;


            var powerDataListPU = from e in lstAppData
                                  select new
            {
                //id = e.PUID,
                label = e.DataSuite + "(" + e.RackID + ")",
                //rackid=e.RackID,
                y = e.PowerUsed,
                //pu=e.PowerUsed,
                //ou=e.OverUnder,
                lastreading = e.LastReading.Value.ToString("MMMM-yyyy"),
            };
            var rowsPU = powerDataListPU.ToArray();

            if (rowsPU.Count() > 0)
            {
                ViewBag.last = rowsPU[0].lastreading;
            }
            string pu  = JsonConvert.SerializeObject(rowsPU);;
            string puf = pu.Replace("[", string.Empty).Replace("]", string.Empty);

            ViewBag.DataPointsPU = puf;


            List <PowerUsageModel> lstTotalPU = new List <PowerUsageModel>();
            string year = Convert.ToString(model.year);

            lstTotalPU = objService.getTotalPU(year, cid);
            objModel.ListTotalTickets = new List <PowerUsageModel>();
            objModel.ListTotalTickets.AddRange(lstTotalPU);

            var TTPCList = from e in lstTotalPU
                           select new
            {
                //id = e.PUID,
                label = e.TTmonth,
                //rackid=e.RackID,
                y = e.TotalPC,
                //pu=e.PowerUsed,
                //ou=e.OverUnder,
                year = e.TTyear,
            };
            var rowTT = TTPCList.ToArray();

            if (rowTT.Count() > 0)
            {
                ViewBag.Year = year;
            }
            string ttpc  = JsonConvert.SerializeObject(rowTT);
            string ttpcf = ttpc.Replace("[", string.Empty).Replace("]", string.Empty);

            ViewBag.TTPC = ttpcf;


            var TTPUList = from e in lstTotalPU
                           select new
            {
                //id = e.PUID,
                label = e.TTmonth,
                //rackid=e.RackID,
                y = e.TotalPU,
            };
            var    rowsTTPU = TTPUList.ToArray();
            string ttpu     = JsonConvert.SerializeObject(rowsTTPU);
            string ttpuf    = ttpu.Replace("[", string.Empty).Replace("]", string.Empty);

            ViewBag.TTPU = ttpuf;

            UserService         objServiceComp = new UserService();
            List <CompanyModel> ListComp       = new List <CompanyModel>();

            ListComp          = objServiceComp.getActiveComp();
            objModel.ListComp = new List <CompanyModel>();
            objModel.ListComp.AddRange(ListComp);
            //return Json(objModel.ListPowerData, JsonRequestBehavior.AllowGet);
            //var jsonResult = Json(objModel.ListPowerData, JsonRequestBehavior.AllowGet);
            //jsonResult.MaxJsonLength = int.MaxValue;
            //return jsonResult;
            //return PartialView("_Data", objModel);

            return(View(objModel));
        }