Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <summary>
        /// 获取树节点
        /// </summary>
        public string GetAllNodes()
        {
            string          nId     = string.Empty;        // 节点id
            string          nName   = string.Empty;        // 节点名称
            string          pId     = string.Empty;        // 上级节点id
            StringBuilder   NodeStr = new StringBuilder(); //节点json字符串
            ChargStation    bean    = new ChargStation();
            DTUInfo         dtu     = new DTUInfo();
            ChargStationBll csbll   = new ChargStationBll();

            NodeStr.Append("[");
            DataTable dta = csbll.Queryall(bean);//查询所有充电站

            if (dta.Rows.Count > 0)
            {
                for (int a = 0; a < dta.Rows.Count; a++)
                {
                    decimal zhanbh = decimal.Parse(dta.Rows[a]["zhan_bh"].ToString());
                    string  zhanmc = dta.Rows[a]["zhan_jc"].ToString();
                    dtu.ZHUAN_BH = zhanbh;
                    DataTable dt     = QueryDTU(dtu);//根据充电站查询dtu
                    string    zhanid = zhanbh.ToString() + ":z";
                    NodeStr.Append("{id:'" + zhanid + "',pId:0,name:'" + zhanmc + "', icon:'../../Images/1_open.png',isParent:true },");
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            string dtuid   = dt.Rows[i]["ID"].ToString();
                            string dtuname = dt.Rows[i]["DTUNAME"].ToString();
                            dtuid = dtuid + ":d";
                            NodeStr.Append("{id:'" + dtuid + "',pId:'" + zhanid + "',name:'" + dtuname + "', icon:'../../Images/dtu.png' },");
                        }
                    }
                }
            }
            if (NodeStr.ToString() != "[")
            {
                int n = NodeStr.ToString().LastIndexOf(",");
                NodeStr.Remove(n, 1);
            }
            NodeStr.Append("]");
            return(NodeStr.ToString());
        }
        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);
        }
Пример #4
0
        /// <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);
        }
Пример #5
0
        protected void save_Click(object sender, EventArgs e)
        {
            string  imgPath   = MapPath("~/EditImages/" + guidString);
            decimal stationid = zhanbh;

            string    zhanmc = d_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    zhanjc = d_zhanjc.Text.ToString();
            DataTable dt3    = csbll.QueryZhanByZJC(zhanjc);

            if (dt3.Rows.Count > 0 && !decimal.Parse(dt3.Rows[0]["ZHAN_BH"].ToString()).Equals(stationid))
            {
                Response.Write("<script>alert(\"充电场站简称已存在!\");</script>");
                return;
            }


            string       xxdz         = d_XiangXiDz.Text;
            decimal      jd           = decimal.Parse(d_Longtude.Text.ToString());
            decimal      wd           = decimal.Parse(d_Latitude.Text.ToString());
            string       yzdw         = d_YeZhuDw.Text.ToString();
            string       lxr          = d_LianXiR.Text.ToString();
            string       lxdh         = d_LianXiDh.Text.ToString();
            DateTime     JianZhan_SJ  = DateTime.Parse(Request.Form["d_JianZhan_SJ"].ToString());
            DateTime     tysj         = DateTime.Parse(Request.Form["d_TouYun_Sj"].ToString());
            ChargStation chargstation = new ChargStation();

            chargstation.ZhuanMc     = zhanmc;
            chargstation.Zhan_Jc     = zhanjc;
            chargstation.XiangXiDz   = xxdz;
            chargstation.Longtude    = jd;
            chargstation.Latitude    = wd;
            chargstation.YeZhuDw     = yzdw;
            chargstation.LianXiDh    = lxdh;
            chargstation.LianXiR     = lxr;
            chargstation.JianZhan_Sj = JianZhan_SJ;
            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     = "修改充电站,充电站id:" + zhanbh,
                OperResult = "成功",
                LogDate    = DateTime.Now
            });

            //DataTable dte = csbll.QueryZhanIdByMC(zhanmc);
            //zhanbh = dte.Rows[0]["zhanbh"].ToString();
            //string json = "{\"ZHAN_BH\":" + stationid + ",\"ZHUAN_MC\":\"" + zhanmc
            //    + "\",\"YEZHU_DW\":\"" + yzdw + "\", \"LIANXI_R\":\"" + lxr + "\",\"LIANXI_DH\":\"" + lxdh
            //    + "\",\"ZHUANGLEI_X\":\"\",\"ZHUANGCHANG_J\":\"\",\"XIANGXI_DZ\":\"" + xxdz
            //    + "\",\"LONGTUDE\":\"" + jd + "\",\"LATITUDE\":\"" + wd
            //    + "\",\"CREATEDT\":\"" + CreateDT.ToString() + "\",\"UPDATEDT\":\"\"}";
            //string ret = mapservice.UpdateCDZ(json);

            //if (ret.ToLower() != "ok")
            //{
            //    context.Response.Write("{\"success\":true,\"msg\":\"保存gis地图数据失败!\"}");
            //    return;
            //}

            if (ifonesave == "true")
            {
                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(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);
                    ifonesave        = "false";
                    ifexitdDirectory = false;

                    //string Id = (Session[Constant.LoginUser] as Employer ?? new Employer()).Id;
                    //Response.Redirect("/pages/ChargPileLedger/ChargStationEdit.htm?Id=" + Id );
                }
            }
            //Response.Write("<script>alert(\"保存成功!\");</script>");
            sign = "refresh";
        }
