Esempio n. 1
0
        public ActionResult IncludeOverviewDataJson(int id)
        {
            Plant plant = PlantService.GetInstance().GetPlantInfoById(id);
            User curUser = UserService.GetInstance().Get(plant.userID);
            plant.currencies = curUser.currencies;
            object temperature = plant.Temperature;
            if (double.IsNaN((double)temperature))
            {
                CityCodeService codeService = CityCodeService.GetInstance();
                temperature = codeService.GetTemperature(plant.city);
            }
            //修正了温度不存在显示0的问题
            if (!double.IsNaN(((double)temperature)) && temperature != null)
            {
                User user = UserUtil.getCurUser();
                if (user != null && !user.TemperatureType.ToLower().Equals("c"))
                {
                    temperature = Math.Round(32 + ((double)temperature * 1.8), 1);
                }
                else
                {
                    temperature = Math.Round((double)temperature, 1);
                }
            }
            else
                temperature = "";

            OverviewDataVO overviewDataVO = new OverviewDataVO();
            overviewDataVO.DisplayTotalDayEnergy = plant.DisplayTotalDayEnergy;
            overviewDataVO.TotalDayEnergyUnit = plant.TotalDayEnergyUnit;
            if (plant.getFirstDetector() != null)
                overviewDataVO.Temperature = plant.getFirstDetector().getMonitorValue(MonitorType.MIC_DETECTOR_ENRIONMENTTEMPRATURE).ToString();
            else
                overviewDataVO.Temperature = temperature.ToString();
            overviewDataVO.TemperatureType = string.Format("°{0}", curUser.TemperatureType.ToUpper());
            overviewDataVO.Sunstrength = (plant.Sunstrength != null) ? plant.Sunstrength.ToString() : "";
            overviewDataVO.SunstrengthUnit = "W/m2";
            overviewDataVO.totalEnergy = StringUtil.formatDouble(Util.upDigtal(plant.TotalEnergy + CompensationService.GetInstance().getPlantTotalCompensations(plant.id)), "0.00");
            overviewDataVO.TotalEnergyUnit = plant.TotalEnergyUnit;
            overviewDataVO.Reductiong = plant.Reductiong.ToString();
            overviewDataVO.ReductiongUnit = plant.ReductiongUnit;
            overviewDataVO.currencies = plant.currencies;
            overviewDataVO.DisplayRevenue = plant.DisplayRevenue;

            //overviewDataVO.DisplayTotalDayEnergy = new Random().Next(65535).ToString();
            //overviewDataVO.TotalDayEnergyUnit = new Random().Next(65535).ToString();

            //overviewDataVO.Temperature = new Random().Next(65535).ToString();
            //overviewDataVO.TemperatureType = new Random().Next(65535).ToString();
            //overviewDataVO.Sunstrength = new Random().Next(65535).ToString();
            //overviewDataVO.SunstrengthUnit = new Random().Next(65535).ToString();
            //overviewDataVO.totalEnergy = new Random().Next(65535).ToString();
            //overviewDataVO.TotalEnergyUnit = new Random().Next(65535).ToString();
            //overviewDataVO.Reductiong = new Random().Next(65535).ToString();
            //overviewDataVO.ReductiongUnit = new Random().Next(65535).ToString();
            //overviewDataVO.currencies = new Random().Next(65535).ToString();
            //overviewDataVO.DisplayRevenue = new Random().Next(65535).ToString();

            return Json(overviewDataVO, JsonRequestBehavior.AllowGet);
        }
Esempio n. 2
0
        public ActionResult IncludeOverviewDataJson()
        {
            OverviewDataVO overviewDataVO = new OverviewDataVO();
            User user = UserUtil.getCurUser();
            double userTotal = 0;
            foreach (Plant plant in user.displayPlants)
                userTotal += CompensationService.GetInstance().getPlantTotalCompensations(plant.id);
            overviewDataVO.DisplayTotalDayEnergy = user.DisplayTotalDayEnergy;
            overviewDataVO.TotalDayEnergyUnit = user.TotalDayEnergyUnit;
            overviewDataVO.totalEnergy = StringUtil.formatDouble(Util.upDigtal(user.TotalEnergy + userTotal), "0.00");
            overviewDataVO.TotalEnergyUnit = user.TotalEnergyUnit;
            overviewDataVO.TotalTrees = user.TotalTrees.ToString();
            overviewDataVO.DisplayRevenue = user.DisplayRevenue;
            overviewDataVO.Reductiong = StringUtil.formatDouble(user.TotalReductiong);
            overviewDataVO.ReductiongUnit = user.TotalReductiongUnit;

            //overviewDataVO.DisplayTotalDayEnergy = new Random().Next(65535).ToString();
            //overviewDataVO.TotalDayEnergyUnit = new Random().Next(65535).ToString();
            //overviewDataVO.totalEnergy = new Random().Next(65535).ToString();
            //overviewDataVO.TotalEnergyUnit = new Random().Next(65535).ToString();
            //overviewDataVO.TotalTrees = new Random().Next(65535).ToString();
            //overviewDataVO.DisplayRevenue = new Random().Next(65535).ToString();
            //overviewDataVO.Reductiong = new Random().Next(65535).ToString();
            //overviewDataVO.ReductiongUnit = new Random().Next(65535).ToString();

            return Json(overviewDataVO, JsonRequestBehavior.AllowGet);
        }