public JsonResult GetDailyHeatMap(int stationId, string beginDate)
        {
            InverterPerformanceView mdl = new InverterPerformanceView();

            try
            {
                CultureHelper.SetCultureInfo();
                var startDate = DateTimeHelper.BeginDate(beginDate);
                var endDate   = DateTimeHelper.EndDate(beginDate);

                mdl.invModel = new InverterModel();

                var sql = "select * from \"TBL_INV_OZET\" where \"STATION_ID\" = " + stationId + " AND \"Tarih\" between TO_DATE('" + startDate + "','DD.MM.YY hh24:mi:ss') and to_date('" + endDate + "','DD.MM.YY hh24:mi:ss')";



                var InvData = DB.Database.SqlQuery <TBL_INV_OZET>(sql)
                              .ToList();

                var hourlyProduction = (from InverterDetail in InvData
                                        join Inverter in DB.Inverters on
                                        InverterDetail.Inv_Id equals Inverter.ID
                                        where
                                        InverterDetail.STATION_ID == stationId &&
                                        InverterDetail.Tarih >= startDate && InverterDetail.Tarih <= endDate &&
                                        InverterDetail.Tarih.Value.Hour > 5 &&
                                        InverterDetail.Tarih.Value.Hour < 22
                                        select new Hour_DTO_
                {
                    InverterName = Inverter.NAME,
                    result = Inverter.INV_DC_GUC == null || InverterDetail.Guc_AC == null ? 0 : Math.Round(((float)InverterDetail.Guc_AC / 1000) / ((float)Inverter.INV_DC_GUC), 1),                        //Math.Round((double)(InverterDetail.Guc_AC == null ? 0 : InverterDetail.Guc_AC) / 1000, 2) / Math.Round((double)(Inverter.INV_DC_GUC == null ? 1 : Inverter.INV_DC_GUC), 2),
                    InverterId = InverterDetail.Inv_Id,
                    _tarih = InverterDetail.Tarih.Value
                })
                                       .AsEnumerable()
                                       .Distinct()
                                       .ToList();
                mdl.invModel.InverterList = hourlyProduction.OrderBy(a => a.InverterId)
                                            .Select(a => a.InverterName)
                                            .Distinct()
                                            .ToList();

                var list_     = new List <Values>();
                var groupList = hourlyProduction.OrderBy(a => a.InverterId).GroupBy(a => a.InverterId).ToList();

                foreach (var hour in groupList[0].OrderBy(a => a._tarih))
                {
                    mdl.invModel.Hours.Add(hour._tarih.ToString("HH:mm"));
                }

                foreach (var item in groupList)
                {
                    var list = new Values();
                    foreach (var i in item.OrderBy(a => a._tarih).ToList())
                    {
                        list.values.Add((float)i.result);
                    }
                    list_.Add(list);
                }

                mdl.invModel.series = list_;
                mdl.ErrorMessage    = "";
            }
            catch (Exception ex)
            {
                mdl.ErrorMessage = ex.ToString();
            }

            return(Json(mdl, JsonRequestBehavior.AllowGet));
        }
        public JsonResult HourlyColorReport(int stationId, string slctDate)
        {
            InverterPerformanceView mdl = new InverterPerformanceView();

            try
            {
                Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");
                DateTime          nowDate       = DateTime.Parse(slctDate);
                NUMBER_FORMAT_DTO convertFormat = ConvertNumberFormat(slctDate);
                long _numberDateBegin           = convertFormat._begin;
                long _numberDateEnd             = convertFormat._end;

                mdl.invModel = new InverterModel();
                var hourlyProduction = (from InverterDetail in DB.InvSums
                                        join Inverter in DB.Inverters on
                                        InverterDetail.Inv_Id equals Inverter.ID
                                        where
                                        InverterDetail.STATION_ID == stationId &&
                                        InverterDetail.TARIH_NUMBER >= _numberDateBegin && InverterDetail.TARIH_NUMBER <= _numberDateEnd &&
                                        InverterDetail.Tarih.Value.Hour > 5 &&
                                        InverterDetail.Tarih.Value.Hour < 22
                                        select new Hour_DTO_
                {
                    InverterName = Inverter.NAME,
                    result = Inverter.INV_DC_GUC == null || InverterDetail.Guc_AC == null ? 0 : Math.Round(((float)InverterDetail.Guc_AC / 1000) / ((float)Inverter.INV_DC_GUC), 1),                        //Math.Round((double)(InverterDetail.Guc_AC == null ? 0 : InverterDetail.Guc_AC) / 1000, 2) / Math.Round((double)(Inverter.INV_DC_GUC == null ? 1 : Inverter.INV_DC_GUC), 2),
                    InverterId = InverterDetail.Inv_Id,
                    _tarih = InverterDetail.Tarih.Value
                })
                                       .AsEnumerable()
                                       .Distinct()
                                       .ToList();
                mdl.invModel.InverterList = hourlyProduction.OrderBy(a => a.InverterId)
                                            .Select(a => a.InverterName)
                                            .Distinct()
                                            .ToList();

                var list_     = new List <Values>();
                var groupList = hourlyProduction.OrderBy(a => a.InverterId).GroupBy(a => a.InverterId).ToList();

                foreach (var hour in groupList[0].OrderBy(a => a._tarih))
                {
                    mdl.invModel.Hours.Add(hour._tarih.ToString("HH:mm"));
                }

                foreach (var item in groupList)
                {
                    var list = new Values();
                    foreach (var i in item.OrderBy(a => a._tarih).ToList())
                    {
                        list.values.Add((float)i.result);
                    }
                    list_.Add(list);
                }

                mdl.invModel.series = list_;
                mdl.ErrorMessage    = "";
            }
            catch (Exception ex)
            {
                mdl.ErrorMessage = ex.ToString();
            }
            return(Json(mdl));
        }