示例#1
0
        private void ShowResult(int order, string projectsuid, string FileName)
        {
            try {
                XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");

                foreach (XmlNode node in list) {
                    SvgElement element = node as SvgElement;
                    tlVectorControl1.SVGDocument.CurrentElement = element;
                    tlVectorControl1.Delete();
                }
                double yinzi = 0, capability = 0, volt = 0, standvolt = 0, current = 0;
                PSPDEV benchmark = new PSPDEV();
                benchmark.Type = "power";
                benchmark.SvgUID = projectsuid;
                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);
                    TLPSPVmin = dev.iV;
                    TLPSPVmax = dev.jV;
                    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);
                };
                Layer lar = null;
                if (Layer.CkLayerExist(FileName, tlVectorControl1.SVGDocument))
                {
                    ArrayList layercol = tlVectorControl1.SVGDocument.getLayerList();
                    for (int i = 0; i < layercol.Count; i++)
                    {
                        if (FileName == (layercol[i] as Layer).GetAttribute("label"))
                        {
                            lar = (Layer)layercol[i];
                            break;
                        }
                    }
                }
                else
                {
                    lar = Layer.CreateNew(FileName, tlVectorControl1.SVGDocument);

                    lar.SetAttribute("layerType", progtype);
                    lar.SetAttribute("ParentID", tlVectorControl1.SVGDocument.CurrentLayer.GetAttribute("ParentID"));
                    this.frmlar.checkedListBox1.SelectedIndex = -1;
                    this.frmlar.checkedListBox1.Items.Add(lar, true);
                }
                int size = tlVectorControl1.ScaleRatio>1?12:(int)(12 / tlVectorControl1.ScaleRatio);
                XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");
                foreach (XmlNode node in useList) {
                    XmlElement element = node as XmlElement;
                    //XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + element.GetAttribute("id") + "']");
                    string strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectsuid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'";
                    IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    for (int i = 0; i < listMX.Count; i++) {
                        PSPDEV elementDEV = (PSPDEV)(listMX[i]);
                        PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                        elcDEV.ProjectSUID = projectsuid;
                        elcDEV.DeviceSUID = ((PSPDEV)listMX[i]).SUID;
                        elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                        if (elcDEV != null) {
                            RectangleF bound = ((IGraph)element).GetBounds();
                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            n1.SetAttribute("x", Convert.ToString(bound.X));
                            n1.SetAttribute("y", Convert.ToString(bound.Y - i * 20));
                            n1.SetAttribute("font-size", size.ToString());//"12");
                            n1.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL2).ToString("N2");
                            //Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));
                            n1.SetAttribute("layer", lar.ID);
                            //MessageBox.Show(Convert.ToString(n1.InnerText));
                            n1.SetAttribute("flag", "1");
                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL2) > TLPSPVmax * elementDEV.RateVolt / elementDEV.ReferenceVolt || Convert.ToDouble(GetColValue(elcDEV, order).COL2) < TLPSPVmin * elementDEV.RateVolt / elementDEV.ReferenceVolt)//电压越限,需修改
                                n1.SetAttribute("stroke", "#FF0000");
                            if (elementDEV.NodeType == "0") {

                                n2.SetAttribute("x", Convert.ToString(bound.X));
                                n2.SetAttribute("y", Convert.ToString(bound.Y + bound.Height + 20));
                                if (Convert.ToDouble(elcDEV.COL5) >= 0) {
                                    n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  + " + "j" + Convert.ToDouble(GetColValue(elcDEV, order).COL5).ToString("N2");
                                } else {
                                    n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  - " + "j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                }
                                n2.SetAttribute("layer", lar.ID);
                                n2.SetAttribute("flag", "1");
                                n2.SetAttribute("font-size", size.ToString());//"12");
                               // n2.SetAttribute("limitsize", "true");

                                double tempi = Convert.ToDouble(GetColValue(elcDEV, order).COL4);
                                double tempj = Convert.ToDouble(GetColValue(elcDEV, order).COL5);
                                double temptotal = Math.Sqrt(tempi * tempi + tempj * tempj);
                                if (temptotal > Convert.ToDouble(elementDEV.Burthen)) {
                                    n2.SetAttribute("stroke", "#FF0000");
                                }
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);

                            }
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            tlVectorControl1.Operation = ToolOperation.Select;

                        }tlVectorControl1.Refresh();
                    }
                }
                XmlNodeList polyLineList = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline");
                foreach (XmlNode node in polyLineList) {
                    XmlElement element = node as XmlElement;
                    PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                    elcDEV.ProjectSUID = projectsuid;
                    elcDEV.DeviceSUID = element.GetAttribute("Deviceid");
                    elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                    PSPDEV elementDEV = new PSPDEV();
                    if (elcDEV != null) {
                        elementDEV.SUID = elcDEV.DeviceSUID;
                        elementDEV = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", elementDEV);
                    } else {
                        continue;
                    }

                    if (elementDEV != null) {
                        PointF[] t = ((Polyline)element).Points;
                        PointF[] t2 = ((Polyline)element).FirstTwoPoint; t = t2;

                        PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2));
                        float angel = 0f;
                        angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);

                        string l3 = Convert.ToString(midt.X);
                        string l4 = Convert.ToString(midt.Y);

                        string tran = ((Polyline)element).Transform.ToString();

                        PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2));
                        XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                        // XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                        //XmlElement n3 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;

                        PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                        PointF pStart2 = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                        XmlNode firstNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("FirstNode") + "']");
                        XmlNode lastNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("LastNode") + "']");
                        if (firstNodeElement != null) {
                            if (t2[0].X > ((IGraph)firstNodeElement).CenterPoint.X || t2[0].Y < ((IGraph)firstNodeElement).CenterPoint.Y) {
                                pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                            } else {
                                pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                                pStart2 = new PointF(center.X + (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                            }
                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL5) >= 0)
                            {
                                n1.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " + j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                            }
                            else
                            {
                                n1.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " - j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                            }
                            Graphics dd = this.CreateGraphics();
                            Font ff = new Font("宋体", 12);
                            SizeF sf= dd.MeasureString(n1.InnerText, ff);
                            double ztlength = Math.Sqrt(sf.Width * sf.Width + sf.Height * sf.Height);
                            PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));
                            n1.SetAttribute("x", Convert.ToString(center.X - (float)(Math.Sin((angel) *Math.PI / 180) * ztlength)));
                            n1.SetAttribute("y", Convert.ToString(center.Y - (float)(Math.Cos((angel)*Math.PI / 180) * ztlength)));

                            //n1.SetAttribute("x", Convert.ToString(pStart.X));
                            //n1.SetAttribute("y", Convert.ToString(pStart.Y));

                            //Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));
                            n1.SetAttribute("layer", lar.ID);
                            n1.SetAttribute("flag", "1");
                            n1.SetAttribute("font-size", size.ToString());//"12");
                           // n1.SetAttribute("limitsize", "true");
                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL14) > (elementDEV.LineChange))//电流越限,需修改。

                                n1.SetAttribute("stroke", "#FF0000");

                            //PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 25) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 25) * Math.PI / 180)));
                            //PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 335) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 335) * Math.PI / 180)));

                            //if (Convert.ToDouble(elcDEV.COL4) < 0)
                            //{
                            //    p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 155) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 155) * Math.PI / 180)));
                            //    p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 205) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 205) * Math.PI / 180)));
                            //}

                            //string l1 = Convert.ToString(p1.X);
                            //string l2 = Convert.ToString(p1.Y);
                            //string l5 = Convert.ToString(p2.X);
                            //string l6 = Convert.ToString(p2.Y);

                            //n2.SetAttribute("points", l1 + " " + l2 + "," + l3 + " " + l4 + "," + l5 + " " + l6);
                            //n2.SetAttribute("fill-opacity", "1");
                            //n2.SetAttribute("layer", SvgDocument.currentLayer);
                            //n2.SetAttribute("flag", "1");
                            //n2.SetAttribute("font-size", "6");
                            //tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);
                            //tlVectorControl1.SVGDocument.CurrentElement = n2 as SvgElement;

                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            tlVectorControl1.Operation = ToolOperation.Select;

                            tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                            RectangleF ttt = ((Polyline)element).GetBounds();

                            tlVectorControl1.RotateSelection(angel, pStart);
                            if (Math.Abs(angel) > 90)
                                tlVectorControl1.RotateSelection(180, pStart);

                            tlVectorControl1.Refresh();
                        }

                    }
                }
                //this.frmlar.checkedListBox1.Items.Add(lar, true);
                //this.frmlar.checkedListBox1.SelectedIndex = -1;

            } catch (System.Exception ex) {
                MessageBox.Show("参数错误,请调整参数后重新计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
示例#2
0
        private void dotNetBarManager1_ItemClick(object sender, EventArgs e)
        {
            DevComponents.DotNetBar.ButtonItem btItem = sender as DevComponents.DotNetBar.ButtonItem;
            //Layer layer1 = (Layer)LayerBox.ComboBoxEx.SelectedItem;
            if (btItem != null) {
                switch (btItem.Name) {
                    #region 文件操作
                    case "mNew":
                        frmNewProject frmprojectDLG = new frmNewProject();
                        frmprojectDLG.Name = "";
                        if (frmprojectDLG.ShowDialog() == DialogResult.OK) {
                            tlVectorControl1.NewFile();
                            PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                            pd.Name = frmprojectDLG.Name;
                            pd.FileType = frmprojectDLG.FileType;
                            pd.Class = System.DateTime.Now.ToString();
                            pd.ProjectID = this.ProjectUID;
                            tlVectorControl1.SVGDocument.SvgdataUid = pd.ID;
                            SvgDocument.currentLayer = Layer.CreateNew("默认层", tlVectorControl1.SVGDocument).ID;
                            Layer la = tlVectorControl1.SVGDocument.GetLayerByID(SvgDocument.currentLayer);
                            la.SetAttribute("layerType", "电网规划层");
                            Services.BaseService.Create<PSP_ELCPROJECT>(pd);
                            if (pd.ID != null) {
                                Open(pd.ID);
                                intdata(pd.ID);
                                //if (this.Text.Contains())
                                //{
                                //}
                                this.Text = frmname + "-" + pd.Name;
                            }
                            this.Show();
                            jxtbar(1);
                            LoadShape("symbol20.xml");
                        }
                        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;
                        //    }

                        //}
                        OpenProject op = new OpenProject();
                        op.ProjectID = this.ProjectUID;
                        op.Initdata(false);
                        if (op.ShowDialog() == DialogResult.OK) {
                            if (op.FileSUID != null) {
                                Open(op.FileSUID);
                                intdata(op.FileSUID);
                                //if (this.Text.Contains())
                                //{
                                //}
                                this.Text = frmname + "-" + op.FileName;
                            }
                            this.Show();
                            jxtbar(1);
                            LoadShape("symbol20.xml");

                        }
                        break;
                    case "barDeviceData":
                        frmProjectManager frmPdlg = new frmProjectManager();
                        frmPdlg.SetMode(tlVectorControl1.SVGDocument.SvgdataUid);
                        frmPdlg.ShowDialog();
                        break;
                    case "btExSymbol":
                        tlVectorControl1.ExportSymbol();
                        break;
                    case "mjxt"://导入接线图
                        ImportJxt2 jxt = new ImportJxt2(tlVectorControl1);
                        jxt.Import();
                        break;
                    case "mSave":
                        Save();
                        //tlVectorControl1.Save();
                        //frmElementName dlg = new frmElementName();
                        //dlg.TextInput = tlVectorControl1.SVGDocument.FileName;
                        //if (dlg.ShowDialog() == DialogResult.OK)
                        //{
                        //    tlVectorControl1.SVGDocument.FileName = dlg.TextInput;
                        //    Save();
                        //}
                        break;
                    case "mSaveAs":
                        tlVectorControl1.SaveAs();
                        break;
                    case "mExit":
                        this.Close();
                        break;
                    case "bt1":
                        //InitTK();
                        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.SvgdataUid);
                        //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":

                        break;
                    case "Dlqibutt":
                        break;
                    //MessageBox.Show("请选中母线点,然后点击右键输入断路器属性" "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //duluqiflag=true;
                    //基础操作
                    case "mFreeTransform":
                        tlVectorControl1.Operation = ToolOperation.FreeTransform;

                        break;
                    case "mCJ":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;
                        csOperation = CustomOperation.OP_MeasureDistance;
                        break;
                    //case "ButtonItem2":
                    //    break;
                    #endregion
                    #region 无功优化参数维护
                    case "VoltLimit":
                        break;
                    case "GeneratorLimit":
                        break;
                    case "TransformLimit":
                        break;
                    case "SVC":
                        break;
                    #endregion
                    #region 基础图元
                    case "mLayer":
                        tlVectorControl1.LayerManager();
                        break;
                    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 "butRef":
                        Ref();
                        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":

                        break;
                    case "ButtonItem8":

                        break;
                    case "mCheck":
                        break;
                    case "DFSResult":
                        frmSetPower frmSPR = new frmSetPower();
                        frmSPR.ProjectID = this.tlVectorControl1.SVGDocument.SvgdataUid;
                        if (frmSPR.ShowDialog() == DialogResult.OK) {
                            ElectricLoadCal elcDFS = new ElectricLoadCal();
                            //string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'";
                            //string strCon2 = null;
                            //string strCon = null;
                            //strCon2 = " AND Type = '05'";
                            //strCon = strCon1 + strCon2;
                            //IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                            //strCon2 = " AND Type = '01'";
                            //strCon = strCon1 + strCon2;
                            //IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                            IList branchList = new List<PSPDEV>();
                            IList busList = new List<PSPDEV>();
                            //foreach (PSPDEV dev in listXL)
                            //{
                            //    if (dev.Number>=14)
                            //    {
                            //        branchList.Add(dev);
                            //    }
                            //}
                            //foreach (PSPDEV dev in listMX)
                            //{
                            //    if (dev.Number<=3)
                            //    {
                            //        busList.Add(dev);
                            //    }
                            //}
                            busList = frmSPR.ListPower;
                            branchList = frmSPR.ListBranch;
                            if (busList != null) {
                                elcDFS.DFSER(branchList, busList, tlVectorControl1.SVGDocument.SvgdataUid, 100, 1);
                            }
                        }
                        break;
                    case "DFS":
                        frmSetPower frmSP = new frmSetPower();
                        frmSP.ProjectID = this.tlVectorControl1.SVGDocument.SvgdataUid;
                        if (frmSP.ShowDialog() == DialogResult.OK) {
                            ElectricLoadCal elcDFS = new ElectricLoadCal();
                            //string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'";
                            //string strCon2 = null;
                            //string strCon = null;
                            //strCon2 = " AND Type = '05'";
                            //strCon = strCon1 + strCon2;
                            //IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                            //strCon2 = " AND Type = '01'";
                            //strCon = strCon1 + strCon2;
                            //IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                            IList branchList = new List<PSPDEV>();
                            IList busList = new List<PSPDEV>();
                            //foreach (PSPDEV dev in listXL)
                            //{
                            //    if (dev.Number>=14)
                            //    {
                            //        branchList.Add(dev);
                            //    }
                            //}
                            //foreach (PSPDEV dev in listMX)
                            //{
                            //    if (dev.Number<=3)
                            //    {
                            //        busList.Add(dev);
                            //    }
                            //}
                            busList = frmSP.ListPower;
                            branchList = frmSP.ListBranch;
                            if (busList != null) {
                                elcDFS.DFS(branchList, busList, tlVectorControl1.SVGDocument.SvgdataUid, 100);
                                ShowResult(0);
                            }
                        }

                        break;
                    case "niula":
                        frnReport wFrom = new frnReport();
                        wFrom.Owner = this;
                        wFrom.Show();
                        wFrom.Text = this.Text + "—牛拉法潮流计算";
                        wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                        ElectricLoadCal elc = new ElectricLoadCal();
                        elc.LFC(tlVectorControl1.SVGDocument.SvgdataUid, 1, 100, wFrom);
                        ShowResult(0, wFrom);
                        break;
                    case "pq":
                        frnReport wFromPQ = new frnReport();
                        wFromPQ.Owner = this;
                        wFromPQ.Show();
                        wFromPQ.Text = this.Text + "—PQ分解法潮流计算";
                        wFromPQ.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                        ElectricLoadCal elcPQ = new ElectricLoadCal();
                        elcPQ.LFC(tlVectorControl1.SVGDocument.SvgdataUid, 2, 100, wFromPQ);
                        ShowResult(1, wFromPQ);
                        break;

                    case "GaussSeidel":
                        frnReport wFromGS = new frnReport();
                        wFromGS.Owner = this;
                        wFromGS.Show();
                        wFromGS.Text = this.Text + "—高斯赛德尔迭代法潮流计算";
                        wFromGS.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                        ElectricLoadCal elcGS = new ElectricLoadCal();
                        elcGS.LFC(tlVectorControl1.SVGDocument.SvgdataUid, 3, 100, wFromGS);
                        ShowResult(2, wFromGS);
                        break;
                    case "N_RZYz":
                        frnReport wFromZYZ = new frnReport();
                        wFromZYZ.Owner = this;
                        wFromZYZ.Show();
                        wFromZYZ.Text = this.Text + "—最有乘子法潮流计算";
                        wFromZYZ.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                        ElectricLoadCal elcN_RZYz = new ElectricLoadCal();
                        elcN_RZYz.LFC(tlVectorControl1.SVGDocument.SvgdataUid, 4, 100, wFromZYZ);
                        ShowResult(3, wFromZYZ);
                        break;
                    case "niulaNfh":
                        elc = new ElectricLoadCal();
                        elc.LFCS(tlVectorControl1.SVGDocument.SvgdataUid, 4, 100);
                        ShowResult(3);
                        break;
                    case "WebRela":                        //进行网络N-1检验

                        ElectricRelcheck elcRela = new ElectricRelcheck();
                        elcRela.WebCalAndPrint(tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID, 100);
                        break;
                    case "TransRela":                       //进行变压器N-1检验

                        break;
                    case "Shortibut":

                        break;
                    case "dd":
                        //SubPrint = true;
                        tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint;
                        break;

                    case "NiulaResult":
                        ElectricLoadCal elcResult = new ElectricLoadCal();
                        elcResult.LFCER(tlVectorControl1.SVGDocument.SvgdataUid, 1, 100);
                        break;
                    case "PQResult":
                        ElectricLoadCal elcPQResult = new ElectricLoadCal();
                        elcPQResult.LFCER(tlVectorControl1.SVGDocument.SvgdataUid, 2, 100);
                        break;
                    case "GaussSeidelResult":
                        ElectricLoadCal elcGSResult = new ElectricLoadCal();
                        elcGSResult.LFCER(tlVectorControl1.SVGDocument.SvgdataUid, 3, 100);
                        break;
                    case "N_RZYzResult":
                        ElectricLoadCal elcNZResult = new ElectricLoadCal();
                        elcNZResult.LFCER(tlVectorControl1.SVGDocument.SvgdataUid, 4, 100);
                        break;
                    case "NLnFHresult":
                        elc = new ElectricLoadCal();
                        elc.LFCERS(tlVectorControl1.SVGDocument.SvgdataUid, 4, 100);
                        break;
                    case "VoltEvaluation":
                        ElectricLoadCal elcVE = new ElectricLoadCal();
                        elcVE.VE(tlVectorControl1.SVGDocument.SvgdataUid, 100);
                        break;
                    case "PowerLossCal":
                        ElectricLoadCal elcPLResult = new ElectricLoadCal();
                        elcPLResult.PLE(tlVectorControl1.SVGDocument.SvgdataUid, 2, 100);
                        ShowPowerLoss();
                        break;
                    case "PowerLoss":
                        ElectricLoadCal elcPLE = new ElectricLoadCal();
                        elcPLE.PLE(tlVectorControl1.SVGDocument.SvgdataUid, 2, 100);
                        break;
                    case "ZLPResult1":

                        break;

                    case "mDLR":

                        break;
                    case "clearResult":
                        try {
                            XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");

                            foreach (XmlNode node in list) {
                                SvgElement element = node as SvgElement;

                                tlVectorControl1.SVGDocument.CurrentElement = element;
                                tlVectorControl1.Delete();

                            }
                        } catch (System.Exception ex) {

                        }
                        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":

                        break;
                    #endregion

                    #region 视图
                    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) {
                                    if (element is Text) {
                                        PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                                        elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        elcDEV.DeviceSUID = element.GetAttribute("Deviceid");
                                        Services.BaseService.Delete<PSP_ElcDevice>(elcDEV);
                                    }
                                }
                                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;
                    case "PSPIdleOptimize":
                        ElectricLoadCal elcORP = new ElectricLoadCal();
                        elcORP.ORP(tlVectorControl1.SVGDocument.SvgdataUid, 100);
                        break;
                    #endregion
                    #region 参数维护
                    case "mNodeParam":

                        break;
                    case "mLineParam":

                        break;
                    case "mWire":

                        break;
                    case "nTransformLineParam":

                        break;
                    case "nGNDLineParam":

                        break;
                    case "mLineDL":

                        break;
                    case "mFadianDL":

                        break;
                    case "mConvert":

                        break;

                    #endregion
                }
            }
        }
示例#3
0
 private DeviceCOL GetColValue(PSP_ElcDevice elcDEV, int order)
 {
     DeviceCOL devCol = new DeviceCOL();
     if (order == 0) {
         devCol.COL1 = elcDEV.COL1;
         devCol.COL2 = elcDEV.COL2;
         devCol.COL3 = elcDEV.COL3;
         devCol.COL4 = elcDEV.COL4;
         devCol.COL5 = elcDEV.COL5;
         devCol.COL6 = elcDEV.COL6;
         devCol.COL7 = elcDEV.COL7;
         devCol.COL8 = elcDEV.COL8;
         devCol.COL9 = elcDEV.COL9;
         devCol.COL10 = elcDEV.COL10;
         devCol.COL11 = elcDEV.COL11;
         devCol.COL12 = elcDEV.COL12;
         devCol.COL13 = elcDEV.COL13;
         devCol.COL14 = elcDEV.COL14;
         devCol.COL15 = elcDEV.COL15;
         devCol.COL16 = elcDEV.COL16;
         devCol.COL17 = elcDEV.COL17;
         devCol.COL18 = elcDEV.COL18;
         devCol.COL19 = elcDEV.COL19;
         devCol.COL20 = elcDEV.COL20;
     } else if (order == 1) {
         devCol.COL1 = elcDEV.COL21;
         devCol.COL2 = elcDEV.COL22;
         devCol.COL3 = elcDEV.COL23;
         devCol.COL4 = elcDEV.COL24;
         devCol.COL5 = elcDEV.COL25;
         devCol.COL6 = elcDEV.COL26;
         devCol.COL7 = elcDEV.COL27;
         devCol.COL8 = elcDEV.COL28;
         devCol.COL9 = elcDEV.COL29;
         devCol.COL10 = elcDEV.COL30;
         devCol.COL11 = elcDEV.COL31;
         devCol.COL12 = elcDEV.COL32;
         devCol.COL13 = elcDEV.COL33;
         devCol.COL14 = elcDEV.COL34;
         devCol.COL15 = elcDEV.COL35;
         devCol.COL16 = elcDEV.COL36;
         devCol.COL17 = elcDEV.COL37;
         devCol.COL18 = elcDEV.COL38;
         devCol.COL19 = elcDEV.COL39;
         devCol.COL20 = elcDEV.COL40;
     } else if (order == 2) {
         devCol.COL1 = elcDEV.COL41;
         devCol.COL2 = elcDEV.COL42;
         devCol.COL3 = elcDEV.COL43;
         devCol.COL4 = elcDEV.COL44;
         devCol.COL5 = elcDEV.COL45;
         devCol.COL6 = elcDEV.COL46;
         devCol.COL7 = elcDEV.COL47;
         devCol.COL8 = elcDEV.COL48;
         devCol.COL9 = elcDEV.COL49;
         devCol.COL10 = elcDEV.COL50;
         devCol.COL11 = elcDEV.COL51;
         devCol.COL12 = elcDEV.COL52;
         devCol.COL13 = elcDEV.COL53;
         devCol.COL14 = elcDEV.COL54;
         devCol.COL15 = elcDEV.COL55;
         devCol.COL16 = elcDEV.COL56;
         devCol.COL17 = elcDEV.COL57;
         devCol.COL18 = elcDEV.COL58;
         devCol.COL19 = elcDEV.COL59;
         devCol.COL20 = elcDEV.COL60;
     } else if (order == 3) {
         devCol.COL1 = elcDEV.COL61;
         devCol.COL2 = elcDEV.COL62;
         devCol.COL3 = elcDEV.COL63;
         devCol.COL4 = elcDEV.COL64;
         devCol.COL5 = elcDEV.COL65;
         devCol.COL6 = elcDEV.COL66;
         devCol.COL7 = elcDEV.COL67;
         devCol.COL8 = elcDEV.COL68;
         devCol.COL9 = elcDEV.COL69;
         devCol.COL10 = elcDEV.COL70;
         devCol.COL11 = elcDEV.COL71;
         devCol.COL12 = elcDEV.COL72;
         devCol.COL13 = elcDEV.COL73;
         devCol.COL14 = elcDEV.COL74;
         devCol.COL15 = elcDEV.COL75;
         devCol.COL16 = elcDEV.COL76;
         devCol.COL17 = elcDEV.COL77;
         devCol.COL18 = elcDEV.COL78;
         devCol.COL19 = elcDEV.COL79;
         devCol.COL20 = elcDEV.COL80;
     }
     return devCol;
 }
