Example #1
0
 public void InitData(string svgDataUid)
 {
     IList ilist = new ArrayList();
     DataTable dataTable = new DataTable();
     LayerGrade obj = new LayerGrade();
     obj.SvgDataUid = svgDataUid;
     ilist = Services.BaseService.GetList("SelectLayerGradeListBySvgDataUid", obj);
     //ilist = Services.BaseService.GetList<PspType>();
     dataTable = DataConverter.ToDataTable(ilist, typeof(LayerGrade));
     pi.Properties.DataSource = dataTable;
     dataTable.Rows.Add(DataConverter.ObjectToRow("", dataTable.NewRow()));
 }
Example #2
0
 private void frmSelectYear_Load(object sender, EventArgs e)
 {
     LayerGrade lay = new LayerGrade();
     IList<LayerGrade> list = Services.BaseService.GetList<LayerGrade>("SelectLayerGradeList", lay);
     for (int i = 0; i < list.Count; i++)
     {
         TreeNode node = new TreeNode();
         node.Text = list[i].Name;
         node.Tag = list[i].SUID;
         treeView1.Nodes[0].Nodes.Add(node);
     }
     treeView1.ExpandAll();
 }
        private void frmProgLayerManager_Load(object sender, EventArgs e)
        {
            suid = ConfigurationSettings.AppSettings.Get("SvgID");
            LayerGrade g = new LayerGrade();
            g.ParentID = "SUID";
            g.SvgDataUid = suid;
            list= Services.BaseService.GetList<LayerGrade>("SelectLayerGradeListBySvgDataUid2", g);

            for (int i = 0; i < list.Count;i++ )
            {
                TreeNode node = new TreeNode();
                node.Tag = list[i].SUID;
                node.Text = list[i].Name;
                LayerGrade _g = new LayerGrade();
                _g.ParentID = list[i].SUID;
                _g.SvgDataUid = suid;
                IList<LayerGrade> _list = Services.BaseService.GetList<LayerGrade>("SelectLayerGradeListBySvgDataUid2", _g);
                for (int j = 0; j < _list.Count; j++)
                {
                    TreeNode _node = new TreeNode();
                    _node.Tag = _list[j].SUID;
                    _node.Text = _list[j].Name;
                    node.Nodes.Add(_node);
                }
                treeView1.Nodes.Add(node);

            }
            Psp_ProgLayerList p2 = new Psp_ProgLayerList();
            p2.ProgUID = progid;
            IList<Psp_ProgLayerList> plist = Services.BaseService.GetList<Psp_ProgLayerList>("SelectPsp_ProgLayerListListByProgUID", p2);
            treeView1.AfterCheck -= new System.Windows.Forms.TreeViewEventHandler(this.tree_AfterCheck);
            foreach(TreeNode tnode in treeView1.Nodes){
                if (GetNodeCheck(tnode, plist))
                {
                    tnode.Checked = true;
                    foreach(TreeNode tnode2 in tnode.Nodes){
                        if (GetNodeCheck(tnode2, plist))
                        {
                            tnode2.Checked = true;
                        }
                    }
                }
            }
            treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.tree_AfterCheck);
        }
Example #4
0
        public void InitData(string svgDataUid)
        {
            strSvgDataUid = svgDataUid;
            LayerGrade lg = new LayerGrade();
            lg.SvgDataUid = svgDataUid;
            ilist = Services.BaseService.GetList("SelectLayerGradeListBySvgDataUid", lg);
            //ilist = Services.BaseService.GetList<PspType>();
            for (int i = 0; i < ilist.Count;i++ )
            {
                int key = 0;
                for (int j = 0; j < savelist.Count; j++)
                {
                    if (savelist[j].ToString() == ((LayerGrade)ilist[i]).SUID)
                    {
                        key = 1;
                    }
                }
                if(key==1){
                    olist.Add(ilist[i]);
                }
                key = 0;

            }

            dataTable = DataConverter.ToDataTable(olist, typeof(LayerGrade));

            //IList list = this.SymbolDoc.getLayerList();
            //foreach (Layer lay in list)
            //{
            //    if (lay.GetAttribute("layerType") == "电网规划层")
            //    {
            //        LayerGrade obj = new LayerGrade();
            //        obj.SUID = lay.ID;
            //        obj.Name = lay.Label;
            //        obj.ParentID = lay.GetAttribute("ParentID");
            //        dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));
            //    }
            //}
            treeList1.DataSource = dataTable;
            Application.DoEvents();
            treeList1.CollapseAll();
        }
Example #5
0
        private void button5_Click_1(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            frmGHDeviceList frmDevList = new frmGHDeviceList();
            frmDevList.ProjectID = Itop.Client.MIS.ProgUID;
            frmDevList.ProjectSUID = ctrlPSP_GProg1.FocusedObject.UID;
            frmDevList.Init();
            if (frmDevList.ShowDialog() == DialogResult.OK) {
                foreach (DataRow row in frmDevList.DT.Rows) {
                    try {
                        if ((bool)row["C"]) {
                            PSP_GprogElevice elcDevice = new PSP_GprogElevice();
                            elcDevice.DeviceSUID = row["A"].ToString();
                            elcDevice.GprogUID = ctrlPSP_GProg1.FocusedObject.UID;
                            elcDevice = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", elcDevice);
                            if (elcDevice != null) {
                                elcDevice.Type = row["D"].ToString();
                                elcDevice.L2 = "0";
                                Services.BaseService.Update<PSP_GprogElevice>(elcDevice);
                            } else {
                                elcDevice = new PSP_GprogElevice();
                                elcDevice.DeviceSUID = row["A"].ToString();
                                elcDevice.GprogUID = ctrlPSP_GProg1.FocusedObject.UID;
                                elcDevice.Type = row["D"].ToString();
                                elcDevice.L2 = "0";
                                Services.BaseService.Create<PSP_GprogElevice>(elcDevice);
                            }

                        } else {
                            PSP_GprogElevice elcDevice = new PSP_GprogElevice();
                            elcDevice.DeviceSUID = row["A"].ToString();
                            elcDevice.GprogUID = ctrlPSP_GProg1.FocusedObject.UID;

                            Services.BaseService.Delete<PSP_GprogElevice>(elcDevice);
                        }
                    } catch (System.Exception ex) {

                    }
                }
            } else
                return;
            //在此处将其选择的元件设备的属性进行更改

            LayerGrade l1 = new LayerGrade();
            l1.Type = "1";
            l1.SvgDataUid = svguid;
            IList ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            int yy1 = System.DateTime.Now.Year, yy2 = System.DateTime.Now.Year, yy3 = System.DateTime.Now.Year;
            if (ttlist.Count > 0) {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy1 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type = "2";
            l1.SvgDataUid = svguid;
            ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0) {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy2 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type = "3";
            l1.SvgDataUid = svguid;
            ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0) {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy3 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            string con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '变电站'";

            IList list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {

                PSP_Substation_Info ps = new PSP_Substation_Info();
                ps.UID = pg.DeviceSUID;
                ps = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", ps);
                if (ps != null) {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S2)) {
                        s2 = Convert.ToInt32(ps.S2);
                    }
                    if (s2 <= System.DateTime.Now.Year) {
                        pg.L1 = "现行";
                    } else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S2) <= yy1) {
                        pg.L1 = "近期";
                    } else if (s2 > yy1 && Convert.ToInt32(ps.S2) <= yy2) {
                        pg.L1 = "中期";
                    } else if (s2 > yy2 && Convert.ToInt32(ps.S2) <= yy3) {
                        pg.L1 = "远期";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                } else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);

            }
            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '电源'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                PSP_PowerSubstation_Info ps = new PSP_PowerSubstation_Info();
                ps.UID = pg.DeviceSUID;
                ps = (PSP_PowerSubstation_Info)Services.BaseService.GetObject("SelectPSP_PowerSubstation_InfoByKey", ps);
                if (ps != null) {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S3)) {
                        s2 = Convert.ToInt32(ps.S3);
                    }
                    if (s2 <= System.DateTime.Now.Year) {
                        pg.L1 = "现行";
                    } else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S3) <= yy1) {
                        pg.L1 = "近期";
                    } else if (s2 > yy1 && Convert.ToInt32(ps.S3) <= yy2) {
                        pg.L1 = "中期";
                    } else if (s2 > yy2 && Convert.ToInt32(ps.S3) <= yy3) {
                        pg.L1 = "远期";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                } else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
            }
            //变电站里判断两绕和三绕是哪个时期的

            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '变电站'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='02'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                IList uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist) {

                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '两绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null) {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update<PSP_GprogElevice>(pglr);
                    }

                }
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='03'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist) {

                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '三绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null) {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update<PSP_GprogElevice>(pglr);
                    }

                }
            }
            //发电厂里两绕和三绕组是哪个时期的
            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '电源'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='02'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                IList uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist) {

                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '两绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null) {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update<PSP_GprogElevice>(pglr);
                    }

                }
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='03'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist) {

                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '三绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null) {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update<PSP_GprogElevice>(pglr);
                    }

                }
            }
            //判断设备参数中有没有在规划设备中的两绕,三绕组变压器,发电机和负荷 如果没有则删掉

            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND (Type= '两绕组变压器'or Type= '三绕组变压器'or Type= '负荷'or Type= '发电机')";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                PSPDEV ps = new PSPDEV();
                ps.SUID = pg.DeviceSUID;
                ps = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", ps);
                if (ps == null) {
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
                }
            }
            //线路信息
            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '线路'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                PSPDEV ps = new PSPDEV();
                ps.SUID = pg.DeviceSUID;
                ps = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", ps);
                if (ps != null) {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.OperationYear)) {
                        s2 = Convert.ToInt32(ps.OperationYear);
                    }
                    if (s2 <= System.DateTime.Now.Year) {
                        pg.L1 = "运行";
                        ps.LineStatus = "运行";
                    } else {
                        pg.L1 = "待选";
                        ps.LineStatus = "待选";

                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                    Services.BaseService.Update<PSPDEV>(ps);
                } else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);

            }
        }
        public void InitDate()
        {
            IList numlist = Services.BaseService.GetList<LineType>();
            TreeNode tn = new TreeNode();
            tn.Text = "原有变电站";
            tn.Tag = "old";
            for (int j = 0; j < numlist.Count; j++)
            {
                TreeNode n1 = new TreeNode();
                n1.Text = ((LineType)numlist[j]).TypeName;
                n1.Tag = ((LineType)numlist[j]).TypeName.Replace("kV", ""); ;
                tn.Nodes.Add(n1);
            }
            treeView1.Nodes[0].Nodes.Add(tn);

            LayerGrade lay=new LayerGrade();
            IList<LayerGrade> list= Services.BaseService.GetList<LayerGrade>("SelectLayerGradeList",lay);
            for (int i = 0; i < list.Count;i++ )
            {
                TreeNode node = new TreeNode();
                node.Text = list[i].Name;
                node.Tag = list[i].SUID;
                for (int j = 0; j < numlist.Count; j++)
                {
                    TreeNode n1 = new TreeNode();
                    n1.Text = ((LineType)numlist[j]).TypeName;
                    n1.Tag = ((LineType)numlist[j]).TypeName.Replace("kV",""); ;
                    node.Nodes.Add(n1);
                }
                treeView1.Nodes[0].Nodes.Add(node);

            }
            treeView1.Nodes[0].Expand();
        }