Пример #6
0
        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);
            }
        }
Пример #7
0
        /// <summary>
        /// 添加充电桩
        /// </summary>
        /// <param name="context"></param>
        private void AddChargPile(HttpContext context)
        {
            try
            {
                ChargPileBll cpbll        = new ChargPileBll();
                int          BOX_ID       = int.Parse(context.Request["BOX_ID"].ToString());
                string       CHANGJIAO_BH = context.Request["CHANGJIAO_BH"].ToString();
                string       YUNXING_BH   = context.Request["YUNXING_BH"].ToString();
                DataTable    dt           = cpbll.QueryPileByYXBH(YUNXING_BH);
                if (dt.Rows.Count > 0)
                {
                    context.Response.Write("{\"success\":false,\"msg\":\"运行编号已存在!\"}");
                    return;
                }
                string   CHANGJIA     = context.Request["CHANGJIA"].ToString();
                string   ZHUANGXING_H = context.Request["ZHUANGXING_H"].ToString();
                string   ZHUANGLEI_X  = context.Request["ZHUANGLEI_X"].ToString();
                string   ZHUANGTAI    = context.Request["ZHUANGTAI"].ToString();
                string   sj           = context.Request["TOUYOU_SJ"] ?? "";
                DateTime TOUYOU_SJ    = new DateTime();
                if (sj.Length > 0)
                {
                    TOUYOU_SJ = DateTime.Parse(sj);
                }
                ChargPile chargpile = new ChargPile();
                chargpile.BOX_ID       = BOX_ID;
                chargpile.CHANGJIAO_BH = CHANGJIAO_BH;
                chargpile.YUNXING_BH   = YUNXING_BH;
                chargpile.CHANGJIA     = CHANGJIA;
                chargpile.ZHUANGXING_H = ZHUANGXING_H;
                chargpile.ZHUANGLEI_X  = ZHUANGLEI_X;
                chargpile.ZHUANGTAI    = ZHUANGTAI;
                chargpile.TOUYOU_SJ    = TOUYOU_SJ;

                cpbll.AddChargPile(chargpile);

                decimal zhanbh = decimal.Parse(BOX_ID.ToString().Substring(0, 3));

                //保存桩厂家和装类型到充电站表里
                DataTable     dtable = csbll.QueryTypes(zhanbh);
                List <string> listcj = new List <string>();
                List <string> listlx = new List <string>();

                for (int i = 0; i < dtable.Rows.Count; i++)
                {
                    if (listcj.Count <= 0)
                    {
                        listcj.Add(dtable.Rows[i]["CHANGJIA"].ToString());
                    }
                    else
                    {
                        for (int j = 0; j < listcj.Count; j++)
                        {
                            if (listcj[j] == dtable.Rows[i]["CHANGJIA"].ToString())
                            {
                                break;
                            }
                            if (j == listcj.Count - 1)
                            {
                                listcj.Add(dtable.Rows[i]["CHANGJIA"].ToString());
                            }
                        }
                    }
                }
                for (int i = 0; i < dtable.Rows.Count; i++)
                {
                    if (listlx.Count <= 0)
                    {
                        listlx.Add(dtable.Rows[i]["ZHUANGLEI_X"].ToString());
                    }
                    else
                    {
                        for (int j = 0; j < listlx.Count; j++)
                        {
                            if (listlx[j] == dtable.Rows[i]["ZHUANGLEI_X"].ToString())
                            {
                                break;
                            }
                            if (j == listlx.Count - 1)
                            {
                                listlx.Add(dtable.Rows[i]["ZHUANGLEI_X"].ToString());
                            }
                        }
                    }
                }

                string cj  = "";
                string zlx = "";

                for (int i = 0; i < listcj.Count; i++)
                {
                    cj += listcj[i].ToString();
                    if (i < listcj.Count - 1)
                    {
                        cj += ",";
                    }
                }
                for (int i = 0; i < listlx.Count; i++)
                {
                    zlx += listlx[i].ToString();
                    if (i < listlx.Count - 1)
                    {
                        zlx += ",";
                    }
                }
                ChargStation cstion = new ChargStation();
                cstion.ZhuangLeiX   = zlx;
                cstion.ZhuangChangJ = cj;
                cstion.ZhanBh       = zhanbh;
                csbll.SaveZhan(cstion);


                //操作日志
                string name = "";
                if (null != context.Session[Constant.LoginUser])
                {
                    name = (context.Session[Constant.LoginUser] as Employer ?? new Employer()).Name;
                }
                else
                {
                    context.Response.Write("{\"success\":true,\"msg\":\"保存成功!\"}");
                }
                new OprLogBll().Add(new OprLog()
                {
                    Operator   = name,
                    OprSrc     = "保存充电桩",
                    OperResult = "成功",
                    TargetDev  = BOX_ID,
                    LogDate    = DateTime.Now
                });
                context.Response.Write("{\"success\":true,\"msg\":\"保存成功!\"}");
            }
            catch (Exception e)
            {
                Log.Error(e);
                context.Response.Write("{\"success\":false,\"msg\":\"保存失败!\"}");
            }
        }