示例#4
0
        private void ShowResult(int order, frnReport wFrom)
        {
            wFrom.ShowText += "\r\n开始显示计算结果\t" + System.DateTime.Now.ToString();
            try {
                XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");

                foreach (XmlNode node in list) {
                    SvgElement element = node as SvgElement;
                    if ((element.GetAttribute("textn1id") == null || element.GetAttribute("textn1id") == "") && (element.GetAttribute("textn2id") == null || element.GetAttribute("textn2id") == "")) {
                        tlVectorControl1.SVGDocument.CurrentElement = element;
                        tlVectorControl1.Delete();
                    }
                }
                double yinzi = 0, capability = 0, volt = 0, standvolt = 0, current = 0;
                //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);
                //    TLPSPVmin = dev.iV;
                //    TLPSPVmax = dev.jV;
                //    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);
                //};

                //SvgDocument.currentLayer = Layer.CreateNew("结果显示", tlVectorControl1.SVGDocument).ID;
                tlVectorControl1.SVGDocument.AcceptChanges = true;
                XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");
                XmlNodeList layerlist = tlVectorControl1.SVGDocument.GetElementsByTagName("layer");
                Layer layResult;
                bool lb = true;
                foreach (Layer lay in layerlist) {
                    if (lay.GetAttribute("label") == "结果显示") {
                        SvgDocument.currentLayer = lay.ID;
                        lb = false;
                    }
                }
                if (lb) {
                    SvgDocument.currentLayer = Layer.CreateNew("结果显示", tlVectorControl1.SVGDocument).ID;
                }
                wFrom.ShowText += "\r\n正在显示变电站信息\t" + System.DateTime.Now.ToString();
                int count = 0;
                foreach (XmlNode node in useList) {
                    count++;
                    XmlElement element = node as XmlElement;
                    string strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col2 desc,col22 desc,col42 desc,col62 desc";
                    switch (order) {
                        case 0:
                            strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col2 desc";
                            break;
                        case 1:
                            strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col22 desc";
                            break;
                        case 2:
                            strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col42 desc";
                            break;
                        case 3:
                            strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col62 desc";
                            break;
                        default:
                            strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col2 desc,col22 desc,col42 desc,col62 desc";
                            break;
                    }
                    //XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + element.GetAttribute("id") + "']");
                    //string strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col2 desc,col22 desc,col42 desc,col62 desc";
                    IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    if (listMX.Count <= 0)
                        continue;

                    if ((PSPDEV)(listMX[0]) != null) {
                        PSPDEV elementDEV = (PSPDEV)(listMX[0]);
                        PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                        elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        elcDEV.DeviceSUID = ((PSPDEV)listMX[0]).SUID;
                        elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                        if (elcDEV != null) {
                            RectangleF bound = ((IGraph)element).GetBounds();
                            XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@textn1id='" + element.GetAttribute("Deviceid") + "']") as XmlElement;
                            XmlElement n2 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@textn2id='" + element.GetAttribute("Deviceid") + "']") as XmlElement;
                            Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));

                            if (n1 == null) {
                                n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                n1.SetAttribute("x", Convert.ToString(bound.X));
                                n1.SetAttribute("y", Convert.ToString(bound.Y - (0 + 1) * 10 * tlVectorControl1.ScaleRatio));
                                n1.SetAttribute("font-size", "10");
                                n1.SetAttribute("font-family", "楷体_GB2312");
                                n1.SetAttribute("layer", SvgDocument.currentLayer);
                                //MessageBox.Show(Convert.ToString(n1.InnerText));

                                //n1.SetAttribute("layer", la.ID);
                                //MessageBox.Show(Convert.ToString(n1.InnerText));
                                n1.SetAttribute("flag", "1");
                                n1.SetAttribute("textn1id", element.GetAttribute("Deviceid"));
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            }

                            if (elementDEV.KSwitchStatus == "1") {
                                n1.InnerText = "0";
                            } else {
                                n1.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL2).ToString("N2");
                            }

                            if (elementDEV.KSwitchStatus == "0") {
                                if (Convert.ToDouble(GetColValue(elcDEV, order).COL2 == "" ? "0" : GetColValue(elcDEV, order).COL2) > elementDEV.jV || Convert.ToDouble(GetColValue(elcDEV, order).COL2 == "" ? "0" : GetColValue(elcDEV, order).COL2) < elementDEV.iV)//电压越限,需修改
                                    n1.SetAttribute("stroke", "#FF0000");

                            }
                            if (elementDEV.NodeType == "0") {

                                if (n2 == null) {
                                    n2 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    n2.SetAttribute("x", Convert.ToString(bound.X));
                                    n2.SetAttribute("y", Convert.ToString(bound.Y + bound.Height + 20));
                                    n2.SetAttribute("layer", SvgDocument.currentLayer);
                                    n2.SetAttribute("flag", "1");
                                    n2.SetAttribute("font-size", "10");
                                    n2.SetAttribute("font-family", "楷体_GB2312");
                                    n2.SetAttribute("textn2id", element.GetAttribute("Deviceid"));
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);
                                }
                                if (elementDEV.KSwitchStatus == "1") {
                                    n2.InnerText = "0" + "j" + "0";
                                } else {
                                    if (Convert.ToDouble(GetColValue(elcDEV, order).COL5) >= 0) {
                                        n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  + " + "j" + Convert.ToDouble(GetColValue(elcDEV, order).COL5).ToString("N2");
                                    } else {
                                        n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  - " + "j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                    }
                                }

                                double tempi = Convert.ToDouble(GetColValue(elcDEV, order).COL4);
                                double tempj = Convert.ToDouble(GetColValue(elcDEV, order).COL5);
                                double temptotal = Math.Sqrt(tempi * tempi + tempj * tempj);
                                if (temptotal > Convert.ToDouble(elementDEV.Burthen)) {
                                    n2.SetAttribute("stroke", "#FF0000");
                                }
                                //tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);

                            }
                            //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            //tlVectorControl1.Operation = ToolOperation.Select;
                            tlVectorControl1.Refresh();
                        }
                    }
                }
                XmlNodeList polyLineList = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline");
                wFrom.ShowText += "\r\n正在显示线路信息\t" + System.DateTime.Now.ToString();
                foreach (XmlNode node in polyLineList) {

                    XmlElement element = node as XmlElement;
                    PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                    elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    elcDEV.DeviceSUID = element.GetAttribute("Deviceid");
                    elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                    PSPDEV elementDEV = new PSPDEV();
                    Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));
                    if (elcDEV != null) {
                        elementDEV.SUID = elcDEV.DeviceSUID;
                        elementDEV = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", elementDEV);

                    } else {
                        continue;
                    }

                    if (elementDEV != null) {
                        PointF[] t = ((Polyline)element).Points;
                        PointF[] t2 = ((Polyline)element).FirstTwoPoint;
                        t = t2;
                        PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2));
                        float angel = 0f;
                        angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);

                        string l3 = Convert.ToString(midt.X);
                        string l4 = Convert.ToString(midt.Y);

                        string tran = ((Polyline)element).Transform.ToString();

                        PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2));
                        XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@textn1id='" + element.GetAttribute("Deviceid") + "']") as XmlElement;
                        //XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                        //XmlElement n3 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;

                        PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                        PointF pStart2 = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                        XmlNode firstNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("FirstNode") + "']");
                        XmlNode lastNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("LastNode") + "']");
                        if (firstNodeElement != null && lastNodeElement != null) {
                            if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350)) {
                                if (t2[0].X > ((IGraph)firstNodeElement).CenterPoint.X) {
                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                }
                            } else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90)) {
                                if (t2[0].Y > ((IGraph)firstNodeElement).CenterPoint.Y) {
                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                }
                            } else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180)) {
                                if (t2[0].Y > ((IGraph)firstNodeElement).CenterPoint.Y) {
                                    pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                                }
                            }
                        }

                        //if (t2[0].X > ((IGraph)firstNodeElement).CenterPoint.X || t2[0].Y < ((IGraph)firstNodeElement).CenterPoint.Y)
                        //{
                        //    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                        //    pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                        //}
                        //else
                        //{
                        //    pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                        //    pStart2 = new PointF(center.X + (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                        //}

                        PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));

                        if (n1 == null) {
                            n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            n1.SetAttribute("x", Convert.ToString(pStart.X));
                            n1.SetAttribute("y", Convert.ToString(pStart.Y));
                            n1.SetAttribute("layer", SvgDocument.currentLayer);
                            n1.SetAttribute("flag", "1");
                            n1.SetAttribute("font-size", "10");
                            n1.SetAttribute("font-family", "楷体_GB2312");
                            n1.SetAttribute("textn1id", element.GetAttribute("Deviceid"));
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            tlVectorControl1.Operation = ToolOperation.Select;

                            tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                            RectangleF ttt = ((Polyline)element).GetBounds();

                            tlVectorControl1.RotateSelection(angel, pStart);
                            if (Math.Abs(angel) > 90)
                                tlVectorControl1.RotateSelection(180, pStart);
                        }

                        if (elementDEV.KSwitchStatus == "1") {
                            n1.InnerText = "0" + "j" + "0";
                        } else {
                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL5) * Convert.ToDouble(GetColValue(elcDEV, order).COL4) >= 0) {
                                n1.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " + j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                            } else {
                                n1.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " - j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                            }

                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL14) > (double)(elementDEV.Burthen))//电流越限,需修改。
                                n1.SetAttribute("stroke", "#FF0000");
                            PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 10) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 10) * Math.PI / 180)));
                            PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 350) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 350) * Math.PI / 180)));

                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL4) < 0) {
                                p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 170) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 170) * Math.PI / 180)));
                                p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 190) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 190) * Math.PI / 180)));
                            }

                            string l1 = Convert.ToString(p1.X);
                            string l2 = Convert.ToString(p1.Y);
                            string l5 = Convert.ToString(p2.X);
                            string l6 = Convert.ToString(p2.Y);
                            XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("polygon") as Polygon;
                            n2.SetAttribute("points", l1 + " " + l2 + "," + l3 + " " + l4 + "," + l5 + " " + l6);
                            n2.SetAttribute("fill-opacity", "1");
                            n2.SetAttribute("layer", la.ID);
                            n2.SetAttribute("flag", "1");
                            n2.SetAttribute("font-size", "10");
                            n2.SetAttribute("style", "fill:#000000");
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);
                            tlVectorControl1.SVGDocument.CurrentElement = n2 as SvgElement;

                        }

                        n1.SetAttribute("font-family", "楷体_GB2312");

                        //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                        //tlVectorControl1.Operation = ToolOperation.Select;

                        //tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                        //RectangleF ttt = ((Polyline)element).GetBounds();

                        //tlVectorControl1.RotateSelection(angel, pStart);
                        //if (Math.Abs(angel) > 90)
                        //    tlVectorControl1.RotateSelection(180, pStart);

                        tlVectorControl1.Refresh();
                    }
                }
            } catch (System.Exception ex) {
                wFrom.ShowText += "\r\n结果显示出错,请检查数据和图形是否一致\t" + System.DateTime.Now.ToString();
                MessageBox.Show("参数错误,请调整参数后重新计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            wFrom.ShowText += "\r\n结果显示完毕\t " + System.DateTime.Now.ToString();
            tlVectorControl1.SVGDocument.CurrentLayer = (Layer)tlVectorControl1.SVGDocument.Layers[0];
        }
示例#5
0
        void tlVectorControl1_AddElement(object sender, AddSvgElementEventArgs e)
        {
            XmlElement temp = e.SvgElement as XmlElement;
            intdata(tlVectorControl1.SVGDocument.SvgdataUid);

            if (temp is Use && (temp.GetAttribute("xlink:href").Contains("Substation"))) {
                //frmSubstation dlgSubstation = new frmSubstation();
                //dlgSubstation.ProjectID = this.ProjectUID;
                //dlgSubstation.InitData();
                XmlNodeList listUSE = tlVectorControl1.SVGDocument.GetElementsByTagName("use");
                IList<object> listID = new List<object>();
                foreach (XmlNode node in listUSE) {
                    string str = ((XmlElement)node).GetAttribute("Deviceid");
                    PSP_Substation_Info obj = DeviceHelper.GetDevice<PSP_Substation_Info>(str);
                    if (obj != null) {
                        listID.Add((object)obj);
                    }
                }
                DeviceHelper.pspflag = true;
                object subID = DeviceHelper.SelectDevice("20", tlVectorControl1.SVGDocument.SvgdataUid, listID);

                XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                if (subID != null) {

                    RectangleF t = ((IGraph)temp).GetBounds();
                    n1.SetAttribute("x", (t.X + t.Width + 10).ToString());
                    n1.SetAttribute("y", (t.Y + t.Height / 2).ToString());
                    n1.InnerText = ((PSP_Substation_Info)subID).Title;
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    n1.SetAttribute("Deviceid", ((PSP_Substation_Info)subID).UID);
                    temp.SetAttribute("Deviceid", ((PSP_Substation_Info)subID).UID);
                    n1.SetAttribute("ParentID", temp.GetAttribute("id"));
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                    tlVectorControl1.Operation = ToolOperation.Select;
                    //PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                    //elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    //elcDEV.DeviceSUID = ((PSP_Substation_Info)subID).UID;
                    //Services.BaseService.Create<PSP_ElcDevice>(elcDEV);
                    //AddLine(temp, elcDEV.DeviceSUID);
                } else {
                    tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement;
                    tlVectorControl1.Delete();
                    return;
                }
                bool projectexitflag = false;               //检验此变电站是否在项目中
                foreach (eleclass ele in Subcol) {
                    if (ele.suid == ((PSP_Substation_Info)subID).UID && ele.selectflag == true) {
                        projectexitflag = true;
                        MessageBox.Show("已经选择此变电站,请重新选择其他的变电站!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement;
                        tlVectorControl1.Delete();
                        tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;
                        tlVectorControl1.Delete();
                    } else if (ele.suid == ((PSP_Substation_Info)subID).UID && ele.selectflag == false) {
                        projectexitflag = true;
                        Subcol.Remove(ele);
                        eleclass ele1 = new eleclass(((PSP_Substation_Info)subID).Title, ((PSP_Substation_Info)subID).UID, "20", true);
                        Subcol.Add(ele1);
                        PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                        elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        elcDEV.DeviceSUID = ((PSP_Substation_Info)subID).UID;
                        Services.BaseService.Create<PSP_ElcDevice>(elcDEV);
                        AddLine(temp, elcDEV.DeviceSUID);
                    }

                }
                if (!projectexitflag) {
                    MessageBox.Show("你所选择的项目中不包括此变电站!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement;
                    tlVectorControl1.Delete();
                    tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;
                    tlVectorControl1.Delete();
                }
            } else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("Power"))) {
                XmlNodeList listUSE = tlVectorControl1.SVGDocument.GetElementsByTagName("use");
                IList<object> listID = new List<object>();
                foreach (XmlNode node in listUSE) {
                    string str = ((XmlElement)node).GetAttribute("Deviceid");
                    PSP_PowerSubstation_Info obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(str);
                    if (obj != null) {
                        listID.Add((object)obj);
                    }
                }
                DeviceHelper.pspflag = true;
                object subID = DeviceHelper.SelectDevice("30", tlVectorControl1.SVGDocument.SvgdataUid, listID);
                XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                if (subID != null) {

                    RectangleF t = ((IGraph)temp).GetBounds();
                    n1.SetAttribute("x", (t.X + t.Width + 10).ToString());
                    n1.SetAttribute("y", (t.Y + t.Height / 2).ToString());
                    n1.InnerText = ((PSP_PowerSubstation_Info)subID).Title;
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    n1.SetAttribute("Deviceid", ((PSP_PowerSubstation_Info)subID).UID);
                    temp.SetAttribute("Deviceid", ((PSP_PowerSubstation_Info)subID).UID);
                    n1.SetAttribute("ParentID", temp.GetAttribute("id"));
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                    tlVectorControl1.Operation = ToolOperation.Select;
                    //PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                    //elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    //elcDEV.DeviceSUID = ((PSP_PowerSubstation_Info)subID).UID;
                    //Services.BaseService.Create<PSP_ElcDevice>(elcDEV);
                    //AddLine(temp, elcDEV.DeviceSUID);
                } else {
                    tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement;
                    tlVectorControl1.Delete();
                    return;
                }
                bool projectexitflag = false;               //检验此变电站是否在项目中
                foreach (eleclass ele in Powcol) {
                    if (ele.suid == ((PSP_PowerSubstation_Info)subID).UID && ele.selectflag == true) {
                        projectexitflag = true;
                        MessageBox.Show("已经选择此发电厂,请重新选择其他的发电厂!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement;
                        tlVectorControl1.Delete();
                        tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;
                        tlVectorControl1.Delete();
                    } else if (ele.suid == ((PSP_PowerSubstation_Info)subID).UID && ele.selectflag == false) {
                        projectexitflag = true;
                        Subcol.Remove(ele);
                        eleclass ele1 = new eleclass(((PSP_PowerSubstation_Info)subID).Title, ((PSP_PowerSubstation_Info)subID).UID, "30", true);
                        Subcol.Add(ele1);
                        PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                        elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        elcDEV.DeviceSUID = ((PSP_PowerSubstation_Info)subID).UID;
                        Services.BaseService.Create<PSP_ElcDevice>(elcDEV);
                        AddLine(temp, elcDEV.DeviceSUID);
                    }

                }
                if (!projectexitflag) {
                    MessageBox.Show("你所选择的项目中不包括此发电厂!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement;
                    tlVectorControl1.Delete();
                    tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;
                    tlVectorControl1.Delete();
                }
            }
        }
示例#6
0
        public bool LFCS(string projectSUID, int type, float ratedCapacity)
        {
            try
            {
                string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'  AND KSwitchStatus ='0'";
                string strCon2 = null;
                string strCon = null;
                string strData = null;
                string strBus = null;
                string strBranch = null;
                double Rad_to_Deg =  Math.PI / 180;
                {
                   // checkfhandfdj(projectSUID, ratedCapacity);
                    strCon2 = " AND Type = '01'";
                    strCon = strCon1 + strCon2;
                    IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strCon2 = " AND Type = '05'";
                    strCon = strCon1 + strCon2;
                    IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strCon2 = " AND Type = '02'";
                    strCon = strCon1 + strCon2;
                    IList listBYQ2 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strCon2 = " AND Type = '03'";
                    strCon = strCon1 + strCon2;
                    IList listBYQ3 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strData += (listXL.Count + listBYQ2.Count + listBYQ3.Count * 3).ToString() + " " + listMX.Count.ToString() + " " + listMX.Count.ToString() + " " + "0.00001" + " " + "100" + " " + "0" + " " + "0";
                    foreach (PSPDEV dev in listXL)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (strBranch != null)
                            {
                                strBranch += "\r\n";
                            }
                            if (strData != null)
                            {
                                strData += "\r\n";
                            }
                            if (dev.FirstNode==dev.LastNode)
                            {
                                if (dev.UnitFlag == "0")
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "3" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0";
                                    strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString());
                                }
                                else
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "3" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0";
                                    strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                                }
                            }
                            else
                            {
                                if (dev.UnitFlag == "0")
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0";
                                    strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString());
                                }
                                else
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0";
                                    strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                                }
                            }

                        }
                    }
                    foreach (PSPDEV dev in listBYQ2)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (strBranch != null)
                            {
                                strBranch += "\r\n";
                            }
                            if (strData != null)
                            {
                                strData += "\r\n";
                            }
                            if (dev.UnitFlag == "0")
                            {
                                strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString();
                                strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.K).ToString() + " " + dev.G.ToString() + " " + dev.Name.ToString());
                            }
                            else
                            {
                                strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString();
                                strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.K.ToString()).ToString() + " " + dev.G.ToString() + " " + dev.Name.ToString());
                            }
                        }
                    }
                    foreach (PSPDEV dev in listBYQ3)
                    {
                        if (dev.KSwitchStatus == "0")
                        {

                            if (dev.UnitFlag == "0")
                            {
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (strData != null)
                                {
                                    strData += "\r\n";
                                }
                                strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ1.ToString() + " " + dev.HuganTQ4.ToString() + " " + "0" + " " + dev.K.ToString() + " " + "0";
                                strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.HuganTQ1).ToString() + " " + (dev.HuganTQ4).ToString() + " " + (dev.K).ToString() + " " + "0" + " " + dev.Name.ToString());
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (strData != null)
                                {
                                    strData += "\r\n";
                                }
                                strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ2.ToString() + " " + dev.HuganTQ5.ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + "0";
                                strData += (dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ2).ToString() + " " + (dev.HuganTQ5).ToString() + " " + (dev.StandardCurrent).ToString() + " " + "0" + " " + dev.Name.ToString());
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (strData != null)
                                {
                                    strData += "\r\n";
                                }
                                strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ3.ToString() + " " + dev.ZeroTQ.ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + "0";
                                strData += (dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ3).ToString() + " " + (dev.ZeroTQ).ToString() + " " + (dev.BigP).ToString() + " " + "0" + " " + dev.Name.ToString());

                            }
                            else
                            {
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (strData != null)
                                {
                                    strData += "\r\n";
                                }
                                strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ1 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ4 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.K.ToString() + " " + "0";
                                strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.HuganTQ1 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ4 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.K).ToString() + " " + "0" + " " + dev.Name.ToString());
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (strData != null)
                                {
                                    strData += "\r\n";
                                }
                                strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ2 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ5 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + "0";
                                strData += (dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ2 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ5 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.StandardCurrent).ToString() + " " + "0" + " " + dev.Name.ToString());
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (strData != null)
                                {
                                    strData += "\r\n";
                                }
                                strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ3 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.ZeroTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + "0";
                                strData += (dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ3 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.ZeroTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.BigP).ToString() + " " + "0" + " " + dev.Name.ToString());
                            }
                        }
                    }
                    foreach (PSPDEV dev in listMX)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (strBus != null)
                            {
                                strBus += "\r\n";
                            }
                            if (strData != null)
                            {
                                strData += "\r\n";
                            }
                            double outP = 0;
                            double outQ = 0;
                            double inputP = 0;
                            double inputQ = 0;
                            string strCon3 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND Type = '04' AND IName = '" + dev.Name + "'";
                            IList listFDJ = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon3);
                            string strCon4 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND Type = '12' AND IName = '" + dev.Name + "'";
                            IList listFH = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon4);
                            foreach (PSPDEV devFDJ in listFDJ)
                            {
                                if (devFDJ.UnitFlag == "0")
                                {
                                    outP += devFDJ.OutP;
                                    outQ += devFDJ.OutQ;
                                }
                                else
                                {
                                    outP += devFDJ.OutP / ratedCapacity;
                                    outQ += devFDJ.OutQ / ratedCapacity;
                                }
                            }
                            foreach (PSPDEV devFH in listFH)
                            {
                                if (devFH.UnitFlag == "0")
                                {
                                    inputP += devFH.InPutP;
                                    inputQ += devFH.InPutQ;
                                    //上海新加
                                    if (devFH.OutP != 0)
                                    {
                                        inputP += devFH.OutP;
                                    }
                                    if (devFH.OutQ != 0)
                                    {
                                        inputQ += devFH.OutQ;
                                    }
                                }
                                else
                                {
                                    inputP += devFH.InPutP / ratedCapacity;
                                    inputQ += devFH.InPutQ / ratedCapacity;
                                    //上海新加
                                    if (devFH.OutP != 0)
                                    {
                                        inputP += devFH.OutP/ ratedCapacity;
                                    }
                                    if (devFH.OutQ != 0)
                                    {
                                        inputQ += devFH.OutQ/ ratedCapacity;
                                    }
                                }
                            }
                            //if (mxflag.ContainsKey(dev.SUID))
                            //{
                            //    gltj tj = mxflag[dev.SUID];
                            //    outP += tj.outP;
                            //    outQ += tj.outQ;
                            //    inputP += tj.inputP;
                            //    inputQ += tj.inputQ;
                            //}

                            if (dev.UnitFlag == "0")
                            {
                                outP += dev.OutP;
                                outQ += dev.OutQ;
                                inputP += dev.InPutP;
                                inputQ += dev.InPutQ ;
                                strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR ).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + ((inputP - outP)).ToString() + " " + ((inputQ - outQ)).ToString());
                                //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString());
                                if (dev.NodeType == "1")
                                {
                                    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((outP)).ToString() + " " + ((outQ)).ToString());
                                }
                                else if (dev.NodeType == "2")
                                {
                                    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((outP)).ToString() + " " + (dev.VoltR).ToString());
                                }
                                else if (dev.NodeType == "0")
                                {
                                    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (dev.VoltR).ToString() + " " + "0");
                                }
                            }
                            else
                            {
                                outP += dev.OutP / ratedCapacity;
                                outQ += dev.OutQ / ratedCapacity;
                                inputP += dev.InPutP / ratedCapacity;
                                inputQ += dev.InPutQ / ratedCapacity;
                                strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + ((inputP - outP)).ToString() + " " + ((inputQ - outQ)).ToString());
                                //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                                if (dev.NodeType == "1")
                                {
                                    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (outP).ToString() + " " + (outQ).ToString());
                                }
                                else if (dev.NodeType == "2")
                                {
                                    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (outP).ToString() + " " + (dev.VoltR / dev.ReferenceVolt).ToString());
                                }
                                else if (dev.NodeType == "0")
                                {
                                    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + "0");
                                }
                            }
                        }
                    }
                    foreach (PSPDEV dev in listMX)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (strData != null)
                            {
                                strData += "\r\n";
                            }
                            double outP = 0;
                            double outQ = 0;
                            double inputP = 0;
                            double inputQ = 0;
                            string strCon3 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND Type = '04' AND IName = '" + dev.Name + "'";
                            IList listFDJ = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon3);
                            string strCon4 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND Type = '12' AND IName = '" + dev.Name + "'";
                            IList listFH = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon4);
                            foreach (PSPDEV devFDJ in listFDJ)
                            {
                                if (devFDJ.UnitFlag == "0")
                                {
                                    outP += devFDJ.OutP;
                                    outQ += devFDJ.OutQ;
                                }
                                else
                                {
                                    outP += devFDJ.OutP / ratedCapacity;
                                    outQ += devFDJ.OutQ / ratedCapacity;
                                }
                            }
                            foreach (PSPDEV devFH in listFH)
                            {
                                if (devFH.UnitFlag == "0")
                                {
                                    inputP += devFH.InPutP;
                                    inputQ += devFH.InPutQ;
                                    //上海新加
                                    if (devFH.OutP != 0)
                                    {
                                        inputP += devFH.OutP;
                                    }
                                    if (devFH.OutQ != 0)
                                    {
                                        inputQ += devFH.OutQ;
                                    }
                                }
                                else
                                {
                                    inputP += devFH.InPutP / ratedCapacity;
                                    inputQ += devFH.InPutQ / ratedCapacity;
                                    //上海新加
                                    if (devFH.OutP != 0)
                                    {
                                        inputP += devFH.OutP/ ratedCapacity;
                                    }
                                    if (devFH.OutQ != 0)
                                    {
                                        inputQ += devFH.OutQ/ ratedCapacity;
                                    }
                                }
                            }
                            if (dev.UnitFlag == "0")
                            {
                                outP += dev.OutP;
                                outQ += dev.OutQ;
                                inputP += dev.InPutP;
                                inputQ += dev.InPutQ;
                            }
                            else
                            {
                                outP += dev.OutP / ratedCapacity;
                                outQ += dev.OutQ / ratedCapacity;
                                inputP += dev.InPutP / ratedCapacity;
                                inputQ += dev.InPutQ / ratedCapacity;
                            }
                            strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + "0" + " " + "0" + " " + "0" + " " + "0" + " " + "0" + " " + ((inputP)).ToString() + " " + ((inputQ)).ToString());

                        }
                    }
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\data.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\data.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\branch.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\branch.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\bus.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\bus.txt");
                }
                FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\data.txt"), FileMode.OpenOrCreate);
                StreamWriter str1 = new StreamWriter(VK, Encoding.Default);
                str1.Write(strData);
                str1.Close();

                FileStream VK1 = new FileStream((System.Windows.Forms.Application.StartupPath + "\\branch.txt"), FileMode.OpenOrCreate);
                StreamWriter str3 = new StreamWriter(VK1, Encoding.Default);
                str3.Write(strBranch);
                str3.Close();
                FileStream L = new FileStream((System.Windows.Forms.Application.StartupPath + "\\bus.txt"), FileMode.OpenOrCreate);
                StreamWriter str2 = new StreamWriter(L, Encoding.Default);
                str2.Write(strBus);
                str2.Close();

                if (strData.Contains("非数字") || strData.Contains("正无穷大") || strBus.Contains("非数字") || strBus.Contains("正无穷大") || strBranch.Contains("非数字") || strBranch.Contains("正无穷大"))
                {
                    MessageBox.Show("缺少参数,请检查输入参数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return false;
                }

                if (type == 1)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF1.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\PF1.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\DH1.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\IH1.txt");
                    }
                    NIULA nr = new NIULA();
                    nr.CurrentCal();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF1.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    FileStream pf = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF1.txt", FileMode.Open);
                    StreamReader readLine = new StreamReader(pf, Encoding.Default);
                    char[] charSplit = new char[] { ' ' };
                    string strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '01' AND Number = " + array1[0];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL1 = devMX.Name;
                                elcDev.COL19 = devMX.ReferenceVolt.ToString();
                                elcDev.COL20 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[1], out temp);
                                elcDev.COL2 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[2], out temp);
                                elcDev.COL3 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL4 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL5 = (temp * ratedCapacity).ToString();

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    FileStream dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);
                    readLine = new StreamReader(dh, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL1 = devMX.Name;
                                elcDev.COL2 = devMX.FirstNode.ToString();
                                elcDev.COL3 = devMX.LastNode.ToString();
                                elcDev.COL19 = devMX.ReferenceVolt.ToString();
                                if (Convert.ToDouble(devMX.Burthen) == 0.0)
                                {
                                    elcDev.COL20 = ratedCapacity.ToString();
                                }
                                else
                                    elcDev.COL20 = devMX.Burthen.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL4 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL5 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[5], out temp);
                                elcDev.COL6 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[6], out temp);
                                elcDev.COL7 = (temp * ratedCapacity).ToString();

                                temp = 0.0;
                                double.TryParse(array1[7], out temp);
                                elcDev.COL8 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[8], out temp);
                                elcDev.COL9 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[9], out temp);
                                elcDev.COL10 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();

                                temp = 0.0;
                                double.TryParse(array1[10], out temp);
                                elcDev.COL11 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[11], out temp);
                                elcDev.COL12 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[12], out temp);
                                elcDev.COL13 = (temp * (devMX.ReferenceVolt)).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    FileStream ih = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH1.txt", FileMode.Open);
                    readLine = new StreamReader(ih, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL1 = devMX.Name;
                                elcDev.COL2 = devMX.FirstNode.ToString();
                                elcDev.COL3 = devMX.LastNode.ToString();
                                elcDev.COL19 = devMX.ReferenceVolt.ToString();
                                if (Convert.ToDouble(devMX.Burthen) == 0.0)
                                {
                                    elcDev.COL20 = ratedCapacity.ToString();
                                }
                                else
                                    elcDev.COL20 = devMX.Burthen.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL14 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL15 = (temp * Rad_to_Deg).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                }
                else if (type == 2)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF2.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\PF2.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH2.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\DH2.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH2.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\IH2.txt");
                    }
                    PQ_PowerFlowCalClass pq = new PQ_PowerFlowCalClass();
                    pq.CurrentCal();

                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF2.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    FileStream pf = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF2.txt", FileMode.Open);
                    StreamReader readLine = new StreamReader(pf, Encoding.Default);
                    char[] charSplit = new char[] { ' ' };
                    string strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '01' AND Number = " + array1[0];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL21 = devMX.Name;
                                elcDev.COL39 = devMX.ReferenceVolt.ToString();
                                elcDev.COL40 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[1], out temp);
                                elcDev.COL22 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[2], out temp);
                                elcDev.COL23 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL24 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL25 = (temp * ratedCapacity).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH2.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    FileStream dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH2.txt", FileMode.Open);
                    readLine = new StreamReader(dh, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL21 = devMX.Name;
                                elcDev.COL22 = devMX.FirstNode.ToString();
                                elcDev.COL23 = devMX.LastNode.ToString();
                                elcDev.COL39 = devMX.ReferenceVolt.ToString();
                                elcDev.COL40 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL24 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL25 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[5], out temp);
                                elcDev.COL26 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[6], out temp);
                                elcDev.COL27 = (temp * ratedCapacity).ToString();

                                temp = 0.0;
                                double.TryParse(array1[7], out temp);
                                elcDev.COL28 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[8], out temp);
                                elcDev.COL29 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[9], out temp);
                                elcDev.COL30 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();

                                temp = 0.0;
                                double.TryParse(array1[10], out temp);
                                elcDev.COL31 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[11], out temp);
                                elcDev.COL32 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[12], out temp);
                                elcDev.COL33 = (temp * (devMX.ReferenceVolt)).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH2.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    FileStream ih = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH2.txt", FileMode.Open);
                    readLine = new StreamReader(ih, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL21 = devMX.Name;
                                elcDev.COL22 = devMX.FirstNode.ToString();
                                elcDev.COL23 = devMX.LastNode.ToString();
                                elcDev.COL39 = devMX.ReferenceVolt.ToString();
                                elcDev.COL40 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL34 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL35 = (temp * Rad_to_Deg).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                }
                else if (type == 3)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF3.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\PF3.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH3.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\DH3.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH3.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\IH3.txt");
                    }
                    Gauss gs = new Gauss();
                    gs.CurrentCal();

                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF3.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    FileStream pf = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF3.txt", FileMode.Open);
                    StreamReader readLine = new StreamReader(pf, Encoding.Default);
                    char[] charSplit = new char[] { ' ' };
                    string strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '01' AND Number = " + array1[0];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL41 = devMX.Name;
                                elcDev.COL59 = devMX.ReferenceVolt.ToString();
                                elcDev.COL60 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[1], out temp);
                                elcDev.COL42 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[2], out temp);
                                elcDev.COL43 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL44 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL45 = (temp * ratedCapacity).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH3.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    FileStream dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH3.txt", FileMode.Open);
                    readLine = new StreamReader(dh, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL41 = devMX.Name;
                                elcDev.COL42 = devMX.FirstNode.ToString();
                                elcDev.COL43 = devMX.LastNode.ToString();
                                elcDev.COL59 = devMX.ReferenceVolt.ToString();
                                elcDev.COL60 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL44 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL45 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[5], out temp);
                                elcDev.COL46 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[6], out temp);
                                elcDev.COL47 = (temp * ratedCapacity).ToString();

                                temp = 0.0;
                                double.TryParse(array1[7], out temp);
                                elcDev.COL48 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[8], out temp);
                                elcDev.COL49 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[9], out temp);
                                elcDev.COL50 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();

                                temp = 0.0;
                                double.TryParse(array1[10], out temp);
                                elcDev.COL51 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[11], out temp);
                                elcDev.COL52 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[12], out temp);
                                elcDev.COL53 = (temp * (devMX.ReferenceVolt)).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH3.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    FileStream ih = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH3.txt", FileMode.Open);
                    readLine = new StreamReader(ih, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL41 = devMX.Name;
                                elcDev.COL42 = devMX.FirstNode.ToString();
                                elcDev.COL43 = devMX.LastNode.ToString();
                                elcDev.COL59 = devMX.ReferenceVolt.ToString();
                                elcDev.COL60 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL54 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL55 = (temp * Rad_to_Deg).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                }
                else if (type == 4)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF4.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\PF4.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH4.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\DH4.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH4.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\IH4.txt");
                    }
                    ZYZ zy = new ZYZ();
                    zy.CurrentCal();

                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF4.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    FileStream pf = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF4.txt", FileMode.Open);
                    StreamReader readLine = new StreamReader(pf, Encoding.Default);
                    char[] charSplit = new char[] { ' ' };
                    string strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '01' AND Number = " + array1[0];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL61 = devMX.Name;
                                elcDev.COL79 = devMX.ReferenceVolt.ToString();
                                elcDev.COL80 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[1], out temp);
                                elcDev.COL62 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[2], out temp);
                                elcDev.COL63 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL64 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL65 = (temp * ratedCapacity).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH4.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    FileStream dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH4.txt", FileMode.Open);
                    readLine = new StreamReader(dh, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL61 = devMX.Name;
                                elcDev.COL62 = devMX.FirstNode.ToString();
                                elcDev.COL63 = devMX.LastNode.ToString();
                                elcDev.COL79 = devMX.ReferenceVolt.ToString();
                                elcDev.COL80 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL64 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL65 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[5], out temp);
                                elcDev.COL66 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[6], out temp);
                                elcDev.COL67 = (temp * ratedCapacity).ToString();

                                temp = 0.0;
                                double.TryParse(array1[7], out temp);
                                elcDev.COL68 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[8], out temp);
                                elcDev.COL69 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[9], out temp);
                                elcDev.COL70 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();

                                temp = 0.0;
                                double.TryParse(array1[10], out temp);
                                elcDev.COL71 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[11], out temp);
                                elcDev.COL72 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[12], out temp);
                                elcDev.COL73 = (temp * (devMX.ReferenceVolt)).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH4.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    FileStream ih = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH4.txt", FileMode.Open);
                    readLine = new StreamReader(ih, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL61 = devMX.Name;
                                elcDev.COL62 = devMX.FirstNode.ToString();
                                elcDev.COL63 = devMX.LastNode.ToString();
                                elcDev.COL79 = devMX.ReferenceVolt.ToString();
                                elcDev.COL80 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL74 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL75 = (temp * Rad_to_Deg).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                }

            }
            catch (System.Exception ex)
            {
                MessageBox.Show("潮流计算结果不收敛,请检查输入参数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return false;
            }
            return true;
        }