Example #7
0
        private void dotNetBarManager1_ItemClick(object sender, EventArgs e)
        {
            FileStream dh;
            StreamReader readLine;
            char[] charSplit;
            string strLine;
            string[] array1;
            string output = null;
            string[] array2;

            string strLine2;

            char[] charSplit2 = new char[] { ' ' };
            FileStream op;
            StreamWriter str1;
            FileStream dh2;
            StreamReader readLine2;
            Excel.Application ex;
            Excel.Worksheet xSheet;
            Excel.Application result1;
            Excel.Worksheet tempSheet;
            Excel.Worksheet newWorksheet;
            DevComponents.DotNetBar.ButtonItem btItem = sender as DevComponents.DotNetBar.ButtonItem;
            //Layer layer1 = (Layer)LayerBox.ComboBoxEx.SelectedItem;
            if (btItem != null)
            {
                switch (btItem.Name)
                {
                    #region 文件操作
                    case "mNew":
                        try
                        {
                            //{
                            XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@layer='" + tlVectorControl1.SVGDocument.CurrentLayer.ID + "']");
                            for (int i = 0; i < list.Count; i++)
                            {
                                SvgElement ele = (SvgElement)list[i];
                                if (ele.LocalName == "polyline")
                                {
                                    PSPDEV _dev = new PSPDEV();
                                    _dev.EleID = ele.ID;
                                    _dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    _dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", _dev);

                                    if (_dev == null)
                                    {
                                        LineInfo _pl = new LineInfo();
                                        _pl.EleID = ele.ID;
                                        _pl.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        _pl = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _pl);
                                        if (_pl != null)
                                        {
                                            PSPDEV pspDev = new PSPDEV();
                                            pspDev.SUID = Guid.NewGuid().ToString();
                                            pspDev.EleID = ele.GetAttribute("id");
                                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                            pspDev.Number = -1;
                                            pspDev.FirstNode = -1;
                                            pspDev.LastNode = -1;
                                            pspDev.Type = "Polyline";
                                            pspDev.Lable = "支路";
                                            pspDev.Name = _pl.LineName;
                                            pspDev.LineLength = Convert.ToDouble(_pl.Length);
                                            pspDev.LineLevel = _pl.Voltage;
                                            pspDev.LineType = _pl.LineType;
                                            pspDev.LineStatus = "运行";
                                            Services.BaseService.Create<PSPDEV>(pspDev);
                                        }
                                    }
                                }
                                if (ele.LocalName == "use")
                                {
                                    PSPDEV _dev = new PSPDEV();
                                    _dev.EleID = ele.ID;
                                    _dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    _dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", _dev);

                                    if (_dev == null)
                                    {
                                        substation _pl = new substation();
                                        _pl.EleID = ele.ID;
                                        _pl.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        _pl = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _pl);
                                        if (_pl != null)
                                        {
                                            PSPDEV pspDev = new PSPDEV();
                                            pspDev.SUID = Guid.NewGuid().ToString();
                                            pspDev.EleID = ele.GetAttribute("id");
                                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                            pspDev.Number = -1;
                                            pspDev.FirstNode = -1;
                                            pspDev.LastNode = -1;
                                            pspDev.Type = "Use";
                                            pspDev.Lable = "变电站";
                                            pspDev.Name = _pl.EleName;
                                            pspDev.VoltR = Convert.ToDouble(_pl.ObligateField1);
                                            pspDev.Burthen = _pl.Number;
                                            Services.BaseService.Create<PSPDEV>(pspDev);
                                        }
                                    }

                                }

                            }

                            PSPDEV pppp = new PSPDEV();
                            pppp.Type = "power";
                            pppp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            IList listpp = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", pppp);
                            if (listpp == null || listpp.Count == 0)
                            {

                                if (MessageBox.Show("新建的潮流计算,需要设置基准值,是否立即设置??", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                                {
                                    PSPDEV pspDev2 = new PSPDEV();

                                    //pspDev2.SUID = Guid.NewGuid().ToString();
                                    pspDev2.Type = "Power";
                                    pspDev2.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    pspDev2 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDAndType", pspDev2);
                                    if (pspDev2 != null)
                                    {
                                    }
                                    else
                                    {
                                        pspDev2 = new PSPDEV();
                                        pspDev2.SUID = Guid.NewGuid().ToString();
                                        pspDev2.Type = "Power";
                                        pspDev2.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        Services.BaseService.Create<PSPDEV>(pspDev2);
                                    }
                                    powerf pp = new powerf(pspDev2);
                                    if (pp.ShowDialog() == DialogResult.OK)
                                    {
                                        pspDev2.PowerFactor = Convert.ToDouble(pp.powerfactor);
                                        pspDev2.StandardVolt = Convert.ToDouble(pp.standardvolt);
                                        pspDev2.StandardCurrent = Convert.ToDouble(pp.standardcurrent);
                                        pspDev2.BigP = Convert.ToDouble(pp.bigP);
                                        Services.BaseService.Update<PSPDEV>(pspDev2);
                                        //PSPDEV voltall = new PSPDEV();
                                        //voltall.Type = "Use";
                                        //voltall.Lable = "电厂";
                                        //voltall.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        //IList allvolt = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandLableandType", voltall);
                                        //foreach (PSPDEV dev in allvolt)
                                        //{
                                        //    dev.OutP = Convert.ToDouble(dev.Burthen) * pspDev2.BigP;
                                        //    //dev.InPutP=dev.Burthen*pspDev2.BigP;
                                        //    dev.OutQ = dev.OutP * Math.Tan(Math.Acos(pspDev2.PowerFactor));
                                        //    Services.BaseService.Update<PSPDEV>(dev);
                                        //}
                                        //voltall.Lable = "变电站";
                                        //allvolt = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandLableandType", voltall);
                                        //foreach (PSPDEV dev in allvolt)
                                        //{
                                        //    dev.InPutP = Convert.ToDouble(dev.Burthen) * pspDev2.BigP;
                                        //    //dev.InPutP=dev.Burthen*pspDev2.BigP;
                                        //    dev.InPutQ = dev.InPutP * pspDev2.BigP * Math.Tan(Math.Acos(pspDev2.PowerFactor));
                                        //    Services.BaseService.Update<PSPDEV>(dev);
                                        //}

                                    }
                                    //powerf pf=new powerf()
                                }
                            }
                            if (!Check())
                            {
                                return;
                            }
                            NIULA pspniula = new NIULA();
                            pspniula.CurrentCal();

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "牛拉法计算结果.xls"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "牛拉法计算结果.xls");
                                //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls");
                            }

                            double yinzi = 0, capability = 0, volt = 0, current = 0, Rad_to_Deg = 57.29577951;
                            PSPDEV benchmark = new PSPDEV();
                            benchmark.Type = "power";
                            benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark);
                            if (list3 == null)
                            {
                                MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            foreach (PSPDEV dev in list3)
                            {
                                yinzi = Convert.ToDouble(dev.PowerFactor);
                                capability = Convert.ToDouble(dev.StandardCurrent);
                                volt = Convert.ToDouble(dev.StandardVolt);
                                if (dev.PowerFactor == 0)
                                {
                                    yinzi = 1;
                                }
                                if (dev.StandardCurrent == 0)
                                {
                                    capability = 1;
                                }
                                if (dev.StandardVolt == 0)
                                {
                                    volt = 1;
                                }
                                current = capability / (Math.Sqrt(3) * volt);

                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF1.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF1.txt", FileMode.Open);
                            readLine = new StreamReader(dh);

                            charSplit = new char[] { ' ' };
                            strLine = readLine.ReadLine();

                            output += ("全网母线(发电、负荷)结果报表 " + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("母线名" + "," + "电压幅值" + "," + "电压相角" + "," + "有功发电" + "," + "无功发电" + "," + "有功负荷" + "," + "无功负荷" + "," + "越限标志" + "," + "过载标志" + "\r\n");
                            int count = 0;
                            while (strLine != null && strLine != "")
                            {
                                array1 = strLine.Split(charSplit);
                                string[] dev = new string[9];
                                dev.Initialize();
                                int i = 0;
                                count++;
                                PSPDEV CR = new PSPDEV();
                                CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                foreach (string str in array1)
                                {
                                    if (str != "")
                                    {
                                        if (str != "NaN")
                                        {
                                            dev[i++] = Convert.ToDouble(str).ToString();
                                        }
                                        else
                                        {
                                            dev[i++] = str;
                                        }

                                    }

                                }

                                CR.Number = Convert.ToInt32(dev[0]);
                                CR.Type = "Use";
                                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR);
                                double vTemp = Convert.ToDouble(dev[1]) * volt;
                                double vTemp1 = volt * 95 / 100;
                                double vTemp2 = volt * 105 / 100;

                                if (vTemp >= vTemp1 && vTemp <= vTemp2)
                                {
                                    dev[5] = "0";
                                }
                                else
                                {
                                    dev[5] = "1";
                                }
                                if (Convert.ToDouble(dev[3]) * capability > Convert.ToDouble(CR.Burthen))
                                {
                                    dev[6] = "1";
                                }
                                else
                                {
                                    dev[6] = "0";
                                }

                                if (Convert.ToDouble(dev[3]) < 0)
                                {
                                    output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + "0" + "," + "0" + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + dev[5] + "," + dev[6] + "\r\n";
                                }
                                else
                                {
                                    output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + "0" + "," + "0" + "," + dev[5] + "," + dev[6] + "\r\n";
                                }
                                strLine = readLine.ReadLine();
                            }
                            PSPDEV ct = new PSPDEV();
                            ct.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            ct.Type = "Use";
                            IList cont = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", ct);
                            if (count < cont.Count)
                            {
                                MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                readLine.Close();
                                return;

                            }
                            readLine.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                            }
                            op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                            str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                            str1.Write(output);
                            str1.Close();

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);
                            dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH1.txt", FileMode.Open);
                            readLine2 = new StreamReader(dh2);
                            readLine = new StreamReader(dh);
                            charSplit = new char[] { ' ' };
                            strLine = readLine.ReadLine();
                            strLine2 = readLine2.ReadLine();

                            output = null;

                            output += ("全网交流线结果报表" + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "," + "\r\n");
                            while (strLine != null && strLine2 != null && strLine != "" && strLine2 != "")
                            {
                                array1 = strLine.Split(charSplit);
                                array2 = strLine2.Split(charSplit2);

                                string[] dev = new string[20];
                                dev.Initialize();
                                int i = 0;
                                PSPDEV CR = new PSPDEV();
                                CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                foreach (string str in array1)
                                {
                                    if (str != "")
                                    {
                                        if (i == 0)
                                        {
                                            dev[i++] = str.ToString();
                                        }
                                        else
                                        {
                                            if (str != "NaN")
                                            {
                                                dev[i++] = Convert.ToDouble(str).ToString();
                                            }
                                            else
                                            {
                                                dev[i++] = str;
                                            }

                                        }
                                    }

                                }
                                i = 7;
                                for (int j = 3; j < 5; j++)
                                {
                                    if (array2[j] != "")
                                    {
                                        if (array2[j] != "NaN")
                                        {
                                            dev[i++] = Convert.ToDouble(array2[j]).ToString();
                                        }
                                        else
                                        {
                                            dev[i++] = array2[j];
                                        }
                                    }

                                }
                                CR.Name = dev[0];
                                CR.Type = "Polyline";
                                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);

                                if (CR != null)
                                {
                                    if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange)
                                    {
                                        dev[11] = "1";
                                    }
                                    else
                                    {
                                        dev[11] = "0";
                                    }
                                    output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                                }
                                else
                                {
                                    CR = new PSPDEV();
                                    CR.Name = dev[0];
                                    CR.Type = "TransformLine";
                                    CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                                    if (CR != null)
                                    {
                                        if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange)
                                        {
                                            dev[11] = "1";
                                        }
                                        else
                                        {
                                            dev[11] = "0";
                                        }
                                        output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                                    }
                                }

                                strLine = readLine.ReadLine();
                                strLine2 = readLine2.ReadLine();
                            }
                            readLine.Close();
                            readLine2.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            }
                            op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                            str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                            str1.Write(output);
                            str1.Close();

                            ex = new Excel.Application();
                            ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                            xSheet = (Excel.Worksheet)ex.Worksheets[1];
                            ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);

                            result1 = new Excel.Application();
                            result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                            newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                            newWorksheet.Name = "线路电流";
                            xSheet.Name = "母线潮流";
                            ex.Visible = true;

                            tempSheet.Cells.Select();
                            tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                            newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                            xSheet.Rows.AutoFit();
                            xSheet.Columns.AutoFit();
                            newWorksheet.Rows.AutoFit();
                            newWorksheet.Columns.AutoFit();
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 9]).MergeCells = true;
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20;
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体";
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            xSheet.get_Range(xSheet.Cells[5, 1], xSheet.Cells[5, 9]).Interior.ColorIndex = 45;
                            xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            xSheet.get_Range(xSheet.Cells[6, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                            xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 9]).MergeCells = true;
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20;
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体";
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            newWorksheet.get_Range(newWorksheet.Cells[5, 1], newWorksheet.Cells[5, 8]).Interior.ColorIndex = 45;
                            newWorksheet.get_Range(newWorksheet.Cells[6, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            newWorksheet.get_Range(newWorksheet.Cells[6, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                            newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                            //op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fck.excel"), FileMode.OpenOrCreate);
                            //str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));

                            string fn = tlVectorControl1.SVGDocument.FileName;

                            //result1.Save(System.Windows.Forms.Application.StartupPath + "\\fck.xls");

                            newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + fn + "牛拉法计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);

                            //str1.Write();
                            //op.Close();

                            System.Windows.Forms.Clipboard.Clear();
                            result1.Workbooks.Close();
                            result1.Quit();

                        }
                        catch (System.Exception e1)
                        {
                            MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        //}
                        break;
                    case "mOpen":
                        if (tlVectorControl1.IsModified == true)
                        {
                            DialogResult a;
                            a = MessageBox.Show("图形已修改,是否保存?", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);

                            if (a == DialogResult.Yes)
                            {
                                Save();
                            }
                            else if (a == DialogResult.No)
                            {
                            }
                            else if (a == DialogResult.Cancel)
                            {
                                return;
                            }

                        }
                        Open();

                        break;
                    case "btExSymbol":
                        tlVectorControl1.ExportSymbol();
                        break;
                    case "mjxt"://导入接线图

                        string _svguid = ConfigurationSettings.AppSettings.Get("SvgID");
                        frmYear f = new frmYear();
                        f.uid = _svguid;
                        f.Show();
                        //ImportJxt jxt = new ImportJxt(tlVectorControl1);
                        //jxt.Import();
                        break;
                    case "mSave":
                        SaveAllLayer();

                        break;
                    case "mExit":
                        this.Close();
                        break;
                    case "bt1":
                        //InitTK();
                        break;
                    case "mFin":
                        frmGProList p = new frmGProList();
                        p.Show();
                        p.LoadData(LoadData());
                        break;
                    case "bt2":
                        break;
                    case "mPriSet":
                        this.tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint;
                        break;
                    case "mPrint":
                        tlVectorControl1.Print();
                        break;
                    case "mImport":
                        ExportImage();
                        break;
                    case "mView":
                        //frmSvgView fView = new frmSvgView();
                        //fView.Open(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        //fView.Show();

                        break;

                    //case "mIncreaseView":
                    //    tlVectorControl1.Operation = ToolOperation.IncreaseView;
                    //    break;
                    case "mRzb":
                        frmRatio fRat = new frmRatio();
                        string viewRat = tlVectorControl1.SVGDocument.getRZBRatio();
                        if (viewRat != "")
                        {
                            fRat.InitData(viewRat);
                        }
                        if (fRat.ShowDialog() == DialogResult.OK)
                        {
                            viewRat = fRat.ViewScale;
                            tlVectorControl1.SVGDocument.setRZBRatio(viewRat);
                        }
                        break;

                    case "mAbout":

                        frmAbout frma = new frmAbout();
                        frma.ShowDialog();
                        break;

                    case "ButtonItem10":
                        int temp411 = 10;
                        frmConvert frmc = new frmConvert();
                        frmc.ShowDialog();
                        temp411++;
                        break;

                    //基础操作
                    case "mFreeTransform":
                        tlVectorControl1.Operation = ToolOperation.FreeTransform;

                        break;
                    case "mCJ":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;
                        csOperation = CustomOperation.OP_MeasureDistance;
                        break;
                    //case "ButtonItem2":
                    //    break;
                    #endregion
                    #region 基础图元
                    case "mDecreaseView":
                        tlVectorControl1.Operation = ToolOperation.DecreaseView;

                        break;
                    case "mIncreaseView":

                        tlVectorControl1.Operation = ToolOperation.IncreaseView;
                        break;
                    case "mRoam":
                        tlVectorControl1.Operation = ToolOperation.Roam;

                        break;
                    case "mSelect":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        break;
                    case "mSel":

                        tlVectorControl1.Operation = ToolOperation.FreeTransform;
                        break;
                    //case "mFreeTransform":
                    //    tlVectorControl1.Operation = ToolOperation.FreeTransform;

                    //    break;
                    case "mFreeLines"://锁套
                        tlVectorControl1.Operation = ToolOperation.FreeLines;

                        break;
                    case "mFreePath":
                        tlVectorControl1.Operation = ToolOperation.FreePath;

                        break;
                    case "mShapeTransform":
                        tlVectorControl1.Operation = ToolOperation.ShapeTransform;

                        break;
                    case "mAngleRectangle":
                        tlVectorControl1.Operation = ToolOperation.AngleRectangle;

                        break;
                    case "mEllipse":
                        tlVectorControl1.Operation = ToolOperation.Ellipse;

                        break;
                    case "mLine":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Polyline;

                        break;
                    case "mPolyline":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;

                        break;
                    case "mConnectLine":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine;
                        break;

                    case "mPolygon":
                        tlVectorControl1.Operation = ToolOperation.Polygon;

                        break;
                    case "mImage":
                        tlVectorControl1.Operation = ToolOperation.Image;
                        break;
                    case "mText":
                        tlVectorControl1.Operation = ToolOperation.Text;
                        break;
                    case "mBezier":
                        tlVectorControl1.Operation = ToolOperation.Bezier;

                        break;
                    case "ButtonItem2":
                        fileType = true;
                        if (fileType == true)
                        {
                            LoadShape("symbol20.xml");
                            //jxtbar(1);
                        }
                        else
                        {
                            LoadShape("symbol21.xml");
                            //jxtbar(0);
                        }
                        tlVectorControl1.SVGDocument.CurrentLayer.ID = Guid.NewGuid().ToString();
                        SvgDocument.currentLayer = Layer.CreateNew("默认层", tlVectorControl1.SVGDocument).ID;
                        tlVectorControl1.IsModified = false;
                        frmElementName dlgnew2 = new frmElementName();
                        dlgnew2.TextInput = tlVectorControl1.SVGDocument.FileName;
                        if (dlgnew2.ShowDialog() == DialogResult.OK)
                        {
                            tlVectorControl1.SVGDocument.FileName = dlgnew2.TextInput;
                            Save();
                        }
                        //NewFile(fileType);
                        break;
                    case "ButtonItem8":
                        fileType = false;
                        //NewFile(fileType);
                        tlVectorControl1.NewFile();
                        if (fileType == true)
                        {
                            LoadShape("symbol20.xml");
                            //jxtbar(1);
                        }
                        else
                        {
                            LoadShape("symbol21.xml");
                            //jxtbar(0);
                        }
                        tlVectorControl1.SVGDocument.CurrentLayer.ID = Guid.NewGuid().ToString();
                        SvgDocument.currentLayer = Layer.CreateNew("默认层", tlVectorControl1.SVGDocument).ID;
                        tlVectorControl1.IsModified = false;
                        frmElementName dlgnew3 = new frmElementName();
                        dlgnew3.TextInput = tlVectorControl1.SVGDocument.FileName;
                        if (dlgnew3.ShowDialog() == DialogResult.OK)
                        {
                            tlVectorControl1.SVGDocument.FileName = dlgnew3.TextInput;
                            Save();
                        }
                        break;
                    case "mCheck":
                        Check();
                        break;
                    case "niula":
                        //MessageBox.Show(Directory.GetCurrentDirectory());
                        //frmTLpsp el = new frmTLpsp();
                        PspNIULA();
                        //oThread = new Thread(new ThreadStart(el.PspNIULA));
                        //oThread.Start();
                        //try
                        //{
                        //    time = new System.Threading.Timer(new TimerCallback(method), null, 50000, 60000);
                        //}
                        //catch { }
                        break;
                    case "pq":
                        //frmTLpsp e2 = new frmTLpsp();
                        PspPQ();
                        break;
                    //case "ShortCut":
                    //    ShortCutCheck();
                    //    break;
                    case "GaussSeidel":
                        PspGaussSeidel();
                        break;
                    case "PowerLossCal":
                        PspPowerLossCal();
                        break;
                    case "N_RZYz":
                        PspN_RZYz();
                        break;
                    case "WebRela":                        //进行网络N-1检验

                        WebCalAndPrint();
                        break;
                    case "TransRela":                       //进行变压器N-1检验

                        break;
                    case "DuanluResult":
                        //ShortCutCheck();
                        //PSPDEV pspDuanlu = new PSPDEV();
                        //pspDuanlu.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        //frmDuanlu dudu = new frmDuanlu(pspDuanlu);
                        //PSPDEV Duanlu = new PSPDEV();
                        //Duanlu.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                        //if (dudu.ShowDialog() == DialogResult.OK)
                        //{

                        //    Duanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", Duanlu);
                        //    n4 = Convert.ToInt32(dudu.hscool);
                        //    if (Duanlu.Type == "Use")
                        //    {
                        //        n1 = Duanlu.Number;
                        //        n2 = Duanlu.Number;
                        //        string dlr=n1.ToString();
                        //        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\dlb.txt"))
                        //        {
                        //            File.Delete(System.Windows.Forms.Application.StartupPath+"\\dlb.txt");
                        //        }

                        //        FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath+"\\data.txt"), FileMode.OpenOrCreate);
                        //        StreamWriter str11 = new StreamWriter(VK);
                        //        str11.Write(dlr);
                        //        str11.Close();

                        //        n4 = 0;
                        //    }
                        //    if (Duanlu.Type == "Polyline")
                        //    {
                        //        n1 = Duanlu.FirstNode;
                        //        n2 = Duanlu.LastNode;
                        //    }
                        //    switch (dudu.DuanluType){

                        //        case "单相接地":
                        //            n3 = 1;
                        //            break;

                        //        case "两相接地":
                        //            n3 = 3;
                        //            break;
                        //        case "两相故障":
                        //            n3 = 2;
                        //            break;
                        //        case "三相故障":
                        //            n3 = 0;
                        //            break;
                        //        default:
                        //            n3 = 1;
                        //            break;
                        //    }
                        //    duanlu.myshort(n1, n2, n3, n4);
                        // }
                        break;
                    //case "DuanluResult":
                    //    il = 1;
                    //    break;
                    case "dd":
                        //SubPrint = true;
                        tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint;
                        break;

                    case "NiulaResult":
                        try
                        {
                            //{
                            if (!Check())
                            {
                                return;
                            }
                            NIULA pspniula = new NIULA();
                            pspniula.CurrentCal();

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "牛拉法计算结果.xls"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "牛拉法计算结果.xls");
                                //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls");
                            }

                            double yinzi = 0, capability = 0, volt = 0, current = 0, standvolt = 0, Rad_to_Deg = 57.29577951;
                            PSPDEV benchmark = new PSPDEV();
                            benchmark.Type = "power";
                            benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark);
                            if (list3 == null)
                            {
                                MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            foreach (PSPDEV dev in list3)
                            {
                                yinzi = Convert.ToDouble(dev.PowerFactor);
                                capability = Convert.ToDouble(dev.StandardCurrent);
                                volt = Convert.ToDouble(dev.StandardVolt);
                                if (dev.PowerFactor == 0)
                                {
                                    yinzi = 1;
                                }
                                if (dev.StandardCurrent == 0)
                                {
                                    capability = 1;
                                }
                                if (dev.StandardVolt == 0)
                                {
                                    volt = 1;
                                }
                                standvolt = volt;
                                current = capability / (Math.Sqrt(3) * volt);

                            }
                            capability = 100;

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF1.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF1.txt", FileMode.Open);
                            readLine = new StreamReader(dh);

                            charSplit = new char[] { ' ' };
                            strLine = readLine.ReadLine();

                            output += ("全网母线(发电、负荷)结果报表 " + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("母线名" + "," + "电压幅值" + "," + "电压相角" + "," + "有功发电" + "," + "无功发电" + "," + "有功负荷" + "," + "无功负荷" + "," + "越限标志" + "," + "过载标志" + "\r\n");
                            int count = 0;
                            while (strLine != null && strLine != "")
                            {
                                array1 = strLine.Split(charSplit);
                                string[] dev = new string[9];
                                dev.Initialize();
                                int i = 0;
                                count++;
                                PSPDEV CR = new PSPDEV();
                                CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                foreach (string str in array1)
                                {
                                    if (str != "")
                                    {
                                        if (str != "NaN")
                                        {
                                            dev[i++] = Convert.ToDouble(str).ToString();
                                        }
                                        else
                                        {
                                            dev[i++] = str;
                                        }

                                    }

                                }

                                CR.Number = Convert.ToInt32(dev[0]);
                                CR.Type = "Use";
                                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR);
                                if (CR.ReferenceVolt != null && CR.ReferenceVolt != 0)
                                {
                                    volt = CR.ReferenceVolt;
                                }
                                else
                                    volt = standvolt;
                                current = capability / (Math.Sqrt(3) * volt);
                                double vTemp = Convert.ToDouble(dev[1]) * volt;
                                double vTemp1 = volt * 95 / 100;
                                double vTemp2 = volt * 105 / 100;

                                if (vTemp >= vTemp1 && vTemp <= vTemp2)
                                {
                                    dev[5] = "0";
                                }
                                else
                                {
                                    dev[5] = "1";
                                }
                                if (Convert.ToDouble(dev[3]) * capability > Convert.ToDouble(CR.Burthen))
                                {
                                    dev[6] = "1";
                                }
                                else
                                {
                                    dev[6] = "0";
                                }

                                if (Convert.ToDouble(dev[3]) < 0)
                                {
                                    output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + "0" + "," + "0" + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + dev[5] + "," + dev[6] + "\r\n";
                                }
                                else
                                {
                                    output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + "0" + "," + "0" + "," + dev[5] + "," + dev[6] + "\r\n";
                                }
                                strLine = readLine.ReadLine();
                            }
                            PSPDEV ct = new PSPDEV();
                            ct.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            ct.Type = "Use";
                            IList cont = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", ct);
                            if (count < cont.Count)
                            {
                                MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                readLine.Close();
                                return;

                            }
                            readLine.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                            }
                            op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                            str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                            str1.Write(output);
                            str1.Close();

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);
                            dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH1.txt", FileMode.Open);
                            readLine2 = new StreamReader(dh2);
                            readLine = new StreamReader(dh);
                            charSplit = new char[] { ' ' };
                            strLine = readLine.ReadLine();
                            strLine2 = readLine2.ReadLine();

                            output = null;

                            output += ("全网交流线结果报表" + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "," + "\r\n");
                            while (strLine != null && strLine2 != null && strLine != "" && strLine2 != "")
                            {
                                array1 = strLine.Split(charSplit);
                                array2 = strLine2.Split(charSplit2);

                                string[] dev = new string[20];
                                dev.Initialize();
                                int i = 0;
                                PSPDEV CR = new PSPDEV();
                                CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                foreach (string str in array1)
                                {
                                    if (str != "")
                                    {
                                        if (i == 0)
                                        {
                                            dev[i++] = str.ToString();
                                        }
                                        else
                                        {
                                            if (str != "NaN")
                                            {
                                                dev[i++] = Convert.ToDouble(str).ToString();
                                            }
                                            else
                                            {
                                                dev[i++] = str;
                                            }

                                        }
                                    }

                                }
                                i = 7;
                                for (int j = 3; j < 5; j++)
                                {
                                    if (array2[j] != "")
                                    {
                                        if (array2[j] != "NaN")
                                        {
                                            dev[i++] = Convert.ToDouble(array2[j]).ToString();
                                        }
                                        else
                                        {
                                            dev[i++] = array2[j];
                                        }
                                    }

                                }
                                CR.Name = dev[0];
                                CR.Type = "Polyline";
                                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                                if (CR.ReferenceVolt != null && CR.ReferenceVolt != 0)
                                {
                                    volt = CR.ReferenceVolt;
                                }
                                else
                                    volt = standvolt;
                                current = capability / (Math.Sqrt(3) * volt);
                                if (CR != null)
                                {
                                    if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange)
                                    {
                                        dev[11] = "1";
                                    }
                                    else
                                    {
                                        dev[11] = "0";
                                    }
                                    output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                                }
                                else
                                {
                                    CR = new PSPDEV();
                                    CR.Name = dev[0];
                                    CR.Type = "TransformLine";
                                    CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                                    if (CR != null)
                                    {
                                        if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange)
                                        {
                                            dev[11] = "1";
                                        }
                                        else
                                        {
                                            dev[11] = "0";
                                        }
                                        output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                                    }
                                }

                                strLine = readLine.ReadLine();
                                strLine2 = readLine2.ReadLine();
                            }
                            readLine.Close();
                            readLine2.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            }
                            op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                            str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                            str1.Write(output);
                            str1.Close();

                            ex = new Excel.Application();
                            ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                            xSheet = (Excel.Worksheet)ex.Worksheets[1];
                            ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);

                            result1 = new Excel.Application();
                            result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                            newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                            newWorksheet.Name = "线路电流";
                            xSheet.Name = "母线潮流";
                            ex.Visible = true;

                            tempSheet.Cells.Select();
                            tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                            newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                            xSheet.Rows.AutoFit();
                            xSheet.Columns.AutoFit();
                            newWorksheet.Rows.AutoFit();
                            newWorksheet.Columns.AutoFit();
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 9]).MergeCells = true;
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20;
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体";
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            xSheet.get_Range(xSheet.Cells[5, 1], xSheet.Cells[5, 9]).Interior.ColorIndex = 45;
                            xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            xSheet.get_Range(xSheet.Cells[6, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                            xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 9]).MergeCells = true;
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20;
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体";
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            newWorksheet.get_Range(newWorksheet.Cells[5, 1], newWorksheet.Cells[5, 8]).Interior.ColorIndex = 45;
                            newWorksheet.get_Range(newWorksheet.Cells[6, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            newWorksheet.get_Range(newWorksheet.Cells[6, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                            newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                            //op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fck.excel"), FileMode.OpenOrCreate);
                            //str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));

                            string fn = tlVectorControl1.SVGDocument.FileName;

                            //result1.Save(System.Windows.Forms.Application.StartupPath + "\\fck.xls");

                            newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + fn + "牛拉法计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);

                            //str1.Write();
                            //op.Close();

                            System.Windows.Forms.Clipboard.Clear();
                            result1.Workbooks.Close();
                            result1.Quit();

                        }
                        catch (System.Exception e1)
                        {
                            MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        //}
                        break;
                    case "GaussSeidelResult":
                        try
                        {

                            if (!Check())
                            {
                                return;
                            }
                            Gauss pspgauss = new Gauss();
                            pspgauss.CurrentCal();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "高斯-赛德尔计算结果.xls"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "高斯-赛德尔计算结果.xls");
                                //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls");
                            }

                            double yinzi = 0, capability = 0, volt = 0, current = 0, Rad_to_Deg = 57.29577951;
                            PSPDEV benchmark = new PSPDEV();
                            benchmark.Type = "power";
                            benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark);
                            if (list3 == null)
                            {
                                MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            foreach (PSPDEV dev in list3)
                            {
                                yinzi = Convert.ToDouble(dev.PowerFactor);
                                capability = Convert.ToDouble(dev.StandardCurrent);
                                volt = Convert.ToDouble(dev.StandardVolt);
                                if (dev.PowerFactor == 0)
                                {
                                    yinzi = 1;
                                }
                                if (dev.StandardCurrent == 0)
                                {
                                    capability = 1;
                                }
                                if (dev.StandardVolt == 0)
                                {
                                    volt = 1;
                                }
                                current = capability / (Math.Sqrt(3) * volt);
                            };
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF3.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF3.txt", FileMode.Open);
                            readLine = new StreamReader(dh);

                            charSplit = new char[] { ' ' };
                            strLine = readLine.ReadLine();

                            output += ("全网母线(发电、负荷)结果报表 " + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("母线名" + "," + "电压幅值" + "," + "电压相角" + "," + "有功发电" + "," + "无功发电" + "," + "有功负荷" + "," + "无功负荷" + "," + "越限标志" + "," + "过载标志" + "\r\n");
                            int count = 0;
                            while (strLine != null && strLine != "")
                            {
                                array1 = strLine.Split(charSplit);
                                string[] dev = new string[9];
                                dev.Initialize();
                                int i = 0;
                                count++;
                                PSPDEV CR = new PSPDEV();
                                CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                foreach (string str in array1)
                                {
                                    if (str != "")
                                    {
                                        if (str != "NaN")
                                        {
                                            dev[i++] = Convert.ToDouble(str).ToString();
                                        }
                                        else
                                        {
                                            dev[i++] = str;
                                        }

                                    }

                                }

                                CR.Number = Convert.ToInt32(dev[0]);
                                CR.Type = "Use";
                                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR);
                                double vTemp = Convert.ToDouble(dev[1]) * volt;
                                double vTemp1 = volt * 95 / 100;
                                double vTemp2 = volt * 105 / 100;

                                if (vTemp >= vTemp1 && vTemp <= vTemp2)
                                {
                                    dev[5] = "0";
                                }
                                else
                                {
                                    dev[5] = "1";
                                }
                                if (Convert.ToDouble(dev[3]) * capability > Convert.ToDouble(CR.Burthen))
                                {
                                    dev[6] = "1";
                                }
                                else
                                {
                                    dev[6] = "0";
                                }

                                if (Convert.ToDouble(dev[3]) < 0)
                                {

                                    output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + "0" + "," + "0" + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + dev[5] + "," + dev[6] + "\r\n";
                                }
                                else
                                {

                                    output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + "0" + "," + "0" + "," + dev[5] + "," + dev[6] + "\r\n";
                                }
                                strLine = readLine.ReadLine();
                            }
                            PSPDEV ct = new PSPDEV();
                            ct.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            ct.Type = "Use";
                            IList cont = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", ct);
                            if (count < cont.Count)
                            {
                                MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                readLine.Close();
                                return;

                            }
                            readLine.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                            }
                            op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                            str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                            str1.Write(output);
                            str1.Close();

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH3.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH3.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH3.txt", FileMode.Open);
                            dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH3.txt", FileMode.Open);
                            readLine2 = new StreamReader(dh2);
                            readLine = new StreamReader(dh);
                            charSplit = new char[] { ' ' };
                            strLine = readLine.ReadLine();
                            strLine2 = readLine2.ReadLine();

                            output = null;

                            output += ("全网交流线结果报表" + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "," + "\r\n");
                            while (strLine != null && strLine2 != null && strLine != "" && strLine2 != "")
                            {
                                array1 = strLine.Split(charSplit);
                                array2 = strLine2.Split(charSplit2);

                                string[] dev = new string[20];
                                dev.Initialize();
                                int i = 0;
                                PSPDEV CR = new PSPDEV();
                                CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                foreach (string str in array1)
                                {
                                    if (str != "")
                                    {
                                        if (i == 0)
                                        {
                                            dev[i++] = str.ToString();
                                        }
                                        else
                                        {
                                            if (str != "NaN")
                                            {
                                                dev[i++] = Convert.ToDouble(str).ToString();
                                            }
                                            else
                                            {
                                                dev[i++] = str;
                                            }

                                        }
                                    }

                                }
                                i = 7;
                                for (int j = 3; j < 5; j++)
                                {
                                    if (array2[j] != "")
                                    {
                                        if (array2[j] != "NaN")
                                        {
                                            dev[i++] = Convert.ToDouble(array2[j]).ToString();
                                        }
                                        else
                                        {
                                            dev[i++] = array2[j];
                                        }
                                    }

                                }
                                CR.Name = dev[0];
                                CR.Type = "Polyline";
                                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);

                                if (CR != null)
                                {
                                    if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange)
                                    {
                                        dev[11] = "1";
                                    }
                                    else
                                    {
                                        dev[11] = "0";
                                    }
                                    output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                                }
                                else
                                {
                                    CR = new PSPDEV();
                                    CR.Name = dev[0];
                                    CR.Type = "TransformLine";
                                    CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                                    if (CR != null)
                                    {
                                        if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange)
                                        {
                                            dev[11] = "1";
                                        }
                                        else
                                        {
                                            dev[11] = "0";
                                        }
                                        output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                                    }
                                }

                                strLine = readLine.ReadLine();
                                strLine2 = readLine2.ReadLine();
                            }
                            readLine.Close();
                            readLine2.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            }
                            op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                            str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                            str1.Write(output);
                            str1.Close();

                            ex = new Excel.Application();
                            ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                            xSheet = (Excel.Worksheet)ex.Worksheets[1];
                            ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);

                            result1 = new Excel.Application();
                            result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                            newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                            newWorksheet.Name = "线路电流";
                            xSheet.Name = "母线潮流";
                            ex.Visible = true;

                            tempSheet.Cells.Select();
                            tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                            newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                            xSheet.Rows.AutoFit();
                            xSheet.Columns.AutoFit();
                            newWorksheet.Rows.AutoFit();
                            newWorksheet.Columns.AutoFit();
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 9]).MergeCells = true;
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20;
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体";
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            xSheet.get_Range(xSheet.Cells[5, 1], xSheet.Cells[5, 9]).Interior.ColorIndex = 45;
                            xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            xSheet.get_Range(xSheet.Cells[6, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                            xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 9]).MergeCells = true;
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20;
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体";
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            newWorksheet.get_Range(newWorksheet.Cells[5, 1], newWorksheet.Cells[5, 8]).Interior.ColorIndex = 45;
                            newWorksheet.get_Range(newWorksheet.Cells[6, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            newWorksheet.get_Range(newWorksheet.Cells[6, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                            newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                            //op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fck.excel"), FileMode.OpenOrCreate);
                            //str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));

                            string fn = tlVectorControl1.SVGDocument.FileName;

                            //result1.Save(System.Windows.Forms.Application.StartupPath + "\\fck.xls");

                            newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + fn + "高斯-赛德尔计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);

                            //str1.Write();
                            //op.Close();

                            System.Windows.Forms.Clipboard.Clear();
                            result1.Workbooks.Close();
                            result1.Quit();

                        }
                        catch (System.Exception e1)
                        {
                            MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }

                        break;
                    case "N_RZYzResult":
                        try
                        {
                            if (!Check())
                            {
                                return;
                            }
                            ZYZ zyz = new ZYZ();
                            zyz.CurrentCal();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "最优乘子法计算结果.xls"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "最优乘子法计算结果.xls");
                                //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls");
                            }

                            double yinzi = 0, capability = 0, volt = 0, current = 0, Rad_to_Deg = 57.29577951;
                            PSPDEV benchmark = new PSPDEV();
                            benchmark.Type = "power";
                            benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark);
                            if (list3 == null)
                            {
                                MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            foreach (PSPDEV dev in list3)
                            {
                                yinzi = Convert.ToDouble(dev.PowerFactor);
                                capability = Convert.ToDouble(dev.StandardCurrent);
                                volt = Convert.ToDouble(dev.StandardVolt);
                                if (dev.PowerFactor == 0)
                                {
                                    yinzi = 1;
                                }
                                if (dev.StandardCurrent == 0)
                                {
                                    capability = 1;
                                }
                                if (dev.StandardVolt == 0)
                                {
                                    volt = 1;
                                }
                                current = capability / (Math.Sqrt(3) * volt);
                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF4.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF4.txt", FileMode.Open);
                            readLine = new StreamReader(dh);

                            charSplit = new char[] { ' ' };
                            strLine = readLine.ReadLine();

                            output += ("全网母线(发电、负荷)结果报表 " + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("母线名" + "," + "电压幅值" + "," + "电压相角" + "," + "有功发电" + "," + "无功发电" + "," + "有功负荷" + "," + "无功负荷" + "," + "越限标志" + "," + "过载标志" + "\r\n");
                            int count = 0;
                            while (strLine != null && strLine != "")
                            {
                                array1 = strLine.Split(charSplit);
                                string[] dev = new string[9];
                                dev.Initialize();
                                int i = 0;
                                count++;
                                PSPDEV CR = new PSPDEV();
                                CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                foreach (string str in array1)
                                {
                                    if (str != "")
                                    {
                                        if (str != "NaN")
                                        {
                                            dev[i++] = Convert.ToDouble(str).ToString();
                                        }
                                        else
                                        {
                                            dev[i++] = str;
                                        }

                                    }

                                }

                                CR.Number = Convert.ToInt32(dev[0]);
                                CR.Type = "Use";
                                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR);
                                double vTemp = Convert.ToDouble(dev[1]) * volt;
                                double vTemp1 = volt * 95 / 100;
                                double vTemp2 = volt * 105 / 100;

                                if (vTemp >= vTemp1 && vTemp <= vTemp2)
                                {
                                    dev[5] = "0";
                                }
                                else
                                {
                                    dev[5] = "1";
                                }
                                if (Convert.ToDouble(dev[3]) * capability > Convert.ToDouble(CR.Burthen))
                                {
                                    dev[6] = "1";
                                }
                                else
                                {
                                    dev[6] = "0";
                                }
                                if (Convert.ToDouble(dev[3]) < 0)
                                {

                                    output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + "0" + "," + "0" + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + dev[5] + "," + dev[6] + "\r\n";
                                }
                                else
                                {

                                    output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + "0" + "," + "0" + "," + dev[5] + "," + dev[6] + "\r\n";
                                }
                                strLine = readLine.ReadLine();
                            }
                            PSPDEV ct = new PSPDEV();
                            ct.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            ct.Type = "Use";
                            IList cont = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", ct);
                            if (count < cont.Count)
                            {
                                MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                readLine.Close();
                                return;

                            }
                            readLine.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                            }
                            op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                            str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                            str1.Write(output);
                            str1.Close();

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH4.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH4.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH4.txt", FileMode.Open);
                            dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH4.txt", FileMode.Open);
                            readLine2 = new StreamReader(dh2);
                            readLine = new StreamReader(dh);
                            charSplit = new char[] { ' ' };
                            strLine = readLine.ReadLine();
                            strLine2 = readLine2.ReadLine();

                            output = null;

                            output += ("全网交流线结果报表" + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "," + "\r\n");
                            while (strLine != null && strLine2 != null && strLine != "" && strLine2 != "")
                            {
                                array1 = strLine.Split(charSplit);
                                array2 = strLine2.Split(charSplit2);

                                string[] dev = new string[20];
                                dev.Initialize();
                                int i = 0;
                                PSPDEV CR = new PSPDEV();
                                CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                foreach (string str in array1)
                                {
                                    if (str != "")
                                    {
                                        if (i == 0)
                                        {
                                            dev[i++] = str.ToString();
                                        }
                                        else
                                        {
                                            if (str != "NaN")
                                            {
                                                dev[i++] = Convert.ToDouble(str).ToString();
                                            }
                                            else
                                            {
                                                dev[i++] = str;
                                            }

                                        }
                                    }

                                }
                                i = 7;
                                for (int j = 3; j < 5; j++)
                                {
                                    if (array2[j] != "")
                                    {
                                        if (array2[j] != "NaN")
                                        {
                                            dev[i++] = Convert.ToDouble(array2[j]).ToString();
                                        }
                                        else
                                        {
                                            dev[i++] = array2[j];
                                        }
                                    }

                                }
                                CR.Name = dev[0];
                                CR.Type = "Polyline";
                                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);

                                if (CR != null)
                                {
                                    if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange)
                                    {
                                        dev[11] = "1";
                                    }
                                    else
                                    {
                                        dev[11] = "0";
                                    }
                                    output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                                }
                                else
                                {
                                    CR = new PSPDEV();
                                    CR.Name = dev[0];
                                    CR.Type = "TransformLine";
                                    CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                                    if (CR != null)
                                    {
                                        if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange)
                                        {
                                            dev[11] = "1";
                                        }
                                        else
                                        {
                                            dev[11] = "0";
                                        }
                                        output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                                    }
                                }

                                strLine = readLine.ReadLine();
                                strLine2 = readLine2.ReadLine();
                            }
                            readLine.Close();
                            readLine2.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            }
                            op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                            str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                            str1.Write(output);
                            str1.Close();

                            ex = new Excel.Application();
                            ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                            xSheet = (Excel.Worksheet)ex.Worksheets[1];
                            ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);

                            result1 = new Excel.Application();
                            result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                            newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                            newWorksheet.Name = "线路电流";
                            xSheet.Name = "母线潮流";
                            ex.Visible = true;

                            tempSheet.Cells.Select();
                            tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                            newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                            xSheet.Rows.AutoFit();
                            xSheet.Columns.AutoFit();
                            newWorksheet.Rows.AutoFit();
                            newWorksheet.Columns.AutoFit();
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 9]).MergeCells = true;
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20;
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体";
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            xSheet.get_Range(xSheet.Cells[5, 1], xSheet.Cells[5, 9]).Interior.ColorIndex = 45;
                            xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            xSheet.get_Range(xSheet.Cells[6, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                            xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 9]).MergeCells = true;
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20;
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体";
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            newWorksheet.get_Range(newWorksheet.Cells[5, 1], newWorksheet.Cells[5, 8]).Interior.ColorIndex = 45;
                            newWorksheet.get_Range(newWorksheet.Cells[6, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            newWorksheet.get_Range(newWorksheet.Cells[6, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                            newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                            //op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fck.excel"), FileMode.OpenOrCreate);
                            //str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));

                            string fn = tlVectorControl1.SVGDocument.FileName;

                            //result1.Save(System.Windows.Forms.Application.StartupPath + "\\fck.xls");

                            newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + fn + "最优乘子法计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);

                            //str1.Write();
                            //op.Close();

                            System.Windows.Forms.Clipboard.Clear();
                            result1.Workbooks.Close();
                            result1.Quit();

                        }
                        catch (System.Exception e1)
                        {
                            MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }

                        break;
                    case "VoltEvaluation":
                        PspVoltEvaluation();
                        break;
                    case "PowerLoss":
                        try
                        {
                            PSPDEV _dev = new PSPDEV();
                            _dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            _dev.Type = "Polyline";
                            IList list = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", _dev);
                            for (int i = 0; i < list.Count; i++)
                            {
                                PSPDEV _pp = (PSPDEV)list[i];
                                if (_pp.BigP == 0)
                                {
                                    MessageBox.Show("请设置线路" + _pp.Name + "的建设投资。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    return;
                                }
                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);
                            readLine = new StreamReader(dh);
                            charSplit = new char[] { ' ' };
                            strLine = readLine.ReadLine();
                            output = null;
                            output += ("全网交流线结果报表" + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "\r\n");
                            while (strLine != null)
                            {
                                array1 = strLine.Split(charSplit);
                                string[] dev = new string[9];
                                dev.Initialize();
                                int i = 0;
                                PSPDEV CR = new PSPDEV();
                            }
                        }
                        catch (System.Exception e1)
                        {
                            MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }

                        break;
                    case "ZLPResult1":
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                        {
                        }
                        else
                        {
                            return;
                        }
                        dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);
                        readLine = new StreamReader(dh);
                        charSplit = new char[] { ' ' };
                        strLine = readLine.ReadLine();
                        output = null;
                        output += ("全网交流线结果报表" + "\r\n" + "\r\n");
                        output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                        output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "\r\n");
                        while (strLine != null)
                        {
                            array1 = strLine.Split(charSplit);
                            string[] dev = new string[9];
                            dev.Initialize();
                            int i = 0;
                            PSPDEV CR = new PSPDEV();
                            CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                            foreach (string str in array1)
                            {
                                if (str != "")
                                {
                                    if (str != "NaN")
                                    {
                                        dev[i++] = Convert.ToDouble(str).ToString();
                                    }
                                    else
                                    {
                                        dev[i++] = str;
                                    }

                                }

                            }
                            CR.Number = Convert.ToInt32(dev[0]);
                            CR.Type = "Polyline";
                            CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR);
                            output += CR.Name + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "\r\n";
                            strLine = readLine.ReadLine();
                        }
                        readLine.Close();
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                        }
                        op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                        str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                        str1.Write(output);
                        str1.Close();

                        ex = new Excel.Application();
                        ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                        ex.Visible = true;

                        break;

                    case "ZLAResult1":

                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt"))
                        {
                        }
                        else
                        {
                            return;
                        }
                        dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH1.txt", FileMode.Open);
                        readLine = new StreamReader(dh);
                        charSplit = new char[] { ' ' };
                        strLine = readLine.ReadLine();
                        output = null;

                        output += ("支路名称" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "\r\n");
                        while (strLine != null)
                        {
                            array1 = strLine.Split(charSplit);
                            string[] dev = new string[9];
                            dev.Initialize();
                            int i = 0;
                            PSPDEV CR = new PSPDEV();
                            CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                            foreach (string str in array1)
                            {
                                if (str != "")
                                {
                                    if (str != "NaN")
                                    {
                                        dev[i++] = Convert.ToDouble(str).ToString();
                                    }
                                    else
                                    {
                                        dev[i++] = str;
                                    }

                                }

                            }
                            CR.Number = Convert.ToInt32(dev[0]);
                            CR.Type = "Polyline";
                            CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR);
                            output += CR.Name + "," + dev[3] + "," + dev[4] + "," + dev[5] + "\r\n";
                            strLine = readLine.ReadLine();
                        }
                        readLine.Close();
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                        }
                        op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                        str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                        str1.Write(output);
                        str1.Close();

                        ex = new Excel.Application();
                        ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                        ex.Visible = true;

                        break;

                    case "PQResult":
                        try
                        {
                            if (!CheckPQ())
                            {
                                return;
                            }
                            PQ_PowerFlowCalClass pq = new PQ_PowerFlowCalClass();
                            pq.CurrentCal();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "PQ法计算结果.xls"))
                            {
                                //System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "PQ法计算结果.xls");
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "PQ法计算结果.xls");

                            }
                            double yinzi = 0, capability = 0, volt = 0, current = 0, Rad_to_Deg = 57.29577951;
                            PSPDEV benchmark = new PSPDEV();
                            benchmark.Type = "power";
                            benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark);
                            if (list3 == null)
                            {
                                MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            foreach (PSPDEV dev in list3)
                            {
                                yinzi = Convert.ToDouble(dev.PowerFactor);
                                capability = Convert.ToDouble(dev.StandardCurrent);
                                volt = Convert.ToDouble(dev.StandardVolt);
                                if (dev.PowerFactor == 0)
                                {
                                    yinzi = 1;
                                }
                                if (dev.StandardCurrent == 0)
                                {
                                    capability = 1;
                                }
                                if (dev.StandardVolt == 0)
                                {
                                    volt = 1;
                                }
                                current = capability / (Math.Sqrt(3) * volt);

                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF2.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF2.txt", FileMode.Open);
                            readLine = new StreamReader(dh);

                            charSplit = new char[] { ' ' };
                            strLine = readLine.ReadLine();
                            output = null;
                            int count = 0;
                            output += ("全网母线(发电、负荷)结果报表 " + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("母线名" + "," + "电压幅值" + "," + "电压相角" + "," + "有功发电" + "," + "无功发电" + "," + "有功负荷" + "," + "无功负荷" + "," + "越限标志" + "," + "过载标志" + "\r\n");
                            while (strLine != null && strLine != "")
                            {
                                array1 = strLine.Split(charSplit);
                                string[] dev = new string[9];
                                dev.Initialize();
                                int i = 0;
                                count++;
                                PSPDEV CR = new PSPDEV();
                                CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                foreach (string str in array1)
                                {
                                    if (str != "")
                                    {
                                        if (str != "NaN")
                                        {
                                            dev[i++] = Convert.ToDouble(str).ToString();
                                        }
                                        else
                                        {
                                            dev[i++] = str;
                                        }

                                    }

                                }

                                CR.Number = Convert.ToInt32(dev[0]);
                                CR.Type = "Use";
                                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR);
                                double vTemp = Convert.ToDouble(dev[1]) * volt;
                                double vTemp1 = volt * 95 / 100;
                                double vTemp2 = volt * 105 / 100;

                                if (vTemp >= vTemp1 && vTemp <= vTemp2)
                                {
                                    dev[5] = "0";
                                }
                                else
                                {
                                    dev[5] = "1";
                                }
                                if (Convert.ToDouble(dev[3]) * capability > Convert.ToDouble(CR.Burthen))
                                {
                                    dev[6] = "1";
                                }
                                else
                                {
                                    dev[6] = "0";
                                }
                                if (Convert.ToDouble(dev[3]) < 0)
                                {

                                    output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2])).ToString() + "," + "0" + "," + "0" + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + dev[5] + "," + dev[6] + "\r\n";
                                }
                                else
                                {

                                    output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2])).ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + "0" + "," + "0" + "," + dev[5] + "," + dev[6] + "\r\n";
                                }
                                strLine = readLine.ReadLine();
                            }
                            PSPDEV ct = new PSPDEV();
                            ct.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            ct.Type = "Use";
                            IList cont = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", ct);
                            if (count < cont.Count)
                            {
                                MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                readLine.Close();
                                return;

                            }
                            readLine.Close();

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                            }
                            op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                            str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                            str1.Write(output);
                            str1.Close();

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH2.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH2.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH2.txt", FileMode.Open);
                            dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH2.txt", FileMode.Open);
                            readLine2 = new StreamReader(dh2);

                            readLine = new StreamReader(dh);
                            charSplit = new char[] { ' ' };
                            strLine = readLine.ReadLine();
                            charSplit2 = new char[] { ' ' };
                            strLine2 = readLine2.ReadLine();
                            output = null;
                            output += ("全网交流线结果报表" + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "," + "\r\n");
                            while (strLine != null && strLine2 != null && strLine != "" && strLine2 != "")
                            {
                                array1 = strLine.Split(charSplit);
                                array2 = strLine2.Split(charSplit2);

                                string[] dev = new string[20];
                                dev.Initialize();
                                int i = 0;
                                PSPDEV CR = new PSPDEV();
                                CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                foreach (string str in array1)
                                {
                                    if (str != "")
                                    {
                                        if (i == 0)
                                        {
                                            dev[i++] = str.ToString();
                                        }
                                        else
                                        {
                                            if (str != "NaN")
                                            {
                                                dev[i++] = Convert.ToDouble(str).ToString();
                                            }
                                            else
                                            {
                                                dev[i++] = str;
                                            }

                                        }
                                    }

                                }
                                i = 7;
                                for (int j = 3; j < 5; j++)
                                {
                                    if (array2[j] != "")
                                    {
                                        if (array2[j] != "NaN")
                                        {
                                            dev[i++] = Convert.ToDouble(array2[j]).ToString();
                                        }
                                        else
                                        {
                                            dev[i++] = array2[j];
                                        }
                                    }

                                }
                                CR.Name = dev[0];
                                CR.Type = "Polyline";
                                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);

                                if (CR != null)
                                {
                                    if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange)
                                    {
                                        dev[11] = "1";
                                    }
                                    else
                                    {
                                        dev[11] = "0";
                                    }
                                    output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                                }
                                else
                                {
                                    CR = new PSPDEV();
                                    CR.Name = dev[0];
                                    CR.Type = "TransformLine";
                                    CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                                    if (CR != null)
                                    {
                                        if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange)
                                        {
                                            dev[11] = "1";
                                        }
                                        else
                                        {
                                            dev[11] = "0";
                                        }
                                        output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                                    }
                                }

                                strLine = readLine.ReadLine();
                                strLine2 = readLine2.ReadLine();
                            }
                            readLine.Close();
                            readLine2.Close();

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            }
                            op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                            str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                            str1.Write(output);
                            str1.Close();

                            Excel.Application ex2 = new Excel.Application();
                            ex2.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                            Excel.Worksheet xSheet2 = (Excel.Worksheet)ex2.Worksheets[1];
                            ex2.Worksheets.Add(System.Reflection.Missing.Value, xSheet2, 1, System.Reflection.Missing.Value);

                            Excel.Application result11 = new Excel.Application();
                            result11.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            Excel.Application result12 = new Excel.Application();

                            Excel.Worksheet tempSheet11 = (Excel.Worksheet)result11.Worksheets.get_Item(1);

                            Excel.Worksheet newWorksheet11 = (Excel.Worksheet)ex2.Worksheets.get_Item(2);

                            newWorksheet11.Name = "线路电流";
                            xSheet2.Name = "母线潮流";

                            ex2.Visible = true;
                            tempSheet11.Cells.Select();
                            tempSheet11.Cells.Copy(System.Reflection.Missing.Value);
                            newWorksheet11.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                            xSheet2.Rows.AutoFit();
                            xSheet2.Columns.AutoFit();
                            newWorksheet11.Rows.AutoFit();
                            newWorksheet11.Columns.AutoFit();

                            xSheet2.get_Range(xSheet2.Cells[1, 1], xSheet2.Cells[1, 9]).MergeCells = true;
                            xSheet2.get_Range(xSheet2.Cells[1, 1], xSheet2.Cells[1, 1]).Font.Size = 20;
                            xSheet2.get_Range(xSheet2.Cells[1, 1], xSheet2.Cells[1, 1]).Font.Name = "黑体";
                            xSheet2.get_Range(xSheet2.Cells[1, 1], xSheet2.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            xSheet2.get_Range(xSheet2.Cells[5, 1], xSheet2.Cells[5, 9]).Interior.ColorIndex = 45;
                            xSheet2.get_Range(xSheet2.Cells[6, 1], xSheet2.Cells[xSheet2.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            xSheet2.get_Range(xSheet2.Cells[6, 2], xSheet2.Cells[xSheet2.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                            xSheet2.get_Range(xSheet2.Cells[3, 1], xSheet2.Cells[xSheet2.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                            newWorksheet11.get_Range(newWorksheet11.Cells[1, 1], newWorksheet11.Cells[1, 9]).MergeCells = true;
                            newWorksheet11.get_Range(newWorksheet11.Cells[1, 1], newWorksheet11.Cells[1, 1]).Font.Size = 20;
                            newWorksheet11.get_Range(newWorksheet11.Cells[1, 1], newWorksheet11.Cells[1, 1]).Font.Name = "黑体";
                            newWorksheet11.get_Range(newWorksheet11.Cells[1, 1], newWorksheet11.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            newWorksheet11.get_Range(newWorksheet11.Cells[5, 1], newWorksheet11.Cells[5, 8]).Interior.ColorIndex = 45;
                            newWorksheet11.get_Range(newWorksheet11.Cells[6, 1], newWorksheet11.Cells[newWorksheet11.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            newWorksheet11.get_Range(newWorksheet11.Cells[6, 2], newWorksheet11.Cells[newWorksheet11.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                            newWorksheet11.get_Range(newWorksheet11.Cells[3, 1], newWorksheet11.Cells[newWorksheet11.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                            string fn = tlVectorControl1.SVGDocument.FileName;

                            //result1.Save(System.Windows.Forms.Application.StartupPath + "\\fck.xls");

                            newWorksheet11.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + fn + "PQ法计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);

                            System.Windows.Forms.Clipboard.Clear();

                            result11.Workbooks.Close();
                            result11.Quit();

                        }
                        catch (System.Exception e3)
                        {
                            MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }

                        break;

                    case "mDLR":

                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.txt"))
                        {
                        }
                        else
                        {
                            return;
                        }
                        int ij = 1;
                        dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\result.txt", FileMode.Open);
                        readLine = new StreamReader(dh);

                        charSplit = new char[] { ' ' };
                        strLine = readLine.ReadLine();
                        output = null;

                        FileStream dh5 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\dlb.txt", FileMode.Open);
                        StreamReader readLine5 = new StreamReader(dh5);
                        string strLine5;
                        string[] array5;
                        char[] charSplit5 = new char[] { ' ' };
                        strLine5 = readLine5.ReadLine();
                        array5 = strLine5.Split(charSplit5);

                        output += ("全网短路计算结果报表" + "\r\n" + "\r\n");

                        PSPDEV CR235 = new PSPDEV();
                        CR235.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        CR235.Number = Convert.ToInt32(array5[0]);
                        CR235.Type = array5[1];
                        double ibb = 0;
                        double temp11 = 0;
                        CR235 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR235);

                        if (CR235 == null)
                        {
                            MessageBox.Show("错误!当前图元与结果报表不符!");
                            readLine.Close();
                            readLine5.Close();
                            return;
                        }
                        output += ("短路点" + ":" + " " + CR235.Name + "   " + "故障类型" + ":" + " " + array5[2] + "\r\n" + "\r\n");

                        output += ("名称" + "," + "零序电流" + "," + "正序电流" + "," + "负序电流" + "," + "A相电流" + "," + "B相电流" + "," + "C相电流" + "," + "短路电流" + "," + "短路容量" + "," + "\r\n");
                        while (strLine != null)
                        {
                            array1 = strLine.Split(charSplit);
                            string[] dev = new string[9];
                            dev.Initialize();
                            int i = 0;
                            PSPDEV CR2 = new PSPDEV();
                            CR2.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            foreach (string str in array1)
                            {
                                if (str != "")
                                {
                                    if (str != "NaN")
                                    {
                                        dev[i++] = Convert.ToDouble(str).ToString();
                                    }
                                    else
                                    {
                                        dev[i++] = str;
                                    }

                                }

                            }

                            //CR2.Number = Convert.ToInt32(dev[2]);
                            //CR2.Type = "Use";
                            //CR2 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR2);
                            CR2.Number = Convert.ToInt32(array5[0]);
                            CR2.Type = array5[1];
                            string nodeName = CR2.Name;

                            CR2 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR2);
                            int vr = Convert.ToInt32(CR2.VoltR);

                            switch (vr)
                            {
                                case 220:
                                    {
                                        ibb = 251.03;
                                        for (int j = 3; j < 9; j++)
                                        {
                                            temp11 = Convert.ToDouble(dev[j]) * ibb * 0.001;
                                            dev[j] = temp11.ToString();
                                        }
                                        ibb = Convert.ToDouble(dev[4]) * 3;
                                        temp11 = 1.732 * ibb * 230;

                                    }
                                    break;
                                case 500:
                                    {
                                        ibb = 104.98;
                                        for (int j = 3; j < 9; j++)
                                        {
                                            temp11 = Convert.ToDouble(dev[j]) * ibb * 0.001;
                                            dev[j] = temp11.ToString();
                                        }
                                        ibb = Convert.ToDouble(dev[4]) * 3;
                                        temp11 = 1.732 * ibb * 550;

                                    }
                                    break;
                                default:
                                    { }
                                    break;
                            }
                            if (ij == 1)
                            {
                                output += CR2.Name + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," + ibb.ToString() + "," + temp11.ToString() + "," + "\r\n";
                            }
                            else
                            {
                                CR2.Number = Convert.ToInt32(dev[2]);

                                CR2.Type = "Polyline";
                                CR2 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR2);

                                //output += CR2.Name + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "\r\n";
                                if (CR2 != null)
                                {
                                    output += CR2.Name + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "\r\n";
                                }
                                else if (dev[2] == "500")
                                {
                                    output += nodeName + "故障生成线路" + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "\r\n";
                                }
                            }
                            ij = 0;
                            strLine = readLine.ReadLine();
                        }
                        readLine.Close();
                        readLine5.Close();
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                        }
                        op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                        str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312"));
                        str1.Write(output);
                        str1.Close();

                        ex = new Excel.Application();
                        ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                        //ex.Visible = true;

                        //Excel.Application ex = new Excel.Application();

                        ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                        xSheet = (Excel.Worksheet)ex.Worksheets[1];
                        //ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);

                        //result1 = new Excel.Application();
                        //result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                        //tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                        //Excel.Worksheet newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                        //newWorksheet.Name = "线路电流";
                        xSheet.Name = "短路计算";

                        //tempSheet.Cells.Select();
                        //tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                        //newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);

                        xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 9]).MergeCells = true;
                        xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20;
                        xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体";
                        xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;

                        xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[3, 1]).Font.Name = "楷体_GB2312";

                        xSheet.get_Range(xSheet.Cells[5, 1], xSheet.Cells[5, 9]).Interior.ColorIndex = 45;

                        xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                        xSheet.get_Range(xSheet.Cells[8, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                        xSheet.get_Range(xSheet.Cells[5, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                        System.Windows.Forms.Clipboard.Clear();
                        //result1.Workbooks.Close();
                        //result1.Quit();
                        ex.Visible = true;
                        break;

                    case "mEnclosure":
                        tlVectorControl1.Operation = ToolOperation.Enclosure;

                        break;

                    case "mGroup":
                        tlVectorControl1.Group();
                        break;
                    case "mUnGroup":
                        tlVectorControl1.UnGroup();
                        break;
                    case "mlinelx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Line;
                        break;
                    case "mzxlx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Rightangle;
                        break;
                    case "mqxlx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Spline;
                        break;
                    case "mqzlx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Polyline;
                        break;
                    case "mCJ1":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;
                        csOperation = CustomOperation.OP_MeasureDistance;
                        break;
                    case "powerFactor":
                        PSPDEV pspDev21 = new PSPDEV();

                        //pspDev2.SUID = Guid.NewGuid().ToString();
                        pspDev21.Type = "Power";
                        pspDev21.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        pspDev21 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDAndType", pspDev21);
                        if (pspDev21 != null)
                        {
                        }
                        else
                        {
                            pspDev21 = new PSPDEV();
                            pspDev21.SUID = Guid.NewGuid().ToString();
                            pspDev21.Type = "Power";
                            pspDev21.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            Services.BaseService.Create<PSPDEV>(pspDev21);
                        }
                        powerf ppz = new powerf(pspDev21);
                        if (ppz.ShowDialog() == DialogResult.OK)
                        {
                            pspDev21.PowerFactor = Convert.ToDouble(ppz.powerfactor);
                            pspDev21.StandardVolt = Convert.ToDouble(ppz.standardvolt);
                            pspDev21.StandardCurrent = Convert.ToDouble(ppz.standardcurrent);
                            pspDev21.BigP = Convert.ToDouble(ppz.bigP);
                            Services.BaseService.Update<PSPDEV>(pspDev21);
                            PSPDEV voltall = new PSPDEV();
                            voltall.Type = "Use";
                            voltall.Lable = "电厂";
                            voltall.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList allvolt = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandLableandType", voltall);
                            foreach (PSPDEV dev in allvolt)
                            {
                                dev.OutP = Convert.ToDouble(dev.Burthen) * pspDev21.BigP;
                                //dev.InPutP=dev.Burthen*pspDev2.BigP;
                                dev.OutQ = dev.OutP * Math.Tan(Math.Acos(pspDev21.PowerFactor));
                                Services.BaseService.Update<PSPDEV>(dev);
                            }
                            voltall.Lable = "变电站";
                            allvolt = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandLableandType", voltall);
                            foreach (PSPDEV dev in allvolt)
                            {
                                dev.InPutP = Convert.ToDouble(dev.Burthen) * pspDev21.BigP;
                                //dev.InPutP=dev.Burthen*pspDev2.BigP;
                                dev.InPutQ = dev.InPutP * pspDev21.BigP * Math.Tan(Math.Acos(pspDev21.PowerFactor));
                                Services.BaseService.Update<PSPDEV>(dev);
                            }

                        }

                        break;
                    //if (=null)
                    //{

                    #endregion

                    #region 视图
                    case "mLayer":
                        frmlar.Show();
                        break;
                    case "mOption":
                        tlVectorControl1.SetOption();
                        break;
                    case "mAirscape":
                        frmAirscape fAir = new frmAirscape();
                        fAir.InitData(tlVectorControl1);
                        fAir.Owner = this;
                        fAir.ShowInTaskbar = false;
                        fAir.Top = Screen.PrimaryScreen.WorkingArea.Height - 250;
                        fAir.Left = Screen.PrimaryScreen.WorkingArea.Width - 300;
                        fAir.Show();
                        break;
                    case "btTL":
                        frmGlebeTypeList fgle = new frmGlebeTypeList();
                        fgle.Show();
                        break;
                    #endregion

                    #region 布局,对齐,顺序
                    case "mRotate":
                        if (btItem.Tag is ButtonItem)
                        {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.FlipX();

                        }
                        else
                        {
                            tlVectorControl1.FlipX();
                        }
                        break;
                    case "mToH":

                        tlVectorControl1.FlipX();
                        //this.rotateButton.Tag = btItem;
                        //this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToV":
                        tlVectorControl1.FlipY();
                        //this.rotateButton.Tag = btItem;
                        //this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToLeft":
                        tlVectorControl1.RotateSelection(-90f);
                        ////this.rotateButton.Tag = btItem;
                        ////this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToRight":
                        tlVectorControl1.RotateSelection(90f);
                        //this.rotateButton.Tag = btItem;
                        //this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mAlign":
                        if (btItem.Tag is ButtonItem)
                        {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.Align(AlignType.Left);

                        }
                        else
                        {
                            tlVectorControl1.Align(AlignType.Left);

                        }
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignLeft":
                        tlVectorControl1.Align(AlignType.Left);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignRight":
                        tlVectorControl1.Align(AlignType.Right);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignTop":
                        tlVectorControl1.Align(AlignType.Top);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignBottom":
                        tlVectorControl1.Align(AlignType.Bottom);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignHorizontalCenter":
                        tlVectorControl1.Align(AlignType.HorizontalCenter);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignVerticalCenter":
                        tlVectorControl1.Align(AlignType.VerticalCenter);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mOrder":
                        if (btItem.Tag is ButtonItem)
                        {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.ChangeLevel(LevelType.Top);

                        }
                        else
                        {
                            tlVectorControl1.ChangeLevel(LevelType.Top);
                        }

                        break;
                    case "mGoTop":
                        tlVectorControl1.ChangeLevel(LevelType.Top);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoUp":
                        tlVectorControl1.ChangeLevel(LevelType.Up);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoDown":
                        tlVectorControl1.ChangeLevel(LevelType.Down);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoBottom":
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    #endregion
                    #region 图元操作
                    case "mCopy":
                        tlVectorControl1.Copy();
                        break;
                    case "mCut":
                        tlVectorControl1.Cut();
                        break;
                    case "mPaste":
                        tlVectorControl1.Paste();
                        break;
                    case "mDelete":
                        if (tlVectorControl1.SVGDocument.CurrentElement is SVG)
                        {
                        }
                        else
                        {
                            if (MessageBox.Show("确定要删除么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                SvgElementCollection collection = tlVectorControl1.SVGDocument.SelectCollection;
                                foreach (XmlElement element in collection)
                                {
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.EleID = element.GetAttribute("id");
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                                    Services.BaseService.Delete<PSPDEV>(pspDev);
                                }
                                tlVectorControl1.Delete();
                            }

                        }
                        break;
                    case "mUodo":
                        tlVectorControl1.Undo();
                        break;
                    case "mRedo":
                        tlVectorControl1.Redo();
                        break;
                    #endregion
                    #region 业务操作

                    case "mXLine":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.XPolyLine;
                        break;
                    case "mYLine":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.YPolyLine;
                        break;

                    case "mSaveGroup":
                        if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1)
                        {
                            string content = "<svg>";
                            SvgElementCollection col = tlVectorControl1.SVGDocument.SelectCollection;
                            for (int i = 0; i < col.Count; i++)
                            {
                                SvgElement _e = (SvgElement)col[i];
                                if (_e.ID != "svg")
                                {
                                    content = content + _e.OuterXml;
                                }
                            }
                            RectangleF rect = tlVectorControl1.DrawArea.viewer.SelectedViewRectangle;

                            content = content + "</svg>";
                            frmSaveGroup fm = new frmSaveGroup();
                            fm.rect = rect;
                            fm.Content = content;
                            fm.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("请至少选择2个图元。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        break;

                    case "mInsert":
                        frmUseGroup fg = new frmUseGroup();
                        if (fg.ShowDialog() == DialogResult.OK)
                        {
                            UseGroup u = fg.SelectedUseGroup;
                            if (u != null)
                            {
                                frmXY xy = new frmXY();
                                if (xy.ShowDialog() == DialogResult.OK)
                                {
                                    decimal x = xy.GetX();
                                    decimal y = xy.GetY();
                                    string content = u.Content;
                                    XmlDocument doc = new XmlDocument();
                                    doc.LoadXml(u.Content);
                                    XmlNodeList list = doc.ChildNodes;
                                    XmlNode _node = list[0];
                                    XmlNodeList sonlist = _node.ChildNodes;
                                    XmlElement ele = tlVectorControl1.SVGDocument.CreateElement("g");
                                    ele.SetAttribute("layer", SvgDocument.currentLayer);
                                    for (int i = 0; i < sonlist.Count; i++)
                                    {
                                        XmlNode _sonnode = sonlist[i];
                                        //string str = _sonnode.OuterXml;
                                        if (_sonnode.Name == "use")
                                        {
                                            string sid = ((XmlElement)_sonnode).GetAttribute("xlink:href");
                                            XmlNode _snode = symbolSelector.SymbolDoc.SelectSingleNode("//*[@id='" + sid.Substring(1) + "']");
                                            tlVectorControl1.SVGDocument.AddDefsElement((SvgElement)_snode);
                                        }
                                        ele.AppendChild(_sonnode);
                                        string ss = ele.OuterXml;
                                    }
                                    //RectangleF r=((Group)ele).GetBounds();
                                    string tr = "matrix(1,0,0,1,";

                                    tr = tr + Convert.ToString(x - Convert.ToDecimal(u.X)) + ",";
                                    tr = tr + Convert.ToString(y - Convert.ToDecimal(u.Y)) + ")";

                                    ele.SetAttribute("transform", tr);
                                    // transform="matrix(1,0,0,1,2558.82,-352.94)"
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(ele);
                                    tlVectorControl1.SVGDocument.SelectCollection.Clear();
                                    tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)ele);
                                    tlVectorControl1.UnGroup();
                                    // tlVectorControl1.Refresh();
                                }
                            }
                        }
                        break;
                    #endregion
                    #region 参数维护
                    case "mNodeParam":
                        frmNodeParam dlgNodeParam = new frmNodeParam(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        dlgNodeParam.ShowDialog();
                        break;
                    case "mLineParam":
                        frmLineParamWJ dlgLineParam = new frmLineParamWJ(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        dlgLineParam.ShowDialog();
                        break;
                    case "mWire":
                        wireTypeParam wirewire = new wireTypeParam();
                        wirewire.ShowDialog();
                        break;
                    case "nTransformLineParam":
                        frmTransformLineParam frmTransfor = new frmTransformLineParam(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        frmTransfor.ShowDialog();
                        break;
                    case "nGNDLineParam":
                        break;
                    case "mLineDL":
                        frmLineParamDL dlgLineParamDL = new frmLineParamDL(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        dlgLineParamDL.ShowDialog();
                        break;
                    case "mFadianDL":
                        frmFadejieDL dlgFadeDL = new frmFadejieDL(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        dlgFadeDL.ShowDialog();
                        break;
                    case "mTest":
                        tlVectorControl1.Operation = ToolOperation.AreaSelect;
                        break;
                    case "mjianLine":

                        if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "4")
                        {
                            zhengtiflag = true;
                            jiqiflag = false;
                            zhongqiflag = false;
                            yuanqiflag = false;
                            jianxiancheck();

                            MessageBox.Show("整体数据减线成功。");
                            Topology2();             //颜色发生变化
                        }
                        if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "1" && zhengtiflag)
                        {
                            jiqiflag = true;
                            zhengtiflag = false;
                            zhongqiflag = false;
                            yuanqiflag = false;
                            jianxiancheck();

                            MessageBox.Show("近期数据减线成功。");
                            Topology2();             //颜色发生变化
                        }
                        if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "2" && jiqiflag)
                        {
                            zhongqiflag = true;
                            jiqiflag = false;
                            yuanqiflag = false;
                            jianxiancheck();

                            MessageBox.Show("中期数据减线成功。");
                            Topology2();             //颜色发生变化
                        }
                        if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "3" && zhongqiflag)
                        {
                            yuanqiflag = true;
                            jiqiflag = false;
                            zhongqiflag = false;
                            jianxiancheck();

                            MessageBox.Show("远期数据减线成功,请查看结果");
                            Topology2();             //颜色发生变化
                        }
                        if (!zhengtiflag && !jiqiflag && !zhongqiflag && !yuanqiflag)
                        {
                            string msg2 = "减线法:\r\n 1、选中整体图层进行网架优化。\r\n 2、将整体图层拷贝到近期图层,然后选中近期图层进行网架优化。\r\n 3、拷贝到中期图层,然后选中中期图层进行网架优化\r\n 4、拷贝到远期图层,然后选中远期图层进行网架优化。";
                            MessageBox.Show(msg2, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        }
                        break;
                    case "mjiaLine":

                        if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "4")
                        {

                            MessageBox.Show("整体图层采用的是减线法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            break;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "1" && zhengtiflag)
                        {
                            jiqiflag = true;
                            zhengtiflag = false;
                            zhongqiflag = false;
                            yuanqiflag = false;
                            addlinecheck();
                            addrightcheck();
                            for (int i = 0; i < ercilinedengdai.Count; i++)
                            {
                                ercilinedengdai[i].LineStatus = "运行";
                                Services.BaseService.Update<PSPDEV>(ercilinedengdai[i]);
                            }
                            for (int i = 0; i < lineyiyou.Count; i++)
                            {
                                lineyiyou[i].LineStatus = "待选";
                                Services.BaseService.Update<PSPDEV>(lineyiyou[i]);
                            }
                            MessageBox.Show("近期数据加线成功。");
                            Topology2();             //颜色发生变化
                        }
                        if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "2" && jiqiflag)
                        {
                            zhongqiflag = true;
                            jiqiflag = false;
                            yuanqiflag = false;
                            addlinecheck();
                            addrightcheck();
                            for (int i = 0; i < ercilinedengdai.Count; i++)
                            {
                                ercilinedengdai[i].LineStatus = "运行";
                                Services.BaseService.Update<PSPDEV>(ercilinedengdai[i]);
                            }
                            for (int i = 0; i < lineyiyou.Count; i++)
                            {
                                lineyiyou[i].LineStatus = "待选";
                                Services.BaseService.Update<PSPDEV>(lineyiyou[i]);
                            }
                            MessageBox.Show("中期数据加线成功。");
                            Topology2();             //颜色发生变化
                        }
                        if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "3" && zhongqiflag)
                        {
                            yuanqiflag = true;
                            jiqiflag = false;
                            zhongqiflag = false;
                            addlinecheck();
                            addrightcheck();
                            for (int i = 0; i < ercilinedengdai.Count; i++)
                            {
                                ercilinedengdai[i].LineStatus = "运行";
                                Services.BaseService.Update<PSPDEV>(ercilinedengdai[i]);
                            }
                            for (int i = 0; i < lineyiyou.Count; i++)
                            {
                                lineyiyou[i].LineStatus = "待选";
                                Services.BaseService.Update<PSPDEV>(lineyiyou[i]);
                            }
                            MessageBox.Show("远期数据加线成功。请查看优化结果");
                            Topology2();             //颜色发生变化
                        }
                        if (!zhengtiflag && !jiqiflag && !zhongqiflag && !yuanqiflag)
                        {
                            string msg2 = "加线法:\r\n 1、选中整体图层进行网架优化,此时采用的是减线法。\r\n 2、将整体图层拷贝到近期图层,然后选中近期图层进行网架优化。\r\n 3、拷贝到中期图层,然后选中中期图层进行网架优化\r\n 4、拷贝到远期图层,然后选中远期图层进行网架优化。";
                            MessageBox.Show(msg2, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            break;
                        }
                        break;

                    case "YhResult":       //优化结果
                        if (yuanqiflag)
                        {
                            frmGProList p1 = new frmGProList();
                            p1.Show();
                            p1.LoadData(LoadData());
                        }
                        else
                            MessageBox.Show("请依次做完各个时期的优化,再看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        break;
                    #endregion
                    #region 参数维护
                    case "m_in":
                        if (tlVectorControl1.SVGDocument.CurrentLayer.ID != tlVectorControl1.SVGDocument.SvgdataUid + "5")
                        {
                            MessageBox.Show("请选择背景参考层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        StringBuilder txt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"1500\" height=\"1000\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\" transform=\"matrix(1 0 0 1 0 1)\"><defs>");
                        StringBuilder Allcontent = new StringBuilder();
                        string svgdefs = "";
                        string layertxt = "";

                        frmLayerSel sel = new frmLayerSel();
                        if (sel.ShowDialog() == DialogResult.OK)
                        {
                            ArrayList tlist = sel.LayList;
                            SVG_SYMBOL sym = new SVG_SYMBOL();
                            sym.svgID = oldsid;
                            IList<SVG_SYMBOL> symlist = Services.BaseService.GetList<SVG_SYMBOL>("SelectSVG_SYMBOLBySvgID", sym);
                            foreach (SVG_SYMBOL _sym in symlist)
                            {
                                svgdefs = svgdefs + _sym.XML;
                            }
                            txt.Append(svgdefs + "</defs>");
                            for (int i = 0; i < tlist.Count; i++)
                            {
                                SVG_LAYER lar = new SVG_LAYER();
                                lar.svgID = oldsid;
                                lar.SUID = ((SVG_LAYER)tlist[i]).SUID;
                                lar = (SVG_LAYER)Services.BaseService.GetObject("SelectSVG_LAYERByKey", lar);
                                layertxt = layertxt + "<layer id=\"" + lar.SUID + "\" label=\"" + lar.NAME + "\" layerType=\"" + lar.layerType + "\" visibility=\"" + lar.visibility + "\" ParentID=\"" + lar.YearID + "\" IsSelect=\"" + lar.IsSelect + "\" />";
                                Allcontent.Append(lar.XML);
                            }
                            txt.Append(layertxt);
                            txt.Append(Allcontent.ToString() + "</svg>");
                            SvgDocument document = new SvgDocument();
                            document.LoadXml(txt.ToString());
                            document.SvgdataUid = oldsid;
                            XmlNodeList xlist = document.SelectNodes("svg/polyline [@IsLead='1']");
                            for (int i = 0; i < xlist.Count; i++)
                            {
                                SvgElement gra = xlist[i] as SvgElement;
                                gra.SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "5");
                                ((IGraph)gra).Layer = tlVectorControl1.SVGDocument.CurrentLayer;
                                tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)gra);

                            }
                            XmlNodeList xlist2 = document.SelectNodes("svg/use");
                            for (int i = 0; i < xlist2.Count; i++)
                            {
                                SvgElement gra = xlist2[i] as SvgElement;
                                gra.SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "5");
                                ((IGraph)gra).Layer = tlVectorControl1.SVGDocument.CurrentLayer;
                                tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)gra);

                            }
                            tlVectorControl1.Refresh();
                            MessageBox.Show("导入数据成功。");
                        }

                        break;
                    case "m_1to2"://近期

                        //删除掉原来元素

                        deltall(tlVectorControl1.SVGDocument.SvgdataUid + "1");
                        //********
                        ArrayList sel_line1 = new ArrayList();
                        LayerGrade l1 = new LayerGrade();
                        l1.Type = "1";
                        l1.SvgDataUid = oldsid;
                        IList ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
                        if (ttlist.Count > 0)
                        {
                            LayerGrade n1 = (LayerGrade)ttlist[0];
                            try
                            {
                                int yy = Convert.ToInt32(n1.Name.Substring(0, 4));
                                XmlNodeList list1to2 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4" + "' and @year<='" + yy + "']");
                                for (int i = 0; i < list1to2.Count; i++)
                                {
                                    SvgElement gra = list1to2[i] as SvgElement;

                                    XmlNode temp = gra.Clone();
                                    ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "1");
                                    XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp);
                                    //加入节点的名称

                                    XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + gra.GetAttribute("id") + "']");
                                    XmlNode textemp = text.Clone();
                                    ((SvgElement)textemp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "1");
                                    ((SvgElement)textemp).SetAttribute("ParentID", ((SvgElement)temp).GetAttribute("id"));
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)textemp);
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.EleID = gra.ID;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4";
                                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                                    if (pspDev != null)
                                    {
                                        pspDev.SUID = Guid.NewGuid().ToString();
                                        pspDev.EleID = ((SvgElement)newnode).ID;
                                        pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "1";
                                        Services.BaseService.Create<PSPDEV>(pspDev);
                                    }
                                }
                                XmlNodeList listline = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4']");
                                //for (int i = 0; i < list1to2.Count; i++)
                                //{
                                //    SvgElement temp = list1to2[i] as SvgElement;
                                //    RectangleF ff = ((IGraph)temp).GetBounds();
                                //    Region r = new Region(((IGraph)temp).GetBounds());
                                //    for (int j = 0; j < listline.Count;j++ )
                                //    {
                                //        Polyline pln = listline[j] as Polyline;
                                //        if (r.IsVisible(pln.Points[0]))
                                //        {
                                //            if (!sel_line1.Contains(pln))
                                //            {
                                //                sel_line1.Add(pln);
                                //            }

                                //        }
                                //    }

                                //}
                                for (int i = 0; i < listline.Count; i++)
                                {
                                    bool firstnodeflag = false; bool lastnodeflag = false;
                                    Polyline pln = listline[i] as Polyline;
                                    PSPDEV psp = new PSPDEV();
                                    psp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4";
                                    psp.EleID = pln.ID;
                                    psp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", psp);
                                    if (psp.LineStatus != "等待")
                                    {
                                        for (int j = 0; j < list1to2.Count; j++)
                                        {
                                            SvgElement temp = list1to2[j] as SvgElement;
                                            Region ff = new Region(((IGraph)temp).GetBounds());
                                            if (ff.IsVisible(pln.Points[0]))
                                            {
                                                firstnodeflag = true;
                                            }
                                            if (ff.IsVisible(pln.Points[1]))
                                            {
                                                lastnodeflag = true;
                                            }
                                        }
                                        if (firstnodeflag && lastnodeflag && !sel_line1.Contains(pln))
                                        {
                                            sel_line1.Add(pln);
                                        }

                                    }

                                }
                                for (int i = 0; i < sel_line1.Count; i++)
                                {
                                    SvgElement gra = sel_line1[i] as SvgElement;

                                    XmlNode temp = gra.Clone();
                                    ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "1");
                                    XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp);
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.EleID = gra.ID;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4";
                                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                                    if (pspDev != null)
                                    {
                                        pspDev.SUID = Guid.NewGuid().ToString();
                                        pspDev.EleID = ((SvgElement)newnode).ID;
                                        pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "1";
                                        Services.BaseService.Create<PSPDEV>(pspDev);
                                    }
                                }
                                MessageBox.Show("数据处理成功。");
                                Topology2();             //颜色发生变化
                            }
                            catch
                            {
                                MessageBox.Show("选择的年份前4位不是数字。");
                            }
                        }
                        break;
                    case "m_2to3"://中期
                        deltall(tlVectorControl1.SVGDocument.SvgdataUid + "2");
                        ArrayList sel_line2 = new ArrayList();
                        LayerGrade l1_2 = new LayerGrade();
                        l1_2.Type = "1";
                        l1_2.SvgDataUid = oldsid;
                        l1_2 = (LayerGrade)Services.BaseService.GetObject("SelectLayerGradeList5", l1_2);
                        LayerGrade l2_2 = new LayerGrade();
                        l2_2.Type = "2";
                        l2_2.SvgDataUid = oldsid;
                        l2_2 = (LayerGrade)Services.BaseService.GetObject("SelectLayerGradeList5", l2_2);
                        if (l1_2 != null && l2_2 != null)
                        {

                            try
                            {
                                //整体规划层里的中期数据

                                int yy1 = Convert.ToInt32(l1_2.Name.Substring(0, 4));
                                int yy2 = Convert.ToInt32(l2_2.Name.Substring(0, 4));

                                XmlNodeList list1to2 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4" + "' and @year>'" + yy1 + "' and @year<='" + yy2 + "']");
                                for (int i = 0; i < list1to2.Count; i++)
                                {
                                    SvgElement gra = list1to2[i] as SvgElement;
                                    XmlNode temp = gra.Clone();
                                    ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "2");
                                    XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp);
                                    //加入节点的名称

                                    XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + gra.GetAttribute("id") + "']");
                                    XmlNode textemp = text.Clone();
                                    ((SvgElement)textemp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "2");
                                    ((SvgElement)textemp).SetAttribute("ParentID", ((SvgElement)temp).GetAttribute("id"));
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)textemp);
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.EleID = gra.ID;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4";
                                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                                    if (pspDev != null)
                                    {
                                        pspDev.SUID = Guid.NewGuid().ToString();
                                        pspDev.EleID = ((SvgElement)newnode).ID;
                                        pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "2";
                                        Services.BaseService.Create<PSPDEV>(pspDev);
                                    }
                                }

                                XmlNodeList listline2 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4']");
                                XmlNodeList list1to1 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4" + "' and @year<='" + yy1 + "']");
                                for (int i = 0; i < listline2.Count; i++)
                                {
                                    bool firstnodeflag = false; bool lastnodeflag = false; bool jinqifirstnodeflag = false; bool jinqilastnodeflag = false;
                                    Polyline pln = listline2[i] as Polyline;
                                    PSPDEV psp = new PSPDEV();
                                    psp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4";
                                    psp.EleID = pln.ID;
                                    psp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", psp);
                                    if (psp.LineStatus != "等待")
                                    {
                                        for (int j = 0; j < list1to2.Count; j++)
                                        {
                                            SvgElement temp = list1to2[j] as SvgElement;
                                            Region ff = new Region(((IGraph)temp).GetBounds());
                                            if (ff.IsVisible(pln.Points[0]))
                                            {
                                                firstnodeflag = true;
                                            }
                                            if (ff.IsVisible(pln.Points[1]))
                                            {
                                                lastnodeflag = true;
                                            }
                                        }
                                        for (int j = 0; j < list1to1.Count; j++)
                                        {
                                            SvgElement temp = list1to1[j] as SvgElement;
                                            Region ff = new Region(((IGraph)temp).GetBounds());
                                            if (ff.IsVisible(pln.Points[0]))
                                            {
                                                jinqifirstnodeflag = true;
                                            }
                                            if (ff.IsVisible(pln.Points[1]))
                                            {
                                                jinqilastnodeflag = true;
                                            }
                                        }
                                        if (firstnodeflag && lastnodeflag && !sel_line2.Contains(pln))
                                        {
                                            sel_line2.Add(pln);
                                        }
                                        if (firstnodeflag && jinqilastnodeflag && !sel_line2.Contains(pln))
                                        {
                                            sel_line2.Add(pln);
                                        }
                                        if (lastnodeflag && jinqifirstnodeflag && !sel_line2.Contains(pln))
                                        {
                                            sel_line2.Add(pln);
                                        }

                                    }

                                }
                                for (int i = 0; i < sel_line2.Count; i++)
                                {
                                    SvgElement gra = sel_line2[i] as SvgElement;

                                    XmlNode temp = gra.Clone();
                                    ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "2");
                                    XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp);
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.EleID = gra.ID;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4";
                                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                                    if (pspDev != null)
                                    {
                                        pspDev.SUID = Guid.NewGuid().ToString();
                                        pspDev.EleID = ((SvgElement)newnode).ID;
                                        pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "2";
                                        Services.BaseService.Create<PSPDEV>(pspDev);
                                    }
                                }
                                //近期数据
                                XmlNodeList list_1 = tlVectorControl1.SVGDocument.SelectNodes("svg/* [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "1']");
                                for (int i = 0; i < list_1.Count; i++)
                                {
                                    SvgElement gra = list_1[i] as SvgElement;
                                    XmlNode temp = gra.Clone();
                                    ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "2");
                                    XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp);
                                    //加入节点的名称

                                    XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + gra.GetAttribute("id") + "']");
                                    if (text != null)
                                    {
                                        XmlNode textemp = text.Clone();
                                        ((SvgElement)textemp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "2");
                                        ((SvgElement)textemp).SetAttribute("ParentID", ((SvgElement)temp).GetAttribute("id"));
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)textemp);
                                    }

                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.EleID = gra.ID;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "1";
                                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                                    if (pspDev != null)
                                    {
                                        pspDev.SUID = Guid.NewGuid().ToString();
                                        pspDev.EleID = ((SvgElement)newnode).ID;
                                        pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "2";
                                        if (pspDev.LineStatus == "待选")
                                        {
                                            pspDev.LineStatus = "运行";
                                        }
                                        if (pspDev.LineStatus == "等待")
                                        {
                                            pspDev.LineStatus = "待选";
                                        }
                                        Services.BaseService.Create<PSPDEV>(pspDev);
                                    }
                                }
                                MessageBox.Show("数据处理成功。");
                                Topology2();             //颜色发生变化
                            }
                            catch
                            {
                                MessageBox.Show("选择的年份前4位不是数字。");
                            }
                        }
                        break;
                    case "m_3to4"://远期
                        deltall(tlVectorControl1.SVGDocument.SvgdataUid + "3");
                        ArrayList sel_line3 = new ArrayList();
                        LayerGrade l1_3 = new LayerGrade();
                        l1_3.Type = "2";
                        l1_3.SvgDataUid = oldsid;
                        l1_3 = (LayerGrade)Services.BaseService.GetObject("SelectLayerGradeList5", l1_3);
                        LayerGrade l2_3 = new LayerGrade();
                        l2_3.Type = "3";
                        l2_3.SvgDataUid = oldsid;
                        l2_3 = (LayerGrade)Services.BaseService.GetObject("SelectLayerGradeList5", l2_3);
                        if (l1_3 != null && l2_3 != null)
                        {

                            try
                            {
                                //整体规划层里的远期数据

                                int yy1 = Convert.ToInt32(l1_3.Name.Substring(0, 4));
                                int yy2 = Convert.ToInt32(l2_3.Name.Substring(0, 4));
                                XmlNodeList list1to2 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4" + "' and @year>'" + yy1 + "' and @year<='" + yy2 + "']");
                                for (int i = 0; i < list1to2.Count; i++)
                                {
                                    SvgElement gra = list1to2[i] as SvgElement;
                                    XmlNode temp = gra.Clone();
                                    ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "3");
                                    XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp);
                                    XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + gra.GetAttribute("id") + "']");
                                    XmlNode textemp = text.Clone();
                                    ((SvgElement)textemp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "3");
                                    ((SvgElement)textemp).SetAttribute("ParentID", ((SvgElement)temp).GetAttribute("id"));
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)textemp);
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.EleID = gra.ID;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4";
                                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                                    if (pspDev != null)
                                    {
                                        pspDev.SUID = Guid.NewGuid().ToString();
                                        pspDev.EleID = ((SvgElement)newnode).ID;
                                        pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "3";
                                        Services.BaseService.Create<PSPDEV>(pspDev);
                                    }
                                }

                                XmlNodeList listline2 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4']");
                                XmlNodeList list1to1 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4" + "' and @year<='" + yy1 + "']");
                                for (int i = 0; i < listline2.Count; i++)
                                {
                                    bool firstnodeflag = false; bool lastnodeflag = false; bool jinqifirstnodeflag = false; bool jinqilastnodeflag = false;
                                    Polyline pln = listline2[i] as Polyline;
                                    PSPDEV psp = new PSPDEV();
                                    psp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4";
                                    psp.EleID = pln.ID;
                                    psp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", psp);
                                    if (psp.LineStatus != "等待")
                                    {
                                        for (int j = 0; j < list1to2.Count; j++)
                                        {
                                            SvgElement temp = list1to2[j] as SvgElement;
                                            Region ff = new Region(((IGraph)temp).GetBounds());
                                            if (ff.IsVisible(pln.Points[0]))
                                            {
                                                firstnodeflag = true;
                                            }
                                            if (ff.IsVisible(pln.Points[1]))
                                            {
                                                lastnodeflag = true;
                                            }
                                        }
                                        for (int j = 0; j < list1to1.Count; j++)
                                        {
                                            SvgElement temp = list1to1[j] as SvgElement;
                                            Region ff = new Region(((IGraph)temp).GetBounds());
                                            if (ff.IsVisible(pln.Points[0]))
                                            {
                                                jinqifirstnodeflag = true;
                                            }
                                            if (ff.IsVisible(pln.Points[1]))
                                            {
                                                jinqilastnodeflag = true;
                                            }
                                        }
                                        if (firstnodeflag && lastnodeflag && !sel_line3.Contains(pln))
                                        {
                                            sel_line3.Add(pln);
                                        }
                                        if (firstnodeflag && jinqilastnodeflag && !sel_line3.Contains(pln))
                                        {
                                            sel_line3.Add(pln);
                                        }
                                        if (lastnodeflag && jinqifirstnodeflag && !sel_line3.Contains(pln))
                                        {
                                            sel_line3.Add(pln);
                                        }

                                    }

                                }
                                for (int i = 0; i < sel_line3.Count; i++)
                                {
                                    SvgElement gra = sel_line3[i] as SvgElement;

                                    XmlNode temp = gra.Clone();
                                    ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "3");
                                    XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp);
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.EleID = gra.ID;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4";
                                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                                    if (pspDev != null)
                                    {
                                        pspDev.SUID = Guid.NewGuid().ToString();
                                        pspDev.EleID = ((SvgElement)newnode).ID;
                                        pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "3";
                                        Services.BaseService.Create<PSPDEV>(pspDev);
                                    }
                                }
                                //中期数据
                                XmlNodeList list_1 = tlVectorControl1.SVGDocument.SelectNodes("svg/* [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "2']");
                                for (int i = 0; i < list_1.Count; i++)
                                {
                                    SvgElement gra = list_1[i] as SvgElement;
                                    XmlNode temp = gra.Clone();
                                    ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "3");
                                    XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp);
                                    //加入节点的名称

                                    XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + gra.GetAttribute("id") + "']");
                                    if (text != null)
                                    {
                                        XmlNode textemp = text.Clone();
                                        ((SvgElement)textemp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "3");
                                        ((SvgElement)textemp).SetAttribute("ParentID", ((SvgElement)temp).GetAttribute("id"));
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)textemp);
                                    }
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.EleID = gra.ID;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "2";
                                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                                    if (pspDev != null)
                                    {
                                        pspDev.SUID = Guid.NewGuid().ToString();
                                        pspDev.EleID = ((SvgElement)newnode).ID;
                                        pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "3";
                                        if (pspDev.LineStatus == "待选")
                                        {
                                            pspDev.LineStatus = "运行";
                                        }
                                        if (pspDev.LineStatus == "等待")
                                        {
                                            pspDev.LineStatus = "待选";
                                        }
                                        Services.BaseService.Create<PSPDEV>(pspDev);
                                    }
                                }
                                MessageBox.Show("数据处理成功。");
                                Topology2();             //颜色发生变化
                            }
                            catch
                            {
                                MessageBox.Show("选择的年份前4位不是数字。");
                            }
                        }
                        break;
                    #endregion
                }
            }
        }
