Exemplo n.º 1
0
        /// <summary>
        /// 加载首页数据,抽取出来供首页加载方法和首页登录方法调用
        /// author:hbqian in 2013/02/21
        /// </summary>
        private void loadIndexData()
        {
            //取得最新加入的电站
            IList <Plant> newPlants = PlantService.GetInstance().GetNewPlantInfoList(4);
            User          userinfo  = UserService.GetInstance().GetUserByName(UserUtil.demousername);

            if (userinfo != null)
            {
                IList <PlantUser> plant = PlantUserService.GetInstance().GetAllPlantUserByUserID(new PlantUser {
                    userID = userinfo.id
                });
                ViewData["examplePlant"] = plant;
            }
            ViewData["newPlants"] = newPlants;
            float co2Rate = ItemConfigService.GetInstance().getCO2Config();

            ViewData["AllPlant"] = PlantService.GetInstance().GetPlantNum();

            double alltotalenergy = DeviceRunDataService.GetInstance().GetAllTotalEnergy();
            //modify by hbqian at 2013-08-02 for 同一时刻 2个值结果不一致 ,首页和内部所有电站日发电量统计值不一致
            //double dayEnergy = CollectorRunDataService.GetInstance().GetAllDayEnergy();
            double dayEnergy = getAllPlantTodayEnergy();
            //modify by hbqian at 2013-08-02 for 同一时刻 2个值结果不一致 ,首页和内部所有电站日发电量统计值不一致 end
            double co2Value = alltotalenergy * co2Rate;

            ViewData["co2Unit"]           = Util.upCo2Unit(co2Value);
            ViewData["energyUnit"]        = Util.upEnergyUnit(alltotalenergy);
            ViewData["dayenergyUnit"]     = Util.upEnergyUnit(dayEnergy);
            ViewData["AllTotalEnergy"]    = StringUtil.formatDouble(Util.upDigtal(alltotalenergy));
            ViewData["AlldayTotalEnergy"] = StringUtil.formatDouble(Util.upDigtal(dayEnergy));
            ViewData["AllCO2"]            = StringUtil.formatDouble(Util.upDigtal(co2Value));
            getPPics();
            getAdPics();
        }
Exemplo n.º 2
0
        public ActionResult SavePlant(Plant plant)
        {
            string long1     = Request.Form["long1"];
            string long2     = Request.Form["long2"];
            string long3     = Request.Form["long3"];
            double value     = 0;
            double longValue = 0;

            double.TryParse(long1, out longValue);
            value += longValue;
            double.TryParse(long2, out longValue);
            value += (longValue / 60);

            double.TryParse(long3, out longValue);
            value += (longValue / 3600);

            plant.longitude = value;
            value           = 0;
            longValue       = 0;
            string lat1 = Request.Form["lat1"];

            double.TryParse(lat1, out longValue);
            value += longValue;

            string lat2 = Request.Form["lat2"];

            double.TryParse(lat2, out longValue);
            value += (longValue / 60);

            string lat3 = Request.Form["lat3"];

            double.TryParse(lat3, out longValue);
            value                += (longValue / 3600);
            plant.latitude        = value;
            plant.longitudeString = string.Format("{0},{1},{2}", long1, long2, long3);
            plant.latitudeString  = string.Format("{0},{1},{2}", lat1, lat2, lat3);
            if (string.IsNullOrEmpty(plant.pic))
            {
                plant.pic = string.Empty;
            }
            plant.userID = UserUtil.getCurUser().id;
            CountryCity area = CountryCityService.GetInstance().GetCity(plant.country);

            plant.area = area == null ? string.Empty : area.weather_code;
            int plantid = plant.id;

            if (plant.id > 0)
            {
                PlantService.GetInstance().UpdatePlantInfo(plant);
            }
            else
            {
                plantid = PlantService.GetInstance().AddPlantInfo(plant);
                PlantUserService.GetInstance().AddPlantUser(new PlantUser {
                    plantID = plantid, userID = int.Parse(plant.userID.ToString())
                });                                                                                                                           //添加电站时,向电站用户关系表中加记录
            }
            UserUtil.ResetLogin(UserUtil.getCurUser());
            return(Redirect("/newregister/addplantcontrol?plantid=" + plantid));
        }
Exemplo n.º 3
0
        public ActionResult SavePlant(Plant plant)
        {
            //设置电站的经纬度
            string long1     = Request.Form["long1"];
            string long2     = Request.Form["long2"];
            string long3     = Request.Form["long3"];
            double value     = 0;
            double longValue = 0;

            double.TryParse(long1, out longValue);
            value += longValue;
            double.TryParse(long2, out longValue);
            value += (longValue / 60);

            double.TryParse(long3, out longValue);
            value += (longValue / 3600);

            plant.longitude = value;
            value           = 0;
            longValue       = 0;
            string lat1 = Request.Form["lat1"];

            double.TryParse(lat1, out longValue);
            value += longValue;

            string lat2 = Request.Form["lat2"];

            double.TryParse(lat2, out longValue);
            value += (longValue / 60);

            string lat3 = Request.Form["lat3"];

            double.TryParse(lat3, out longValue);
            value                += (longValue / 3600);
            plant.latitude        = value;
            plant.longitudeString = string.Format("{0},{1},{2}", long1, long2, long3);
            plant.latitudeString  = string.Format("{0},{1},{2}", lat1, lat2, lat3);
            if (string.IsNullOrEmpty(plant.pic))
            {
                plant.pic = string.Empty;
            }

            //设置电站的创建者
            plant.userID = UserUtil.getCurUser().id;
            CountryCity area = CountryCityService.GetInstance().GetCity(plant.country);

            plant.area = area == null ? string.Empty : area.weather_code;
            int plantid = plant.id;

            if (plant.id > 0)
            {
                PlantService.GetInstance().UpdatePlantInfo(plant);
            }
            else
            {
                plant.PaymentLimitDate = DateTime.Now.AddMonths(PaymentDelayMonth);
                plantid = PlantService.GetInstance().AddPlantInfo(plant);
                //添加电站时,向电站用户关系表中加记录,shared=false表示是自己创建的
                PlantUserService.GetInstance().AddPlantUser(new PlantUser {
                    plantID = plantid, userID = plant.userID, shared = false, roleId = Role.ROLE_SYSMANAGER
                });
            }
            UserUtil.ResetLogin(UserUtil.getCurUser());
            return(Redirect("/newregister/addplantcontrol?plantid=" + plantid));
        }