示例#7
0
        void barSelectDevice_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TreeListNode node;
            if (strID == null) {
                MessageBox.Show("����ѡ��������㷽����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //strID = node["ID"].ToString();
            DataTable dt = new DataTable();
            frmDeviceList frmDevList = new frmDeviceList();
            frmDevList.ProjectID = this.ProjectUID;
            frmDevList.ProjectSUID = strID;
            node = treeList2.FocusedNode;
            string devicenodename = null;
            if (node != null) {
                devicenodename = node["name"].ToString();
            }
            frmDevList.DeviceName = devicenodename;
            frmDevList.Init();
            if (frmDevList.ShowDialog() == DialogResult.OK) {
                foreach (DataRow row in frmDevList.DT.Rows) {
                    try {
                        if ((bool)row["C"]) {
                            PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                            elcDevice.DeviceSUID = row["A"].ToString();
                            elcDevice.ProjectSUID = strID;
                            UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice);
                        } else {
                            PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                            elcDevice.DeviceSUID = row["A"].ToString();
                            elcDevice.ProjectSUID = strID;
                            UCDeviceBase.DataService.Delete<PSP_ElcDevice>(elcDevice);
                        }
                    } catch (System.Exception ex) {

                    }
                }
                if (curDevice != null) {
                    curDevice.strCon = ",psp_elcdevice where psp_elcdevice.devicesuid = pspdev.suid and psp_elcdevice.projectsuid = '" + strID + "' and ";
                    curDevice.Init();
                }
            }
        }
        void barSelectDevice_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TreeListNode node;
            if (strID == null) {
                MessageBox.Show("����ѡ��������㷽����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            frmSeldevtype fm = new frmSeldevtype();
            int devtype = 0;
            if (fm.ShowDialog() == DialogResult.OK)
            {
                devtype = fm.UnitFlag;
            }
            else
                return;
            //strID = node["ID"].ToString();
            DataTable dt = new DataTable();
            frmDeviceList_sh frmDevList = new frmDeviceList_sh();
            frmDevList.ProjectID = this.ProjectUID;
            frmDevList.ProjectSUID = strID;
            frmDevList.BelongYear = parentobj.BelongYear;
            frmDevList.Devicetype = devtype;
            node = treeList2.FocusedNode;
            string devicenodename = null;
            if (node != null) {
                devicenodename = node["name"].ToString();
            }
            frmDevList.DeviceName = devicenodename;
            frmDevList.initCheckcombox();
            frmDevList.initcombox();
            if (frmDevList.ShowDialog() == DialogResult.OK) {
                foreach (DataRow row in frmDevList.DT.Rows) {
                    try {
                        if ((bool)row["C"]) {
                            PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                            elcDevice.DeviceSUID = row["A"].ToString();
                            elcDevice.ProjectSUID = strID;
                            UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice);
                        } else {
                            PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                            elcDevice.DeviceSUID = row["A"].ToString();
                            elcDevice.ProjectSUID = strID;
                            UCDeviceBase.DataService.Delete<PSP_ElcDevice>(elcDevice);
                        }
                    } catch (System.Exception ex) {

                    }
                }
                if (curDevice != null) {

                    if (curDevice.GetClassName() == "PSP_Substation_Info")
                    {
                        curDevice.proInit(parentobj.ID);
                    }
                    else if (curDevice.GetClassName() == "PSP_PowerSubstation_Info")
                    {
                        curDevice.proInit(parentobj.ID);
                    }
                    else if (curDevice.GetClassName() == "PSPDEV")
                    {
                        curDevice.strCon = ",psp_elcdevice where psp_elcdevice.devicesuid = pspdev.suid and psp_elcdevice.projectsuid = '" + strID + "' and ";
                        curDevice.Init();
                    }
                }
            }
        }
 private void barCopy_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     //TreeListNode node = treeList1.FocusedNode;
     if (string.IsNullOrEmpty(strID))
     {
         MessageBox.Show("����ѡ��������㷽����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     } else {
         if (MessageBox.Show("�Ƿ��Ʒ�����" + parentobj.Name,"��ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
         {
             string name = "����" + parentobj.Name.ToString();
             string strC = " Name like '" + name + "%'";
             IList list1 = UCDeviceBase.DataService.GetList("SelectPSP_ELCPROJECTByWhere", strC);
             if (list1.Count>0)
             {
                 name = "����" + parentobj.Name + "-" + list1.Count.ToString();
             }
             string strCon = " WHERE ProjectSUID = '" + parentobj.ID + "'";
             IList list = UCDeviceBase.DataService.GetList("SelectPSP_ElcDeviceByCondition", strCon);
             PSP_ELCPROJECT elcPro = new PSP_ELCPROJECT();
             elcPro.FileType = parentobj.FileType;
             elcPro.Name = name;
             elcPro.ProjectID = Itop.Client.MIS.ProgUID;
             elcPro.Class = System.DateTime.Now.ToString();
             DataRow row = datatable.NewRow();
             Itop.Common.DataConverter.ObjectToRow(elcPro, row);
             datatable.Rows.Add(row);
             UCDeviceBase.DataService.Create<PSP_ELCPROJECT>(elcPro);
             SVGFILE svg = UCDeviceBase.DataService.GetOneByKey<SVGFILE>(parentobj.ID);
             SVGFILE svgNew = new SVGFILE();
             svgNew.SUID = elcPro.ID;
             svgNew.FILENAME = elcPro.Name;
             svgNew.SVGDATA = svg.SVGDATA;
             UCDeviceBase.DataService.Create<SVGFILE>(svgNew);
             foreach (PSP_ElcDevice elcDEV in list) {
                 PSP_ElcDevice elcElement = new PSP_ElcDevice();
                 elcElement.ProjectSUID = elcPro.ID;
                 elcElement.DeviceSUID = elcDEV.DeviceSUID;
                 UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcElement);
             }
         }
         return;
     }
 }
示例#10
0
 public void Init()
 {
     dt.Columns.Add("A");
     dt.Columns.Add("B");
     dt.Columns.Add("C", typeof(bool));
     Stream fs = Assembly.GetExecutingAssembly().GetManifestResourceStream("Itop.TLPSP.DEVICE.devicetypes.xml");
     //Assembly.GetExecutingAssembly().GetManifestResourceStream
     XmlDocument xml = new XmlDocument();
     xml.Load(fs);
     XmlNodeList nodes = xml.GetElementsByTagName("device");
     DataTable table = new DataTable();
     table.Columns.Add("id", typeof(string));
     table.Columns.Add("name", typeof(string));
     table.Columns.Add("class", typeof(string));
     foreach (XmlNode node in nodes)
     {
         DataRow row = table.NewRow();
         row["id"] = node.Attributes["id"].Value;
         row["name"] = node.Attributes["name"].Value;
         row["class"] = node.Attributes["class"].Value;
         table.Rows.Add(row);
     }
     comboBox1.DataSource = table;
     comboBox1.DisplayMember = "name";
     if (DeviceName!=null)
     {
         comboBox1.Text=DeviceName;
     }
     {
         dt.Clear();
         object obj = comboBox1.SelectedItem;
         if (obj != null)
         {
             DataRowView row1 = obj as DataRowView;
             string id = row1.Row["id"].ToString();
             string con = " where type = '" + id + "'";
             string con2 = " and ProjectID = '" + this.ProjectID + "'";
             con = con + con2;
             IList list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
             foreach (PSPDEV dev in list)
             {
                 PSP_ElcDevice pspDev = new PSP_ElcDevice();
                 pspDev.DeviceSUID = dev.SUID;
                 pspDev.ProjectSUID = ProjectSUID;
                 IList list1 = Services.BaseService.GetList("SelectPSP_ElcDeviceByKey", pspDev);
                 if (list1.Count > 0)
                 {
                     DataRow row = dt.NewRow();
                     row["A"] = dev.SUID;
                     row["B"] = dev.Name;
                     row["C"] = true;
                     dt.Rows.Add(row);
                 }
                 else
                 {
                     DataRow row = dt.NewRow();
                     row["A"] = dev.SUID;
                     row["B"] = dev.Name;
                     row["C"] = false;
                     dt.Rows.Add(row);
                 }
             }
         }
         gridControl1.DataSource = dt;
     }
 }
示例#11
0
        private void ShowResult(int order, string projectsuid, string FileName, int pspouttype, frnReport wFrom)
        {
            try
            {
                //删除原来的text文本
                //XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");

                //foreach (XmlNode node in list)
                //{
                //    SvgElement element = node as SvgElement;
                //    tlVectorControl1.SVGDocument.CurrentElement = element;
                //    tlVectorControl1.Delete();
                //}
                wFrom.ShowText += "\r\n开始显示计算结果\t" + System.DateTime.Now.ToString();
                double yinzi = 0, capability = 0, volt = 0, standvolt = 0, current = 0;
                PSPDEV benchmark = new PSPDEV();
                benchmark.Type = "power";
                benchmark.SvgUID = projectsuid;
                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);
                    TLPSPVmin = dev.iV;
                    TLPSPVmax = dev.jV;
                    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);
                };
                Layer lar = null;
                if (Layer.CkLayerExist(FileName, tlVectorControl1.SVGDocument))
                {
                    ArrayList layercol = tlVectorControl1.SVGDocument.getLayerList();
                    for (int i = 0; i < layercol.Count; i++)
                    {
                        if (FileName == (layercol[i] as Layer).GetAttribute("label"))
                        {
                            lar = (Layer)layercol[i];
                            break;
                        }
                    }
                }
                else
                {
                    lar = Layer.CreateNew(FileName, tlVectorControl1.SVGDocument);

                    lar.SetAttribute("layerType", progtype);
                    lar.SetAttribute("ParentID", tlVectorControl1.SVGDocument.CurrentLayer.GetAttribute("ParentID"));
                    this.frmlar.checkedListBox1.SelectedIndex = -1;
                    this.frmlar.checkedListBox1.Items.Add(lar, true);
                }
                int size = tlVectorControl1.ScaleRatio > 1 ? 12 : (int)(12 / tlVectorControl1.ScaleRatio);
                XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");
                foreach (XmlNode node in useList)
                {
                    XmlElement element = node as XmlElement;
                    string strCon = null;
                    IList listMX = null;
                    if (pspouttype == 0)
                    {
                        strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectsuid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'";
                        listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    }

                    //XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + element.GetAttribute("id") + "']");
                    if (pspouttype == 1)
                    {
                        bool pspflag = false;
                        PSP_Substation_Info ps = new PSP_Substation_Info();
                        ps.UID = (element).GetAttribute("Deviceid");
                        ps = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", ps);
                        if (ps != null)
                        {
                            if (ps.Flag == "2")
                            {
                                strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectsuid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'";
                                listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                            }

                            pspflag = true;
                        }
                        if (!pspflag)
                        {
                            PSP_PowerSubstation_Info ppi = new PSP_PowerSubstation_Info();
                            ppi.UID = (element).GetAttribute("Deviceid");
                            ppi = (PSP_PowerSubstation_Info)Services.BaseService.GetObject("SelectPSP_PowerSubstation_InfoByKey", ppi);
                            if (ppi != null)
                            {
                                if (ppi.Flag == "2")
                                {
                                    strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectsuid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'";
                                    listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                                }

                            }
                        }

                    }

                    if (listMX != null)
                    {
                        for (int i = 0; i < listMX.Count; i++)
                        {
                            PSPDEV elementDEV = (PSPDEV)(listMX[i]);
                            PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                            elcDEV.ProjectSUID = projectsuid;
                            elcDEV.DeviceSUID = ((PSPDEV)listMX[i]).SUID;
                            elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                            if (elcDEV != null)
                            {
                                XmlElement elementn1 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID1='" + ((PSPDEV)listMX[i]).SUID + "']") as XmlElement;
                                XmlElement elementn2 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID2='" + ((PSPDEV)listMX[i]).SUID + "']") as XmlElement;
                                if (elementn1 == null)
                                {
                                    //RectangleF bound = ((IGraph)element).GetBounds();
                                    //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    //XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    //n1.SetAttribute("x", Convert.ToString(bound.X));
                                    //n1.SetAttribute("y", Convert.ToString(bound.Y - i * 20));
                                    //n1.SetAttribute("font-size", size.ToString());//"12");
                                    //n1.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL2).ToString("N2");
                                    ////Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));
                                    //n1.SetAttribute("layer", lar.ID);
                                    ////MessageBox.Show(Convert.ToString(n1.InnerText));
                                    //n1.SetAttribute("flag", "1");
                                    //n1.SetAttribute("ParentID1", ((PSPDEV)listMX[i]).SUID);
                                    //if (Convert.ToDouble(GetColValue(elcDEV, order).COL2) > TLPSPVmax * elementDEV.RateVolt / elementDEV.ReferenceVolt || Convert.ToDouble(GetColValue(elcDEV, order).COL2) < TLPSPVmin * elementDEV.RateVolt / elementDEV.ReferenceVolt)//电压越限,需修改
                                    //    n1.SetAttribute("stroke", "#FF0000");
                                    //if (elementDEV.NodeType == "0")
                                    //{

                                    //    n2.SetAttribute("x", Convert.ToString(bound.X));
                                    //    n2.SetAttribute("y", Convert.ToString(bound.Y + bound.Height + 20));
                                    //    if (Convert.ToDouble(elcDEV.COL5) >= 0)
                                    //    {
                                    //        n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  + " + "j" + Convert.ToDouble(GetColValue(elcDEV, order).COL5).ToString("N2");
                                    //    }
                                    //    else
                                    //    {
                                    //        n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  - " + "j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                    //    }
                                    //    n2.SetAttribute("layer", lar.ID);
                                    //    n2.SetAttribute("flag", "1");
                                    //    n2.SetAttribute("ParentID", ((PSPDEV)listMX[i]).SUID);
                                    //    n2.SetAttribute("font-size", size.ToString());//"12");
                                    //    // n2.SetAttribute("limitsize", "true");

                                    //    double tempi = Convert.ToDouble(GetColValue(elcDEV, order).COL4);
                                    //    double tempj = Convert.ToDouble(GetColValue(elcDEV, order).COL5);
                                    //    double temptotal = Math.Sqrt(tempi * tempi + tempj * tempj);
                                    //    if (temptotal > Convert.ToDouble(elementDEV.Burthen))
                                    //    {
                                    //        n2.SetAttribute("stroke", "#FF0000");
                                    //    }
                                    //    tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);

                                    //}
                                    //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                    //tlVectorControl1.Operation = ToolOperation.Select;
                                }
                                else
                                {
                                    //elementn1.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL2).ToString("N2");
                                    //if (Convert.ToDouble(GetColValue(elcDEV, order).COL2) > TLPSPVmax * elementDEV.RateVolt / elementDEV.ReferenceVolt || Convert.ToDouble(GetColValue(elcDEV, order).COL2) < TLPSPVmin * elementDEV.RateVolt / elementDEV.ReferenceVolt)//电压越限,需修改
                                    //    elementn1.SetAttribute("stroke", "#FF0000");
                                    //if (elementDEV.NodeType == "0")
                                    //{

                                    //    if (Convert.ToDouble(elcDEV.COL5) >= 0)
                                    //    {
                                    //        elementn2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  + " + "j" + Convert.ToDouble(GetColValue(elcDEV, order).COL5).ToString("N2");
                                    //    }
                                    //    else
                                    //    {
                                    //        elementn2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  - " + "j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                    //    }
                                    //}
                                }

                            } tlVectorControl1.Refresh();
                        }
                    }

                }
                List<PSPDEV> listline = new List<PSPDEV>();
                if (pspouttype==1)
                {
                     SelShowlineform selbusfrm = new SelShowlineform();
                    selbusfrm.ProjectSUID = projectsuid;
                    selbusfrm.ProjectID = Itop.Client.MIS.ProgUID;
                    selbusfrm.ShowDialog();
                    if (selbusfrm.DialogResult == DialogResult.OK)
                    {

                        foreach (DataRow row in selbusfrm.DT.Rows)
                        {
                            try
                            {
                                if ((bool)row["C"])
                                {
                                    PSPDEV psp = new PSPDEV();
                                    psp.SUID = row["A"].ToString();

                                    psp = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByKey", psp);
                                    if (psp != null)
                                    {
                                        listline.Add(psp);
                                    }
                                }

                            }
                            catch (System.Exception ex)
                            {

                            }
                        }
                        if (listline.Count == 0)
                        {
                            MessageBox.Show("没有选择显示的线路!");
                            return;
                        }
                    }
                }
                wFrom.ShowText += "\r\n正在显示线路信息\t" + System.DateTime.Now.ToString();
                XmlNodeList polyLineList = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline");

                foreach (XmlNode node in polyLineList)
                {
                    XmlElement element = node as XmlElement;
                    PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                    elcDEV.ProjectSUID = projectsuid;
                    elcDEV.DeviceSUID = element.GetAttribute("Deviceid");
                    elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                    PSPDEV elementDEV = new PSPDEV();
                    if (elcDEV != null)
                    {
                        elementDEV.SUID = elcDEV.DeviceSUID;
                        elementDEV = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", elementDEV);
                        if (pspouttype == 1)                             //如果只显示规划线路的数据
                        {
                            bool flag = false;
                            foreach (PSPDEV showdev in listline)
                            {
                                if (elementDEV.SUID==showdev.SUID)
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            if (!flag)
                            {
                                //删除不是选中的线路的数据

                                XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID='" + elementDEV.SUID + "']") as XmlElement;
                                if (elementdl != null)
                                {
                                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(elementdl);
                                }
                                tlVectorControl1.Refresh();

                                continue;
                            }
                            //if (Convert.ToInt32(elementDEV.OperationYear) <= DateTime.Now.Year)
                            //{
                            //    continue;
                            //}
                        }
                    }
                    else
                    {
                        continue;
                    }

                    if (elementDEV != null && elementDEV.KSwitchStatus == "0")
                    {
                        XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID='" + elementDEV.SUID + "']") as XmlElement;

                        if (elementdl == null)
                        {
                            List<PointF> pcol = CheckLenth((Polyline)element);

                            PointF[] t = ((Polyline)element).Points;
                            PointF[] t2 = ((Polyline)element).Points; t = t2;
                            int lastnum = t2.Length - 1;
                            PointF midt = new PointF((float)((pcol[0].X + pcol[1].X) / 2), (float)((pcol[0].Y + pcol[1].Y) / 2));
                            float angel = 0f;
                            angel = (float)(180 * Math.Atan2((pcol[0].Y - pcol[1].Y), (pcol[1].X - pcol[0].X)) / Math.PI);

                            string l3 = Convert.ToString(midt.X);
                            string l4 = Convert.ToString(midt.Y);

                            string tran = ((Polyline)element).Transform.ToString();

                            PointF center = new PointF((float)(pcol[0].X + (pcol[1].X - pcol[0].X) / 2), (float)(pcol[0].Y + (pcol[1].Y - pcol[0].Y) / 2));
                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            // XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                            //XmlElement n3 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;

                            PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                            PointF pStart2 = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                            XmlNode firstNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("FirstNode") + "']");
                            XmlNode lastNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("LastNode") + "']");
                            //if (firstNodeElement != null)
                            {
                                if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350))
                                {
                                    //if (t2[0].X > ((IGraph)firstNodeElement).CenterPoint.X)
                                    //{
                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    //}
                                }
                                else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90))
                                {
                                    //if (t2[0].Y > ((IGraph)firstNodeElement).CenterPoint.Y)
                                    //{
                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    //}
                                }
                                else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180))
                                {
                                    //if (t2[0].Y > ((IGraph)firstNodeElement).CenterPoint.Y)
                                    //{
                                    pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                                    //}
                                }
                                if (Convert.ToDouble(GetColValue(elcDEV, order).COL5) >= 0)
                                {
                                    n1.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " + j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                }
                                else
                                {
                                    n1.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " - j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                }
                                Graphics dd = this.CreateGraphics();
                                Font ff = new Font("宋体", 12);
                                SizeF sf = dd.MeasureString(n1.InnerText, ff);
                                double ztlength = Math.Sqrt(sf.Width * sf.Width + sf.Height * sf.Height);
                                PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));
                                //n1.SetAttribute("x", Convert.ToString(center.X - (float)(Math.Sin((angel) * Math.PI / 180) * ztlength)));
                                //n1.SetAttribute("y", Convert.ToString(center.Y - (float)(Math.Cos((angel) * Math.PI / 180) * ztlength)));

                                n1.SetAttribute("x", Convert.ToString(center.X));
                                n1.SetAttribute("y", Convert.ToString(center.Y));

                                //Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));
                                n1.SetAttribute("layer", lar.ID);
                                n1.SetAttribute("ParentID", elementDEV.SUID);
                                n1.SetAttribute("flag", "1");
                                n1.SetAttribute("Showline", "1");            //为显示哪条线路做标志
                                n1.SetAttribute("font-size", "96");// size.ToString());//"12");
                                // n1.SetAttribute("limitsize", "true");
                                if (Convert.ToDouble(GetColValue(elcDEV, order).COL14) > (elementDEV.LineChange))//电流越限,需修改。

                                    n1.SetAttribute("stroke", "#FF0000");

                                //PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 25) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 25) * Math.PI / 180)));
                                //PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 335) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 335) * Math.PI / 180)));

                                //if (Convert.ToDouble(elcDEV.COL4) < 0)
                                //{
                                //    p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 155) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 155) * Math.PI / 180)));
                                //    p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 205) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 205) * Math.PI / 180)));
                                //}

                                //string l1 = Convert.ToString(p1.X);
                                //string l2 = Convert.ToString(p1.Y);
                                //string l5 = Convert.ToString(p2.X);
                                //string l6 = Convert.ToString(p2.Y);

                                //n2.SetAttribute("points", l1 + " " + l2 + "," + l3 + " " + l4 + "," + l5 + " " + l6);
                                //n2.SetAttribute("fill-opacity", "1");
                                //n2.SetAttribute("layer", SvgDocument.currentLayer);
                                //n2.SetAttribute("flag", "1");
                                //n2.SetAttribute("font-size", "6");
                                //tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);
                                //tlVectorControl1.SVGDocument.CurrentElement = n2 as SvgElement;

                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                tlVectorControl1.Operation = ToolOperation.Select;

                                tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                                RectangleF ttt = ((Polyline)element).GetBounds();

                                tlVectorControl1.RotateSelection(angel, pStart);
                                if (Math.Abs(angel) > 90)
                                    tlVectorControl1.RotateSelection(180, pStart);

                            }
                        }
                        else
                        {
                            elementdl.SetAttribute("Showline", "1");            //为显示哪条线路做标志
                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL5) >= 0)
                            {
                                elementdl.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " + j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                            }
                            else
                            {
                                elementdl.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " - j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                            }
                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL14) > (elementDEV.LineChange))//电流越限,需修改。

                                elementdl.SetAttribute("stroke", "#FF0000");
                        }
                        tlVectorControl1.Refresh();
                    }
                    //删除不投入运行的输出结果
                    else if (elementDEV != null && elementDEV.KSwitchStatus == "1")
                    {
                        XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID='" + elementDEV.SUID + "']") as XmlElement;
                        if (elementdl != null)
                        {
                            tlVectorControl1.SVGDocument.RootElement.RemoveChild(elementdl);
                        }
                        tlVectorControl1.Refresh();
                    }

                }
                //this.frmlar.checkedListBox1.Items.Add(lar, true);
                //this.frmlar.checkedListBox1.SelectedIndex = -1;
                MessageBox.Show("显示完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("参数错误,请调整参数后重新计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
示例#12
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     dt.Clear();
     object obj = comboBox1.SelectedItem;
     if (obj!=null)
     {
         DataRowView row1 = obj as DataRowView;
         string id = row1.Row["id"].ToString();
         string con = " where type = '" + id + "'";
         string con2 = " and ProjectID = '" + this.ProjectID + "'";
         con = con + con2;
         IList list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
         foreach (PSPDEV dev in list)
         {
             PSP_ElcDevice pspDev = new PSP_ElcDevice();
             pspDev.DeviceSUID = dev.SUID;
             pspDev.ProjectSUID = ProjectSUID;
             IList list1 = Services.BaseService.GetList("SelectPSP_ElcDeviceByKey",pspDev);
             if (list1.Count>0)
             {
                 DataRow row = dt.NewRow();
                 row["A"] = dev.SUID;
                 row["B"] = dev.Name;
                 row["C"] = true;
                 dt.Rows.Add(row);
             }
             else
             {
                 DataRow row = dt.NewRow();
                 row["A"] = dev.SUID;
                 row["B"] = dev.Name;
                 row["C"] = false;
                 dt.Rows.Add(row);
             }
         }
     }
     gridControl1.DataSource = dt;
 }