Example #8
0
        void tlVectorControl1_AddElement(object sender, AddSvgElementEventArgs e)
        {
            //MessageBox.Show(e.SvgElement.ID);
            string larid = tlVectorControl1.SVGDocument.CurrentLayer.ID;

            if (!ChangeLayerList.Contains(larid))
            {
                ChangeLayerList.Add(larid);
            }
            XmlElement temp = e.SvgElement as XmlElement;
            if (temp is Polyline)
            {
                XmlNodeList list2 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline");
                foreach (XmlNode node in list2)
                {
                    PSPDEV dev = new PSPDEV();
                    //(node as Text).InnerText = dev.Name;
                    //XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");

                    PSPDEV dlg11 = new PSPDEV();
                    XmlElement element = node as XmlElement;
                    dev.EleID = element.GetAttribute("id");
                    PSPDEV psp = new PSPDEV();
                    dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    dlg11 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", dev);
                    if (dlg11 == null)
                    {
                        SvgElement element2 = node as SvgElement;
                        tlVectorControl1.SVGDocument.CurrentElement = element2;
                        tlVectorControl1.Delete();
                    }
                }
            }

            if (temp is Use && (temp.GetAttribute("xlink:href").Contains("Substation") || temp.GetAttribute("xlink:href").Contains("Power") || temp.GetAttribute("xlink:href").Contains("motherlinenode")))
            {
                PSPDEV pspDev22 = new PSPDEV();
                //pspDev.EleID = element.GetAttribute("id");
                str_power = getPower(temp.GetAttribute("xlink:href"));
                pspDev22.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                if (temp.GetAttribute("xlink:href").Contains("Substation"))
                {
                    pspDev22.Lable = "变电站";

                }
                else if (temp.GetAttribute("xlink:href").Contains("motherlinenode"))
                {
                    pspDev22.Lable = "母线节点";
                }
                else if (temp.GetAttribute("xlink:href").Contains("Power"))
                {
                    pspDev22.Lable = "电厂";
                }
                frmSubstation dlg = new frmSubstation(pspDev22);
                dlg.Str_Power = str_power;
                if (tlVectorControl1.SVGDocument.FileName.Length > 5)
                {
                    dlg.Str_year = tlVectorControl1.SVGDocument.FileName.Substring(0, 4);
                }

                if (dlg.ShowDialog(this) == DialogResult.OK)
                {

                    //XmlElement temp = tlVectorControl1.SVGDocument.CurrentElement;
                    if (temp != null)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlg.Name;
                        pspName.Type = "Use";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        //if (pspName.Name == "")
                        //{
                        //    MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        //    tlVectorControl1.Delete();
                        //    return;
                        //}
                        if (true)
                        {

                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            if (temp is Polyline)
                            {
                                double x1 = Convert.ToDouble(temp.GetAttribute("x1"));
                                double y1 = Convert.ToDouble(temp.GetAttribute("y1"));
                                double x2 = Convert.ToDouble(temp.GetAttribute("x2"));
                                double y2 = Convert.ToDouble(temp.GetAttribute("y2"));

                                tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                n1.SetAttribute("x", Convert.ToString(x1 + (x2 - x1) / 2));
                                n1.SetAttribute("y", Convert.ToString(y1 + (y2 - y1) / 2));

                            }
                            else
                            {
                                n1.SetAttribute("x", temp.GetAttribute("x"));
                                n1.SetAttribute("y", temp.GetAttribute("y"));
                                RectangleF t = ((IGraph)temp).GetBounds();
                                n1.SetAttribute("x", (t.X - 10).ToString());
                                n1.SetAttribute("y", (t.Y - 10).ToString());
                            }

                            n1.InnerText = dlg.Name;
                            n1.SetAttribute("layer", SvgDocument.currentLayer);
                            n1.SetAttribute("ParentID", temp.GetAttribute("id"));
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            tlVectorControl1.Operation = ToolOperation.Select;
                        }
                        else
                        {
                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            if (temp is Polyline)
                            {
                                double x1 = Convert.ToDouble(temp.GetAttribute("x1"));
                                double y1 = Convert.ToDouble(temp.GetAttribute("y1"));
                                double x2 = Convert.ToDouble(temp.GetAttribute("x2"));
                                double y2 = Convert.ToDouble(temp.GetAttribute("y2"));

                                tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                n1.SetAttribute("x", Convert.ToString(x1 + (x2 - x1) / 2));
                                n1.SetAttribute("y", Convert.ToString(y1 + (y2 - y1) / 2));
                            }
                            else
                            {
                                RectangleF t = ((IGraph)temp).GetBounds();
                                n1.SetAttribute("x", (t.X - 10).ToString());
                                n1.SetAttribute("y", (t.Y - 10).ToString());
                            }

                            n1.InnerText = dlg.Name;
                            n1.SetAttribute("print", dlg.IsTJ ? "no" : "yes");
                            n1.SetAttribute("layer", SvgDocument.currentLayer);
                            n1.SetAttribute("ParentID", temp.GetAttribute("id"));
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            tlVectorControl1.Operation = ToolOperation.Select;

                        }
                        PSPDEV pspDev = new PSPDEV();
                        if (temp is Use)
                        {
                            RectangleF t = ((IGraph)temp).GetBounds();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = temp.GetAttribute("id");
                            pspDev.Name = dlg.Name;
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.X1 = t.X;
                            pspDev.Y1 = t.Y;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = -1;
                            pspDev.Type = "Use";
                            if (temp.GetAttribute("xlink:href").Contains("Substation"))
                            {
                                pspDev.Lable = "变电站";
                                temp.SetAttribute("print", dlg.IsTJ ? "no" : "yes");
                            }
                            else if (temp.GetAttribute("xlink:href").Contains("motherlinenode"))
                            {
                                pspDev.Lable = "母线节点";
                            }
                            else if (temp.GetAttribute("xlink:href").Contains("Power"))
                            {
                                pspDev.Lable = "电厂";
                            }
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            if (dlg.Burthen != "")
                                pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);
                            if (dlg.ReferenceVolt != "")
                            {
                                pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);
                            }
                            //if ((dlg.InPutP == ""))
                            //{
                            //    PSPDEV powerfactor = new PSPDEV();
                            //    powerfactor.Type = "Power";
                            //    powerfactor.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            //    powerfactor = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDAndType", powerfactor);
                            //    pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            //    pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);

                            //    //if (powerfactor!=null && (Convert.ToDecimal(dlg.Change)==2))
                            //    pspDev.InPutP = Convert.ToDouble(dlg.Burthen) * powerfactor.BigP;
                            //}

                            //if (pspDev.InPutP == 0 && dlg.Burthen!="")
                            //    pspDev.InPutP = Convert.ToDouble(dlg.Burthen) * 0.65;
                            if (dlg.InPutP != "")
                                pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            if (dlg.InPutQ != "")
                                pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            if (dlg.OutP != "")
                                pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            if (dlg.OutQ != "")
                                pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            if (dlg.NodeType == "是")
                            {
                                pspDev.NodeType = "0";
                            }
                            else
                            {
                                pspDev.NodeType = "1";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg.TYear);

                        }
                        else if (temp is Polyline)
                        {
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = temp.GetAttribute("id");
                            pspDev.Name = dlg.Name;
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.X1 = Convert.ToDouble(temp.GetAttribute("x1"));
                            pspDev.Y1 = Convert.ToDouble(temp.GetAttribute("y1"));
                            pspDev.X2 = Convert.ToDouble(temp.GetAttribute("x2"));
                            pspDev.Y2 = Convert.ToDouble(temp.GetAttribute("y2"));
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = -1;
                            pspDev.Type = "Polyline";
                            Services.BaseService.Create<PSPDEV>(pspDev);
                        }
                    }
                    //*************
                    string fyear = tlVectorControl1.SVGDocument.FileName.Substring(0, 4);
                    LayerGrade lag = new LayerGrade();
                    lag.Name = fyear + "%";
                    IList laglist = Services.BaseService.GetList("SelectLayerGradeByYear", lag);
                    string power = getPower(temp.GetAttribute("xlink:href"));
                    if (laglist.Count > 0)
                    {
                        LineInfo line = new LineInfo();
                        line.LineName = " Voltage='" + power + "' and length<>'' and LayerID in (select SUID from SVG_LAYER where yearid='" + ((LayerGrade)laglist[0]).SUID + "') and ObligateField6 ='" + dlg.Name + "' order by LineName";
                        IList linList = Services.BaseService.GetList("SelectLineInfoByWhere", line);
                        for (int j = 0; j < linList.Count; j++)
                        {
                            if (((LineInfo)linList[j]).ObligateField7 != "")
                            {
                                PSPDEV p1 = new PSPDEV();
                                p1.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                p1.Name = ((LineInfo)linList[j]).ObligateField6;
                                p1.Type = "Use";
                                IList p1list = Services.BaseService.GetList("SelectPSPDEVByName", p1);
                                PSPDEV p2 = new PSPDEV();
                                p2.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                p2.Name = ((LineInfo)linList[j]).ObligateField7;
                                p2.Type = "Use";
                                IList p2list = Services.BaseService.GetList("SelectPSPDEVByName", p2);
                                if (p1list.Count > 0 && p2list.Count > 0)
                                {
                                    PointF TempPoint = TLMath.getUseOffset(temp.GetAttribute("xlink:href"));
                                    PointF[] ptt = new PointF[] { new PointF(((Use)temp).X + TempPoint.X, ((Use)temp).Y + TempPoint.Y) };
                                    Transf tran = (temp as Graph).Transform;
                                    tran.Matrix.TransformPoints(ptt);
                                    XmlNode n2 = tlVectorControl1.SVGDocument.SelectSingleNode("//*[@id='" + ((PSPDEV)p2list[0]).EleID + "']");
                                    PointF TempPoint2 = TLMath.getUseOffset(((XmlElement)n2).GetAttribute("xlink:href"));
                                    PointF[] ptt2 = new PointF[] { new PointF(((Use)n2).X + TempPoint2.X, ((Use)n2).Y + TempPoint2.Y) };
                                    Transf tran2 = (n2 as Graph).Transform;
                                    tran2.Matrix.TransformPoints(ptt2);
                                    XmlElement line1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                    line1.SetAttribute("stroke", "#000000");
                                    line1.SetAttribute("layer", ((Layer)tlVectorControl1.SVGDocument.getLayerList()[0]).ID);
                                    line1.SetAttribute("points", ptt[0].X.ToString() + " " + ptt[0].Y.ToString() + "," + ptt2[0].X.ToString() + " " + ptt2[0].Y.ToString());
                                    line1.SetAttribute("FirstNode", ((PSPDEV)p1list[0]).EleID);
                                    line1.SetAttribute("LastNode", ((PSPDEV)p2list[0]).EleID);
                                    XmlNode fn = tlVectorControl1.SVGDocument.RootElement.AppendChild(line1);
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.SUID = Guid.NewGuid().ToString();
                                    pspDev.EleID = ((Polyline)fn).ID;
                                    pspDev.Name = ((LineInfo)linList[j]).LineName;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    pspDev.X1 = ptt[0].X;
                                    pspDev.Y1 = ptt[0].Y;
                                    pspDev.X2 = ptt2[0].X;
                                    pspDev.Y2 = ptt2[0].Y;
                                    pspDev.LineLength = Convert.ToDouble(((LineInfo)linList[j]).Length);
                                    pspDev.Number = -1;
                                    pspDev.FirstNode = -1;
                                    pspDev.LastNode = -1;
                                    pspDev.Type = "Polyline";
                                    pspDev.LineType = ((LineInfo)linList[j]).LineType;
                                    pspDev.VoltR = Convert.ToDouble(((LineInfo)linList[j]).Voltage);
                                    Services.BaseService.Create<PSPDEV>(pspDev);
                                    tlVectorControl1.SVGDocument.CurrentElement = n2 as SvgElement;
                                    tlVectorControl1.ChangeLevel(LevelType.Top);
                                }
                            }
                        }
                    }
                    if (laglist.Count > 0)
                    {
                        LineInfo line = new LineInfo();
                        line.LineName = " Voltage='" + power + "' and length<>'' and LayerID in (select SUID from SVG_LAYER where yearid='" + ((LayerGrade)laglist[0]).SUID + "') and ObligateField7 ='" + dlg.Name + "' order by LineName";
                        IList linList = Services.BaseService.GetList("SelectLineInfoByWhere", line);
                        for (int j = 0; j < linList.Count; j++)
                        {
                            if (((LineInfo)linList[j]).ObligateField6 != "")
                            {
                                PSPDEV p1 = new PSPDEV();
                                p1.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                p1.Name = ((LineInfo)linList[j]).ObligateField6;
                                p1.Type = "Use";
                                IList p1list = Services.BaseService.GetList("SelectPSPDEVByName", p1);
                                PSPDEV p2 = new PSPDEV();
                                p2.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                p2.Name = ((LineInfo)linList[j]).ObligateField7;
                                p2.Type = "Use";
                                IList p2list = Services.BaseService.GetList("SelectPSPDEVByName", p2);
                                if (p1list.Count > 0 && p2list.Count > 0)
                                {
                                    PointF TempPoint = TLMath.getUseOffset(temp.GetAttribute("xlink:href"));
                                    PointF[] ptt = new PointF[] { new PointF(((Use)temp).X + TempPoint.X, ((Use)temp).Y + TempPoint.Y) };
                                    Transf tran = (temp as Graph).Transform;
                                    tran.Matrix.TransformPoints(ptt);
                                    XmlNode n2 = tlVectorControl1.SVGDocument.SelectSingleNode("//*[@id='" + ((PSPDEV)p1list[0]).EleID + "']");
                                    PointF TempPoint2 = TLMath.getUseOffset(((XmlElement)n2).GetAttribute("xlink:href"));
                                    PointF[] ptt2 = new PointF[] { new PointF(((Use)n2).X + TempPoint2.X, ((Use)n2).Y + TempPoint2.Y) };
                                    Transf tran2 = (n2 as Graph).Transform;
                                    tran2.Matrix.TransformPoints(ptt2);
                                    XmlElement line1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                    line1.SetAttribute("stroke", "#000000");
                                    line1.SetAttribute("layer", ((Layer)tlVectorControl1.SVGDocument.getLayerList()[0]).ID);
                                    line1.SetAttribute("points", ptt2[0].X.ToString() + " " + ptt2[0].Y.ToString() + "," + ptt[0].X.ToString() + " " + ptt[0].Y.ToString());
                                    line1.SetAttribute("FirstNode", ((PSPDEV)p2list[0]).EleID);
                                    line1.SetAttribute("LastNode", ((PSPDEV)p1list[0]).EleID);
                                    XmlNode fn = tlVectorControl1.SVGDocument.RootElement.AppendChild(line1);
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.SUID = Guid.NewGuid().ToString();
                                    pspDev.EleID = ((Polyline)fn).ID;
                                    pspDev.Name = ((LineInfo)linList[j]).LineName;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    pspDev.X1 = ptt2[0].X;
                                    pspDev.Y1 = ptt2[0].Y;
                                    pspDev.X2 = ptt[0].X;
                                    pspDev.Y2 = ptt[0].Y;
                                    pspDev.LineLength = Convert.ToDouble(((LineInfo)linList[j]).Length);
                                    pspDev.Number = -1;
                                    pspDev.FirstNode = -1;
                                    pspDev.LastNode = -1;
                                    pspDev.Type = "Polyline";
                                    pspDev.LineType = ((LineInfo)linList[j]).LineType;
                                    pspDev.VoltR = Convert.ToDouble(((LineInfo)linList[j]).Voltage);
                                    Services.BaseService.Create<PSPDEV>(pspDev);
                                    tlVectorControl1.SVGDocument.CurrentElement = n2 as SvgElement;
                                    tlVectorControl1.ChangeLevel(LevelType.Top);
                                }
                            }
                        }

                    }
                    tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement;
                    tlVectorControl1.ChangeLevel(LevelType.Top);

                }
                else
                {
                    //tlVectorControl1.Delete();
                    //tlVectorControl1.Dispose();
                    //tlVectorControl1.Undo();
                    XmlNodeList list2 = tlVectorControl1.SVGDocument.SelectNodes("svg/use");
                    foreach (XmlNode node in list2)
                    {
                        PSPDEV dev = new PSPDEV();
                        //(node as Text).InnerText = dev.Name;
                        //XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");

                        PSPDEV dlg11 = new PSPDEV();
                        XmlElement element = node as XmlElement;
                        dev.EleID = element.GetAttribute("id");
                        PSPDEV psp = new PSPDEV();
                        dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        dlg11 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", dev);
                        if (dlg11 == null)
                        {
                            SvgElement element2 = node as SvgElement;
                            tlVectorControl1.SVGDocument.CurrentElement = element2;
                            tlVectorControl1.Delete();
                        }
                    }

                }
            }
            else
            {
                if (temp is Use && (temp.GetAttribute("xlink:href").Contains("dynamotorline")))//接地支路
                {
                    frmFadejie dlg = new frmFadejie(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                    dlg.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {

                        //XmlElement temp = tlVectorControl1.SVGDocument.CurrentElement;
                        if (temp != null)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "dynamotorline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }
                            if (true)
                            {
                                tlVectorControl1.Operation = ToolOperation.Select;
                                PSPDEV pspDev = new PSPDEV();
                                tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                RectangleF t = ((IGraph)temp).GetBounds();
                                pspDev.SUID = Guid.NewGuid().ToString();
                                pspDev.EleID = temp.GetAttribute("id");
                                pspDev.Name = dlg.Name;
                                pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                pspDev.X1 = t.X;
                                pspDev.Y1 = t.Y;
                                pspDev.Number = -1;
                                pspDev.FirstNode = -1;
                                pspDev.LastNode = 0;
                                pspDev.Type = "dynamotorline";
                                if (temp.GetAttribute("xlink:href").Contains("dynamotorline"))
                                {
                                    pspDev.Lable = "发电厂支路";
                                }
                                else if (temp.GetAttribute("xlink:href").Contains("gndline"))
                                {
                                    pspDev.Lable = "接地支路";
                                }

                                pspDev.HuganLine1 = dlg.FirstNodeName;
                                pspDev.HuganLine3 = dlg.SwitchStatus;
                                if (dlg.OutP != "")
                                    pspDev.OutP = Convert.ToDouble(dlg.OutP);
                                if (dlg.OutQ != "")
                                    pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                                if (dlg.VoltR != "")
                                    pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                                if (dlg.VoltV != "")
                                    pspDev.VoltV = Convert.ToDouble(dlg.VoltV);
                                if (dlg.PositiveTQ != "")
                                    pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                                if (dlg.NegativeTQ != "")
                                    pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ);
                                Services.BaseService.Create<PSPDEV>(pspDev);
                            }
                        }
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("gndline")))//接地支路
                {
                    frmFadejie dlg = new frmFadejie(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                    dlg.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {

                        //XmlElement temp = tlVectorControl1.SVGDocument.CurrentElement;
                        if (temp != null)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "gndline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }
                            if (true)
                            {
                                tlVectorControl1.Operation = ToolOperation.Select;
                                PSPDEV pspDev = new PSPDEV();
                                tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                RectangleF t = ((IGraph)temp).GetBounds();
                                pspDev.SUID = Guid.NewGuid().ToString();
                                pspDev.EleID = temp.GetAttribute("id");
                                pspDev.Name = dlg.Name;
                                pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                pspDev.X1 = t.X;
                                pspDev.Y1 = t.Y;
                                pspDev.Number = -1;
                                pspDev.FirstNode = -1;
                                pspDev.LastNode = 0;
                                pspDev.Type = "gndline";
                                if (temp.GetAttribute("xlink:href").Contains("dynamotorline"))
                                {
                                    pspDev.Lable = "发电厂支路";
                                }
                                else if (temp.GetAttribute("xlink:href").Contains("gndline"))
                                {
                                    pspDev.Lable = "接地支路";
                                }

                                pspDev.HuganLine1 = dlg.FirstNodeName;
                                pspDev.HuganLine3 = dlg.SwitchStatus;
                                if (dlg.OutP != "")
                                    pspDev.OutP = Convert.ToDouble(dlg.OutP);
                                if (dlg.OutQ != "")
                                    pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                                if (dlg.VoltR != "")
                                    pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                                if (dlg.VoltV != "")
                                    pspDev.VoltV = Convert.ToDouble(dlg.VoltV);
                                if (dlg.PositiveTQ != "")
                                    pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                                if (dlg.NegativeTQ != "")
                                    pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ);
                                Services.BaseService.Create<PSPDEV>(pspDev);
                            }
                        }
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("loadline")))
                {
                    frmLoad dlgLoad = new frmLoad();
                    dlgLoad.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgLoad.ShowDialog(this) == DialogResult.OK)
                    {
                        if (temp != null)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlgLoad.Name;
                            pspName.Type = "loadline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }

                            tlVectorControl1.Operation = ToolOperation.Select;
                            PSPDEV pspDev = new PSPDEV();
                            tlVectorControl1.ChangeLevel(LevelType.Bottom);
                            RectangleF t = ((IGraph)temp).GetBounds();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = temp.GetAttribute("id");
                            pspDev.Name = dlgLoad.Name;
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.X1 = t.X;
                            pspDev.Y1 = t.Y;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "loadline";

                            pspDev.Lable = "负荷支路";

                            pspDev.HuganLine1 = dlgLoad.FirstNodeName;
                            if (dlgLoad.InPutP != "")
                            {
                                pspDev.InPutP = Convert.ToDouble(dlgLoad.InPutP);
                            }
                            if (dlgLoad.InPutQ != "")
                            {
                                pspDev.InPutQ = Convert.ToDouble(dlgLoad.InPutQ);
                            }
                            if (dlgLoad.VoltR != "")
                            {
                                pspDev.VoltR = Convert.ToDouble(dlgLoad.VoltR);
                            }

                            pspDev.HuganLine3 = dlgLoad.LoadSwitchState;

                            Services.BaseService.Create<PSPDEV>(pspDev);
                        }
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("transformertwozu")))
                {
                    frmTwoTra dlgTra = new frmTwoTra(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                    dlgTra.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgTra.ShowDialog(this) == DialogResult.OK)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlgTra.Name;
                        pspName.Type = "transformertwozu";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        tlVectorControl1.Operation = ToolOperation.Select;
                        PSPDEV pspDev = new PSPDEV();
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        RectangleF t = ((IGraph)temp).GetBounds();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = temp.GetAttribute("id");
                        pspDev.Name = dlgTra.Name;
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.X1 = t.X;
                        pspDev.Y1 = t.Y;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = 0;
                        pspDev.Type = "transformertwozu";

                        pspDev.Lable = "二绕组变压器";
                        pspDev.HuganLine1 = dlgTra.FirstName;
                        pspDev.HuganLine2 = dlgTra.LastName;
                        pspDev.HuganLine3 = dlgTra.FirstSwitchState;
                        pspDev.HuganLine4 = dlgTra.LastSwitchState;
                        pspDev.LineLevel = dlgTra.FirstType;
                        pspDev.LineType = dlgTra.LastType;

                        if (dlgTra.K != "")
                        {
                            pspDev.K = Convert.ToDouble(dlgTra.K);
                        }
                        if (dlgTra.PositiveR != "")
                        {
                            pspDev.PositiveR = Convert.ToDouble(dlgTra.PositiveR);
                        }
                        if (dlgTra.PositiveTQ != "")
                        {
                            pspDev.PositiveTQ = Convert.ToDouble(dlgTra.PositiveTQ);
                        }
                        if (dlgTra.ZeroR != "")
                        {
                            pspDev.ZeroR = Convert.ToDouble(dlgTra.ZeroR);
                        }
                        if (dlgTra.ZeroTQ != "")
                        {
                            pspDev.ZeroTQ = Convert.ToDouble(dlgTra.ZeroTQ);
                        }
                        if (dlgTra.NeutralNodeTQ != "")
                        {
                            pspDev.BigTQ = Convert.ToDouble(dlgTra.NeutralNodeTQ);
                        }

                        Services.BaseService.Create<PSPDEV>(pspDev);
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("transformerthirdzu")))
                {
                    frmThridTra dlgThridTra = new frmThridTra(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                    dlgThridTra.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgThridTra.ShowDialog(this) == DialogResult.OK)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlgThridTra.Name;
                        pspName.Type = "transformerthirdzu";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        tlVectorControl1.Operation = ToolOperation.Select;
                        PSPDEV pspDev = new PSPDEV();
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        RectangleF t = ((IGraph)temp).GetBounds();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = temp.GetAttribute("id");
                        pspDev.Name = dlgThridTra.Name;
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.X1 = t.X;
                        pspDev.Y1 = t.Y;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = 0;
                        pspDev.Type = "transformerthirdzu";

                        pspDev.Lable = "三绕组变压器";
                        pspDev.HuganLine1 = dlgThridTra.IName;
                        pspDev.HuganLine2 = dlgThridTra.JName;
                        pspDev.HuganLine3 = dlgThridTra.ISwitchState;
                        pspDev.HuganLine4 = dlgThridTra.JSwitchState;
                        pspDev.LineLevel = dlgThridTra.IType;
                        pspDev.LineType = dlgThridTra.JType;
                        pspDev.LineStatus = dlgThridTra.KType;
                        pspDev.KName = dlgThridTra.KName;
                        pspDev.KSwitchStatus = dlgThridTra.KSwitchState;

                        if (dlgThridTra.IK != "")
                        {
                            pspDev.K = Convert.ToDouble(dlgThridTra.IK);
                        }
                        if (dlgThridTra.JK != "")
                        {
                            pspDev.G = Convert.ToDouble(dlgThridTra.JK);
                        }
                        if (dlgThridTra.KK != "")
                        {
                            pspDev.BigP = Convert.ToDouble(dlgThridTra.KK);
                        }
                        if (dlgThridTra.IR != "")
                        {
                            pspDev.HuganTQ1 = Convert.ToDouble(dlgThridTra.IR);
                        }
                        if (dlgThridTra.JR != "")
                        {
                            pspDev.HuganTQ2 = Convert.ToDouble(dlgThridTra.JR);
                        }
                        if (dlgThridTra.KR != "")
                        {
                            pspDev.HuganTQ3 = Convert.ToDouble(dlgThridTra.KR);
                        }
                        if (dlgThridTra.ITQ != "")
                        {
                            pspDev.HuganTQ4 = Convert.ToDouble(dlgThridTra.ITQ);
                        }
                        if (dlgThridTra.JTQ != "")
                        {
                            pspDev.HuganTQ5 = Convert.ToDouble(dlgThridTra.JTQ);
                        }
                        if (dlgThridTra.KTQ != "")
                        {
                            pspDev.SmallTQ = Convert.ToDouble(dlgThridTra.KTQ);
                        }
                        if (dlgThridTra.ZeroTQ != "")
                        {
                            pspDev.ZeroTQ = Convert.ToDouble(dlgThridTra.ZeroTQ);
                        }
                        if (dlgThridTra.NeutralNodeTQ != "")
                        {
                            pspDev.BigTQ = Convert.ToDouble(dlgThridTra.NeutralNodeTQ);
                        }

                        Services.BaseService.Create<PSPDEV>(pspDev);
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("串联电容电抗器")))
                {
                    frmCapacity dlgCapacity = new frmCapacity(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                    dlgCapacity.SetEnable(true);
                    dlgCapacity.Text = "串联电容电抗器";
                    dlgCapacity.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgCapacity.ShowDialog(this) == DialogResult.OK)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlgCapacity.Name;
                        pspName.Type = "串联电容电抗器";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        tlVectorControl1.Operation = ToolOperation.Select;
                        PSPDEV pspDev = new PSPDEV();
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        RectangleF t = ((IGraph)temp).GetBounds();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = temp.GetAttribute("id");
                        pspDev.Name = dlgCapacity.Name;
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.X1 = t.X;
                        pspDev.Y1 = t.Y;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = 0;
                        pspDev.Type = "串联电容电抗器";

                        pspDev.Lable = dlgCapacity.Lable;

                        if (dlgCapacity.PositiveTQ != "")
                        {
                            pspDev.PositiveTQ = Convert.ToDouble(dlgCapacity.PositiveTQ);
                        }
                        pspDev.HuganLine1 = dlgCapacity.FirstNodeName;
                        //pspDev.HuganLine2 = dlgCapacity.LastNodeName;

                        Services.BaseService.Create<PSPDEV>(pspDev);
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }

                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("并联电容电抗器")))
                {
                    frmCapacity dlgCapacity = new frmCapacity(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                    dlgCapacity.SetEnable(false);
                    dlgCapacity.Text = "并联电容电抗器";
                    dlgCapacity.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgCapacity.ShowDialog(this) == DialogResult.OK)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlgCapacity.Name;
                        pspName.Type = "并联电容电抗器";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        tlVectorControl1.Operation = ToolOperation.Select;
                        PSPDEV pspDev = new PSPDEV();
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        RectangleF t = ((IGraph)temp).GetBounds();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = temp.GetAttribute("id");
                        pspDev.Name = dlgCapacity.Name;
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.X1 = t.X;
                        pspDev.Y1 = t.Y;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = 0;
                        pspDev.Type = "并联电容电抗器";

                        pspDev.Lable = dlgCapacity.Lable;

                        if (dlgCapacity.PositiveTQ != "")
                        {
                            pspDev.PositiveTQ = Convert.ToDouble(dlgCapacity.PositiveTQ);
                        }
                        pspDev.HuganLine1 = dlgCapacity.FirstNodeName;
                        //pspDev.HuganLine2 = dlgCapacity.LastNodeName;

                        Services.BaseService.Create<PSPDEV>(pspDev);
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("1/2母联开关")))
                {
                    frmMuLian dlgmulian = new frmMuLian(tlVectorControl1.SVGDocument.CurrentLayer.ID);

                    dlgmulian.Text = "1/2母联开关";
                    dlgmulian.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgmulian.ShowDialog(this) == DialogResult.OK)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlgmulian.Name;
                        pspName.Type = "1/2母联开关";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        tlVectorControl1.Operation = ToolOperation.Select;
                        PSPDEV pspDev = new PSPDEV();
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        RectangleF t = ((IGraph)temp).GetBounds();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = temp.GetAttribute("id");
                        pspDev.Name = dlgmulian.Name;
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.X1 = t.X;
                        pspDev.Y1 = t.Y;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = 0;
                        pspDev.Type = "1/2母联开关";

                        pspDev.Lable = "1/2母联开关";

                        pspDev.HuganLine1 = dlgmulian.FirstNodeName;
                        pspDev.HuganLine2 = dlgmulian.LastNodeName;
                        pspDev.HuganLine3 = dlgmulian.SwitchStatus;

                        Services.BaseService.Create<PSPDEV>(pspDev);
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("2/3母联开关")))
                {
                    frmMuLian2 dlgmulian = new frmMuLian2(tlVectorControl1.SVGDocument.CurrentLayer.ID);

                    dlgmulian.Text = "2/3母联开关";
                    dlgmulian.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgmulian.ShowDialog(this) == DialogResult.OK)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlgmulian.Name;
                        pspName.Type = "2/3母联开关";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        tlVectorControl1.Operation = ToolOperation.Select;
                        PSPDEV pspDev = new PSPDEV();
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        RectangleF t = ((IGraph)temp).GetBounds();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = temp.GetAttribute("id");
                        pspDev.Name = dlgmulian.Name;
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.X1 = t.X;
                        pspDev.Y1 = t.Y;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = 0;
                        pspDev.Type = "2/3母联开关";

                        pspDev.Lable = "2/3母联开关";

                        pspDev.HuganLine1 = dlgmulian.INodeName;
                        pspDev.HuganLine2 = dlgmulian.JNodeName;
                        pspDev.HuganLine3 = dlgmulian.ILineName;
                        pspDev.HuganLine4 = dlgmulian.JLineName;
                        pspDev.KName = dlgmulian.ILoadName;
                        pspDev.KSwitchStatus = dlgmulian.JLoadName;
                        pspDev.LineLevel = dlgmulian.SwitchStatus1;
                        pspDev.LineType = dlgmulian.SwitchStatus2;
                        pspDev.LineStatus = dlgmulian.SwitchStatus3;

                        Services.BaseService.Create<PSPDEV>(pspDev);
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                //temp.RemoveAll();
            }
        }
