// GET: DataHandle/StationList public ActionResult Index() { //登录超时验证 if (Session["UserID"] == null || Session["UserID"].ToString() == "") { //超时则返回登录页面 return(Content("<script>alert('登录超时!');location.href='/RainWaterData/';</script>")); } string UserID = Session["UserID"].ToString(); string CompanyID = Session["CompanyID"].ToString(); //查询登录账户管辖区域下的所有站点信息 StructuralEntity structuralEntity = cbll.GetSationList(CompanyID, UserID); ViewBag.UserID = UserID; ViewBag.proviceList = structuralEntity.provinceEntity; return(View()); }
/// <summary> /// 查询站点列表和省份集合 /// </summary> /// <param name="CompanyID"></param> /// <param name="UserID"></param> /// <returns></returns> public StructuralEntity GetSationList(string CompanyID, string UserID) { StructuralEntity StEntity = new StructuralEntity(); //加载操作表格对象 AbsFacory absfact = AbsFacory.CreatInstance(); IhydStationBLL hsbll = absfact.CreathydStationBllInstance(); IWM_CompanyBLL cbll = absfact.CreatIWM_CompanyBLLInstance(); //超级管理员账户 if (UserID == ConfigHelper.AppSettings("CurrentUserName")) { //加载所有站点信息 //List<hydStation> hs = hsbll.Query(p=>true).ToList(); //加载所有省份信息 List <ProvinceEntity> pentity = new List <ProvinceEntity>(); var pe = cbll.Query(p => true) .Select(x => new { x.Province }).Distinct().ToList(); for (int i = 0; i < pe.Count; i++) { ProvinceEntity ppe = new ProvinceEntity(); ppe.Province = pe[i].Province; pentity.Add(ppe); } //StEntity.stationEntity = hs; StEntity.provinceEntity = pentity; } else//区域管理员账户 { //加载区域管理员账户管辖的所有站点信息 //List<hydStation> hs = new List<hydStation>(); //List<ProvinceEntity> pe = new List<ProvinceEntity>(); var pe = cbll.Query(p => p.CompanyId == CompanyID) .Select(x => new ProvinceEntity { Province = x.Province, City = x.City, County = x.County }).FirstOrDefault(); //if ((pe.City==""||pe.City==null||pe.City== " ")&&(pe.County==""||pe.City==null||pe.County== " ")) //{ // hs = hsbll.Query(p => p.Province == pe.Province).ToList(); //} //else if((pe.City != "" || pe.City != null || pe.City != " ") && (pe.County == "" || pe.City == null || pe.County == " ")) //{ // hs = hsbll.Query(p => p.Province == pe.Province&&p.City==pe.City).ToList(); //} //else if ((pe.City != "" || pe.City != null || pe.City != " ") && (pe.County != "" || pe.City != null || pe.County != " ")) //{ // hs = hsbll.Query(p => p.Province == pe.Province && p.City == pe.City&&p.County==pe.County).ToList(); //} List <ProvinceEntity> provice = new List <ProvinceEntity>(); ProvinceEntity pentity = new ProvinceEntity(); pentity.Province = pe.Province; provice.Add(pentity); //StEntity.stationEntity = hs; StEntity.provinceEntity = provice; } return(StEntity); }