示例#13
0
        //���ݲ����Ĵ���������ʾ
        public void Allshortcheck(string projectSUID, string projectid, double ratecaplity, int caozuoi)
        {
            try
            {
                string con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                PSPDEV pspDev = new PSPDEV();
                IList list1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                PSPDEV psp = new PSPDEV();
                Dictionary<string, double> nodeshorti = new Dictionary<string, double>();      //��¼ĸ����û�н��й���·
                KeyValuePair<string, double> maxshorti = new KeyValuePair<string, double>();
                con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='06'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                IList list = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                if (caozuoi != 3)
                {
                    AllShorti(projectSUID, projectid, 0, ratecaplity, nodeshorti);
                    //�ҳ���·��������ֵ
                    //maxshorti.Key = 1;
                    //maxshorti.Value = nodeshorti[1];

                    foreach (KeyValuePair<string, double> keyvalue in nodeshorti)
                    {
                        if (keyvalue.Value > maxshorti.Value)
                        {
                            maxshorti = keyvalue;
                        }
                    }

                    //����ȡ����·�� �ж�����ĸ���ڲ��� ������ھͽ���ɾ�� Ȼ������ѹ���бȽ�

                    for (int i = 0; i < list.Count; i++)
                    {
                        bool flag = false;
                        pspDev = list[i] as PSPDEV;
                        for (int j = 0; j < list1.Count; j++)
                        {
                            psp = list1[j] as PSPDEV;
                            if (pspDev.IName == psp.Name)
                                flag = true;

                        }
                        if (!flag)
                        {
                            PSP_ElcDevice pel = new PSP_ElcDevice();
                            pel.ProjectSUID = projectSUID;
                            pel.DeviceSUID = pspDev.SUID;
                            UCDeviceBase.DataService.Delete<PSP_ElcDevice>(pel);
                            //UCDeviceBase.DataService.Delete<PSPDEV>(pspDev);
                        }
                    }
                    con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='06'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                    list = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    for (int i = 0; i < list.Count; i++)
                    {
                        pspDev = list[i] as PSPDEV;
                        pspDev.HuganLine3 = "";
                        pspDev.KName = "";
                        if (pspDev.KSwitchStatus == "0")
                        {
                            pspDev.OutP = maxshorti.Value;
                            if (maxshorti.Value > pspDev.HuganTQ1)
                            {
                                pspDev.HuganLine3 = "���ϸ�";
                            }
                            else
                            {
                                pspDev.HuganLine3 = "�ϸ�";
                            }
                            pspDev.HuganLine4 = "";
                            if (pspDev.HuganLine3 == "�ϸ�")
                            {
                                pspDev.KName = "�ϸ�";
                            }
                            else
                                pspDev.KName = "���ϸ�";
                        }

                        UCDeviceBase.DataService.Update<PSPDEV>(pspDev);
                    }
                }

                switch (caozuoi)
                {
                    case 1:           //ȫ����·����
                        {
                            pspDev.SvgUID = projectSUID;
                            pspDev.Type = "06";
                            DlqiCheckform dlqicheckform = new DlqiCheckform(pspDev);
                            dlqicheckform.getusercltr.gridView.GroupPanelText = "��·�����������������������";
                            dlqicheckform.ShowDialog();
                            break;
                        }
                    case 2:             //����·����
                        {
                            con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='06'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                            list = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            for (int i = 0; i < list.Count; i++)
                            {
                                pspDev = list[i] as PSPDEV;
                                if (pspDev.KSwitchStatus == "0")
                                {
                                    con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0'AND PSPDEV.Name='" + pspDev.IName + "'";

                                    IList list4 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                                    psp = list4[0] as PSPDEV;
                                    try
                                    {
                                        pspDev.OutQ = nodeshorti[psp.Name];
                                        if (pspDev.HuganLine3 == "���ϸ�")
                                        {
                                            if (pspDev.OutQ <= pspDev.HuganTQ1)
                                            {
                                                pspDev.HuganLine3 = "�ϸ�";
                                            }
                                        }
                                        pspDev.HuganLine4 = "";

                                        if (pspDev.HuganLine3 == "�ϸ�")
                                        {
                                            pspDev.KName = "�ϸ�";
                                        }
                                        else
                                            pspDev.KName = "���ϸ�";
                                        UCDeviceBase.DataService.Update<PSPDEV>(pspDev);
                                    }
                                    catch (System.Exception ex)
                                    {
                                        MessageBox.Show("��·���ݲ�����");
                                    }
                                }

                            }
                            pspDev.SvgUID = projectSUID;
                            pspDev.Type = "06";
                            DlqiCheckform dlqicheckform = new DlqiCheckform(pspDev);
                            dlqicheckform.getusercltr.gridView.GroupPanelText = "����·У�˽����";
                            dlqicheckform.ShowDialog();
                            break;
                        }
                    case 3:          //��·��ֱ������
                        {
                            con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='06'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                            list = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            for (int i = 0; i < list.Count; i++)
                            {
                                pspDev = list[i] as PSPDEV;
                                if (pspDev.KSwitchStatus == "0")
                                {
                                    double tx = 0.0;
                                    if (pspDev.HuganLine2 == "���ѿ۶�·��")
                                    {
                                        tx = 0.0;
                                    }
                                    else if (pspDev.HuganLine2 == "���������ѿ۵Ķ�·��")
                                    {
                                        tx = 10;
                                    }
                                    pspDev.HuganTQ4 = (pspDev.OutP / pspDev.HuganTQ1) * Math.Exp((-pspDev.HuganTQ2 - tx) / 45) * 100;
                                    pspDev.HuganTQ5 = (pspDev.OutQ / pspDev.HuganTQ1) * Math.Exp((-pspDev.HuganTQ2 - tx) / 45) * 100;
                                    if (pspDev.HuganTQ3 >= pspDev.HuganTQ4)
                                    {
                                        pspDev.HuganLine4 = "�ϸ�";
                                    }
                                    if (pspDev.HuganTQ3 >= pspDev.HuganTQ5)
                                    {
                                        pspDev.HuganLine4 = "�ϸ�";
                                    }
                                    else if (pspDev.HuganTQ3 < pspDev.HuganTQ5)
                                    {
                                        pspDev.HuganLine4 = "���ϸ�";
                                    }
                                    if (pspDev.HuganLine3 == "�ϸ�" && pspDev.HuganLine4 == "�ϸ�")
                                    {
                                        pspDev.KName = "�ϸ�";
                                    }
                                    else
                                    {
                                        pspDev.KName = "���ϸ�";
                                    }

                                    UCDeviceBase.DataService.Update<PSPDEV>(pspDev);
                                }

                            }
                            pspDev.SvgUID = projectSUID;
                            pspDev.Type = "06";
                            DlqiCheckform dlqicheckform = new DlqiCheckform(pspDev);
                            dlqicheckform.getusercltr.gridView.GroupPanelText = "��·��������������������";
                            dlqicheckform.ShowDialog();
                            break;
                        }

                }

            }
            catch (System.Exception ex)
            {
                MessageBox.Show("��·����������������·�����Ƿ��ܽ��У�");
            }
        }