Example #9
0
        public void InitData()
        {
            IList svglist = Services.BaseService.GetList("SelectLayerFileList", svg);
            LayerGrade lg = new LayerGrade();
            IList ilist = Services.BaseService.GetList("SelectLayerGradeList", lg);
            DataTable dataTable = DataConverter.ToDataTable(ilist, typeof(LayerGrade));
            SVG_LAYER sl = new SVG_LAYER();
            IList list = Services.BaseService.GetList("SelectSVG_LAYERList", sl);
            treeList1.DataSource = dataTable;
            string ide = treeList1.Nodes[0].GetValue(0).ToString();//��ȡijһ�ڵ��ֵ
            foreach (SVG_LAYER lay in list)
            {
                if (lay.layerType == "�����滮��")
                {
                    LayerGrade obj = new LayerGrade();
                    obj.SUID = lay.SUID;
                    obj.Name = lay.NAME;
                    obj.ParentID = lay.YearID;
                    string tempobj = "";
                    string tempyear = "";
                    if (obj.Name.ToString().Length >= 3)
                    {
                        tempobj = obj.Name.ToString().Substring(obj.Name.ToString().Length - 3, 3);
                    }
                    if (obj.Name.ToString().Length >= 4)
                    {
                        tempyear = obj.Name.ToString().Substring(0, 4);
                    }
                    if (tempobj == "���վ")
                    {
                        for (int j = 0; j < treeList1.Nodes.Count; j++)
                        {
                            if (treeList1.Nodes[j].GetValue(0).ToString().Length > 3)
                            {
                                if (treeList1.Nodes[j].GetValue(0).ToString().Substring(0, 4) == tempyear)
                                {
                                    substation _substat = new substation();
                                    _substat.LayerID = obj.SUID;
                                    _substat.ObligateField1 = "220";
                                    IList subList = Services.BaseService.GetList("SelectsubstationByLayerIDandObligateField1", _substat);

                                    int templ = treeList1.Nodes[j].Nodes.Count;
                                    treeList1.AppendNode(obj.Name, treeList1.Nodes[j]);
                                    treeList1.Nodes[j].Nodes[templ].SetValue(0, obj.Name);
                                    if (subList.Count != 0)
                                    {
                                        int jj = 0;
                                        foreach (substation temps in subList)
                                        {
                                            treeList1.AppendNode(temps, treeList1.Nodes[j].Nodes[templ]);
                                            treeList1.Nodes[j].Nodes[templ].Nodes[jj].SetValue(0, temps.EleName);
                                            jj++;
                                        }
                                    }
                                    _substat.ObligateField1 = "110";
                                    subList = Services.BaseService.GetList("SelectsubstationByLayerIDandObligateField1", _substat);

                                    templ = treeList1.Nodes[j].Nodes.Count;
                                    treeList1.AppendNode(obj.Name, treeList1.Nodes[j]);
                                    treeList1.Nodes[j].Nodes[templ].SetValue(0, obj.Name);
                                    if (subList.Count != 0)
                                    {
                                        int jj = 0;
                                        foreach (substation temps in subList)
                                        {
                                            treeList1.AppendNode(temps, treeList1.Nodes[j].Nodes[templ]);
                                            treeList1.Nodes[j].Nodes[templ].Nodes[jj].SetValue(0, temps.EleName);
                                            jj++;
                                        }
                                    }
                                    _substat.ObligateField1 = "66";
                                    subList = Services.BaseService.GetList("SelectsubstationByLayerIDandObligateField1", _substat);

                                    templ = treeList1.Nodes[j].Nodes.Count;
                                    treeList1.AppendNode(obj.Name, treeList1.Nodes[j]);
                                    treeList1.Nodes[j].Nodes[templ].SetValue(0, obj.Name);
                                    if (subList.Count != 0)
                                    {
                                        int jj = 0;
                                        foreach (substation temps in subList)
                                        {
                                            treeList1.AppendNode(temps, treeList1.Nodes[j].Nodes[templ]);
                                            treeList1.Nodes[j].Nodes[templ].Nodes[jj].SetValue(0, temps.EleName);
                                            jj++;
                                        }
                                    }
                                    _substat.ObligateField1 = "500";
                                    subList = Services.BaseService.GetList("SelectsubstationByLayerIDandObligateField1", _substat);

                                    templ = treeList1.Nodes[j].Nodes.Count;
                                    treeList1.AppendNode(obj.Name, treeList1.Nodes[j]);
                                    treeList1.Nodes[j].Nodes[templ].SetValue(0, obj.Name);
                                    if (subList.Count != 0)
                                    {
                                        int jj = 0;
                                        foreach (substation temps in subList)
                                        {
                                            treeList1.AppendNode(temps, treeList1.Nodes[j].Nodes[templ]);
                                            treeList1.Nodes[j].Nodes[templ].Nodes[jj].SetValue(0, temps.EleName);
                                            jj++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Application.DoEvents();
        }
Example #10
0
        private void simpleButtonOK_Click(object sender, EventArgs e)
        {
            //if (f.ShowDialog() == DialogResult.OK)
            //{
            string sel = GetSelectNode();
            LayerGrade lg = new LayerGrade();
            lg.SvgDataUid = strSvgDataUid;
            lg.Type = type;
            IList list1 = Services.BaseService.GetList("SelectLayerGradeList5", lg);
            if (list1.Count > 0) {
                foreach (LayerGrade ld in list1) {
                    ld.Type = "";
                    Services.BaseService.Update<LayerGrade>(ld);
                }
            }
            string[] id = sel.Split(",".ToCharArray());
            //消除原来的

            if (id.Length > 1) {
                for (int i = 1; i < id.Length; i++) {
                    LayerGrade _l = Services.BaseService.GetOneByKey<LayerGrade>(id[i]);
                    _l.Type = type;
                    Services.BaseService.Update<LayerGrade>(_l);
                }
            }
            //}
            this.Close();
        }
Example #11
0
        public void InitData(string svgDataUid)
        {
            strSvgDataUid = svgDataUid;
            LayerGrade lg = new LayerGrade();
            lg.SvgDataUid = svgDataUid;
            lg.ParentID = "SUID";
            ilist = Services.BaseService.GetList("SelectLayerGradeListBySvgDataUid2", lg);
            //ilist = Services.BaseService.GetList<PspType>();
            dataTable = DataConverter.ToDataTable(ilist, typeof(LayerGrade));

            treeList1.DataSource = dataTable;
            Application.DoEvents();
        }
Example #12
0
 public void InitDate()
 {
     LayerGrade lay=new LayerGrade();
     IList<LayerGrade> list= Services.BaseService.GetList<LayerGrade>("SelectLayerGradeList",lay);
     for (int i = 0; i < list.Count;i++ )
     {
         TreeNode node = new TreeNode();
         node.Text = list[i].Name;
         node.Tag = list[i].SUID;
         treeView1.Nodes[0].Nodes.Add(node);
     }
     treeView1.ExpandAll();
 }
Example #13
0
        public void InitData(string svgDataUid)
        {
            #region MyRegion
               // /* 原有区分关联图层功能代码 _lgm
            ilist2.Clear();
            strSvgDataUid = svgDataUid;
            LayerGrade lg = new LayerGrade();
            lg.SvgDataUid = svgDataUid;
            ilist = Services.BaseService.GetList("SelectLayerGradeListBySvgDataUid", lg);
            //----------------按项目关联年份分级-------------------
            Psp_ProgLayerList p = new Psp_ProgLayerList();
            p.ProgUID = MIS.ProgUID;
            IList<Psp_ProgLayerList> _plist = Services.BaseService.GetList<Psp_ProgLayerList>("SelectPsp_ProgLayerListListByProgUID", p);
            for (int i = 0; i < ilist.Count; i++)
            {
                for (int j = 0; j < _plist.Count; j++)
                {
                    if (((LayerGrade)ilist[i]).SUID == _plist[j].LayerGradeID)
                    {
                        ilist2.Add(ilist[i]);
                        continue;
                    }
                }
            }

            //ilist2.Clear();
            //strSvgDataUid = svgDataUid;
            //LayerGrade lg = new LayerGrade();
            //lg.SvgDataUid = svgDataUid;
            //ilist = Services.BaseService.GetList("SelectLayerGradeListBySvgDataUid", lg);
            ////----------------按项目关联年份分级-------------------
            //Psp_ProgLayerList p = new Psp_ProgLayerList();
            //p.ProgUID = MIS.ProgUID;
            //IList<Psp_ProgLayerList> _plist = Services.BaseService.GetList<Psp_ProgLayerList>("SelectPsp_ProgLayerListListByProgUID", p);
            //for (int i = 0; i < ilist.Count; i++) {

            //    ilist2.Add(ilist[i]);

            //}
            #endregion

            //-----------------------------------------------------
            //ilist = Services.BaseService.GetList<PspType>();
            dataTable = DataConverter.ToDataTable(ilist2, typeof(LayerGrade));

            IList list = this.SymbolDoc.getLayerList();
            foreach (Layer lay in list) {
                if (lay.GetAttribute("layerType") == "电网规划层") {
                    LayerGrade obj = new LayerGrade();
                    obj.SUID = lay.ID;
                    obj.Name = lay.Label;
                    obj.ParentID = lay.GetAttribute("ParentID");
                    dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));
                }
            }
            treeList1.DataSource = dataTable;

            Application.DoEvents();
            treeList1.FocusedNode = null;
            treeList1.CollapseAll();
        }
Example #14
0
        //�������ڵ�ʱ��ָ�pspdev����·������״̬ ��Ϊ���кʹ�ѡ��״̬
        public void initdat(string GprogUID)
        {
            //�ڴ˴�����ѡ���Ԫ���豸�����Խ��и���
            LayerGrade l1 = new LayerGrade();
            l1.Type = "1";
            l1.SvgDataUid = svguid;
            IList ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            int yy1 = System.DateTime.Now.Year, yy2 = System.DateTime.Now.Year, yy3 = System.DateTime.Now.Year;
            if (ttlist.Count > 0)
            {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy1 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type = "2";
            l1.SvgDataUid = svguid;
            ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0)
            {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy2 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type = "3";
            l1.SvgDataUid = svguid;
            ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0)
            {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy3 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            string con = "GprogUID = '" + GprogUID + "' AND Type= '���վ'";

            IList list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {

                PSP_Substation_Info ps = new PSP_Substation_Info();
                ps.UID = pg.DeviceSUID;
                ps = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", ps);
                if (ps != null)
                {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S2))
                    {
                        s2 = Convert.ToInt32(ps.S2);
                    }
                    if (s2 <= System.DateTime.Now.Year)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S2) <= yy1)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > yy1 && Convert.ToInt32(ps.S2) <= yy2)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > yy2 && Convert.ToInt32(ps.S2) <= yy3)
                    {
                        pg.L1 = "Զ��";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                }
                else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
            }
            con = "GprogUID = '" + GprogUID + "' AND Type= '��Դ'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {
                PSP_PowerSubstation_Info ps = new PSP_PowerSubstation_Info();
                ps.UID = pg.DeviceSUID;
                ps = (PSP_PowerSubstation_Info)Services.BaseService.GetObject("SelectPSP_PowerSubstation_InfoByKey", ps);
                if (ps != null)
                {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S3))
                    {
                        s2 = Convert.ToInt32(ps.S3);
                    }
                    if (s2 <= System.DateTime.Now.Year)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S3) <= yy1)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > yy1 && Convert.ToInt32(ps.S3) <= yy2)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 >yy2 && Convert.ToInt32(ps.S3) <= yy3)
                    {
                        pg.L1 = "Զ��";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                }
                else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
            }
            con = "GprogUID = '" + GprogUID + "' AND Type= '��·'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {
                PSPDEV ps = new PSPDEV();
                ps.SUID = pg.DeviceSUID;
                ps = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", ps);
                if (ps != null)
                {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.OperationYear))
                    {
                        s2 = Convert.ToInt32(ps.OperationYear);
                    }
                    if (s2 <= System.DateTime.Now.Year)
                    {
                        pg.L1 = "����";
                        ps.LineStatus = "����";
                    }
                    else
                    {
                        pg.L1 = "��ѡ";
                        ps.LineStatus = "��ѡ";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                    Services.BaseService.Update<PSPDEV>(ps);
                }
                else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
            }
        }
