public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string treetype = context.Request.Params["treetype"]; string id = context.Request.Params["id"]; DTUBll dtubll = new DTUBll(); if (treetype.Equals("piletree")) { string strOut = ""; string nodeid = string.Empty; ChargStationBll csbll = new ChargStationBll(); if (id != null) { nodeid = id; } if (nodeid.Length == 0) { strOut = csbll.GetAllNodes(); } else { strOut = csbll.getNode(nodeid); } context.Response.Write(strOut); } else if (treetype.Equals("dtutree")) { string strOut = ""; string nodeid = string.Empty; if (id != null) { nodeid = id; } if (nodeid.Length == 0) { strOut = dtubll.GetAllNodes(); } else { strOut = dtubll.getNode(nodeid); } context.Response.Write(strOut); } }
/// <summary> /// 获取充电桩数量 /// </summary> /// <param name="context"></param> /// <returns></returns> public void GetChargPileCount(HttpContext context) { var chargstationbll = new ChargStationBll(); var id = Int32.Parse(context.Request.Params["id"]); string str = null; try { var count = chargstationbll.FindByChargPileCount(id); str += count + "|"; } catch (Exception e) { Log.Error(e); } context.Response.Write(str); }
/// <summary> /// 获取充电站 /// </summary> /// <param name="context"></param> /// <returns></returns> public void GetChargStation(HttpContext context) { var chargstationbll = new ChargStationBll(); var chargstation = new ChargStation(); string str = ""; var count = 0; try { var dt = chargstationbll.Query(chargstation); str = ConvertToJson.DataTableToJson("rows", dt); str += "|"; } catch (Exception e) { Log.Error(e); } context.Response.Write(str); }
public string GetChargStation(HttpContext context) { var chargstationbll = new ChargStationBll(); var chargstation = new ChargStation(); string str; var count = 0; try { var dt = chargstationbll.Query(chargstation); str = ConvertToJson.DataTableToJson("rows", dt); str += "|"; } catch (Exception e) { Log.Error(e); throw; } return(str); }
/// <summary> /// 获取经纬度 /// </summary> /// <param name="context"></param> public void GetCoordinates(HttpContext context) { var chargstationbll = new ChargStationBll(); var chargstation = new ChargStation() { ZhanBh = Int32.Parse(context.Request.Params["id"]) }; string str = ""; try { var dt = chargstationbll.Query(chargstation); str = ConvertToJson.DataTableToJson("rows", dt); str += "|"; } catch (Exception e) { Log.Error(e); } context.Response.Write(str); }
/// <summary> ///充电站GIS地图上标住 /// </summary> /// <param name="context"></param> public void GisFunction(HttpContext context, string strSort) { string strMsg = "{\"success\":false,\"msg\":\"标注失败!\"}"; string zhanbh = context.Request["zhanbh"].ToString(); if (zhanbh != "") { ChargStationBll cdzBll = new ChargStationBll(); DataTable tb = cdzBll.GetstationByid(decimal.Parse(zhanbh)); if (tb.Rows.Count > 0) { //充电站编号 string ZHAN_BH = tb.Rows[0]["ZHAN_BH"].ToString(); //充电点名称 string ZHUAN_MC = tb.Rows[0]["ZHUAN_MC"].ToString(); //场地业主单位 string YEZHU_DW = tb.Rows[0]["YEZHU_DW"].ToString(); //联系人 string LIANXI_R = tb.Rows[0]["LIANXI_R"].ToString(); //联系电话 string LIANXI_DH = tb.Rows[0]["LIANXI_DH"].ToString(); //桩类型 string ZHUANGLEI_X = tb.Rows[0]["ZHUANGLEI_X"].ToString(); //桩厂家 string ZHUANGCHANG_J = tb.Rows[0]["ZHUANGCHANG_J"].ToString(); //详细地址 string XIANGXI_DZ = tb.Rows[0]["XIANGXI_DZ"].ToString(); //经度坐标 string LONGTUDE = tb.Rows[0]["LONGTUDE"].ToString(); //维度坐标 string LATITUDE = tb.Rows[0]["LATITUDE"].ToString(); //创建时间 string CREATEDT = tb.Rows[0]["CREATEDT"].ToString(); //更新时间 string UPDATEDT = tb.Rows[0]["UPDATEDT"].ToString(); //整合JSON string gisJson = "{"; gisJson += "\"ZHAN_BH\":\"" + ZHAN_BH + "\","; gisJson += "\"ZHUAN_MC\":\"" + ZHUAN_MC + "\","; gisJson += "\"YEZHU_DW\":\"" + YEZHU_DW + "\","; gisJson += "\"LIANXI_R\":\"" + LIANXI_R + "\","; gisJson += "\"LIANXI_DH\":\"" + LIANXI_DH + "\","; gisJson += "\"ZHUANGLEIX\":\"" + ZHUANGLEI_X + "\","; gisJson += "\"ZHUANGCJ\":\"" + ZHUANGCHANG_J + "\","; gisJson += "\"XIANGXI_DZ\":\"" + XIANGXI_DZ + "\","; gisJson += "\"LONGTUDE\":\"" + LONGTUDE + "\","; gisJson += "\"LATITUDE\":\"" + LATITUDE + "\","; gisJson += "\"CREATEDT\":\"\","; gisJson += "\"UPDATEDT\":\"\""; //gisJson += "\"CREATEDT\":\"" + CREATEDT + "\","; //gisJson += "\"UPDATEDT\":\"" + UPDATEDT+"\""; gisJson += "}"; try { CdzWebService.CDZWebServiceClient objGis = new CdzWebService.CDZWebServiceClient(); if (strSort == "gisAdd") { objGis.DeleteCDZ(gisJson); string result = objGis.InsertIntoCDZ(gisJson); if (result == "OK") { strMsg = "{\"success\":true,\"msg\":\"标注成功!\"}"; } } else if (strSort == "gisDelete") { if (objGis.DeleteCDZ(gisJson) == "OK") { strMsg = "{\"success\":true,\"msg\":\"删除成功!\"}"; } } } catch (Exception ex) { strMsg = "{\"success\":false,\"msg\":\"操作出现异常!\"}"; } } } context.Response.Write(strMsg); }
protected void save_Click(object sender, EventArgs e) { string zhanid = Request["zhanbh"] ?? ""; if (zhanid.Length > 0) { string imgPath = MapPath("~/UpImages/" + guidString); string zhanbh = ""; decimal stationid = decimal.Parse(zhanid.ToString()); ChargStationBll csbll = new ChargStationBll(); string zhanmc = ZhuanMc.Text.ToString(); bool b = csbll.QueryZhanIFExit(zhanmc); DataTable dte = csbll.QueryZhanByZMC(zhanmc); if (b == false && !decimal.Parse(dte.Rows[0]["ZHAN_BH"].ToString()).Equals(stationid)) { Response.Write("<script>alert(\"充电场站名称已存在!\");</script>"); return; } string zjc = zhanjc.Text.ToString(); DataTable dt3 = csbll.QueryZhanByZJC(zjc); if (dt3.Rows.Count > 0 && !decimal.Parse(dt3.Rows[0]["ZHAN_BH"].ToString()).Equals(stationid)) { Response.Write("<script>alert(\"充电场站简称已存在!\");</script>"); return; } string xxdz = XiangXiDz.Text; decimal jd = decimal.Parse(Longtude.Text.ToString()); decimal wd = decimal.Parse(Latitude.Text.ToString()); string yzdw = YeZhuDw.Text.ToString(); string lxr = LianXiR.Text.ToString(); string lxdh = LianXiDh.Text.ToString(); decimal boxsl = decimal.Parse(BoxCounts.Text.ToString()); DateTime jzsj = DateTime.Parse(JianZhan_SJ.Text.ToString()); DateTime tysj = DateTime.Parse(TouYun_Sj.Text.ToString()); ChargStation chargstation = new ChargStation(); chargstation.ZhuanMc = zhanmc; chargstation.Zhan_Jc = zjc; chargstation.XiangXiDz = xxdz; chargstation.Longtude = jd; chargstation.Latitude = wd; chargstation.YeZhuDw = yzdw; chargstation.LianXiDh = lxdh; chargstation.LianXiR = lxr; chargstation.BoxCounts = boxsl; chargstation.JianZhan_Sj = jzsj; chargstation.TouYun_Sj = tysj; chargstation.ZhanBh = stationid; csbll.ModifyStation(chargstation); //操作日志 string name = ""; if (null != Session[Constant.LoginUser]) { name = (Session[Constant.LoginUser] as Employer ?? new Employer()).Name; } new OprLogBll().Add(new OprLog() { Operator = name, OprSrc = "添加充电场站", OperResult = "成功", LogDate = DateTime.Now }); //DataTable dte = csbll.QueryZhanIdByMC(zhanmc); //zhanbh = dte.Rows[0]["zhanbh"].ToString(); //string json = "{\"ZHAN_BH\":" + zhanbh + ",\"ZHUAN_MC\":\"" + zhanmc // + "\",\"YEZHU_DW\":\"" + yzdw + "\", \"LIANXI_R\":\"" + lxr + "\",\"LIANXI_DH\":\"" + lxdh // + "\",\"ZHUANGLEI_X\":\"\",\"ZHUANGCHANG_J\":\"\",\"XIANGXI_DZ\":\"" + xxdz // + "\",\"LONGTUDE\":\"" + jd + "\",\"LATITUDE\":\"" + wd // + "\",\"CREATEDT\":\"" + jzsj.ToString() + "\",\"UPDATEDT\":\"\"}"; //string ret = mapservice.UpdateCDZ(json); //if (ret.ToLower() != "ok") //{ // context.Response.Write("{\"success\":true,\"msg\":\"保存gis地图数据失败!\"}"); // return; //} csbll.DelStationFile(stationid); byte[] fileBuffer = null; decimal fileSize = 0; ChargStationFile csfile = new ChargStationFile(); if (Directory.Exists(imgPath)) { foreach (string flName in Directory.GetFiles(imgPath)) { string strName = flName.Substring(flName.LastIndexOf("\\") + 1); //文件名 string tpid = Guid.NewGuid().ToString(); //图片id string hz = strName.Substring(strName.LastIndexOf('.') + 1); //图片后缀 string strDataPath = imgPath + "\\" + strName; //数据库保存路径 fileBuffer = File.ReadAllBytes(strDataPath); //图片内容 fileSize = fileBuffer.Length; //图片大小 DataTable dt = csbll.QueryZhanByZMC(zhanmc); if (dt.Rows.Count > 0) { csfile.ZhanBh = decimal.Parse(dt.Rows[0]["zhan_bh"].ToString()); } csfile.Id = tpid; csfile.Filename = strName; csfile.Filecontext = fileBuffer; csfile.Filesize = fileSize; csfile.Filemime = hz; csbll.AddPilePicture(csfile); } //删除解压文件夹 //Directory.Delete(imgPath, true); } //添加分支箱 //清除方法 DataTable dt2 = csbll.QueryBoxID(stationid); string boxids = null; if (dt2.Rows.Count > 0) { for (int i = 0; i < dt2.Rows.Count; i++) { boxids += dt2.Rows[i]["BRANCHNO"].ToString(); if (i < (dt2.Rows.Count - 1)) { boxids += "_"; } } csbll.DelBranch(stationid); csbll.DelPile(boxids); } Branch branch = new Branch(); DataTable dt1 = csbll.QueryZhanByZMC(zhanmc); if (dt1.Rows.Count > 0) { branch.ZhuanBh = decimal.Parse(dt1.Rows[0]["zhan_bh"].ToString()); } ; bool a = csbll.QueryBranch(branch.ZhuanBh); for (int i = 0; i < boxsl; i++) { branch.Createdt = DateTime.Now; if (a == false) { branch.BranchNo = branch.ZhuanBh * 100 + (i + 1); } else if (a == true) { DataTable dta = csbll.QueryBranchId(branch.ZhuanBh); decimal branchid = decimal.Parse(dta.Rows[0]["BRANCHNO"].ToString()); branch.BranchNo = branchid + 1; } csbll.AddBranch(branch); } string Id = (Session[Constant.LoginUser] as Employer ?? new Employer()).Id; decimal zhan_id = decimal.Parse(csbll.QueryZhanByZMC(zhanmc).Rows[0]["zhan_bh"].ToString()); Response.Redirect("/pages/ChargPileLedger/AddBranch.htm?bs=" + boxsl + "&Id=" + Id + "&gid=" + guidString + "&zhanbh=" + zhan_id); } else { string imgPath = MapPath("~/UpImages/" + guidString); string zhanbh = ""; string zmc = ZhuanMc.Text.ToString(); bool b = csbll.QueryZhanIFExit(zmc); if (b == false) { Response.Write("<script>alert(\"充电场站名称已存在!\")</script>"); return; } string zjc = zhanjc.Text.ToString(); DataTable dt2 = csbll.QueryZhanByZJC(zjc); if (dt2.Rows.Count > 0) { Response.Write("<script>alert(\"充电场站简称已存在!\");</script>"); return; } string xxdz = XiangXiDz.Text; decimal jd = decimal.Parse(Longtude.Text.ToString()); decimal wd = decimal.Parse(Latitude.Text.ToString()); string yzdw = YeZhuDw.Text.ToString(); string lxr = LianXiR.Text.ToString(); string lxdh = LianXiDh.Text.ToString(); decimal boxsl = decimal.Parse(BoxCounts.Text.ToString()); DateTime jzsj = DateTime.Parse(JianZhan_SJ.Text.ToString());; DateTime tysj = DateTime.Parse(TouYun_Sj.Text.ToString()); ChargStation chargstation = new ChargStation(); chargstation.ZhuanMc = zmc; chargstation.Zhan_Jc = zjc; chargstation.XiangXiDz = xxdz; chargstation.Longtude = jd; chargstation.Latitude = wd; chargstation.YeZhuDw = yzdw; chargstation.LianXiDh = lxdh; chargstation.LianXiR = lxr; chargstation.BoxCounts = boxsl; chargstation.JianZhan_Sj = jzsj; chargstation.TouYun_Sj = tysj; csbll.Add(chargstation); //操作日志 string name = ""; if (null != Session[Constant.LoginUser]) { name = (Session[Constant.LoginUser] as Employer ?? new Employer()).Name; } new OprLogBll().Add(new OprLog() { Operator = name, OprSrc = "添加充电场站", OperResult = "成功", LogDate = DateTime.Now }); //DataTable dte = csbll.QueryZhanIdByMC(zmc); //zhanbh = dte.Rows[0]["zhanbh"].ToString(); //string json = "{\"ZHAN_BH\":" + zhanbh + ",\"ZHUAN_MC\":\"" + zmc // + "\",\"YEZHU_DW\":\"" + yzdw + "\", \"LIANXI_R\":\"" + lxr + "\",\"LIANXI_DH\":\"" + lxdh // + "\",\"ZHUANGLEI_X\":\"\",\"ZHUANGCHANG_J\":\"\",\"XIANGXI_DZ\":\"" + xxdz // + "\",\"LONGTUDE\":\"" + jd + "\",\"LATITUDE\":\"" + wd // + "\",\"CREATEDT\":\"" + jzsj.ToString() + "\",\"UPDATEDT\":\"\"}"; //string ret = mapservice.InsertIntoCDZ(json); //if (ret.ToLower() != "ok") //{ // context.Response.Write("{\"success\":true,\"msg\":\"保存gis地图数据失败!\"}"); // return; //} //如果存在guid文件夹,则执行图片保存 if (Directory.Exists(imgPath)) { byte[] fileBuffer = null; decimal fileSize = 0; ChargStationFile csfile = new ChargStationFile(); foreach (string flName in Directory.GetFiles(imgPath)) { string strName = flName.Substring(flName.LastIndexOf("\\") + 1); //文件名 string tpid = Guid.NewGuid().ToString(); //图片id string hz = strName.Substring(strName.LastIndexOf('.') + 1); //图片后缀 string strDataPath = imgPath + "\\" + strName; //数据库保存路径 fileBuffer = File.ReadAllBytes(strDataPath); //图片内容 fileSize = fileBuffer.Length; //图片大小 DataTable dt = csbll.QueryZhanByZMC(zmc); if (dt.Rows.Count > 0) { csfile.ZhanBh = decimal.Parse(dt.Rows[0]["zhan_bh"].ToString()); } csfile.Id = tpid; csfile.Filename = strName; csfile.Filecontext = fileBuffer; csfile.Filesize = fileSize; csfile.Filemime = hz; csbll.AddPilePicture(csfile); } } //删除解压文件夹 //Directory.Delete(imgPath, true); //添加分支箱 Branch branch = new Branch(); DataTable dt1 = csbll.QueryZhanByZMC(zmc); if (dt1.Rows.Count > 0) { branch.ZhuanBh = decimal.Parse(dt1.Rows[0]["zhan_bh"].ToString()); } ; bool a = csbll.QueryBranch(branch.ZhuanBh); for (int i = 0; i < boxsl; i++) { branch.Createdt = DateTime.Now; if (a == false) { branch.BranchNo = branch.ZhuanBh * 100 + (i + 1); } else if (a == true) { DataTable dta = csbll.QueryBranchId(branch.ZhuanBh); decimal branchid = decimal.Parse(dta.Rows[0]["BRANCHNO"].ToString()); branch.BranchNo = branchid + 1; } csbll.AddBranch(branch); } string Id = (Session[Constant.LoginUser] as Employer ?? new Employer()).Id; decimal zhan_id = decimal.Parse(csbll.QueryZhanByZMC(zmc).Rows[0]["zhan_bh"].ToString()); Response.Redirect("/pages/ChargPileLedger/AddBranch.htm?bs=" + boxsl + "&Id=" + Id + "&gid=" + guidString + "&zhanbh=" + zhan_id); } }