示例#14
0
        /*public void ResetPoly()
        {
            SvgElementCollection col= tlVectorControl1.SVGDocument.SelectCollection;
            if(col.Count<1){
                return;
            }
            SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();
            foreach(SvgElement ele in col){
                if (ele.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                {
                    glebeProperty p=new glebeProperty();
                    p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    p.EleID = ((IGraph)ele).ID;
                    p = Services.BaseService.GetObject("SelectglebePropertyByEleID", p);
                    if(p!=null){
                        PointF[] tfArray1 = TLMath.getPolygonPoints(ele);
                        GraphicsPath selectAreaPath = new GraphicsPath();
                        selectAreaPath.AddLines(tfArray1);
                        selectAreaPath.CloseFigure();
                        Region region1 = new Region(selectAreaPath);
                        while (enumerator1.MoveNext())
                        {
                            IGraph graph1 = (IGraph)enumerator1.Current;
                            GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                            path1.Transform(graph1.GraphTransform.Matrix);
                            Region region2 = new Region(path1);
                            region2.Intersect(region1);
                            if (!region2.GetBounds(Graphics.FromHwnd(IntPtr.Zero)).IsEmpty)
                            {
                                glebeProperty p1 = new glebeProperty();
                                p1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                p1.EleID = graph1.ID;
                                p1 = Services.BaseService.GetObject("SelectglebePropertyByEleID", p1);
                                if(p1!=null){
                                    p1.ParentEleID = p.UID;
                                    Services.BaseService.Update("UpdateglebePropertyAreaAll", p1);
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show("更新完成。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }*/
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try {
                if (e.ClickedItem.Text == "可靠性分析") {
                    XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                        string deviceid = xml1.GetAttribute("Deviceid");
                        if (!string.IsNullOrEmpty(deviceid)) {
                            DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                            DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;

                            PSPDEV obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                            if (obj != null && obj.Type == "73") {
                                //更换为元件可靠性
                                Itop.TLPSP.DEVICE.FrmpdrelProject xf = new Itop.TLPSP.DEVICE.FrmpdrelProject();
                                xf.init(obj);
                                xf.ShowDialog();
                            }

                        }
                    }

                }
                if (e.ClickedItem.Text == "属性") {
                    XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    //PointF[] pf = TLMath.getPolygonPoints(xml1);
                    DeviceHelper.xml1 = xml1;
                    //((Polygon)xml1).Transform.Matrix.TransformPoints(pf);
                    // 规划
                    if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) {

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择规划区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") {
                            //frmImgManager frm = new frmImgManager();
                            //frm.Show();
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use");
                            PointF[] tfArray1 = TLMath.getPolygonPoints(xml1);
                            string str220 = "";
                            string str110 = "";
                            string str66 = "";

                            string str_id = "";
                            GraphicsPath selectAreaPath = new GraphicsPath();
                            selectAreaPath.AddLines(tfArray1);
                            selectAreaPath.CloseFigure();
                            //Matrix x=new Matrix(
                            //Region region1 = new Region(selectAreaPath);
                            for (int i = 0; i < n1.Count; i++) {
                                float OffX = 0f;
                                float OffY = 0f;
                                bool ck = false;
                                Use use = (Use)n1[i];
                                if (use.GetAttribute("xlink:href").Contains("byq") || use.GetAttribute("xlink:href").Contains("pds")) {
                                    if (selectAreaPath.IsVisible(use.CenterPoint)) {
                                        if (use.GetAttribute("Deviceid") != "") {
                                            str_id = str_id + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                    }
                                }
                                if (use.GetAttribute("xlink:href").Contains("Substation")) {
                                    //string strMatrix = use.GetAttribute("transform");
                                    //if (strMatrix != "")
                                    //{
                                    //    strMatrix = strMatrix.Replace("matrix(", "");
                                    //    strMatrix = strMatrix.Replace(")", "");
                                    //    string[] mat = strMatrix.Split(',');
                                    //    if (mat.Length > 5)
                                    //    {
                                    //        OffX = Convert.ToSingle(mat[4]);
                                    //        OffY = Convert.ToSingle(mat[5]);
                                    //    }
                                    //}
                                    //if (frmlar.getSelectedLayer().Contains(use.GetAttribute("layer"))) {
                                    //    ck = true;
                                    //}
                                    for (int j= 0; j< frmlar.GetSelectLayers().Count;j++ )
                                    {
                                        if ((frmlar.GetSelectLayers()[j] as Layer).ID==use.GetAttribute("layer"))
                                        {
                                            ck = true;
                                        }
                                    }
                                    PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href"));
                                    //if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY) && ck)
                                    if (selectAreaPath.IsVisible(use.CenterPoint) && ck) {
                                        if (use.GetAttribute("xlink:href").Contains("220")) {
                                            str220 = str220 + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                        if (use.GetAttribute("xlink:href").Contains("110")) {
                                            str110 = str110 + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                        if (use.GetAttribute("xlink:href").Contains("66")) {
                                            str66 = str66 + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                    }
                                }
                            }
                            if (str220.Length > 1) {
                                str220 = str220.Substring(0, str220.Length - 1);
                            }
                            if (str110.Length > 1) {
                                str110 = str110.Substring(0, str110.Length - 1);
                            }
                            if (str66.Length > 1) {
                                str66 = str66.Substring(0, str66.Length - 1);
                            }
                            if (str_id.Length > 1) {
                                str_id = str_id.Substring(0, str_id.Length - 1);
                            }
                            glebeProperty _gle = new glebeProperty();
                            _gle.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                            _gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                            IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle);
                            if (UseProList.Count > 0) {
                                _gle = UseProList[0];
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();
                                f.strID = str_id;
                                f.InitData(_gle, str220, str110, str66);
                                PointF[] pn = (PointF[])((Polygon)xml1).Points.Clone();
                                ((Polygon)xml1).Transform.Matrix.TransformPoints(pn);
                                string s1 = "";
                                for (int p = 0; p < pn.Length; p++) {
                                    s1 = s1 + pn[p].X.ToString() + " " + pn[p].Y.ToString() + ",";
                                }
                                f.Str = s1;
                                f.ShowDialog();
                                if (f.checkBox1.Checked == false) {
                                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(tlVectorControl1.SVGDocument.CurrentElement);
                                }
                                //tlVectorControl1.Refresh();
                            } else {
                                _gle = new glebeProperty();
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();
                                f.strID = str_id;
                                f.InitData(_gle, str220, str110, str66);
                                PointF[] pn = (PointF[])((Polygon)xml1).Points.Clone();
                                ((Polygon)xml1).Transform.Matrix.TransformPoints(pn);
                                string s1 = "";
                                for (int p = 0; p < pn.Length; p++) {
                                    s1 = s1 + pn[p].X.ToString() + " " + pn[p].Y.ToString() + ",";
                                }
                                f.Str = s1;
                                f.ShowDialog();
                            }
                            //}
                        }

                    }
                    if (getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) {

                        if (tlVectorControl1.SVGDocument.getRZBRatio() != "") {
                            rzb = tlVectorControl1.SVGDocument.getRZBRatio();
                        }

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            string IsArea = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsArea");
                            if (IsArea != "") {

                                frmProperty f = new frmProperty();//地块属性
                                if (SelUseArea == "") { SelUseArea = "0"; }
                                f.XZ_bdz = XZ_bdz;
                                f.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer);
                                //f.ShowDialog();
            #if(!CITY)
                                //将其中心点保存在XML中
                                PointF p = TLMath.polyCentriod((XmlElement)tlVectorControl1.SVGDocument.CurrentElement);
                                string title = p.X.ToString() + "," + p.Y.ToString();
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("centrpoint", title);
                                if (progtype != "城市规划层") {
                                    f.IsReadonly = true;
                                }
            #endif
                                if (f.ShowDialog() == DialogResult.OK) {
                                    SVG_ENTITY ent = new SVG_ENTITY();
                                    if (f.IsCreate) {
                                        ent.SUID = Guid.NewGuid().ToString();
                                        ent.EleID = f.gPro.EleID;
                                        ent.layerID = f.gPro.LayerID;
                                        ent.MDATE = System.DateTime.Now;
                                        ent.NAME = f.gPro.UseID;
                                        ent.svgID = f.gPro.SvgUID;
                                        ent.TYPE = "polygon-dk";
                                        //ent.voltage = f.gPro.Voltage;
                                        Services.BaseService.Create<SVG_ENTITY>(ent);
                                    } else {
                                        ent.NAME = f.gPro.UseID;
                                        ent.layerID = f.gPro.LayerID;
                                        ent.MDATE = System.DateTime.Now;
                                        //ent.voltage = fl.Line.Voltage;
                                        Services.BaseService.Update<SVG_ENTITY>(ent);
                                    }
                                    if (f.gPro.ObligateField1 != "") {
                                        string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(f.gPro.ObligateField1)));
                                        color1 = "fill:" + color1 + ";";
                                        ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", color1);
                                        tlVectorControl1.UpdateProperty();
                                    }
                                    if (xzwcflag == "1" && f.bdzflag)
                                   {

                                          if (extsublist.Count > 0 && subandfhlist.Count > 0)
                                          {
                                              bool sfsflag=false;
                                              for(int m=0;m<polylist.Count;m++)
                                              {
                                               if((polylist[m] as XmlElement).GetAttribute("id")==f.gPro.EleID)
                                               {
                                                   sfsflag=true;
                                                   break;
                                               }

                                              }
                                              if (!sfsflag)
                                              {
                                                  MessageBox.Show("地块非选址的地块中 请重新选址!");
                                                  return;
                                              }
                                              try
                                              {
                                                List<Layer> layercol=  getxzxllayers(tlVectorControl1.SVGDocument.getLayerList());
                                                  if (layercol.Count>0)
                                                  {
                                                      FrmSelxzlayer frm=new FrmSelxzlayer();
                                                      frm.Layercol=layercol;
                                                      if (frm.ShowDialog()==DialogResult.OK)
                                                      {
                                                          string layerid=frm.sellayerid;
                                                           RebdzxzResult1(subandfhlist, extsublist, f.gPro, f.bdzzqname,layerid);
                                                      }
                                                      else
                                                        RebdzxzResult(subandfhlist, extsublist, f.gPro, f.bdzzqname);
                                                  }
                                                 // RebdzxzResult(subandfhlist, extsublist, f.gPro, f.bdzzqname);
                                              }
                                              catch (System.Exception ex)
                                              {
                                                  MessageBox.Show("请计算有问题 请重新计算!");
                                                  return;
                                              }

                                          }
                                          else
                                          {
                                              MessageBox.Show("选址变电站没有数据 请重新选址!");
                                              return;
                                          }

                                  }
                                 else
                                  {
                                      MessageBox.Show("请重新选址!");
                                     return;
                                  }

                                }
                            }
                        }
                    }
                    if (!Wjghboolflag) {
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                            string lineWidth = "2";
                            string IsLead = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsLead");
                            //if (IsLead != "")       //原先导线的属性添加情况

                            if (IsLead != "")       //修改后的导线的属性添加情况
                            {
                                XmlNodeList n11 = tlVectorControl1.SVGDocument.SelectNodes("svg/polygon [@IsArea='1']");
                                using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) {
                                    List<glebeProperty> glist = new List<glebeProperty>();
                                    for (int i = 0; i < n11.Count; i++) {
                                        IGraph graph1 = (IGraph)n11[i];
                                        GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                                        //path1.Transform(graph1.GraphTransform.Matrix);
                                        Region ef1 = new Region(path1);

                                        Polyline line = tlVectorControl1.SVGDocument.CurrentElement as Polyline;
                                        GraphicsPath gr2 = new GraphicsPath();
                                        //gr2.AddLines(pfs);
                                        gr2.AddPath(line.GPath, true);
                                        gr2.CloseFigure();
                                        Region region = new Region(gr2);
                                        ef1.Intersect(region);
                                        if (!ef1.GetBounds(g).IsEmpty) {
                                            glebeProperty gy = new glebeProperty();
                                            gy.EleID = graph1.ID;
                                            gy.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                            gy = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", gy);
                                            if (gy != null) {
                                                glebeType gt = new glebeType();
                                                gt.UID = gy.TypeUID;
                                                gt = (glebeType)Services.BaseService.GetObject("SelectglebeTypeByKey", gt);
                                                gy.TypeUID = gt.TypeName;
                                                glist.Add(gy);
                                            }
                                        }
                                    }
                                    DeviceHelper.glist = glist;
                                }
                                string dhx = xml1.GetAttribute("dhx_key");
                                if (dhx == "1" && checkEdit2.Checked == false) {
                                    frmDHXdlg d = new frmDHXdlg();
                                    d.uid = xml1.GetAttribute("id");
                                    d.Show();
                                    return;
                                }

                                PSPDEV obj = new PSPDEV();
                                string deviceid = xml1.GetAttribute("Deviceid");
                                DeviceHelper.pspflag = false;
                                DeviceHelper.Wjghflag = false;
                                if (string.IsNullOrEmpty(deviceid)) {
                                    string[] deviceType = new string[] { "05", "73", "75" };
                                    string xlwhere = " where SUID not in (";
                                    XmlNodeList lslist = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@Deviceid!=''] [@layer='" + SvgDocument.currentLayer + "']");
                                    for (int x1 = 0; x1 < lslist.Count; x1++) {
                                        XmlElement _node = lslist[x1] as XmlElement;
                                        xlwhere = xlwhere + "'" + _node.GetAttribute("Deviceid") + "',";
                                    }
                                    if (xlwhere.Length > 20) {
                                        xlwhere = xlwhere.Substring(0, xlwhere.Length - 1);
                                        xlwhere = xlwhere + ") and ";
                                    } else {
                                        xlwhere = "";
                                    }
                                    DeviceHelper.xlwhere = xlwhere;
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(Itop.Client.MIS.ProgUID, deviceType);
                                    DeviceHelper.xlwhere = "";
                                    if (obj is PSPDEV) {
                                        deviceid = ((PSPDEV)obj).SUID;
                                        xml1.SetAttribute("Deviceid", deviceid);
                                        obj.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        obj.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        obj.EleID = ((SvgElement)xml1).ID;
                                        Services.BaseService.Update<PSPDEV>(obj);

                                        //将其设备加入到计算方案中
                                        //获得方案名称
                                        PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                                        pd.ID = frmlar.FAID;
                                        pd = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pd);
                                        if (pd != null) {
                                            bool operflag = false, dataflag = false;
                                            if (!string.IsNullOrEmpty(((PSPDEV)obj).OperationYear) && ((PSPDEV)obj).OperationYear.Length == 4 && pd.BelongYear.Length == 4) {
                                                if (Convert.ToInt32(((PSPDEV)obj).OperationYear) < Convert.ToInt32(pd.BelongYear)) {
                                                    operflag = true;
                                                }
                                            }
                                            if (!string.IsNullOrEmpty(((PSPDEV)obj).Date2) && ((PSPDEV)obj).Date2.Length == 4 && pd.BelongYear.Length == 4) {
                                                if (Convert.ToInt32(((PSPDEV)obj).Date2) > Convert.ToInt32(pd.BelongYear)) {
                                                    dataflag = true;
                                                }
                                            }
                                            if (operflag && dataflag) {
                                                PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                                                elcDevice.DeviceSUID = deviceid;
                                                elcDevice.ProjectSUID = frmlar.FAID;
                                                elcDevice = UCDeviceBase.DataService.GetOneByKey<PSP_ElcDevice>(elcDevice);
                                                if (elcDevice == null) {
                                                    elcDevice = new PSP_ElcDevice();
                                                    elcDevice.DeviceSUID = deviceid;
                                                    elcDevice.ProjectSUID = frmlar.FAID;
                                                    UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice);
                                                }
                                            }

                                        }

                                    }
                                }
                                if (!string.IsNullOrEmpty(deviceid)) {
                                    DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                                    DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;

                                    obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                                    if (obj != null)//------------wwwMX
                                    {
                                        xml1.SetAttribute("info-name", ((PSPDEV)obj).Name);
                                        if (obj.Type == "05") {
                                            DeviceHelper.ShowDeviceDlg(DeviceType.XL, deviceid, false);
                                        }
                                        if (obj.Type == "01") {
                                            DeviceHelper.ShowDeviceDlg(DeviceType.MX, deviceid, false);
                                        }
                                        if (obj.Type == "73") {
                                            DeviceHelper.ShowDeviceDlg(DeviceType.PDXL, deviceid, false);
                                        }
                                        if (obj.Type == "75") {
                                            DeviceHelper.ShowDeviceDlg(DeviceType.LUX, deviceid, false);
                                        }
                                    }

                                    //***** ********添加FistNode和LastNode
                                    XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");

                                    foreach (XmlNode element in useList) {
                                        if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid"))) {
                                            string con = "WHERE SvgUID='" + (element as XmlElement).GetAttribute("Deviceid") + "'AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='01'";
                                            IList pspMX = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                            if (pspMX != null) {
                                                foreach (PSPDEV pspmx in pspMX) {
                                                    if (obj.IName == pspmx.Name) {
                                                        (xml1 as XmlElement).SetAttribute("FirstNode", (element as XmlElement).GetAttribute("id"));

                                                    } else if (obj.JName == pspmx.Name) {
                                                        (xml1 as XmlElement).SetAttribute("LastNode", (element as XmlElement).GetAttribute("id"));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                //**

                            }
                        }

                        if (xml1.GetAttribute("xlink:href").Contains("Substation") || xml1.GetAttribute("xlink:href").Contains("Power")) {//变电站属性
                            string lab = xml1.GetAttribute("xlink:href");

                            float x = 0f;
                            float y = 0f;
                            //判断电压等级
                            int dyinfo = Convert.ToInt32(getDY(lab));
                            x = ((Use)xml1).X;

                            y = ((Use)xml1).Y;

                            PointF p1 = new PointF(x, y);
                            PointF[] pnt = new PointF[1];
                            pnt[0] = p1;
                            Use temp = xml1.Clone() as Use;
                            temp.Transform.Matrix.TransformPoints(pnt);

                            LongLat templat = mapview.OffSetZero(-(int)(pnt[0].X * tlVectorControl1.ScaleRatio), -(int)(pnt[0].Y * tlVectorControl1.ScaleRatio));

                            string[] jd = templat.Longitude.ToString("####.####").Split('.');
                            int d1 = Convert.ToInt32(jd[0]);
                            string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                            int f1 = Convert.ToInt32(df1[0]);
                            decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                            string[] wd = templat.Latitude.ToString("####.####").Split('.');
                            int d2 = Convert.ToInt32(wd[0]);
                            string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                            int f2 = Convert.ToInt32(df2[0]);
                            decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;

                            string strjwd = "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″";
                            object obj = null;
                            string deviceid = xml1.GetAttribute("Deviceid");
                            DeviceHelper.pspflag = false;
                            DeviceHelper.Wjghflag = false;
                            if (dyinfo >= 66) {
                                DeviceHelper.subflag = false;
                            } else
                                DeviceHelper.subflag = true;
                        Lab1://变电站、电源属性
                            if (string.IsNullOrEmpty(deviceid)) {
                                //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                    obj = DeviceHelper.SelectDevice(DeviceType.DY, Itop.Client.MIS.ProgUID);
                                    //if (obj == null)
                                    //{
                                    //    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    //    tlVectorControl1.Delete();
                                    //}
                                    if (obj is PSP_PowerSubstation_Info) {
                                        deviceid = ((PSP_PowerSubstation_Info)obj).UID;
                                        ((PSP_PowerSubstation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        //((PSP_PowerSubstation_Info)obj). = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        Services.BaseService.Update<PSP_PowerSubstation_Info>(((PSP_PowerSubstation_Info)obj));
                                        xml1.SetAttribute("Deviceid", deviceid);
                                        xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title);

                                        //获得方案名称
                                        PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                                        pd.ID = frmlar.FAID;
                                        pd = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pd);
                                        if (pd != null) {
                                            string where = "where projectid='" + Itop.Client.MIS.ProgUID + "'and SvgUID='" + ((PSP_PowerSubstation_Info)obj).UID + "'";
                                            IList<PSPDEV> list = Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", where);
                                            //根据年份进行筛选
                                            if (!string.IsNullOrEmpty(pd.BelongYear))   //根据参与计算设备属于那一年先进行一次筛选
                                            {
                                                for (int i = 0; i < list.Count; i++) {
                                                    if (!string.IsNullOrEmpty((list[i] as PSPDEV).OperationYear) && (list[i] as PSPDEV).OperationYear.Length == 4 && pd.BelongYear.Length == 4) {
                                                        if (Convert.ToInt32((list[i] as PSPDEV).OperationYear) > Convert.ToInt32(pd.BelongYear)) {
                                                            list.RemoveAt(i);
                                                            i--;
                                                            continue;
                                                        }
                                                    }
                                                    if (!string.IsNullOrEmpty((list[i] as PSPDEV).Date2) && (list[i] as PSPDEV).Date2.Length == 4 && pd.BelongYear.Length == 4) {
                                                        if (Convert.ToInt32((list[i] as PSPDEV).Date2) < Convert.ToInt32(pd.BelongYear)) {
                                                            list.RemoveAt(i);
                                                            i--;
                                                            continue;
                                                        }
                                                    }
                                                }
                                            }

                                            foreach (PSPDEV pv in list) {
                                                //将其设备加入到计算方案中
                                                PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                                                elcDevice.DeviceSUID = pv.SUID;
                                                elcDevice.ProjectSUID = frmlar.FAID;
                                                elcDevice = UCDeviceBase.DataService.GetOneByKey<PSP_ElcDevice>(elcDevice);
                                                if (elcDevice == null) {
                                                    elcDevice = new PSP_ElcDevice();
                                                    elcDevice.DeviceSUID = pv.SUID;
                                                    elcDevice.ProjectSUID = frmlar.FAID;
                                                    UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice);
                                                }
                                            }
                                        }
                                    }

                                    substation sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);

                                    }
                                } else {
                                    DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                                    DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                                    DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    //wwww
                                    string bdzwhere = " UID not in (";

                                    XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@Deviceid!=''] [@layer='" + SvgDocument.currentLayer + "']");

                                    for (int x2 = 0; x2 < useList.Count; x2++) {
                                        XmlElement _node = useList[x2] as XmlElement;
                                        bdzwhere = bdzwhere + "'" + _node.GetAttribute("Deviceid") + "',";
                                    }
                                    if (bdzwhere.Length > 13) {
                                        bdzwhere = bdzwhere.Substring(0, bdzwhere.Length - 1);
                                        bdzwhere = bdzwhere + ") and ";
                                    } else {
                                        bdzwhere = "";
                                    }

                                    DeviceHelper.bdzwhere = bdzwhere;
                                    obj = DeviceHelper.SelectDevice(DeviceType.BDZ, Itop.Client.MIS.ProgUID);
                                    DeviceHelper.bdzwhere = "";
                                    //if (obj == null)
                                    //{
                                    //    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    //    tlVectorControl1.Delete();
                                    //}
                                    if (obj is PSP_Substation_Info) {
                                        deviceid = ((PSP_Substation_Info)obj).UID;
                                        ((PSP_Substation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        ((PSP_Substation_Info)obj).EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;

                                        ((PSP_Substation_Info)obj).AreaID = Itop.Client.MIS.ProgUID;

                                        Services.BaseService.Update<PSP_Substation_Info>(((PSP_Substation_Info)obj));
                                        xml1.SetAttribute("Deviceid", deviceid);
                                        xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title);

                                        //获得方案名称
                                        PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                                        pd.ID = frmlar.FAID;
                                        pd = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pd);
                                        if (pd != null) {
                                            string where = "where projectid='" + Itop.Client.MIS.ProgUID + "'and SvgUID='" + ((PSP_Substation_Info)obj).UID + "'";
                                            IList<PSPDEV> list = Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", where);
                                            //根据年份进行筛选
                                            if (!string.IsNullOrEmpty(pd.BelongYear))   //根据参与计算设备属于那一年先进行一次筛选
                                            {
                                                for (int i = 0; i < list.Count; i++) {
                                                    if (!string.IsNullOrEmpty((list[i] as PSPDEV).OperationYear) && (list[i] as PSPDEV).OperationYear.Length == 4 && pd.BelongYear.Length == 4) {
                                                        if (Convert.ToInt32((list[i] as PSPDEV).OperationYear) > Convert.ToInt32(pd.BelongYear)) {
                                                            list.RemoveAt(i);
                                                            i--;
                                                            continue;
                                                        }
                                                    }
                                                    if (!string.IsNullOrEmpty((list[i] as PSPDEV).Date2) && (list[i] as PSPDEV).Date2.Length == 4 && pd.BelongYear.Length == 4) {
                                                        if (Convert.ToInt32((list[i] as PSPDEV).Date2) < Convert.ToInt32(pd.BelongYear)) {
                                                            list.RemoveAt(i);
                                                            i--;
                                                            continue;
                                                        }
                                                    }
                                                }
                                            }

                                            foreach (PSPDEV pv in list) {
                                                //将其设备加入到计算方案中
                                                PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                                                elcDevice.DeviceSUID = pv.SUID;
                                                elcDevice.ProjectSUID = frmlar.FAID;
                                                elcDevice = UCDeviceBase.DataService.GetOneByKey<PSP_ElcDevice>(elcDevice);
                                                if (elcDevice == null) {
                                                    elcDevice = new PSP_ElcDevice();
                                                    elcDevice.DeviceSUID = pv.SUID;
                                                    elcDevice.ProjectSUID = frmlar.FAID;
                                                    UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice);
                                                }
                                            }
                                        }

                                        //return;
                                        //根据变站创建线路
                                        createLine(xml1, deviceid);
                                    }
                                    /*
                                    substation sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null)
                                    {

                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_Substation_Info)obj).Flag == "2")
                                        {
                                            sb.ObligateField3 = "规划";
                                        }
                                        else if (((PSP_Substation_Info)obj).Flag == "1")
                                        {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    }
                                    else
                                    {
                                        sb = new substation();
                                        sb.UID = ((PSP_Substation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_Substation_Info)obj).Flag == "2")
                                        {
                                            sb.ObligateField3 = "规划";
                                        }
                                        else if (((PSP_Substation_Info)obj).Flag == "1")
                                        {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }*/
                                }
                            }
                            if (!string.IsNullOrEmpty(deviceid)) {
                                if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                    DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                                    DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                                    DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid);
                                    if (obj != null) {
                                        DeviceHelper.StartYear = startyear;
                                        //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                        if (DeviceHelper.ShowDeviceDlg(DeviceType.DY, deviceid, false)) {
                                            obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid);
                                            xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title);
                                        }
                                    } else {
                                        deviceid = ""; goto Lab1;
                                    }

                                    // re
                                    substation sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }
                                } else {
                                    obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                                    if (obj != null) {
                                        DeviceHelper.StartYear = startyear;
                                        //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                        if (DeviceHelper.ShowDeviceDlg(DeviceType.BDZ, deviceid, false)) {
                                            obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                                            xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title);
                                        }
                                    } else {
                                        deviceid = ""; goto Lab1;
                                    }
                                    substation sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_Substation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_Substation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_Substation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }
                                }

                            }

                        }
                        if (xml1.GetAttribute("xlink:href").Contains("XL_GT_3") || xml1.GetAttribute("xlink:href").Contains("XL_GT_4")) {
                            frmInputNum num = new frmInputNum();
                            num.InputStr = xml1.GetAttribute("order");
                            num.ShowDialog();
                            xml1.SetAttribute("order", num.InputStrSEL);
                        }
                        if (xml1.GetAttribute("xlink:href").Contains("hwg") || xml1.GetAttribute("xlink:href").Contains("pds") ||
                            xml1.GetAttribute("xlink:href").Contains("fjx") || xml1.GetAttribute("xlink:href").Contains("kbs") ||
                            xml1.GetAttribute("xlink:href").Contains("byq") || xml1.GetAttribute("xlink:href").Contains("kg") ||
                             xml1.GetAttribute("xlink:href").Contains("gt")) {
                            //frmInputDialog n1 = new frmInputDialog();
                            //n1.InputStr = xml1.GetAttribute("info-name").ToString();
                            //if (n1.ShowDialog() == DialogResult.OK)
                            //{
                            //    xml1.SetAttribute("info-name", n1.InputStr);
                            //}
                            PSPDEV obj = new PSPDEV();
                            string deviceid = xml1.GetAttribute("Deviceid");
                            DeviceHelper.pspflag = false;
                            DeviceHelper.Wjghflag = false;
                            if (string.IsNullOrEmpty(deviceid)) {
                                if (xml1.GetAttribute("xlink:href").Contains("kbs")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.KBS, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("fjx")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.FZX, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("hwg")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.HWG, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("kg")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.ZSKG, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("pds")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.PDS, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("byq")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(Itop.Client.MIS.ProgUID, "51", "52");
                                }
                                //if (xml1.GetAttribute("xlink:href").Contains("gt"))
                                //{
                                //    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.GT, Itop.Client.MIS.ProgUID);
                                //}
                                if (obj is PSPDEV) {
                                    deviceid = ((PSPDEV)obj).SUID;
                                    xml1.SetAttribute("Deviceid", deviceid);
                                    obj.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    obj.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    // obj.EleID = ((SvgElement)xml1).ID;
                                    Services.BaseService.Update<PSPDEV>(obj);
                                }
                            }
                            if (!string.IsNullOrEmpty(deviceid)) {
                                DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                                DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;

                                obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                                if (obj != null)//------------wwwMX
                                {
                                    xml1.SetAttribute("info-name", ((PSPDEV)obj).Name);
                                    DeviceHelper.ShowDeviceDlg((DeviceType)int.Parse(obj.Type), deviceid, false);
                                    //if (obj.Type == "54")
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.KBS, deviceid, false);
                                    //}
                                    //if (obj.Type == "56")
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.HWG, deviceid, false);
                                    //}
                                    //if (obj.Type == "58")
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.FZX, deviceid, false);
                                    //}
                                    //if (obj.Type == "51" )
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.FZX, deviceid, false);
                                    //}
                                    //if (obj.Type == "52")
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.FZX, deviceid, false);
                                    //}
                                }
                            }

                        }
                        /* if (xml1.GetAttribute("xlink:href").Contains("kbs") || xml1.GetAttribute("xlink:href").Contains("hwg"))
                         {
                             //frmkbsProperty num = new frmkbsProperty();
                             //num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                             //num.ShowDialog();

                         }
                         if (xml1.GetAttribute("xlink:href").Contains("fjx"))
                         {
                             frmfjxProperty num = new frmfjxProperty();
                             num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                             num.ShowDialog();
                         }
                         if (xml1.GetAttribute("xlink:href").Contains("byq"))
                         {
                             frmbyqProperty num = new frmbyqProperty();
                             num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                             num.ShowDialog();
                         } */
                        if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) {
                            string lineWidth = "2";

                            string Code = xltProcessor.GetCurrentLineCode();
                            string _len = xltProcessor.GetWholeLineLength(Code).ToString("#####.####");

                            frmLineProperty fl = new frmLineProperty();
                            fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement;
                            fl.InitData(Code, tlVectorControl1.SVGDocument.SvgdataUid, _len, SvgDocument.currentLayer);
                            if (fl.ShowDialog() == DialogResult.OK) {
                                //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;"
                                lineWidth = fl.LineWidth;
                                string styleValue = "";
                                if (fl.Line.ObligateField1 == "规划") {
                                    styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";";
                                } else {
                                    styleValue = "stroke-width:" + lineWidth + ";";
                                }

                                styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("style");
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", styleValue);

                                xltProcessor.SetWholeLineAttribute(Code, "style", styleValue);
                            }
                        }
                    }
                    #region 网架优化的属性输入

                    if (Wjghboolflag) {
                        checkwjghelement();
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                            string lineWidth = "2";
                            string IsLead = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsLead");
                            if (IsLead != "")       //修改后的导线的属性添加情况
                            {
                                PSPDEV obj = new PSPDEV();
                                string deviceid = xml1.GetAttribute("Deviceid");
                                DeviceHelper.pspflag = false;
                                DeviceHelper.Wjghflag = true;
                                DeviceHelper.wjghuid = ff.Key;
                                if (string.IsNullOrEmpty(deviceid)) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.XL, Itop.Client.MIS.ProgUID);
                                    if (obj == null) {
                                        tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                        tlVectorControl1.Delete();
                                    }
                                    if (obj is PSPDEV) {
                                        deviceid = ((PSPDEV)obj).SUID;
                                        xml1.SetAttribute("Deviceid", deviceid);
                                        obj.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        obj.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        obj.EleID = ((SvgElement)xml1).ID;
                                        Services.BaseService.Update<PSPDEV>((PSPDEV)obj);
                                    }
                                }
                                if (!string.IsNullOrEmpty(deviceid)) {
                                    obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                                    if (obj != null) {
                                        xml1.SetAttribute("info-name", ((PSPDEV)obj).Name);
                                        DeviceHelper.ShowDeviceDlg(DeviceType.XL, deviceid, false);
                                    }

                                    LineInfo li = new LineInfo();
                                    li.UID = obj.SUID;
                                    li = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByKey", li);
                                    if (li != null) {
                                        li.LayerID = SvgDocument.currentLayer;
                                        li.EleID = xml1.GetAttribute("id");
                                        li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        LineType lt = new LineType();
                                        lt.TypeName = li.Voltage.ToString() + "kV";
                                        lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt);
                                        li.ObligateField3 = obj.OperationYear;
                                        li.ObligateField2 = lt.Color;
                                        lineWidth = lt.ObligateField1;
                                        if (!string.IsNullOrEmpty(li.ObligateField3)) {
                                            if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) {
                                                li.ObligateField1 = "规划";
                                            } else
                                                li.ObligateField1 = "运行";
                                        }
                                        Services.BaseService.Update<LineInfo>(li);
                                    } else {
                                        li = new LineInfo();
                                        li.UID = obj.SUID;
                                        li.LineName = obj.Name;
                                        li.Length = obj.LineLength.ToString();
                                        li.LineType = obj.LineType;
                                        li.Voltage = obj.ReferenceVolt.ToString();
                                        li.EleID = xml1.GetAttribute("id");
                                        li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        LineType lt = new LineType();
                                        lt.TypeName = obj.ReferenceVolt.ToString() + "kV";
                                        lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt);
                                        li.ObligateField3 = obj.OperationYear;
                                        li.ObligateField2 = lt.Color;
                                        lineWidth = lt.ObligateField1;
                                        if (!string.IsNullOrEmpty(li.ObligateField3)) {
                                            if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) {
                                                li.ObligateField1 = "规划";
                                            } else
                                                li.ObligateField1 = "运行";
                                        }

                                        Services.BaseService.Create<LineInfo>(li);
                                    }

                                    string styleValue = "";
                                    if (li.ObligateField1 == "规划") {
                                        styleValue = "stroke-dasharray:" + ghType + ";stroke-width:" + lineWidth + ";";
                                    } else {
                                        styleValue = "stroke-width:" + lineWidth + ";";
                                    }
                                    //string aa= ColorTranslator.ToHtml(Color.Black);
                                    styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(li.ObligateField2)));
                                    SvgElement se = tlVectorControl1.SVGDocument.CurrentElement;
                                    se.RemoveAttribute("style");
                                    se.SetAttribute("style", styleValue);
                                    se.SetAttribute("info-name", li.LineName);
                                    //***** ********添加FistNode和LastNode
                                    XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");

                                    foreach (XmlNode element in useList) {
                                        if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid"))) {
                                            string con = "WHERE SvgUID='" + (element as XmlElement).GetAttribute("Deviceid") + "'AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='01'";
                                            IList pspMX = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                            if (pspMX != null) {
                                                foreach (PSPDEV pspmx in pspMX) {
                                                    if (obj.IName == pspmx.Name) {
                                                        (xml1 as XmlElement).SetAttribute("FirstNode", (element as XmlElement).GetAttribute("id"));

                                                    } else if (obj.JName == pspmx.Name) {
                                                        (xml1 as XmlElement).SetAttribute("LastNode", (element as XmlElement).GetAttribute("id"));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                //**

                            }
                        }

                        if (xml1.GetAttribute("xlink:href").Contains("Substation") || xml1.GetAttribute("xlink:href").Contains("Power")) {
                            string lab = xml1.GetAttribute("xlink:href");

                            float x = 0f;
                            float y = 0f;

                            x = ((Use)xml1).X;

                            y = ((Use)xml1).Y;

                            PointF p1 = new PointF(x, y);
                            PointF[] pnt = new PointF[1];
                            pnt[0] = p1;
                            Use temp = xml1.Clone() as Use;
                            temp.Transform.Matrix.TransformPoints(pnt);

                            LongLat templat = mapview.OffSetZero(-(int)(pnt[0].X * tlVectorControl1.ScaleRatio), -(int)(pnt[0].Y * tlVectorControl1.ScaleRatio));

                            string[] jd = templat.Longitude.ToString("####.####").Split('.');
                            int d1 = Convert.ToInt32(jd[0]);
                            string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                            int f1 = Convert.ToInt32(df1[0]);
                            decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                            string[] wd = templat.Latitude.ToString("####.####").Split('.');
                            int d2 = Convert.ToInt32(wd[0]);
                            string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                            int f2 = Convert.ToInt32(df2[0]);
                            decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;

                            string strjwd = "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″";
                            object obj = null;
                            string deviceid = xml1.GetAttribute("Deviceid");
                            DeviceHelper.pspflag = false;
                            DeviceHelper.Wjghflag = true;
                            if (string.IsNullOrEmpty(deviceid)) {
                                //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                    obj = DeviceHelper.SelectDevice(DeviceType.DY, Itop.Client.MIS.ProgUID);
                                    if (obj == null) {
                                        tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                        tlVectorControl1.Delete();
                                    }
                                    if (obj is PSP_PowerSubstation_Info) {
                                        deviceid = ((PSP_PowerSubstation_Info)obj).UID;
                                        ((PSP_PowerSubstation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                        Services.BaseService.Update<PSP_PowerSubstation_Info>(((PSP_PowerSubstation_Info)obj));
                                        xml1.SetAttribute("Deviceid", deviceid);
                                    }
                                    substation sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }
                                } else {
                                    obj = DeviceHelper.SelectDevice(DeviceType.BDZ, Itop.Client.MIS.ProgUID);
                                    if (obj == null) {
                                        tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                        tlVectorControl1.Delete();
                                    }
                                    if (obj is PSP_Substation_Info) {
                                        deviceid = ((PSP_Substation_Info)obj).UID;
                                        ((PSP_Substation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        ((PSP_Substation_Info)obj).EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                                        Services.BaseService.Update<PSP_Substation_Info>(((PSP_Substation_Info)obj));
                                        xml1.SetAttribute("Deviceid", deviceid);

                                    }
                                    substation sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {

                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_Substation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_Substation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_Substation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }
                                }
                            }
                            if (!string.IsNullOrEmpty(deviceid)) {
                                if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                    obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid);
                                    if (obj != null) {
                                        xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title);
                                        //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                        DeviceHelper.ShowDeviceDlg(DeviceType.DY, deviceid, false);
                                    }

                                } else {
                                    obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                                    if (obj != null) {
                                        xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title);
                                        //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                        DeviceHelper.ShowDeviceDlg(DeviceType.BDZ, deviceid, false);
                                    }

                                }

                            }

                        }
                        if (xml1.GetAttribute("xlink:href").Contains("XL_GT_3") || xml1.GetAttribute("xlink:href").Contains("XL_GT_4")) {
                            frmInputNum num = new frmInputNum();
                            num.InputStr = xml1.GetAttribute("order");
                            num.ShowDialog();
                            xml1.SetAttribute("order", num.InputStrSEL);
                        }

                        //if (xml1.GetAttribute("xlink:href").Contains("kbs") || xml1.GetAttribute("xlink:href").Contains("hwg"))
                        //{
                        //    frmkbsProperty num = new frmkbsProperty();
                        //    num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        //    num.ShowDialog();
                        //}
                        //if (xml1.GetAttribute("xlink:href").Contains("fjx"))
                        //{
                        //    frmfjxProperty num = new frmfjxProperty();
                        //    num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        //    num.ShowDialog();
                        //}
                        //if (xml1.GetAttribute("xlink:href").Contains("byq"))
                        //{
                        //    frmbyqProperty num = new frmbyqProperty();
                        //    num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        //    num.ShowDialog();
                        //}
                        if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) {
                            string lineWidth = "2";

                            string Code = xltProcessor.GetCurrentLineCode();
                            string _len = xltProcessor.GetWholeLineLength(Code).ToString("#####.####");

                            frmLineProperty fl = new frmLineProperty();
                            fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement;
                            fl.InitData(Code, tlVectorControl1.SVGDocument.SvgdataUid, _len, SvgDocument.currentLayer);
                            if (fl.ShowDialog() == DialogResult.OK) {
                                //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;"
                                lineWidth = fl.LineWidth;
                                string styleValue = "";
                                if (fl.Line.ObligateField1 == "规划") {
                                    styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";";
                                } else {
                                    styleValue = "stroke-width:" + lineWidth + ";";
                                }

                                styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("style");
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", styleValue);

                                xltProcessor.SetWholeLineAttribute(Code, "style", styleValue);
                            }
                        }
                    }
                    #endregion
                }
                if (e.ClickedItem.Text == "移动") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    XmlElement xmln = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    frmMove fm = new frmMove();
                    PointF pf11 = ((Use)xmln).CenterPoint;
                    LongLat temp = mapview.ParseToLongLat((int)pf11.X, (int)pf11.Y);
                    string[] jd = temp.Longitude.ToString("####.####").Split('.');
                    int d1 = Convert.ToInt32(jd[0]);
                    string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                    int f1 = Convert.ToInt32(df1[0]);
                    decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                    string[] wd = temp.Latitude.ToString("####.####").Split('.');
                    int d2 = Convert.ToInt32(wd[0]);
                    string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                    int f2 = Convert.ToInt32(df2[0]);
                    decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;
                    strj1 = d1.ToString();
                    strw1 = f1.ToString();
                    strd1 = m1.ToString();
                    strj2 = d2.ToString();
                    strw2 = f2.ToString();
                    strd2 = m2.ToString();
                    fm.Init(strj1, strw1, strd1, strj2, strw2, strd2);
                    if (fm.ShowDialog() == DialogResult.OK) {
                        string strValue = fm.StrValue;
                        string[] str = strValue.Split(',');
                        string[] JWD1 = str[0].Split(' ');
                        decimal J1 = Convert.ToDecimal(JWD1[0]);
                        decimal W1 = Convert.ToDecimal(JWD1[1]);
                        decimal D1 = Convert.ToDecimal(JWD1[2]);
                        string[] JWD2 = str[1].Split(' ');
                        decimal J2 = Convert.ToDecimal(JWD2[0]);
                        decimal W2 = Convert.ToDecimal(JWD2[1]);
                        decimal D2 = Convert.ToDecimal(JWD2[2]);

                        decimal JD = J1 + W1 / 60 + D1 / 3600;
                        decimal WD = J2 + W2 / 60 + D2 / 3600;

                        PointF pf1 = mapview.ParseToPoint(JD, WD);

                        PointF p1 = ((Use)xmln).CenterPoint;

                        SvgElement e1 = xmln as SvgElement;
                        Matrix matrix2 = ((IGraph)e1).GraphTransform.Matrix.Clone();
                        Matrix matrix3 = tlVectorControl1.DrawArea.CoordTransform.Clone();
                        matrix3.Invert();
                        matrix2.Multiply(matrix3, MatrixOrder.Append);
                        matrix2.Invert();
                        PointF[] pfArray1 = new PointF[] { new PointF(pf1.X / tlVectorControl1.ScaleRatio, pf1.Y / tlVectorControl1.ScaleRatio), p1 };
                        matrix2.TransformPoints(pfArray1);

                        float single1 = pfArray1[0].X - pfArray1[1].X;
                        float single2 = pfArray1[0].Y - pfArray1[1].Y;

                        Matrix matrix6 = ((IGraph)e1).Transform.Matrix.Clone();
                        if (e1.SvgAttributes.ContainsKey("transform")) {
                            Matrix matrix7 = ((Matrix)e1.SvgAttributes["transform"]).Clone();
                            matrix7.Invert();
                            matrix6.Multiply(matrix7, MatrixOrder.Append);
                        }
                        Matrix matrix5 = new Matrix();
                        matrix5.Translate(single1, single2);
                        Matrix matrix8 = ((IGraph)e1).Transform.Matrix.Clone();
                        matrix8.Multiply(matrix5);
                        matrix6.Invert();
                        matrix6.Multiply(matrix8, MatrixOrder.Append);
                        Transf tf = new Transf();
                        tf.setMatrix(matrix6);
                        (xmln as Use).Transform = tf;

                    }
                }
                if (e.ClickedItem.Text == "接线图") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    ParentUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    Save();
                    ParentUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    SVGFILE svg_temp = new SVGFILE();
                    //XmlElement xml1 = ((XmlElement)(e.Elements[0]));xml1.GetAttribute("id");
                    svg_temp.SUID = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("id");
                    svg_temp.FILENAME = getBdzName(svg_temp.SUID);// ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("info-name");
                    string strWhere = string.Format("suid='{0}' or filename='{1}' ", svg_temp.SUID, svg_temp.FILENAME);
                    IList svglist = Services.BaseService.GetList("SelectSVGFILEByWhere", strWhere);
                    OpenJXT(svglist, svg_temp);
                    //frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
                    //frmlar.Progtype = MapType;
                    //frmlar.InitData();
                    //JxtBar();
                }
                if (e.ClickedItem.Text == "打开") {
                    if (tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRelating UseRel = new UseRelating();
                    UseRel.UseID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                    IList<UseRelating> UseRelList = Services.BaseService.GetList<UseRelating>("SelectUseRelatingByUseID", UseRel);
                    if (UseRelList.Count < 1) {
                        MessageBox.Show("选择的地块还没有关联到其他地图,请先设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRel = UseRelList[0];
                    SVGFILE svgFile = new SVGFILE();
                    svgFile.SUID = UseRel.LinkUID;
                    IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile);
                    if (svgList.Count < 1) {
                        MessageBox.Show("被关联的地图已经被删除,请重新设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    svgFile = (SVGFILE)svgList[0];
                    //SvgDocument doc = new SvgDocument();

                    if (!string.IsNullOrEmpty(svgFile.SVGDATA)) {
                        //doc.LoadXml(svgFile.SVGDATA);
                        ctlfile_OnOpenSvgDocument(sender, svgFile.SUID);
                    }

                }
                if (e.ClickedItem.Text == "区域打印") {
                    PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                    frmPrinter dlg = new frmPrinter();
                    dlg.printHelper = ph;
                    dlg.ShowDialog();
                    return;
                    ArrayList idlist = new ArrayList();
                    ArrayList symlist = new ArrayList();

                    SvgDocument _doc = new SvgDocument();

                    Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph;
                    if (poly1 == null || poly1.GetAttribute("id") == "svg") {
                        return;
                    }

                    GraphicsPath gr1 = new GraphicsPath();
                    //gr1.AddRectangle(TLMath.getRectangle(poly1));
                    gr1.AddPolygon(TLMath.getPolygonPoints(poly1));
                    //gr1.CloseFigure();
                    gr1 = (GraphicsPath)poly1.GPath.Clone();
                    gr1.Transform((poly1 as IGraph).Transform.Matrix);

                    RectangleF ef1 = gr1.GetBounds();
                    ef1 = PathFunc.GetBounds(gr1);
                    StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">");

                    XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs");
                    if (nlist.Count > 0) {
                        XmlNode node = nlist[0];
                        svgtxt.AppendLine(node.OuterXml);
                    }
                    SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator();
                    while (enumerator1.MoveNext()) {
                        IGraph graph1 = (IGraph)enumerator1.Current;

                        GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                        //path1.Transform(graph1.GraphTransform.Matrix);
                        //path1.Transform(graph1.Transform.Matrix);
                        // RectangleF ef2 = path1.GetBounds();// PathFunc.GetBounds(path1);

                        //for (int n = 0; n < selCol.Count - 1; n++)
                        //{
                        //    //_doc.AppendChild((XmlNode)selCol[n]);
                        //    svgtxt = svgtxt + ((XmlElement)selCol[n]).OuterXml + "\r\n";
                        //}
                        if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue;

                        GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone();
                        path2.Transform(graph1.Transform.Matrix);
                        RectangleF ef2 = PathFunc.GetBounds(path2);

                        if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty) {

                            SvgElement ele = (SvgElement)graph1;
                            svgtxt.AppendLine(ele.OuterXml);
                            //tlVectorControl1.SVGDocument.AddSelectElement(graph1);
                            if (graph1 is Use) {
                                //PointF offset = TLMath.getUseOffset(((XmlElement)graph1).GetAttribute("xlink:href"));
                                //if (ef1.Contains(new PointF(((Use)graph1).X + offset.X, ((Use)graph1).Y + offset.Y))) {
                                //SvgElement ele = (SvgElement)graph1;
                                //svgtxt.AppendLine(ele.OuterXml);

                                string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                                if (!symlist.Contains(symid)) {
                                    symlist.Add(symid);
                                }
                                //}
                            }
                            if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") {
                                string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                                if (IsLead != "") {
                                    if (ef1.Contains(ef2)) {
                                        idlist.Add(graph1.ID);
                                    }
                                }
                            }
                        }
                    }
                    symlist = ResetList(symlist);
                    svgtxt.AppendLine("</svg>");
                    _doc.LoadXml(svgtxt.ToString());
                    _doc.SvgdataUid = tlVectorControl1.SVGDocument.SvgdataUid;
                    frmPrintF pri = new frmPrintF();
                    pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                    if (pri.ShowDialog() == DialogResult.OK) {
                        frmSubPrint s = new frmSubPrint();
                        s.Vector = tlVectorControl1;
                        s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist);
                        s.Open(_doc, ef1);
                        s.Show();
                    }
                }
                if (e.ClickedItem.Text == "分类统计报表") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    IGraph poly1 = (IGraph)tlVectorControl1.SVGDocument.CurrentElement;
                    frmPloyPrint p = new frmPloyPrint();

                    p.InitDate(poly1.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                    p.ShowDialog();
                }
                if (e.ClickedItem.Text == "保存图片") {
                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") {

                        PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                        frmImgManager frm = new frmImgManager();
                        frm.Pic = ph.getImage();
                        frm.ShowDialog();
                    }
                }

            } catch (Exception e1) {
                //MessageBox.Show(e1.Message);
            }
            if (e.ClickedItem.Text == "三维变电站") {
                try {
                    string strid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                    substation s = new substation();
                    s.EleID = strid;
                    s.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    s = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", s);
                    ProcessStartInfo p = new ProcessStartInfo();
                    p.FileName = Application.StartupPath + "\\" + s.EleName + "\\bdz.exe";
                    p.WorkingDirectory = Application.StartupPath + "\\" + s.EleName;
                    Process.Start(p);
                } catch (Exception e1) { }
            }
            if (e.ClickedItem.Text == "清除关联") {
                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("Deviceid");
            }
            if (e.ClickedItem.Text == "更新关联变电站") {
                UpdateLine();
            }
            if (e.ClickedItem.Text == "删除") {
                Delete();
            }
        }
        //�ų��豸
        void barDeleteDevice_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (psp_proj.ID == null || curDevice == null)
            {
                MessageBox.Show("ѡ�������⣡", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (curDevice.SelectedDevice != null)
            {
                if (curDevice.SelectedDevice.GetType() == typeof(PSPDEV))
                {
                    PSPDEV dev = curDevice.SelectedDevice as PSPDEV;
                    PSP_ElcDevice elcdevice = new PSP_ElcDevice();
                    elcdevice.ProjectSUID = psp_proj.ID;
                    elcdevice.DeviceSUID = dev.SUID;
                    Services.BaseService.Delete<PSP_ElcDevice>(elcdevice);

                }
                else if (curDevice.SelectedDevice.GetType() == typeof(PSP_Substation_Info))
                {
                    PSP_Substation_Info dev = curDevice.SelectedDevice as PSP_Substation_Info;
                    PSP_ElcDevice elcdevice = new PSP_ElcDevice();
                    elcdevice.ProjectSUID = psp_proj.ID;
                    elcdevice.DeviceSUID = dev.UID;
                    Services.BaseService.Delete<PSP_ElcDevice>(elcdevice);
                }
                else if (curDevice.SelectedDevice.GetType() == typeof(PSP_PowerSubstation_Info))
                {
                    PSP_PowerSubstation_Info dev = curDevice.SelectedDevice as PSP_PowerSubstation_Info;
                    PSP_ElcDevice elcdevice = new PSP_ElcDevice();
                    elcdevice.ProjectSUID = psp_proj.ID;
                    elcdevice.DeviceSUID = dev.UID;
                    Services.BaseService.Delete<PSP_ElcDevice>(elcdevice);
                }
            }

            if (curDevice != null)
            {
                if (curDevice.GetClassName() == "PSP_Substation_Info")
                {
                    curDevice.proInit(psp_proj.ID);
                }
                else if (curDevice.GetClassName() == "PSP_PowerSubstation_Info")
                {
                    curDevice.proInit(psp_proj.ID);
                }
                else if (curDevice.GetClassName() == "PSPDEV")
                {
                    if (ParentObj is PSP_Substation_Info)
                    {
                        curDevice.strCon = ",psp_elcdevice where psp_elcdevice.devicesuid = pspdev.suid and psp_elcdevice.projectsuid = '" + psp_proj.ID + "' and pspdev.SvgUID='" + ((PSP_Substation_Info)ParentObj).UID + "'and";
                    }
                    else if (ParentObj is PSP_PowerSubstation_Info)
                    {
                        curDevice.strCon = ",psp_elcdevice where psp_elcdevice.devicesuid = pspdev.suid and psp_elcdevice.projectsuid = '" + psp_proj.ID + "' and pspdev.SvgUID='" + ((PSP_PowerSubstation_Info)ParentObj).UID + "'and"; ;
                    }
                    else if (ParentObj is PSPDEV)
                    {
                        curDevice.strCon = ",psp_elcdevice where psp_elcdevice.devicesuid = pspdev.suid and psp_elcdevice.projectsuid = '" + psp_proj.ID + "' and pspdev.SvgUID='" + ((PSPDEV)ParentObj).SUID + "'and"; ;
                    }
                    curDevice.Init();
                }
            }
        }
示例#16
0
        private void intdata(string filesuid)
        {
            Subcol.Clear();
            Powcol.Clear();
            linecol.Clear();
            string con = " AreaID = '" + Itop.Client.MIS.ProgUID + "' AND UID IN (SELECT PSPDEV.SVGUID FROM PSPDEV, PSP_ELCDEVICE WHERE  PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + filesuid + "')";

            listSub = Services.BaseService.GetList("SelectPSP_Substation_InfoListByWhere", con);
            foreach (PSP_Substation_Info dev in listSub) {

                XmlNode element = tlVectorControl1.SVGDocument.SelectSingleNode("//*[@Deviceid='" + dev.UID + "']");
                bool selectflag = false;
                if (element != null) {
                    selectflag = true;
                }
                eleclass li = new eleclass(dev.Title, dev.UID, "20", selectflag);
                Subcol.Add(li);
                if (!selectflag) {
                    PSP_ElcDevice pg = new PSP_ElcDevice();
                    pg.DeviceSUID = dev.UID;
                    pg.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    // pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg);
                    Services.BaseService.Delete<PSP_ElcDevice>(pg);
                }

            }
            con = " AreaID = '" + Itop.Client.MIS.ProgUID + "' AND UID IN (SELECT PSPDEV.SVGUID FROM PSPDEV, PSP_ELCDEVICE WHERE  PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + filesuid + "')";

            listPow = Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", con);
            foreach (PSP_PowerSubstation_Info dev in listPow) {

                XmlNode element = tlVectorControl1.SVGDocument.SelectSingleNode("//*[@Deviceid='" + dev.UID + "']");
                bool selectflag = false;
                if (element != null) {
                    selectflag = true;
                }
                eleclass li = new eleclass(dev.Title, dev.UID, "30", selectflag);
                Powcol.Add(li);
                if (!selectflag) {
                    PSP_ElcDevice pg = new PSP_ElcDevice();
                    pg.DeviceSUID = dev.UID;
                    pg.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    // pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg);
                    Services.BaseService.Delete<PSP_ElcDevice>(pg);
                }
            }
            con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + filesuid + "' AND PSPDEV.Type = '05' ORDER BY PSPDEV.Number";
            listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
            foreach (PSPDEV dev in listXL) {
                if (dev.KSwitchStatus == "0") {
                    XmlNode element = tlVectorControl1.SVGDocument.SelectSingleNode("//*[@Deviceid='" + dev.SUID + "']");
                    bool selectflag = false;
                    if (element != null) {
                        selectflag = true;
                    }
                    eleclass li = new eleclass(dev.Name, dev.SUID, dev.Type, selectflag);
                    linecol.Add(li);
                }
            }
        }
示例#17
0
        public bool DFS(IList branchlist, IList buslist, string projectSUID, float ratedCapacity)
        {
            string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'";
            string strCon2 = null;
            string strCon = null;

            double Rad_to_Deg = 180 / Math.PI;
            double Deg_to_Rad = Math.PI / 180;

            strCon2 = " AND Type = '01'";
            strCon = strCon1 + strCon2;
            IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
            strCon2 = " AND Type = '05'";
            strCon = strCon1 + strCon2;
            IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
            strCon2 = " AND Type = '02'";
            strCon = strCon1 + strCon2;
            IList listBYQ2 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
            strCon2 = " AND Type = '03'";
            strCon = strCon1 + strCon2;
            IList listBYQ3 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);

            foreach (PSPDEV devBUS in buslist)
            {
                ArrayList listLine = new ArrayList();
                ArrayList listLineTemp = new ArrayList();
                IList listBusTxt = new List<PSPDEV>();
                bool visited = false;
                foreach (PSPDEV line in listXL)
                {
                    if (line.FirstNode == devBUS.Number && !branchlist.Contains(line))
                    {
                        if (visited == false)
                        {
                            visited = true;
                            listLine.Add(line);
                        }
                        else if (visited == true)
                        {
                            listLineTemp.Add(line);
                        }
                    }
                }
                PSPDEV lineTemp = new PSPDEV();
                if (listLineTemp.Count > 0)
                {
                    lineTemp = (PSPDEV)listLineTemp[listLineTemp.Count - 1];
                }
                else
                {
                    lineTemp = (PSPDEV)listLine[listLine.Count - 1];
                }
                bool dFlag = true;
                bool flag = true;
                while ((lineTemp.LastNode > 0 && !branchlist.Contains(lineTemp)) || dFlag)
                {
                    bool TFlag = false;
                    foreach (PSPDEV lineDEV in branchlist)
                    {
                        if (lineDEV.SUID == lineTemp.SUID)
                        {
                            TFlag = true;
                        }
                    }
                    if (TFlag == true)
                    {
                        break;
                    }
                    flag = true;
                    while (flag)
                    {
                        visited = false;
                        flag = false;
                        lineTemp = (PSPDEV)listLine[listLine.Count - 1];
                        foreach (PSPDEV line in listXL)
                        {

                            if (line.FirstNode == lineTemp.LastNode && !branchlist.Contains(line.SUID))
                            {
                                bool cFlag = false;
                                foreach (PSPDEV lineDEV in branchlist)
                                {
                                    if (lineDEV.SUID == line.SUID)
                                    {
                                        cFlag = true;
                                    }
                                }
                                if (cFlag == true)
                                {
                                    continue;
                                }
                                flag = true;
                                if (visited == false)
                                {
                                    visited = true;
                                    listLine.Add(line);
                                }
                                else if (visited == true)
                                {
                                    listLineTemp.Add(line);
                                }
                            }
                        }
                    }
                    dFlag = false;
                    if (listLineTemp.Count > 0)
                    {
                        lineTemp = (PSPDEV)listLineTemp[listLineTemp.Count - 1];
                        if (!branchlist.Contains(lineTemp))
                        {
                            listLine.Add(lineTemp);
                        }
                        listLineTemp.Remove(lineTemp);
                    }
                    else
                    {
                        lineTemp = new PSPDEV();
                    }
                }
                listBusTxt.Add(devBUS);
                foreach (PSPDEV busDEV in listMX)
                {
                    foreach (PSPDEV lineD in listLine)
                    {
                        if (busDEV.Number == lineD.LastNode)
                        {
                            listBusTxt.Add(busDEV);
                        }
                    }
                }
                string strData = null;
                string strBus = null;
                string strBranch = null;
                foreach (PSPDEV dev in listLine)
                {
                    if (dev.KSwitchStatus == "0")
                    {
                        if (strBranch != null)
                        {
                            strBranch += "\r\n";
                        }
                        if (strData != null)
                        {
                            strData += "\r\n";
                        }
                        if (dev.UnitFlag == "0")
                        {
                            strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0";
                            //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString());
                        }
                        else
                        {
                            strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0";
                            //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                        }
                    }
                }
                foreach (PSPDEV dev in listBYQ2)
                {
                    if (dev.KSwitchStatus == "0")
                    {
                        if (strBranch != null)
                        {
                            strBranch += "\r\n";
                        }
                        if (strData != null)
                        {
                            //strData += "\r\n";
                        }
                        if (dev.UnitFlag == "0")
                        {
                            strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + dev.K.ToString();
                            // strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.K).ToString() + " " + dev.G.ToString() + " " + dev.Name.ToString());
                        }
                        else
                        {
                            strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + dev.K.ToString();
                            // strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.K.ToString()).ToString() + " " + dev.G.ToString() + " " + dev.Name.ToString());
                        }
                    }
                }
                foreach (PSPDEV dev in listBYQ3)
                {
                    if (dev.KSwitchStatus == "0")
                    {

                        if (strData != null)
                        {
                            // strData += "\r\n";
                        }
                        if (dev.UnitFlag == "0")
                        {
                            if (strBranch != null)
                            {
                                strBranch += "\r\n";
                            }
                            strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ1.ToString() + " " + dev.HuganTQ4.ToString() + " " + "0" + " " + dev.K.ToString();
                            //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.HuganTQ1).ToString() + " " + (dev.HuganTQ4).ToString() + " " + (dev.K).ToString() + " " + "0" + " " + dev.Name.ToString());
                            if (strBranch != null)
                            {
                                strBranch += "\r\n";
                            }
                            strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ2.ToString() + " " + dev.HuganTQ5.ToString() + " " + "0" + " " + dev.StandardCurrent.ToString();
                            //strData += (dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ2).ToString() + " " + (dev.HuganTQ5).ToString() + " " + (dev.StandardCurrent).ToString() + " " + "0" + " " + dev.Name.ToString());
                            if (strBranch != null)
                            {
                                strBranch += "\r\n";
                            }
                            strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ3.ToString() + " " + dev.ZeroTQ.ToString() + " " + "0" + " " + dev.BigP.ToString();
                            //strData += (dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ3).ToString() + " " + (dev.HuganFirst).ToString() + " " + (dev.BigP).ToString() + " " + "0" + " " + dev.Name.ToString());

                        }
                        else
                        {
                            if (strBranch != null)
                            {
                                strBranch += "\r\n";
                            }
                            strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ1 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ4 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.K.ToString();
                            // strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.HuganTQ1 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ4 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.K).ToString() + " " + "0" + " " + dev.Name.ToString());
                            if (strBranch != null)
                            {
                                strBranch += "\r\n";
                            }
                            strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ2 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ5 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.StandardCurrent.ToString();
                            //strData += (dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ2 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ5 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.StandardCurrent).ToString() + " " + "0" + " " + dev.Name.ToString());
                            if (strBranch != null)
                            {
                                strBranch += "\r\n";
                            }
                            strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ3 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.ZeroTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.BigP.ToString();
                            //strData += (dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ3 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((float)dev.HuganFirst * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.BigP).ToString() + " " + "0" + " " + dev.Name.ToString());
                        }
                    }
                }
                foreach (PSPDEV dev in listBusTxt)
                {
                    if (dev.KSwitchStatus == "0")
                    {
                        if (strBus != null)
                        {
                            strBus += "\r\n";
                        }
                        if (strData != null)
                        {
                            //strData += "\r\n";
                        }
                        if (dev.UnitFlag == "0")
                        {
                            strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR).ToString() + " " + dev.VoltV.ToString() + " " + ((dev.InPutP - dev.OutP)).ToString() + " " + ((dev.InPutQ - dev.OutQ)).ToString());
                            //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString());
                            //if (dev.NodeType == "1")
                            //{
                            //    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((dev.OutP)).ToString() + " " + ((dev.OutQ)).ToString());
                            //}
                            //else if (dev.NodeType == "2")
                            //{
                            //    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((dev.OutP)).ToString() + " " + (dev.VoltR / dev.ReferenceVolt).ToString());
                            //}
                            //else if (dev.NodeType == "0")
                            //{
                            //    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + "0");
                            //}
                        }
                        else
                        {
                            strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + dev.VoltV.ToString() + " " + ((dev.InPutP - dev.OutP) / ratedCapacity).ToString() + " " + ((dev.InPutQ - dev.OutQ) / ratedCapacity).ToString());
                            //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                            //if (dev.NodeType == "1")
                            //{
                            //    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((dev.OutP) / ratedCapacity).ToString() + " " + ((dev.OutQ) / ratedCapacity).ToString());
                            //}
                            //else if (dev.NodeType == "2")
                            //{
                            //    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((dev.OutP) / ratedCapacity).ToString() + " " + (dev.VoltR / dev.ReferenceVolt).ToString());
                            //}
                            //else if (dev.NodeType == "0")
                            //{
                            //    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + "0");
                            //}
                        }
                    }
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\branch.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\branch.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\bus.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\bus.txt");
                }

                FileStream VK1 = new FileStream((System.Windows.Forms.Application.StartupPath + "\\branch.txt"), FileMode.OpenOrCreate);
                StreamWriter str3 = new StreamWriter(VK1, Encoding.Default);
                str3.Write(strBranch);
                str3.Close();
                FileStream L = new FileStream((System.Windows.Forms.Application.StartupPath + "\\bus.txt"), FileMode.OpenOrCreate);
                StreamWriter str2 = new StreamWriter(L, Encoding.Default);
                str2.Write(strBus);
                str2.Close();
                if (strBus.Contains("非数字") || strBus.Contains("正无穷大") || strBranch.Contains("非数字") || strBranch.Contains("正无穷大"))
                {
                    MessageBox.Show("缺少参数,请检查输入参数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return false;
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF1.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\PF1.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\DH1.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\IH1.txt");
                }
                DisFlowCal disf = new DisFlowCal();
                disf.CurrentCal(1);
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF1.txt"))
                {
                }
                else
                {
                    return false;
                }
                FileStream pf = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF1.txt", FileMode.Open);
                StreamReader readLine = new StreamReader(pf, Encoding.Default);
                char[] charSplit = new char[] { ' ' };
                string strLine = readLine.ReadLine();
                while (strLine != null && strLine != "")
                {
                    string[] array1 = strLine.Split(charSplit);
                    strCon2 = " AND Type= '01' AND Number = " + array1[0];
                    strCon = strCon1 + strCon2;
                    PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                    if (devMX != null)
                    {
                        PSP_ElcDevice elcDev = new PSP_ElcDevice();
                        elcDev.ProjectSUID = projectSUID;
                        elcDev.DeviceSUID = devMX.SUID;
                        elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                        if (elcDev != null)
                        {
                            elcDev.COL1 = devMX.Name;
                            elcDev.COL19 = devMX.ReferenceVolt.ToString();
                            elcDev.COL20 = ratedCapacity.ToString();
                            double temp = 0.0;
                            double.TryParse(array1[1], out temp);
                            elcDev.COL2 = (temp * (devMX.ReferenceVolt)).ToString();
                            temp = 0.0;
                            double.TryParse(array1[2], out temp);
                            elcDev.COL3 = (temp * Rad_to_Deg).ToString();
                            temp = 0.0;
                            double.TryParse(array1[3], out temp);
                            elcDev.COL4 = (temp * ratedCapacity).ToString();
                            temp = 0.0;
                            double.TryParse(array1[4], out temp);
                            elcDev.COL5 = (temp * ratedCapacity).ToString();

                            Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                        }
                    }
                    strLine = readLine.ReadLine();
                }
                readLine.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                {
                }
                else
                {
                    return false;
                }
                FileStream dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);
                readLine = new StreamReader(dh, Encoding.Default);
                strLine = readLine.ReadLine();
                while (strLine != null && strLine != "")
                {
                    string[] array1 = strLine.Split(charSplit);
                    strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                    strCon = strCon1 + strCon2;
                    PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                    if (devMX != null)
                    {
                        PSP_ElcDevice elcDev = new PSP_ElcDevice();
                        elcDev.ProjectSUID = projectSUID;
                        elcDev.DeviceSUID = devMX.SUID;
                        elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                        if (elcDev != null)
                        {
                            elcDev.COL1 = devMX.Name;
                            elcDev.COL2 = devMX.FirstNode.ToString();
                            elcDev.COL3 = devMX.LastNode.ToString();
                            elcDev.COL19 = devMX.ReferenceVolt.ToString();
                            if (Convert.ToDouble(devMX.Burthen) ==0.0)
                            {
                                elcDev.COL20 = ratedCapacity.ToString();
                            }
                            else
                                elcDev.COL20 = devMX.Burthen.ToString();

                            double temp = 0.0;
                            double.TryParse(array1[3], out temp);
                            elcDev.COL4 = (temp * ratedCapacity).ToString();
                            temp = 0.0;
                            double.TryParse(array1[4], out temp);
                            elcDev.COL5 = (temp * ratedCapacity).ToString();
                            temp = 0.0;
                            double.TryParse(array1[5], out temp);
                            elcDev.COL6 = (temp * ratedCapacity).ToString();
                            temp = 0.0;
                            double.TryParse(array1[6], out temp);
                            elcDev.COL7 = (temp * ratedCapacity).ToString();

                            temp = 0.0;
                            double.TryParse(array1[7], out temp);
                            elcDev.COL8 = (temp * ratedCapacity).ToString();
                            temp = 0.0;
                            double.TryParse(array1[8], out temp);
                            elcDev.COL9 = (temp * ratedCapacity).ToString();
                            temp = 0.0;
                            double.TryParse(array1[9], out temp);
                            elcDev.COL10 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();

                            temp = 0.0;
                            double.TryParse(array1[10], out temp);
                            elcDev.COL11 = (temp * Rad_to_Deg).ToString();
                            temp = 0.0;
                            double.TryParse(array1[11], out temp);
                            elcDev.COL12 = (temp * (devMX.ReferenceVolt)).ToString();
                            temp = 0.0;
                            double.TryParse(array1[12], out temp);
                            elcDev.COL13 = (temp * (devMX.ReferenceVolt)).ToString();
                            PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                            Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                        }
                    }
                    strLine = readLine.ReadLine();
                }
                readLine.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt"))
                {
                }
                else
                {
                    return false;
                }
                FileStream ih = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH1.txt", FileMode.Open);
                readLine = new StreamReader(ih, Encoding.Default);
                strLine = readLine.ReadLine();
                while (strLine != null && strLine != "")
                {
                    string[] array1 = strLine.Split(charSplit);
                    strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                    strCon = strCon1 + strCon2;
                    PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                    if (devMX != null)
                    {
                        PSP_ElcDevice elcDev = new PSP_ElcDevice();
                        elcDev.ProjectSUID = projectSUID;
                        elcDev.DeviceSUID = devMX.SUID;
                        elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                        if (elcDev != null)
                        {
                            elcDev.COL1 = devMX.Name;
                            elcDev.COL2 = devMX.FirstNode.ToString();
                            elcDev.COL3 = devMX.LastNode.ToString();
                            elcDev.COL19 = devMX.ReferenceVolt.ToString();
                            if (Convert.ToDouble(devMX.Burthen) == 0.0)
                            {
                                elcDev.COL20 = ratedCapacity.ToString();
                            }
                            else
                                elcDev.COL20 = devMX.Burthen.ToString();
                            double temp = 0.0;
                            double.TryParse(array1[3], out temp);
                            elcDev.COL14 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();
                            temp = 0.0;
                            double.TryParse(array1[4], out temp);
                            elcDev.COL15 = (temp * Rad_to_Deg).ToString();
                            PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                            Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                        }
                    }
                    strLine = readLine.ReadLine();
                }
                readLine.Close();
            }
            foreach (PSPDEV devLine in branchlist)
            {
                PSP_ElcDevice elcDev = new PSP_ElcDevice();
                elcDev.ProjectSUID = projectSUID;
                elcDev.DeviceSUID = devLine.SUID;
                elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                strCon2 = " AND Type= '01' AND Number = " + devLine.FirstNode;
                strCon = strCon1 + strCon2;
                PSPDEV devMXI = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);

                PSP_ElcDevice elcDevi = new PSP_ElcDevice();
                elcDevi.ProjectSUID = projectSUID;
                elcDevi.DeviceSUID = devMXI.SUID;
                elcDevi = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDevi);

                strCon2 = " AND Type= '01' AND Number = " + devLine.LastNode;
                strCon = strCon1 + strCon2;
                PSPDEV devMXJ = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);

                PSP_ElcDevice elcDevj = new PSP_ElcDevice();
                elcDevj.ProjectSUID = projectSUID;
                elcDevj.DeviceSUID = devMXJ.SUID;
                elcDevj = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDevj);
                complex Vi = new complex((Convert.ToDouble(GetColValue(elcDevi, 0).COL2) / devMXI.ReferenceVolt) * Math.Sin(Convert.ToDouble(GetColValue(elcDevi, 0).COL3) * Deg_to_Rad), (Convert.ToDouble(GetColValue(elcDevi, 0).COL2) / devMXI.ReferenceVolt) * Math.Cos(Convert.ToDouble(GetColValue(elcDevi, 0).COL3) * Deg_to_Rad));
                complex Vj = new complex((Convert.ToDouble(GetColValue(elcDevj, 0).COL2) / devMXJ.ReferenceVolt) * Math.Sin(Convert.ToDouble(GetColValue(elcDevj, 0).COL3) * Deg_to_Rad), (Convert.ToDouble(GetColValue(elcDevj, 0).COL2) / devMXJ.ReferenceVolt) * Math.Cos(Convert.ToDouble(GetColValue(elcDevj, 0).COL3) * Deg_to_Rad));
                complex Iij;
                complex Iji;
                if (devLine.UnitFlag == "0")
                {
                    Iij = (Vi.complex_minus(Vj)).complex_divide(new complex(devLine.LineR, devLine.LineTQ));
                    Iji = (Vj.complex_minus(Vi)).complex_divide(new complex(devLine.LineR, devLine.LineTQ));
                }
                else
                {
                    Iij = (Vi.complex_minus(Vj)).complex_divide(new complex(devLine.LineR * ratedCapacity / (devLine.ReferenceVolt * devLine.ReferenceVolt), devLine.LineTQ * ratedCapacity / (devLine.ReferenceVolt * devLine.ReferenceVolt)));
                    Iji = (Vj.complex_minus(Vi)).complex_divide(new complex(devLine.LineR * ratedCapacity / (devLine.ReferenceVolt * devLine.ReferenceVolt), devLine.LineTQ * ratedCapacity / (devLine.ReferenceVolt * devLine.ReferenceVolt)));
                }

                complex Pij = Vi.complex_multi(Iij);
                complex Pji = Vj.complex_multi(Iji);

                if (elcDev != null)
                {
                    elcDev.COL1 = devLine.Name;
                    elcDev.COL2 = devLine.FirstNode.ToString();
                    elcDev.COL3 = devLine.LastNode.ToString();
                    elcDev.COL19 = devLine.ReferenceVolt.ToString();
                    elcDev.COL20 = ratedCapacity.ToString();

                    elcDev.COL4 = (Pij.Real * ratedCapacity).ToString();
                    elcDev.COL5 = (Pij.Image * ratedCapacity).ToString();

                    elcDev.COL6 = ((Pij.Real - Pji.Real) * ratedCapacity).ToString();
                    elcDev.COL7 = ((Pij.Image - Pij.Image) * ratedCapacity).ToString();

                    elcDev.COL8 = (Pji.Real * ratedCapacity).ToString();

                    elcDev.COL9 = (Pji.Image * ratedCapacity).ToString();

                    elcDev.COL12 = GetColValue(elcDevi, 0).COL2;

                    elcDev.COL13 = GetColValue(elcDevj, 0).COL2;

                    elcDev.COL14 = (Math.Sqrt(Iij.Real * Iij.Real + Iij.Image * Iij.Image) * ratedCapacity / (Math.Sqrt(3) * devLine.ReferenceVolt)).ToString();

                    elcDev.COL15 = (Math.Atan(Iij.Image / Iij.Real) * Rad_to_Deg).ToString();
                    PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                    Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                }
            }
            return true;
        }