Example #15
0
        public void InitData2(string svgDataUid)
        {
            treeList1.OptionsSelection.MultiSelect = false;
            //this.treeList1.GetStateImage -= new DevExpress.XtraTreeList.GetStateImageEventHandler(this.treeList1_GetStateImage);
            //this.treeList1.KeyDown -= new System.Windows.Forms.KeyEventHandler(this.treeList1_KeyDown);
            //this.treeList1.MouseDown -= new System.Windows.Forms.MouseEventHandler(this.treeList1_MouseDown);
            strSvgDataUid = svgDataUid;
            LayerGrade lg = new LayerGrade();
            lg.SvgDataUid = svgDataUid;
            ilist = Services.BaseService.GetList("SelectLayerGradeListBySvgDataUid", lg);

            dataTable = DataConverter.ToDataTable(ilist, typeof(LayerGrade));

            treeList1.DataSource = dataTable;
            Application.DoEvents();
            treeList1.CollapseAll();
        }
Example #16
0
        public void LayerManagerShow()
        {
            frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
            frmlar.YearID = yearID;
            if (MapType == "所内接线图")
            {
                frmlar.Progtype = MapType;
            }
            else
            {
                frmlar.Progtype = progtype;
            }
            frmlar.Owner = this;
            frmlar.OnClickLayer += new OnClickLayerhandler(frmlar_OnClickLayer);
            frmlar.OnDeleteLayer += new OnDeleteLayerhandler(frmlar_OnDeleteLayer);
            frmlar.OnCheck += new OnCheckhandler(frmlar_OnCheck);
            // Init(progtype);
            frmlar.ShowInTaskbar = false;
            frmlar.Top = 25;//Screen.PrimaryScreen.WorkingArea.Height - 500;
            frmlar.Left = Screen.PrimaryScreen.WorkingArea.Width - frmlar.Width;

            string myear = yearID.Replace("'", "");
            string[] y = myear.Split(",".ToCharArray());
            if (y.Length > 1)
            {
                LayerGrade lar = new LayerGrade();
                lar.SUID = y[1];
                lar = (LayerGrade)Services.BaseService.GetObject("SelectLayerGradeByKey", lar);
               // startyear = frmlar.StrYear = lar.Name.Substring(0, 4);

            }
            frmlar.Show();
        }