Пример #8
0
        /// <summary>
        /// 根据桩id删除充电桩
        /// </summary>
        /// <param name="context"></param>
        private void DelChargPile(HttpContext context)
        {
            try
            {
                string       chargPileId = context.Request["pileid"].ToString();
                ChargPileBll cpbll       = new ChargPileBll();
                cpbll.DelChargPile(chargPileId);


                decimal zhanbh = decimal.Parse(chargPileId.ToString().Substring(0, 3));

                //保存桩厂家和装类型到充电站表里
                DataTable     dtable = csbll.QueryTypes(zhanbh);
                List <string> listcj = new List <string>();
                List <string> listlx = new List <string>();

                for (int i = 0; i < dtable.Rows.Count; i++)
                {
                    if (listcj.Count <= 0)
                    {
                        listcj.Add(dtable.Rows[i]["CHANGJIA"].ToString());
                    }
                    else
                    {
                        for (int j = 0; j < listcj.Count; j++)
                        {
                            if (listcj[j] == dtable.Rows[i]["CHANGJIA"].ToString())
                            {
                                break;
                            }
                            if (j == listcj.Count - 1)
                            {
                                listcj.Add(dtable.Rows[i]["CHANGJIA"].ToString());
                            }
                        }
                    }
                }
                for (int i = 0; i < dtable.Rows.Count; i++)
                {
                    if (listlx.Count <= 0)
                    {
                        listlx.Add(dtable.Rows[i]["ZHUANGLEI_X"].ToString());
                    }
                    else
                    {
                        for (int j = 0; j < listlx.Count; j++)
                        {
                            if (listlx[j] == dtable.Rows[i]["ZHUANGLEI_X"].ToString())
                            {
                                break;
                            }
                            if (j == listlx.Count - 1)
                            {
                                listlx.Add(dtable.Rows[i]["ZHUANGLEI_X"].ToString());
                            }
                        }
                    }
                }

                string cj  = "";
                string zlx = "";

                for (int i = 0; i < listcj.Count; i++)
                {
                    cj += listcj[i].ToString();
                    if (i < listcj.Count - 1)
                    {
                        cj += ",";
                    }
                }
                for (int i = 0; i < listlx.Count; i++)
                {
                    zlx += listlx[i].ToString();
                    if (i < listlx.Count - 1)
                    {
                        zlx += ",";
                    }
                }
                ChargStation cstion = new ChargStation();
                cstion.ZhuangLeiX   = zlx;
                cstion.ZhuangChangJ = cj;
                cstion.ZhanBh       = zhanbh;
                csbll.SaveZhan(cstion);


                //操作日志
                string name = "";
                if (null != context.Session[Constant.LoginUser])
                {
                    name = (context.Session[Constant.LoginUser] as Employer ?? new Employer()).Name;
                }
                else
                {
                    context.Response.Write("{\"success\":true,\"msg\":\"删除成功!\"}");
                }
                new OprLogBll().Add(new OprLog()
                {
                    Operator   = name,
                    OprSrc     = "删除充电桩,桩id:" + chargPileId,
                    OperResult = "成功",
                    LogDate    = DateTime.Now
                });
                context.Response.Write("{\"success\":true,\"msg\":\"删除成功!\"}");
            }
            catch (Exception e)
            {
                Log.Error(e);
                context.Response.Write("{\"success\":false,\"msg\":\"删除失败!\"}");
            }
        }