示例#18
0
        private void ShowPowerLoss()
        {
            int order = 1;
            try {
                XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");

                foreach (XmlNode node in list) {
                    SvgElement element = node as SvgElement;
                    if ((element.GetAttribute("textn1id") == null || element.GetAttribute("textn1id") == "") && (element.GetAttribute("textn2id") == null || element.GetAttribute("textn2id") == "")) {
                        tlVectorControl1.SVGDocument.CurrentElement = element;
                        tlVectorControl1.Delete();
                    }
                }
                double yinzi = 0, capability = 0, volt = 0, standvolt = 0, current = 0;
                //PSPDEV benchmark = new PSPDEV();
                //benchmark.Type = "power";
                //benchmark.ProjectID = Itop.Client.MIS.ProgUID;
                //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);
                //    TLPSPVmin = dev.iV;
                //    TLPSPVmax = dev.jV;
                //    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);
                //};

                //XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");
                //foreach (XmlNode node in useList)
                //{
                //    XmlElement element = node as XmlElement;
                //    //XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + element.GetAttribute("id") + "']");
                //    string strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'";
                //    IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                //    for (int i = 0; i < listMX.Count; i++)
                //    {
                //        PSPDEV elementDEV = (PSPDEV)(listMX[i]);
                //        PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                //        elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                //        elcDEV.DeviceSUID = ((PSPDEV)listMX[i]).SUID;
                //        elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                //        if (elcDEV != null)
                //        {
                //            RectangleF bound = ((IGraph)element).GetBounds();
                //            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                //            XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                //            n1.SetAttribute("x", Convert.ToString(bound.X));
                //            n1.SetAttribute("y", Convert.ToString(bound.Y - i * 20));
                //            n1.SetAttribute("font-size", "6");
                //            n1.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL2).ToString("N2");
                //            Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));
                //            n1.SetAttribute("layer", la.ID);
                //            //MessageBox.Show(Convert.ToString(n1.InnerText));
                //            n1.SetAttribute("flag", "1");
                //            if (Convert.ToDouble(GetColValue(elcDEV, order).COL2) > TLPSPVmax * elementDEV.RateVolt / elementDEV.ReferenceVolt || Convert.ToDouble(GetColValue(elcDEV, order).COL2) < TLPSPVmin * elementDEV.RateVolt / elementDEV.ReferenceVolt)//电压越限,需修改
                //                n1.SetAttribute("stroke", "#FF0000");
                //            if (elementDEV.NodeType == "0")
                //            {

                //                n2.SetAttribute("x", Convert.ToString(bound.X));
                //                n2.SetAttribute("y", Convert.ToString(bound.Y + bound.Height + 20));
                //                if (Convert.ToDouble(elcDEV.COL5) >= 0)
                //                {
                //                    n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  + " + "j" + Convert.ToDouble(GetColValue(elcDEV, order).COL5).ToString("N2");
                //                }
                //                else
                //                {
                //                    n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  - " + "j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                //                }
                //                n2.SetAttribute("layer", la.ID);
                //                n2.SetAttribute("flag", "1");
                //                n2.SetAttribute("font-size", "6");
                //                double tempi = Convert.ToDouble(GetColValue(elcDEV, order).COL4);
                //                double tempj = Convert.ToDouble(GetColValue(elcDEV, order).COL5);
                //                double temptotal = Math.Sqrt(tempi * tempi + tempj * tempj);
                //                if (temptotal > Convert.ToDouble(elementDEV.Burthen))
                //                {
                //                    n2.SetAttribute("stroke", "#FF0000");
                //                }
                //                tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);

                //            }
                //            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                //            tlVectorControl1.Operation = ToolOperation.Select;
                //            tlVectorControl1.Refresh();
                //        }
                //    }
                //}
                tlVectorControl1.SVGDocument.AcceptChanges = true;
                XmlNodeList polyLineList = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline");
                XmlNodeList layerlist = tlVectorControl1.SVGDocument.GetElementsByTagName("layer");
                Layer layResult;
                bool lb = true;
                foreach (Layer lay in layerlist) {
                    if (lay.GetAttribute("label") == "结果显示") {
                        SvgDocument.currentLayer = lay.ID;
                        lb = false;
                    }
                }
                if (lb) {
                    SvgDocument.currentLayer = Layer.CreateNew("结果显示", tlVectorControl1.SVGDocument).ID;
                }
                foreach (XmlNode node in polyLineList) {
                    XmlElement element = node as XmlElement;
                    PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                    elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    elcDEV.DeviceSUID = element.GetAttribute("Deviceid");
                    elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                    PSPDEV elementDEV = new PSPDEV();
                    if (elcDEV != null) {
                        elementDEV.SUID = elcDEV.DeviceSUID;
                        elementDEV = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", elementDEV);
                    } else {
                        continue;
                    }

                    if (elementDEV != null && elementDEV.KSwitchStatus == "0") {
                        PointF[] t = ((Polyline)element).Points;
                        PointF[] t2 = ((Polyline)element).FirstTwoPoint; t = t2;

                        PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2));
                        float angel = 0f;
                        angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);

                        string l3 = Convert.ToString(midt.X);
                        string l4 = Convert.ToString(midt.Y);

                        string tran = ((Polyline)element).Transform.ToString();

                        PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2));
                        XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@textn1id='" + element.GetAttribute("Deviceid") + "']") as XmlElement;
                        // XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                        //XmlElement n3 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;

                        PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                        PointF pStart2 = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                        XmlNode firstNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("FirstNode") + "']");
                        XmlNode lastNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("LastNode") + "']");
                        if (firstNodeElement == null || lastNodeElement == null)
                            continue;
                        if (t2[0].X > ((IGraph)firstNodeElement).CenterPoint.X || t2[0].Y < ((IGraph)firstNodeElement).CenterPoint.Y) {
                            pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                            pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                        } else {
                            pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                            pStart2 = new PointF(center.X + (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                        }

                        PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));
                        if (n1 == null) {
                            n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            n1.SetAttribute("x", Convert.ToString(pStart.X));
                            n1.SetAttribute("y", Convert.ToString(pStart.Y));
                            n1.SetAttribute("layer", SvgDocument.currentLayer);
                            n1.SetAttribute("flag", "1");
                            n1.SetAttribute("font-size", "10");
                            n1.SetAttribute("textn1id", element.GetAttribute("Deviceid"));
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            tlVectorControl1.Operation = ToolOperation.Select;

                            tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                            RectangleF ttt = ((Polyline)element).GetBounds();

                            tlVectorControl1.RotateSelection(angel, pStart);
                            if (Math.Abs(angel) > 90)
                                tlVectorControl1.RotateSelection(180, pStart);
                        }

                        if ((Convert.ToDouble(GetColValue(elcDEV, order).COL7) + Convert.ToDouble(GetColValue(elcDEV, order).COL11)) * (Convert.ToDouble(GetColValue(elcDEV, order).COL6) + Convert.ToDouble(GetColValue(elcDEV, order).COL10)) >= 0) {
                            n1.InnerText = (Math.Abs((Convert.ToDouble(GetColValue(elcDEV, order).COL6) + Convert.ToDouble(GetColValue(elcDEV, order).COL10)))).ToString("N2") + " + j" + (Math.Abs((Convert.ToDouble(GetColValue(elcDEV, order).COL7) + Convert.ToDouble(GetColValue(elcDEV, order).COL11)))).ToString("N2");
                        } else {
                            n1.InnerText = (Math.Abs((Convert.ToDouble(GetColValue(elcDEV, order).COL6) + Convert.ToDouble(GetColValue(elcDEV, order).COL10)))).ToString("N2") + " - j" + (Math.Abs((Convert.ToDouble(GetColValue(elcDEV, order).COL7) + Convert.ToDouble(GetColValue(elcDEV, order).COL11)))).ToString("N2");
                        }

                        //if (Convert.ToDouble(GetColValue(elcDEV, order).COL14) > (elementDEV.LineChange))//电流越限,需修改。

                        //    n1.SetAttribute("stroke", "#FF0000");

                        PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 10) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 10) * Math.PI / 180)));
                        PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 350) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 350) * Math.PI / 180)));

                        //if ((Convert.ToDouble(GetColValue(elcDEV, order).COL6) + Convert.ToDouble(GetColValue(elcDEV, order).COL10)) < 0)
                        if (Convert.ToDouble(GetColValue(elcDEV, order).COL4) < 0) {
                            p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 170) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 170) * Math.PI / 180)));
                            p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 190) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 190) * Math.PI / 180)));
                        }

                        string l1 = Convert.ToString(p1.X);
                        string l2 = Convert.ToString(p1.Y);
                        string l5 = Convert.ToString(p2.X);
                        string l6 = Convert.ToString(p2.Y);
                        XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("polygon") as Polygon;
                        n2.SetAttribute("points", l1 + " " + l2 + "," + l3 + " " + l4 + "," + l5 + " " + l6);
                        n2.SetAttribute("fill-opacity", "1");
                        n2.SetAttribute("layer", SvgDocument.currentLayer);
                        n2.SetAttribute("flag", "1");
                        n2.SetAttribute("font-size", "10");
                        n2.SetAttribute("style", "fill:#000000");
                        tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);
                        tlVectorControl1.SVGDocument.CurrentElement = n2 as SvgElement;

                        //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                        //tlVectorControl1.Operation = ToolOperation.Select;

                        //tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                        //RectangleF ttt = ((Polyline)element).GetBounds();

                        //tlVectorControl1.RotateSelection(angel, pStart);
                        //if (Math.Abs(angel) > 90)
                        //    tlVectorControl1.RotateSelection(180, pStart);

                        tlVectorControl1.Refresh();
                    }
                }
            } catch (System.Exception ex) {
                MessageBox.Show("参数错误,请调整参数后重新计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
示例#19
0
 private DeviceCOL GetColValue(PSP_ElcDevice elcDEV, int order)
 {
     DeviceCOL devCol = new DeviceCOL();
     if (order == 0)
     {
         devCol.COL1 =String.IsNullOrEmpty(elcDEV.COL1) ? "0" : elcDEV.COL1;
         devCol.COL2 = String.IsNullOrEmpty(elcDEV.COL2) ? "0" : elcDEV.COL2;
         devCol.COL3 = String.IsNullOrEmpty(elcDEV.COL3) ? "0" : elcDEV.COL3;
         devCol.COL4 = String.IsNullOrEmpty(elcDEV.COL4) ? "0" : elcDEV.COL4;
         devCol.COL5 = String.IsNullOrEmpty(elcDEV.COL5) ? "0" : elcDEV.COL5;
         devCol.COL6 = String.IsNullOrEmpty(elcDEV.COL6) ? "0" : elcDEV.COL6;
         devCol.COL7 = String.IsNullOrEmpty(elcDEV.COL7) ? "0" : elcDEV.COL7;
         devCol.COL8 = String.IsNullOrEmpty(elcDEV.COL8) ? "0" : elcDEV.COL8;
         devCol.COL9 = String.IsNullOrEmpty(elcDEV.COL9) ? "0" : elcDEV.COL9;
         devCol.COL10 = String.IsNullOrEmpty(elcDEV.COL10) ? "0" : elcDEV.COL10;
         devCol.COL11 = String.IsNullOrEmpty(elcDEV.COL11) ? "0" : elcDEV.COL11;
         devCol.COL12 = String.IsNullOrEmpty(elcDEV.COL12) ? "0" : elcDEV.COL12;
         devCol.COL13 = String.IsNullOrEmpty(elcDEV.COL13) ? "0" : elcDEV.COL13;
         devCol.COL14 = String.IsNullOrEmpty(elcDEV.COL14) ? "0" : elcDEV.COL14;
         devCol.COL15 = String.IsNullOrEmpty(elcDEV.COL15) ? "0" : elcDEV.COL15;
         devCol.COL16 = String.IsNullOrEmpty(elcDEV.COL16) ? "0" : elcDEV.COL16;
         devCol.COL17 = String.IsNullOrEmpty(elcDEV.COL17) ? "0" : elcDEV.COL17;
         devCol.COL18 = String.IsNullOrEmpty(elcDEV.COL18) ? "0" : elcDEV.COL18;
         devCol.COL19 = String.IsNullOrEmpty(elcDEV.COL19) ? "0" : elcDEV.COL19;
         devCol.COL20 = String.IsNullOrEmpty(elcDEV.COL20) ? "0" : elcDEV.COL20;
     }
     else if (order == 1)
     {
         devCol.COL1 =  String.IsNullOrEmpty(elcDEV.COL21) ? "0" : elcDEV.COL21;
         devCol.COL2 =  String.IsNullOrEmpty(elcDEV.COL22) ? "0" : elcDEV.COL22;
         devCol.COL3 =  String.IsNullOrEmpty(elcDEV.COL23) ? "0" : elcDEV.COL23;
         devCol.COL4 = String.IsNullOrEmpty(elcDEV.COL24) ? "0" : elcDEV.COL24;
         devCol.COL5 =  String.IsNullOrEmpty(elcDEV.COL25) ? "0" : elcDEV.COL25;
         devCol.COL6 =  String.IsNullOrEmpty(elcDEV.COL26) ? "0" : elcDEV.COL26;
         devCol.COL7 =  String.IsNullOrEmpty(elcDEV.COL27) ? "0" : elcDEV.COL27;
         devCol.COL8 =  String.IsNullOrEmpty(elcDEV.COL28) ? "0" : elcDEV.COL28;
         devCol.COL9 =  String.IsNullOrEmpty(elcDEV.COL29) ? "0" : elcDEV.COL29;
         devCol.COL10 = String.IsNullOrEmpty(elcDEV.COL30) ? "0" : elcDEV.COL30;
         devCol.COL11 = String.IsNullOrEmpty(elcDEV.COL31) ? "0" : elcDEV.COL31;
         devCol.COL12 = String.IsNullOrEmpty(elcDEV.COL32) ? "0" : elcDEV.COL32;
         devCol.COL13 = String.IsNullOrEmpty(elcDEV.COL33) ? "0" : elcDEV.COL33;
         devCol.COL14 = String.IsNullOrEmpty(elcDEV.COL34) ? "0" : elcDEV.COL34;
         devCol.COL15 = String.IsNullOrEmpty(elcDEV.COL35) ? "0" : elcDEV.COL35;
         devCol.COL16 = String.IsNullOrEmpty(elcDEV.COL36) ? "0" : elcDEV.COL36;
         devCol.COL17 = String.IsNullOrEmpty(elcDEV.COL37) ? "0" : elcDEV.COL37;
         devCol.COL18 = String.IsNullOrEmpty(elcDEV.COL38) ? "0" : elcDEV.COL38;
         devCol.COL19 =  String.IsNullOrEmpty(elcDEV.COL39) ? "0" : elcDEV.COL39;
         devCol.COL20 = String.IsNullOrEmpty(elcDEV.COL40) ? "0" : elcDEV.COL40;
     }
     else if (order == 2)
     {
         devCol.COL1 =  String.IsNullOrEmpty(elcDEV.COL41) ? "0" : elcDEV.COL41;
         devCol.COL2 = String.IsNullOrEmpty(elcDEV.COL42) ? "0" : elcDEV.COL42;
         devCol.COL3 = String.IsNullOrEmpty(elcDEV.COL43) ? "0" : elcDEV.COL43;
         devCol.COL4 =  String.IsNullOrEmpty(elcDEV.COL44) ? "0" : elcDEV.COL44;
         devCol.COL5 =  String.IsNullOrEmpty(elcDEV.COL45) ? "0" : elcDEV.COL45;
         devCol.COL6 =String.IsNullOrEmpty(elcDEV.COL46) ? "0" : elcDEV.COL46;
         devCol.COL7 =  String.IsNullOrEmpty(elcDEV.COL47) ? "0" : elcDEV.COL47;
         devCol.COL8 =  String.IsNullOrEmpty(elcDEV.COL48) ? "0" : elcDEV.COL48;
         devCol.COL9 = String.IsNullOrEmpty(elcDEV.COL49) ? "0" : elcDEV.COL49;
         devCol.COL10 =  String.IsNullOrEmpty(elcDEV.COL50) ? "0" : elcDEV.COL50;
         devCol.COL11 = String.IsNullOrEmpty(elcDEV.COL51) ? "0" : elcDEV.COL51;
         devCol.COL12 = String.IsNullOrEmpty(elcDEV.COL52) ? "0" : elcDEV.COL52;
         devCol.COL13 =  String.IsNullOrEmpty(elcDEV.COL53) ? "0" : elcDEV.COL53;
         devCol.COL14 =  String.IsNullOrEmpty(elcDEV.COL54) ? "0" : elcDEV.COL54;
         devCol.COL15 = String.IsNullOrEmpty(elcDEV.COL55) ? "0" : elcDEV.COL55;
         devCol.COL16 =  String.IsNullOrEmpty(elcDEV.COL56) ? "0" : elcDEV.COL56;
         devCol.COL17 = String.IsNullOrEmpty(elcDEV.COL57) ? "0" : elcDEV.COL57;
         devCol.COL18 =String.IsNullOrEmpty(elcDEV.COL58) ? "0" : elcDEV.COL58;
         devCol.COL19 = String.IsNullOrEmpty(elcDEV.COL59) ? "0" : elcDEV.COL59;
         devCol.COL20 =  String.IsNullOrEmpty(elcDEV.COL60) ? "0" : elcDEV.COL60;
     }
     else if (order == 3)
     {
         devCol.COL1 = String.IsNullOrEmpty(elcDEV.COL61) ? "0" : elcDEV.COL61;
         devCol.COL2 = String.IsNullOrEmpty(elcDEV.COL62) ? "0" : elcDEV.COL62;
         devCol.COL3 =  String.IsNullOrEmpty(elcDEV.COL63) ? "0" : elcDEV.COL63;
         devCol.COL4 = String.IsNullOrEmpty(elcDEV.COL64) ? "0" : elcDEV.COL64;
         devCol.COL5 = String.IsNullOrEmpty(elcDEV.COL65) ? "0" : elcDEV.COL65;
         devCol.COL6 = String.IsNullOrEmpty(elcDEV.COL66) ? "0" : elcDEV.COL66;
         devCol.COL7 =  String.IsNullOrEmpty(elcDEV.COL67) ? "0" : elcDEV.COL67;
         devCol.COL8 = String.IsNullOrEmpty(elcDEV.COL68) ? "0" : elcDEV.COL68;
         devCol.COL9 = String.IsNullOrEmpty(elcDEV.COL69) ? "0" : elcDEV.COL69;
         devCol.COL10 = String.IsNullOrEmpty(elcDEV.COL70) ? "0" : elcDEV.COL70;
         devCol.COL11 = String.IsNullOrEmpty(elcDEV.COL71) ? "0" : elcDEV.COL71;
         devCol.COL12 =  String.IsNullOrEmpty(elcDEV.COL72) ? "0" : elcDEV.COL72;
         devCol.COL13 = String.IsNullOrEmpty(elcDEV.COL73) ? "0" : elcDEV.COL73;
         devCol.COL14 =  String.IsNullOrEmpty(elcDEV.COL74) ? "0" : elcDEV.COL74;
         devCol.COL15 =  String.IsNullOrEmpty(elcDEV.COL75) ? "0" : elcDEV.COL75;
         devCol.COL16 =  String.IsNullOrEmpty(elcDEV.COL76) ? "0" : elcDEV.COL76;
         devCol.COL17 =  String.IsNullOrEmpty(elcDEV.COL77) ? "0" : elcDEV.COL77;
         devCol.COL18 = String.IsNullOrEmpty(elcDEV.COL78) ? "0" : elcDEV.COL78;
         devCol.COL19 = String.IsNullOrEmpty(elcDEV.COL79) ? "0" : elcDEV.COL79;
         devCol.COL20 =  String.IsNullOrEmpty(elcDEV.COL80) ? "0" : elcDEV.COL80;
     }
     return devCol;
 }
示例#20
0
        public void Init(string obj)
        {
            dt.Columns.Add("A");
            dt.Columns.Add("B");
            dt.Columns.Add("C", typeof(bool));
            //Stream fs = Assembly.GetExecutingAssembly().GetManifestResourceStream("Itop.TLPSP.DEVICE.devicetypes.xml");
            ////Assembly.GetExecutingAssembly().GetManifestResourceStream
            //XmlDocument xml = new XmlDocument();
            //xml.Load(fs);
            //XmlNodeList nodes = xml.GetElementsByTagName("device");
            DataTable table = new DataTable();
            table.Columns.Add("id", typeof(string));
            table.Columns.Add("name", typeof(string));
            table.Columns.Add("class", typeof(string));
            //foreach (XmlNode node in nodes)
            //{
            //    DataRow row = table.NewRow();
            //    row["id"] = node.Attributes["id"].Value;
            //    row["name"] = node.Attributes["name"].Value;
            //    row["class"] = node.Attributes["class"].Value;
            //    table.Rows.Add(row);
            //}
            //comboBox1.DataSource = table;
            //comboBox1.DisplayMember = "name";
            //if (DeviceName != null)
            //{
            //    comboBox1.Text = DeviceName;
            //}

            {
                dt.Clear();
                if (obj != null)
                {
                //    DataRowView row1 = obj as DataRowView;
                    string id = obj;
                    string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + ProjectID + "'";
                    string strCon2 = null;
                    string strCon = null;

                    strCon2 = " AND Type = '" + obj + "'";
                    strCon = strCon1 + strCon2;
                    IList list = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    foreach (PSPDEV dev in list)
                    {
                        PSP_ElcDevice pspDev = new PSP_ElcDevice();
                        pspDev.DeviceSUID = dev.SUID;
                        pspDev.ProjectSUID = ProjectSUID;
                        IList list1 = Services.BaseService.GetList("SelectPSP_ElcDeviceByKey", pspDev);
                        if (list1.Count > 0)
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.SUID;
                            row["B"] = dev.Name;
                            row["C"] = true;
                            dt.Rows.Add(row);
                        }
                        else
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.SUID;
                            row["B"] = dev.Name;
                            row["C"] = false;
                            dt.Rows.Add(row);
                        }
                    }
                }
                gridControl1.DataSource = dt;
            }
        }