Example #17
0
        private void LayerGradeAdd(object sender, EventArgs e)
        {
            string uid = "";
            if (treeList1.FocusedNode != null)
            {
                uid = treeList1.FocusedNode[treeListColumn2].ToString();
            }
            frmLayerGradeInPut dlg = new frmLayerGradeInPut(strSvgDataUid);
            LayerGrade objnew = new LayerGrade();
            objnew.SUID = Guid.NewGuid().ToString();
            objnew.SvgDataUid = strSvgDataUid;
            //objnew.ParentID = uid;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                objnew.Name = dlg.TextInPut;
                objnew.ParentID = dlg.ParentID;
            }
            else
            {
                return;
            }
            if (objnew.Name=="")
            {
                MessageBox.Show("分级名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            foreach (LayerGrade lay in ilist)
            {
                if (objnew.Name==lay.Name)
                {
                    MessageBox.Show("分级已经存在。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            dataTable.Rows.Add(DataConverter.ObjectToRow(objnew, dataTable.NewRow()));
            Services.BaseService.Create<LayerGrade>(objnew);
            InitData(strSvgDataUid);
        }
Example #18
0
        private void simpleButton1_Click_1(object sender, EventArgs e)
        {
            string text1 = textEdit1.Text;
            string text2 = textEdit2.Text;
            if(textEdit1.Text==""){
                MessageBox.Show("��ָ��Ҫ���Ƶ���ݡ�", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textEdit1.Focus();
                return;
            }
            if (textEdit2.Text == "")
            {
                MessageBox.Show("��ָ��Ҫ���Ƶ���Ŀ����ݡ�", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textEdit2.Focus();
                return;
            }
            LayerGrade gra = new LayerGrade();
            gra.Name = text2+"%";
            IList <LayerGrade> list= Services.BaseService.GetList<LayerGrade>("SelectLayerGradeByYear", gra);
            if(list.Count==0){
                MessageBox.Show("û���ҵ�ָ���������Ϣ�����Ƚ�����Ӧ��ݵ�ͼ��ּ���", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            int itemcount = checkedListBox1.Items.Count;
            if (checkedListBox1.Items != null)
            {
                f.SetText("�����У���ȴ�......");
                f.Show();
                for (int num = 0; num < itemcount; num++)
                {

                    string itemname = checkedListBox1.Items[num].ToString();
                    string item4 = itemname.Substring(0, 4);
                    if ((item4 == text1) && (text2 != "") && checkedListBox1.GetItemChecked(num)==true)
                    {
                        Layer layer = this.checkedListBox1.Items[num] as Layer;
                        f.SetText("��ѡ��" + checkedListBox1.CheckedItems.Count + "�㣬���ڸ���" + layer.Label + "�㡣");
                        string str = layer.GetAttribute("layerType");
                        Layer layer2 = CopyLayer2(layer, text2);
                        if (layer2 != null)
                        {
                            if (layer.Visible)
                            {
                                layer.Visible = false;
                                layer.Visible = true;
                            }
                            layer2.SetAttribute("layerType", str);
                            this.checkedListBox1.Items.Add(layer2);
                            layer2.Visible = false;

                            string xml = "";
                            XmlNodeList oldList = symbolDoc.SelectNodes("//*[@layer=\"" + layer2.ID + "\"]");
                            for (int i = 0; i < oldList.Count; i++)
                            {
                                xml = xml+((SvgElement)oldList[i]).OuterXml;
                            }
                            SVG_LAYER obj = new SVG_LAYER();
                            obj.SUID = layer2.ID;
                            obj.svgID = symbolDoc.SvgdataUid;
                            obj.NAME = layer2.Label;
                            obj.MDATE = System.DateTime.Now;
                            obj.OrderID = num + 10;
                            obj.YearID = ((LayerGrade)list[0]).SUID;
                            obj.layerType = "�����滮��";
                            obj.visibility = "visible";
                            obj.IsSelect = "true";
                            obj.XML = xml;
                            Services.BaseService.Create<SVG_LAYER>(obj);
                        }
                    }

                }
                f.Hide();
            }
        }