public frmGNDLimit() { InitializeComponent(); dataGridView1.DataError += new DataGridViewDataErrorEventHandler(dataGridView1_DataError); dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged); WireCategory wirewire = new WireCategory(); IList list1 = Services.BaseService.GetList("SelectWireCategoryList", wirewire); IList list2=null; foreach (WireCategory sub in list1) { list2.Add(sub); lineTypeDataGridViewTextBoxColumn.Items.Add(sub.WireType); foreach (WireCategory sub2 in list2) { if (sub2 == sub) { list2.Remove(sub2); lineTypeDataGridViewTextBoxColumn.Items.Remove(sub.WireType); } } } }
public void InitData(string vr) { WireCategory wirewire = new WireCategory(); wirewire.WireLevel = wirel; IList list2 = Services.BaseService.GetList("SelectWireCategoryList", wirewire); foreach (WireCategory wirewire2 in list2) { if (wirewire2.WireLevel != null) { if (!WireLevel.Items.Contains(wirewire2.WireLevel)) { wirewire2.WireLevel = ""; } } Services.BaseService.Update<WireCategory>(wirewire2); } //IList list = Services.BaseService.GetList("SelectWireCategoryListBYWireLevel", wirewire); IList list = Services.BaseService.GetList("SelectWireCategoryList", wirewire); DataTable dt = Itop.Common.DataConverter.ToDataTable(list, typeof(WireCategory)); this.Text = vr; dataGridView1.DataSource = dt; }
public frmLinenew(PSPDEV pspDev) { InitializeComponent(); mc.Select(); WireCategory wirewire = new WireCategory(); wirewire.WireLevel = pspDev.VoltR.ToString(); IList list1 = Services.BaseService.GetList("SelectWireCategoryListBYWireLevel", wirewire); foreach (WireCategory sub in list1) { comboBox22.Properties.Items.Add(sub.WireType); } InitData(pspDev); this.comboBox22.SelectedIndexChanged += new System.EventHandler(this.comboBox22_SelectedIndexChanged); this.textBox11.Leave += new System.EventHandler(this.textBox11_Leave); this.textBox11.TextChanged += new System.EventHandler(this.textBox11_TextChanged); this.comboBoxEdit1.SelectedIndexChanged += new System.EventHandler(this.comboBoxEdit1_SelectedIndexChanged); this.comboBoxEdit1.Leave += new System.EventHandler(this.comboBoxEdit1_Leave); object[] o = new object[30]; for (int i = 0; i < 30; i++) { o[i] = 2009 + i; } this.tyear.Properties.Items.AddRange(o); //this.tyear.Visible = false; }
public frmLine() { InitializeComponent(); WireCategory wirewire = new WireCategory(); IList list1 = Services.BaseService.GetList("SelectWireCategoryList", wirewire); foreach (WireCategory sub in list1) { comboBox22.Properties.Items.Add(sub.WireType); } mc.Text = null; mc.Select(); }
public frmLineParamDL() { InitializeComponent(); dataGridView1.DataError += new DataGridViewDataErrorEventHandler(dataGridView1_DataError); dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged); WireCategory wirewire = new WireCategory(); IList list1 = Services.BaseService.GetList("SelectWireCategoryList", wirewire); foreach (WireCategory sub in list1) { lineTypeDataGridViewTextBoxColumn.Items.Add(sub.WireType); } //huganLine1DataGridViewTextBoxColumn.Items.Add }
public frmLineParamDL(string svgUID) { InitializeComponent(); dataGridView1.DataError += new DataGridViewDataErrorEventHandler(dataGridView1_DataError); dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged); WireCategory wirewire = new WireCategory(); IList list1 = Services.BaseService.GetList("SelectWireCategoryList", wirewire); IList list2 = Services.BaseService.GetList("SelectWireCategoryList", wirewire); list2.Clear(); foreach (WireCategory sub in list1) { list2.Add(sub); lineTypeDataGridViewTextBoxColumn.Items.Add(sub.WireType); int i = 1; foreach (WireCategory sub2 in list2) { if (sub2.WireType == sub.WireType) { i++; if (i > 2) lineTypeDataGridViewTextBoxColumn.Items.Remove(sub.WireType); //list2.Remove(sub2); } } Refresh(); } PSPDEV dev = new PSPDEV(); //dev.Number = pspDev.FirstNode; dev.SvgUID = svgUID; dev.Type = "Polyline"; IList list = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", dev); foreach (PSPDEV sub in list) { if (sub.Lable == "֧·") { huganLine1DataGridViewTextBoxColumn.Items.Add(sub.Name); huganLine2DataGridViewTextBoxColumn.Items.Add(sub.Name); huganLine3DataGridViewTextBoxColumn.Items.Add(sub.Name); huganLine4DataGridViewTextBoxColumn.Items.Add(sub.Name); } } InitData(svgUID); //huganLine1DataGridViewTextBoxColumn.Items.Add(" "); //huganLine2DataGridViewTextBoxColumn.Items.Add(" "); //huganLine3DataGridViewTextBoxColumn.Items.Add(" "); //huganLine4DataGridViewTextBoxColumn.Items.Add(" "); }
public frmLine(PSPDEV pspDev) { InitializeComponent(); mc.Select(); WireCategory wirewire = new WireCategory(); wirewire.WireLevel = pspDev.VoltR.ToString(); IList list1 = Services.BaseService.GetList("SelectWireCategoryListBYWireLevel", wirewire); foreach (WireCategory sub in list1) { comboBox22.Properties.Items.Add(sub.WireType); } InitData(pspDev); this.comboBox22.SelectedIndexChanged += new System.EventHandler(this.comboBox22_SelectedIndexChanged); this.comboBoxEdit5.SelectedIndexChanged += new System.EventHandler(this.comboBoxEdit5_SelectedIndexChanged); this.textBox11.Leave += new System.EventHandler(this.textBox11_Leave); this.textBox11.TextChanged += new System.EventHandler(this.textBox11_TextChanged); }
public chaoliuResult() { InitializeComponent(); //gridControl1.DataError += new DataGridViewDataErrorEventHandler(dataGridView1_DataError); //dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged); WireCategory wirewire = new WireCategory(); IList list1 = Services.BaseService.GetList("SelectWireCategoryList", wirewire); foreach (WireCategory sub in list1) { repositoryItemComboBox2.Items.Add(sub.WireType); //repositoryItemComboBox2.Items. //repositoryItemComboBox2.add //repositoryItemComboBox1 //lineTypeDataGridViewTextBoxColumn.Items.Add(sub.WireType); //colLineType.ColumnEdit. } string svgUID = "78ea0682-ad15-423b-8c61-68e7d5a6c29b"; InitData(svgUID); }
//记录负荷的线路 private bool fuhecheck() { FileStream dh; StreamReader readLine; char[] charSplit; string strLine; string[] array1; string output = null; string[] array2; string strLine2; char[] charSplit2 = new char[] { ' ' }; FileStream op; StreamWriter str1; FileStream dh2; StreamReader readLine2; fuheline.Clear(); //清空上一次的记录 为下一个时期的应用做准备 // linedengdai.Clear(); //清空上一次记录待选线路 为下一个时期的应用做准备 if (!Checkfuhe()) return true; N1Test.NBcal zl = new NBcal(); //zl.Show_KmRelia(1); zl.ZLpsp(); double yinzi = 0, capability = 0, volt = 0, current = 0, standvolt = 0, Rad_to_Deg = 57.29577951; PSPDEV benchmark = new PSPDEV(); benchmark.Type = "power"; benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark); if (list3 == null) { MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } foreach (PSPDEV dev in list3) { yinzi = Convert.ToDouble(dev.PowerFactor); capability = Convert.ToDouble(dev.StandardCurrent); volt = Convert.ToDouble(dev.StandardVolt); if (dev.PowerFactor == 0) { yinzi = 1; } if (dev.StandardCurrent == 0) { capability = 1; } if (dev.StandardVolt == 0) { volt = 1; } standvolt = volt; current = capability / (Math.Sqrt(3) * volt); } capability = 100; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt")) { } else { return true; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); output = null; //double sumpij = 0.0; bool lineflag = true; while (!string.IsNullOrEmpty(strLine)) { array1 = strLine.Split(charSplit); string[] dev = new string[2]; dev.Initialize(); int i = 0; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (i == 0) { dev[i++] = str.ToString(); } else { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } } CR.Name = dev[0]; CR.Type = "Polyline"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null && CR.ReferenceVolt != 0) { volt = CR.ReferenceVolt; } else volt = standvolt; current = capability / (Math.Sqrt(3) * volt); if (CR != null && !CR.Name.Contains("虚拟线路")) { double linepij = System.Math.Abs(Convert.ToDouble(dev[1])) * capability; double voltR = CR.VoltR; WireCategory wirewire = new WireCategory(); wirewire.WireType = CR.LineType; if (string.IsNullOrEmpty(CR.LineType)) { MessageBox.Show(CR.Name + "的线路类型没有输入,无法进行可靠性检验", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } WireCategory listware = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); double Ichange = (double)listware.WireChange; double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000; if (linepij >= linXij) { lineflag = false; linedaixuan ld = new linedaixuan(CR.Number, CR.SUID, CR.Name); ld.linepij = linepij; fuheline.Add(ld); } // // //output += "'" + CR.Name.ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } strLine = readLine.ReadLine(); } readLine.Close(); return lineflag; }
public void InitCom() { comboBoxEdit9.Properties.Items.Add("新建"); comboBoxEdit9.Properties.Items.Add("扩建"); comboBoxEdit9.Properties.Items.Add("改造"); comboBoxEdit9.SelectedIndex = 0; for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++) { comboBoxEdit1.Properties.Items.Add(i.ToString()); comboBoxEdit2.Properties.Items.Add(i.ToString()); } comboBoxEdit1.Text = DateTime.Now.Year.ToString(); comboBoxEdit2.Text = DateTime.Now.AddYears(1).Year.ToString() ; string conn = "ProjectID='" + projectID + "' order by Sort"; IList<PS_Table_AreaWH> list1 = Common.Services.BaseService.GetList<PS_Table_AreaWH>("SelectPS_Table_AreaWHByConn", conn); foreach (PS_Table_AreaWH area in list1) { comboBoxEdit10.Properties.Items.Add(area.Title); } //导线型号 WireCategory wc = new WireCategory(); wc.Type = "40"; IList<WireCategory> list = Common.Services.BaseService.GetList<WireCategory>("SelectWireCategoryList", wc); for (int k = 0; k < list.Count; k++) { combDXXH.Properties.Items.Add(list[k].WireType); } //网区类型 IList<string> areatyplist = null; if (Common.Services.BaseService.GetList<string>("SelectBuildProDifAreaType", "") != null) { areatyplist = Common.Services.BaseService.GetList<string>("SelectBuildProDifAreaType", ""); for (int j = 0; j < areatyplist.Count; j++) { combWQFL.Properties.Items.Add(areatyplist[j]); } } }
private void jianxiancheck() { FileStream dh; StreamReader readLine; char[] charSplit; string strLine; string[] array1; string output = null; string[] array2; string strLine2; char[] charSplit2 = new char[] { ' ' }; FileStream op; StreamWriter str1; FileStream dh2; StreamReader readLine2; if (!Check()) { return; } //NIULA pspniula = new NIULA(); //pspniula.CurrentCal(); N1Test.NBcal zl = new NBcal(); //zl.Show_KmRelia(1); zl.ZLpsp(); double yinzi = 0, capability = 0, volt = 0, current = 0, standvolt = 0, Rad_to_Deg = 57.29577951; PSPDEV benchmark = new PSPDEV(); benchmark.Type = "power"; benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark); if (list3 == null) { MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (PSPDEV dev in list3) { yinzi = Convert.ToDouble(dev.PowerFactor); capability = Convert.ToDouble(dev.StandardCurrent); volt = Convert.ToDouble(dev.StandardVolt); if (dev.PowerFactor == 0) { yinzi = 1; } if (dev.StandardCurrent == 0) { capability = 1; } if (dev.StandardVolt == 0) { volt = 1; } standvolt = volt; current = capability / (Math.Sqrt(3) * volt); } capability = 100; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); output = null; while (!string.IsNullOrEmpty(strLine)) { array1 = strLine.Split(charSplit); string[] dev = new string[2]; dev.Initialize(); int i = 0; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (i == 0) { dev[i++] = str.ToString(); } else { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } } CR.Name = dev[0]; CR.Type = "Polyline"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null && CR.ReferenceVolt != 0) { volt = CR.ReferenceVolt; } else volt = standvolt; current = capability / (Math.Sqrt(3) * volt); if (CR != null) { if (CR.LineStatus == "待选") { for (int n = 0; n < waitlinecoll.Count; n++) //加入线路功率 { if (waitlinecoll[n].linename == CR.Name) { double linepij = System.Math.Abs(Convert.ToDouble(dev[1])) * capability; XmlNode el = tlVectorControl1.SVGDocument.SelectSingleNode("svg/polyline[@layer='" + tlVectorControl1.SVGDocument.CurrentLayer.ID + "' and @id='" + CR.EleID + "']"); double linevalue = 0; if (!string.IsNullOrEmpty(((XmlElement)el).GetAttribute("linevalue"))) { linevalue = Convert.ToDouble(((XmlElement)el).GetAttribute("linevalue")); } else linevalue = 1; waitlinecoll[n].Suid = CR.SUID; waitlinecoll[n].linepij = linepij; waitlinecoll[n].linevalue = linevalue; waitlinecoll[n].linetouzilv = linepij / linevalue; } } } //output += "'" + CR.Name.ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } strLine = readLine.ReadLine(); } readLine.Close(); waitlinecoll.Sort(); //进行大小排序 然后进行直流方法的检验 bool lineflag = true; //只要有一个不合格则就为不合格 bool jielieflag = true; //判断有没有线路解裂 for (int i = 0; i < waitlinecoll.Count; i++) { N1Test.NBcal kk = new N1Test.NBcal(); kk.Show_KmRelia(waitlinecoll[i].linenum); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ZL.txt")) { } else { return; } dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ZL.txt", FileMode.Open); readLine2 = new StreamReader(dh2); charSplit2 = new char[] { ' ' }; strLine2 = readLine2.ReadLine(); output = null; while (!string.IsNullOrEmpty(strLine2)) { array2 = strLine2.Split(charSplit2); string[] dev = new string[2 * brchcount + 1]; dev.Initialize(); PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; int m = 0; foreach (string str in array2) { if (str != "") { dev[m++] = str.ToString(); } } //进行解裂和负荷判断 if (dev[1] != "-1") { for (int j = 0; j < brchcount; j++) { double pij = System.Math.Abs(Convert.ToDouble(dev[j * 2 + 2])) * capability; PSPDEV psp = new PSPDEV(); psp.Name = dev[j * 2 + 1]; psp.Type = "Polyline"; psp.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", psp); PSPDEV pspline = (PSPDEV)listName[0]; double voltR = pspline.VoltR; WireCategory wirewire = new WireCategory(); wirewire.WireType = pspline.LineType; if (string.IsNullOrEmpty(pspline.LineType)) { MessageBox.Show(pspline.Name + "的线路类型没有输入,无法进行可靠性检验", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } WireCategory listware = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); double Ichange = (double)listware.WireChange; double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000; if (pij >= linXij) { lineflag = false; //lineclass _line = new lineclass(n, j); //Overlinp.Add(_line); // OverPhege[n] = j; } } } else { jielieflag = false; } if (jielieflag && lineflag) { readLine2.Close(); //关闭读取的文件 PSPDEV psp = new PSPDEV(); psp.Name = dev[0]; psp.Type = "Polyline"; psp.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", psp); PSPDEV pspline = (PSPDEV)listName[0]; pspline.LineStatus = "等待"; Services.BaseService.Update<PSPDEV>(pspline); jianxiancheck(); //进行下一轮的减线处理 return; } /* else break;*/ strLine2 = readLine2.ReadLine(); } readLine2.Close(); } // readLine2.Close(); }
//void DrawArea_OnMouseMove(object sender, MouseEventArgs e) //{ //} void tlVectorControl1_DoubleLeftClick(object sender, SvgElementSelectedEventArgs e) { if (!Check()) { return; } XmlElement element = tlVectorControl1.SVGDocument.CurrentElement; if (element is Use) { if (element.GetAttribute("xlink:href").Contains("Substation") || element.GetAttribute("xlink:href").Contains("motherlinenode")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmSubstation dlg; if (pspDev != null) { dlg = new frmSubstation(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Use"; if (element.GetAttribute("xlink:href").Contains("Substation")) { pspDev.Lable = "变电站"; } else if (element.GetAttribute("xlink:href").Contains("motherlinenode")) { pspDev.Lable = "母线节点"; } else if (element.GetAttribute("xlink:href").Contains("Power")) { pspDev.Lable = "电厂"; } //Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmSubstation(pspDev); } dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Use"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } PSPDEV powerfactor = new PSPDEV(); powerfactor.Type = "Power"; powerfactor.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; powerfactor = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDAndType", powerfactor); pspDev.VoltR = Convert.ToDouble(dlg.VoltR); pspDev.Burthen = Convert.ToDecimal(dlg.Burthen); //if (powerfactor!=null && (Convert.ToDecimal(dlg.Change)==2)) //pspDev.InPutP = Convert.ToDouble(dlg.Burthen) * powerfactor.BigP; //if (Convert.ToDecimal(dlg.Change)==1) pspDev.InPutP = Convert.ToDouble(dlg.InPutP); pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); pspDev.OutP = Convert.ToDouble(dlg.OutP); pspDev.OutQ = Convert.ToDouble(dlg.OutQ); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); if (dlg.NodeType == "是") { pspDev.NodeType = "0"; } else { pspDev.NodeType = "1"; } Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("Power")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmSubstation dlg; if (pspDev != null) { dlg = new frmSubstation(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Use"; if (element.GetAttribute("xlink:href").Contains("Substation")) { pspDev.Lable = "变电站"; } else if (element.GetAttribute("xlink:href").Contains("motherlinenode")) { pspDev.Lable = "母线节点"; } else if (element.GetAttribute("xlink:href").Contains("Power")) { pspDev.Lable = "电厂"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmSubstation(pspDev); dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Use"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.VoltR = Convert.ToDouble(dlg.VoltR); pspDev.Burthen = Convert.ToDecimal(dlg.Burthen); pspDev.OutP = Convert.ToDouble(dlg.OutP); pspDev.OutQ = Convert.ToDouble(dlg.OutQ); pspDev.InPutP = Convert.ToDouble(dlg.InPutP); pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); if (dlg.NodeType == "是") { pspDev.NodeType = "0"; } else { pspDev.NodeType = "2"; } Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmFadejie dlg; if (pspDev != null) { dlg = new frmFadejie(pspDev, pspDev.SvgUID); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "dynamotorline"; if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { pspDev.Lable = "发电厂支路"; } else if (element.GetAttribute("xlink:href").Contains("gndline")) { pspDev.Lable = "接地支路"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmFadejie(pspDev, pspDev.SvgUID); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "dynamotorline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; if (dlg.OutP != "") pspDev.OutP = Convert.ToDouble(dlg.OutP); if (dlg.OutQ != "") pspDev.OutQ = Convert.ToDouble(dlg.OutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); if (dlg.VoltV != "") pspDev.VoltV = Convert.ToDouble(dlg.VoltV); if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); if (dlg.NegativeTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("gndline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmFadejie dlg; if (pspDev != null) { dlg = new frmFadejie(pspDev, pspDev.SvgUID); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "gndline"; if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { pspDev.Lable = "发电厂支路"; } else if (element.GetAttribute("xlink:href").Contains("gndline")) { pspDev.Lable = "接地支路"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmFadejie(pspDev, pspDev.SvgUID); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "gndline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; if (dlg.OutP != "") pspDev.OutP = Convert.ToDouble(dlg.OutP); if (dlg.OutQ != "") pspDev.OutQ = Convert.ToDouble(dlg.OutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); if (dlg.VoltV != "") pspDev.VoltV = Convert.ToDouble(dlg.VoltV); if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); if (dlg.NegativeTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("loadline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLoad dlg; if (pspDev != null) { dlg = new frmLoad(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "loadline"; pspDev.Lable = "负荷支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmLoad(pspDev); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "loadline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.LoadSwitchState; if (dlg.InPutP != "") pspDev.InPutP = Convert.ToDouble(dlg.InPutP); if (dlg.InPutQ != "") pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("串联电容电抗器")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmCapacity dlg; if (pspDev != null) { dlg = new frmCapacity(pspDev, pspDev.SvgUID); dlg.SetEnable(true); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "串联电容电抗器"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; // pspDev.HuganLine2 = dlg.LastNodeName; if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("并联电容电抗器")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmCapacity dlg; if (pspDev != null) { dlg = new frmCapacity(pspDev, pspDev.SvgUID); dlg.SetEnable(false); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "并联电容电抗器"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; // pspDev.HuganLine2 = dlg.LastNodeName; if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("transformerthirdzu")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmThridTra dlg; if (pspDev != null) { dlg = new frmThridTra(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "transformerthirdzu"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.IName; pspDev.HuganLine2 = dlg.JName; pspDev.HuganLine3 = dlg.ISwitchState; pspDev.HuganLine4 = dlg.JSwitchState; pspDev.LineLevel = dlg.IType; pspDev.LineType = dlg.JType; pspDev.LineStatus = dlg.KType; pspDev.KName = dlg.KName; pspDev.KSwitchStatus = dlg.KSwitchState; if (dlg.IK != "") { pspDev.K = Convert.ToDouble(dlg.KK); } if (dlg.JK != "") { pspDev.G = Convert.ToDouble(dlg.JK); } if (dlg.KK != "") { pspDev.BigP = Convert.ToDouble(dlg.KK); } if (dlg.IR != "") { pspDev.HuganTQ1 = Convert.ToDouble(dlg.IR); } if (dlg.JR != "") { pspDev.HuganTQ2 = Convert.ToDouble(dlg.JR); } if (dlg.KR != "") { pspDev.HuganTQ3 = Convert.ToDouble(dlg.KR); } if (dlg.ITQ != "") { pspDev.HuganTQ4 = Convert.ToDouble(dlg.ITQ); } if (dlg.JTQ != "") { pspDev.HuganTQ5 = Convert.ToDouble(dlg.JTQ); } if (dlg.KTQ != "") { pspDev.SmallTQ = Convert.ToDouble(dlg.KTQ); } if (dlg.ZeroTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); if (dlg.NeutralNodeTQ != "") pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("transformertwozu")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmTwoTra dlg; if (pspDev != null) { dlg = new frmTwoTra(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "transformertwozu"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstName; pspDev.HuganLine2 = dlg.LastName; pspDev.HuganLine3 = dlg.FirstSwitchState; pspDev.HuganLine4 = dlg.LastSwitchState; pspDev.LineLevel = dlg.FirstType; pspDev.LineType = dlg.LastType; if (dlg.PositiveR != "") { pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR); } if (dlg.PositiveTQ != "") { pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); } if (dlg.ZeroR != "") { pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR); } if (dlg.ZeroTQ != "") { pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); } if (dlg.K != "") pspDev.K = Convert.ToDouble(dlg.K); if (dlg.NeutralNodeTQ != "") pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("1/2母联开关")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmMuLian dlg; if (pspDev != null) { dlg = new frmMuLian(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "1/2母联开关"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine2 = dlg.LastNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("2/3母联开关")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmMuLian2 dlg; if (pspDev != null) { dlg = new frmMuLian2(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "2/3母联开关"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.INodeName; pspDev.HuganLine2 = dlg.JNodeName; pspDev.HuganLine3 = dlg.ILineName; pspDev.HuganLine4 = dlg.JLineName; pspDev.KName = dlg.ILoadName; pspDev.KSwitchStatus = dlg.JLoadName; pspDev.LineLevel = dlg.SwitchStatus1; pspDev.LineType = dlg.SwitchStatus2; pspDev.LineStatus = dlg.SwitchStatus3; Services.BaseService.Update<PSPDEV>(pspDev); } } } else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType == true)//潮流下线路 { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLinenew dlg2; if (pspDev != null) { dlg2 = new frmLinenew(pspDev); dlg2.derefucelineflag = Reducelineflag; } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Polyline"; pspDev.Lable = "支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg2 = new frmLinenew(pspDev); dlg2.derefucelineflag = Reducelineflag; } dlg2.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); dlg2.linevalue = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("linevalue"); //获得线路投资 if (dlg2.ShowDialog() == DialogResult.OK) { if (dlg2.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg2.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Polyline"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg2.Name; pspDev.LineLength = Convert.ToDouble(dlg2.LineLength); pspDev.LineR = Convert.ToDouble(dlg2.LineR); pspDev.LineTQ = Convert.ToDouble(dlg2.LineTQ); pspDev.LineGNDC = Convert.ToDouble(dlg2.LineGNDC); pspDev.LineLevel = dlg2.LineLevel; pspDev.LineType = dlg2.LineType; pspDev.LineStatus = dlg2.LineStatus; pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt); if (dlg2.linevalue != "") { pspDev.BigP = Convert.ToDouble(dlg2.linevalue); } WireCategory wirewire = new WireCategory(); wirewire.WireType = dlg2.LineType; WireCategory wirewire2 = new WireCategory(); wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); //if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength)*wirewire2.WireR ; //if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireTQ; //if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireGNDC; if (wirewire2 != null) pspDev.LineChange =(double) wirewire2.WireChange; string tempp = dlg2.LineLev; int tel = tempp.Length; // tempp = tempp.Substring(0, tel - 2); pspDev.VoltR = Convert.ToDouble(tempp); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg2.TYear); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("linevalue", dlg2.linevalue); //获得线路投资 //switch (dlg2.LineType) //{ // case "2*LGJ-400": // { // if (pspDev.LineR==0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.04; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.303; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.054; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.308; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.066; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.310; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.08; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.417; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} Services.BaseService.Update<PSPDEV>(pspDev); Topology2(); } } else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType != true)//短路下线路 { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLine dlg; if (pspDev != null) { dlg = new frmLine(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Polyline"; pspDev.Lable = "支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmLine(pspDev); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Polyline"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; pspDev.LineLength = Convert.ToDouble(dlg.LineLength); pspDev.LineLevel = dlg.LineLevel; pspDev.LineType = dlg.LineType; pspDev.LineStatus = dlg.LineStatus; pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR); pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR); pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); if (dlg.HuganFirst == "是") pspDev.HuganFirst = 1; else pspDev.HuganFirst = 0; pspDev.HuganLine1 = dlg.HuganLine1; pspDev.HuganLine2 = dlg.HuganLine2; pspDev.HuganLine3 = dlg.HuganLine3; pspDev.HuganLine4 = dlg.HuganLine4; pspDev.HuganTQ1 = Convert.ToDouble(dlg.HuganTQ1); pspDev.HuganTQ2 = Convert.ToDouble(dlg.HuganTQ2); pspDev.HuganTQ3 = Convert.ToDouble(dlg.HuganTQ3); pspDev.HuganTQ4 = Convert.ToDouble(dlg.HuganTQ4); pspDev.HuganTQ5 = Convert.ToDouble(dlg.HuganTQ5); string tempp = dlg.LineLev; int tel = tempp.Length; if (tel == 1) pspDev.VoltR = 0; else { //tempp = tempp.Substring(0, tel - 2); pspDev.VoltR = Convert.ToDouble(tempp); } //switch (dlg.LineType) //{ // case "2*LGJ-400": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} Services.BaseService.Update<PSPDEV>(pspDev); Topology2(); } } }
public frmGNDLimit(string svgUID) { InitializeComponent(); dataGridView1.DataError += new DataGridViewDataErrorEventHandler(dataGridView1_DataError); dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged); WireCategory wirewire = new WireCategory(); IList list1 = Services.BaseService.GetList("SelectWireCategoryList", wirewire); IList list2 = Services.BaseService.GetList("SelectWireCategoryList", wirewire); list2.Clear(); foreach (WireCategory sub in list1) { //lineTypeDataGridViewTextBoxColumn.Items.Add(sub.WireType); list2.Add(sub); lineTypeDataGridViewTextBoxColumn.Items.Add(sub.WireType); int i = 1; foreach (WireCategory sub2 in list2) { if (sub2.WireType == sub.WireType) { i++; if (i>2) lineTypeDataGridViewTextBoxColumn.Items.Remove(sub.WireType); //list2.Remove(sub2); } } Refresh(); } //foreach (WireCategory sub in list1) //{ // //lineTypeDataGridViewTextBoxColumn.Items.Add(sub.WireType); // list2.Add(sub); // lineLevelDataGridViewTextBoxColumn.Items.Add(sub.WireLevel); // //int i = 1; // //foreach (WireCategory sub2 in list2) // //{ // // if (sub2.WireType == sub.WireType) // // { // // //i++; // // //if (i > 2) // // // lineTypeDataGridViewTextBoxColumn.Items.Remove(sub.WireType); // // //list2.Remove(sub2); // // } // //} // Refresh(); //} //PSPDEV pspd = new PSPDEV(); //pspd.Type = "Polyline"; //pspd.SvgUID = svgUID; //IList list2 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", pspd); //foreach (PSPDEV level in list2) //{ // voltRDataGridViewTextBoxColumn.Items.Add(level.VoltR); //} InitData(svgUID); }
private void textBox11_Leave(object sender, EventArgs e) { if (textBox11.Text == "") textBox11.Text = "0"; //MessageBox.Show("hello"); if (textBox11.Text == leel.LineLength.ToString()) { } else { leel.LineLength = Convert.ToDouble(textBox11.Text); leel.LineType = comboBox22.Text; leel.Name = mc.Text; leel.LineStatus = comboBox44.Text; leel.LineLevel = "����·"; WireCategory wirewire = new WireCategory(); wirewire.WireType = comboBox22.Text; WireCategory wirewire2 = new WireCategory(); wirewire.WireLevel = comboBoxEdit5.Text; wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKeyANDWireLevel", wirewire); if (wirewire2 != null) { leel.LineR = Convert.ToDouble(leel.LineLength) * wirewire2.WireR; leel.LineTQ = Convert.ToDouble(leel.LineLength) * wirewire2.WireTQ; leel.LineGNDC = Convert.ToDouble(leel.LineLength) * wirewire2.WireGNDC; leel.PositiveTQ = Convert.ToDouble(leel.LineLength) * wirewire2.WireTQ; leel.ZeroTQ = leel.PositiveTQ * 3; } //textBox2.Text= string tempp = comboBoxEdit5.Text; int tel = tempp.Length; //tempp = tempp.Substring(0, tel - 2); //pspDev.VoltR = Convert.ToDouble(tempp); leel.VoltR = Convert.ToDouble(tempp); InitData(leel); } }
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem.Text == "短路计算") { int tuxing = 0; int baobiao = 0; PSPDEV pspDuanlu = new PSPDEV(); pspDuanlu.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; XmlElement element = tlVectorControl1.SVGDocument.CurrentElement; pspDuanlu.EleID = element.GetAttribute("id"); pspDuanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDuanlu); if (pspDuanlu == null) return; if (pspDuanlu.Type == "Polyline" && pspDuanlu.Lable != "支路") return; frmDuanlu dudu = new frmDuanlu(pspDuanlu); PSPDEV Duanlu = new PSPDEV(); Duanlu.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; int n11 = 0, n2 = 0, n3 = 0, n4 = 0; if (dudu.ShowDialog() == DialogResult.OK) { //int bigsmall=Convert.ToInt32(dudu.DuanluBigsmall); CheckDL(); string nodeType; if (dudu.DuanluBaobiao == "是") baobiao = 1; if (dudu.DuanluTuxing == "所有故障点短路电流") tuxing = 1; if (dudu.DuanluTuxing == "指定故障点短路电流") tuxing = 2; //Duanlu.Name = dudu.DuanluPoint; //Duanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", Duanlu); n4 = Convert.ToInt32(dudu.hscool); nodeType = pspDuanlu.Type; if (pspDuanlu.Type == "Use") { n11 = 0; n2 = pspDuanlu.Number; switch (dudu.DuanluType) { case "单相接地": n3 = 1; break; case "两相接地": n3 = 3; break; case "两相故障": n3 = 2; break; case "三相故障": n3 = 0; break; default: n3 = 1; break; } string dlr = null; dlr = "0" + " " + n3.ToString() + " " + pspDuanlu.Number + " " + "-1" + " " + "-1" + n4; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt"); } FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate); StreamWriter str11 = new StreamWriter(VK); str11.Write(dlr); str11.Close(); n4 = 0; } else if (pspDuanlu.Type == "Polyline") { //n11 = pspDuanlu.FirstNode; //n2 = pspDuanlu.LastNode; n11 = pspDuanlu.Number; n2 = n11; switch (dudu.DuanluType) { case "单相接地": n3 = 1; break; case "两相接地": n3 = 3; break; case "两相故障": n3 = 2; break; case "三相故障": n3 = 0; break; default: n3 = 1; break; } string dlr = null; dlr = "0" + " " + n3.ToString() + " " + pspDuanlu.Number + " " + pspDuanlu.FirstNode + " " + pspDuanlu.LastNode + " " + n4; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt"); } FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate); StreamWriter str11 = new StreamWriter(VK); str11.Write(dlr); str11.Close(); } else { return; } XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']"); foreach (XmlNode node in list) { SvgElement elementde = node as SvgElement; tlVectorControl1.SVGDocument.CurrentElement = elementde; tlVectorControl1.Delete(); } shortcir shortCutCal = new shortcir(); shortCutCal.Show_shortcir(0,0); string duanResult = null; duanResult += "短路电流简表" + "\r\n" + "\r\n"; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt")) { } else { return; } FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open); StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default); string strLineGU; string[] arrayGU; char[] charSplitGU = new char[] { ' ' }; strLineGU = readLineGU.ReadLine(); while (strLineGU != null) { arrayGU = strLineGU.Split(charSplitGU); int i = 0; string[] dev = new string[9]; dev.Initialize(); foreach (string str in arrayGU) { if (str != "") { dev[i++] = str; } } if (tuxing == 2) { PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; CR.Name = dev[1]; CR.Type = nodeType; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null) { if (CR.Type != "Polyline") { XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement; if (elementdl != null) { RectangleF bound = ((IGraph)elementdl).GetBounds(); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; n1.SetAttribute("x", Convert.ToString(bound.X)); n1.SetAttribute("y", Convert.ToString(bound.Y - 20)); n1.InnerText = (Convert.ToDouble(dev[3])).ToString("N4"); n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("flag", "1"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Refresh(); } } else { XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement; if (elementdl != null) { PointF[] t = ((Polyline)elementdl).Points; PointF[] t2 = ((Polyline)elementdl).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)elementdl).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 n2dl = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180))); PSPDEV psp = new PSPDEV(); psp.FirstNode = CR.FirstNode; psp.LastNode = CR.LastNode; psp.SvgUID = CR.SvgUID; PSPDEV tempss = new PSPDEV(); IList listParallel = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandFirstOrLastNode", psp); foreach (PSPDEV devP in listParallel) { if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350)) { if (((devP.X1) > (CR.X1))) { pStart = 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 (((devP.Y1) > (CR.Y1))) { pStart = 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 (((devP.Y1) > (CR.Y1))) { pStart = 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))); n1.SetAttribute("x", Convert.ToString(pStart.X)); n1.SetAttribute("y", Convert.ToString(pStart.Y)); //if (Convert.ToDouble(dev[4]) >= 0) //{ n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4"); //} //else //{ // n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4"); //} n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("flag", "1"); //if (Convert.ToDouble(dev[5]) == 1) // 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(dev[3]) < 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); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; RectangleF ttt = ((Polyline)elementdl).GetBounds(); tlVectorControl1.RotateSelection(angel, pStart); if (Math.Abs(angel) > 90) tlVectorControl1.RotateSelection(180, pStart); PointF newp = new PointF(center.X + 10, center.Y + 10); tlVectorControl1.Refresh(); } } } } duanResult += dev[0] + "," + dev[1] + "," + dev[3] + "\r\n"; strLineGU = readLineGU.ReadLine(); } string dianYaResult = null; dianYaResult += "母线电压结果" + "\r\n" + "\r\n"; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt")) { } else { return; } FileStream dianYa = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt", FileMode.Open); StreamReader readLineDY = new StreamReader(dianYa, System.Text.Encoding.Default); string strLineDY; string[] arrayDY; char[] charSplitDY = new char[] { ' ' }; strLineDY = readLineDY.ReadLine(); while (strLineDY != null) { arrayDY = strLineDY.Split(charSplitDY); int i = 0; string[] dev = new string[14]; dev.Initialize(); foreach (string str in arrayDY) { if (str != "") { dev[i++] = str; } } PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; CR.Name = dev[1]; CR.Type = nodeType; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (tuxing == 1) { XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement; if (elementdl != null) { RectangleF bound = ((IGraph)elementdl).GetBounds(); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; XmlElement n22 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; XmlElement n33 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; n1.SetAttribute("x", Convert.ToString(bound.X)); n1.SetAttribute("y", Convert.ToString(bound.Y - 60)); n1.InnerText = "A相:" + (Convert.ToDouble(dev[8])).ToString("N4") + "Kv/" + (Convert.ToDouble(dev[9])).ToString("N4") + "°"; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("flag", "1"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Refresh(); n22.SetAttribute("x", Convert.ToString(bound.X)); n22.SetAttribute("y", Convert.ToString(bound.Y - 40)); n22.InnerText = "B相:" + (Convert.ToDouble(dev[10])).ToString("N4") + "Kv/" + (Convert.ToDouble(dev[11])).ToString("N4") + "°"; n22.SetAttribute("layer", SvgDocument.currentLayer); n22.SetAttribute("flag", "1"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n22); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Refresh(); n33.SetAttribute("x", Convert.ToString(bound.X)); n33.SetAttribute("y", Convert.ToString(bound.Y - 20)); n33.InnerText = "C相:" + (Convert.ToDouble(dev[12])).ToString("N4") + "Kv/" + (Convert.ToDouble(dev[13])).ToString("N4") + "°"; n33.SetAttribute("layer", SvgDocument.currentLayer); n33.SetAttribute("flag", "1"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n33); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Refresh(); } } dianYaResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," + dev[9] + "," + dev[10] + "," + dev[11] + "," + dev[12] + "," + dev[13] + "\r\n"; strLineDY = readLineDY.ReadLine(); } string dianLiuResult = null; dianLiuResult += "支路电流结果" + "\r\n" + "\r\n"; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt")) { } else { return; } FileStream dianLiu = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt", FileMode.Open); StreamReader readLineDL = new StreamReader(dianLiu, System.Text.Encoding.Default); string strLineDL; string[] arrayDL; char[] charSplitDL = new char[] { ' ' }; strLineDL = readLineDL.ReadLine(); while (strLineDL != null) { arrayDL = strLineDL.Split(charSplitDL); int i = 0; string[] dev = new string[15]; dev.Initialize(); foreach (string str in arrayDL) { if (str != "") { dev[i++] = str; } } PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; CR.Name = dev[1]; CR.Type = nodeType; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (tuxing == 1) { XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement; if (elementdl != null) { PointF[] t = ((Polyline)elementdl).Points; PointF[] t2 = ((Polyline)elementdl).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)elementdl).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 n2dl = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180))); PSPDEV psp = new PSPDEV(); psp.FirstNode = CR.FirstNode; psp.LastNode = CR.LastNode; psp.SvgUID = CR.SvgUID; PSPDEV tempss = new PSPDEV(); IList listParallel = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandFirstOrLastNode", psp); foreach (PSPDEV devP in listParallel) { if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350)) { if (((devP.X1) > (CR.X1))) { pStart = 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 (((devP.Y1) > (CR.Y1))) { pStart = 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 (((devP.Y1) > (CR.Y1))) { pStart = 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))); n1.SetAttribute("x", Convert.ToString(pStart.X)); n1.SetAttribute("y", Convert.ToString(pStart.Y)); //if (Convert.ToDouble(dev[4]) >= 0) //{ n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4"); //} //else //{ // n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4"); //} n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("flag", "1"); //if (Convert.ToDouble(dev[3]) == 1) // 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(dev[3]) < 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); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; RectangleF ttt = ((Polyline)elementdl).GetBounds(); tlVectorControl1.RotateSelection(angel, pStart); if (Math.Abs(angel) > 90) tlVectorControl1.RotateSelection(180, pStart); PointF newp = new PointF(center.X + 10, center.Y + 10); tlVectorControl1.Refresh(); } } dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," + dev[9] + "," + dev[10] + "," + dev[11] + dev[12] + "," + dev[13] + "," + dev[14] + "\r\n"; strLineDL = readLineDL.ReadLine(); } if (baobiao == 1) { if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv"); } FileStream tempGU = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate); StreamWriter strGU = new StreamWriter(tempGU, Encoding.GetEncoding("GB2312")); strGU.Write(duanResult); strGU.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); } FileStream tempDY = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate); StreamWriter strDY = new StreamWriter(tempDY, Encoding.GetEncoding("GB2312")); strDY.Write(dianYaResult); strDY.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result2.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result2.csv"); } FileStream tempDL = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result2.csv"), FileMode.OpenOrCreate); StreamWriter strDL = new StreamWriter(tempDL, Encoding.GetEncoding("GB2312")); strDL.Write(dianLiuResult); strDL.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + "短路计算结果.xls")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + "短路计算结果.xls"); } Excel.Application ex; Excel.Worksheet xSheet; Excel.Application result1; Excel.Application result2; Excel.Worksheet tempSheet; Excel.Worksheet tempSheet1; Excel.Worksheet newWorksheet; Excel.Worksheet newWorkSheet1; object oMissing = System.Reflection.Missing.Value; ex = new Excel.Application(); ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv"); xSheet = (Excel.Worksheet)ex.Worksheets[1]; ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value); xSheet = (Excel.Worksheet)ex.Worksheets[2]; ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value); xSheet = (Excel.Worksheet)ex.Worksheets[1]; result1 = new Excel.Application(); result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); result2 = new Excel.Application(); result2.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result2.csv"); tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1); tempSheet1 = (Excel.Worksheet)result2.Worksheets.get_Item(1); newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2); newWorkSheet1 = (Excel.Worksheet)ex.Worksheets.get_Item(3); newWorksheet.Name = "母线电压"; newWorkSheet1.Name = "支路电流"; xSheet.Name = "短路电流"; ex.Visible = true; tempSheet.Cells.Select(); tempSheet.Cells.Copy(System.Reflection.Missing.Value); newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value); tempSheet1.Cells.Select(); tempSheet1.Cells.Copy(System.Reflection.Missing.Value); newWorkSheet1.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value); xSheet.Rows.AutoFit(); xSheet.Columns.AutoFit(); newWorksheet.Rows.AutoFit(); newWorksheet.Columns.AutoFit(); newWorkSheet1.Rows.AutoFit(); newWorkSheet1.Columns.AutoFit(); xSheet.UsedRange.Font.Name = "楷体_GB2312"; newWorksheet.UsedRange.Font.Name = "楷体_GB2312"; newWorkSheet1.UsedRange.Font.Name = "楷体_GB2312"; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 3]).MergeCells = true; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体"; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[3, 3]).Interior.ColorIndex = 45; xSheet.get_Range(xSheet.Cells[4, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; xSheet.get_Range(xSheet.Cells[4, 3], xSheet.Cells[xSheet.UsedRange.Rows.Count, 13]).NumberFormat = "0.0000_ "; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 14]).MergeCells = true; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体"; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[3, 14]).Interior.ColorIndex = 45; newWorksheet.get_Range(newWorksheet.Cells[4, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; newWorksheet.get_Range(newWorksheet.Cells[4, 3], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 14]).NumberFormat = "0.0000_ "; newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 15]).MergeCells = true; newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Size = 20; newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Name = "黑体"; newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; newWorkSheet1.get_Range(newWorkSheet1.Cells[3, 1], newWorkSheet1.Cells[3, 14]).Interior.ColorIndex = 45; newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 1], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 2], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 2]).Interior.ColorIndex = 6; newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 4], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 14]).NumberFormat = "0.0000_ "; newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + "短路计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null); System.Windows.Forms.Clipboard.Clear(); result1.Workbooks.Close(); result1.Quit(); result2.Workbooks.Close(); result2.Quit(); } } } 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.AddPolygon(TLMath.getPolygonPoints(poly1)); 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(); 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); if (graph1 is Use) { 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.CurrentLayer.ID; frmPrintF pri = new frmPrintF(); pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.CurrentLayer.ID); 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 (!Check()) //{ // return; //} XmlElement element = tlVectorControl1.SVGDocument.CurrentElement; if (element is Use) { if (element.GetAttribute("xlink:href").Contains("Substation") || element.GetAttribute("xlink:href").Contains("motherlinenode")) { string str_power = getPower(element.GetAttribute("xlink:href")); PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmSubstation dlg; if (pspDev != null) { dlg = new frmSubstation(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Use"; if (element.GetAttribute("xlink:href").Contains("Substation")) { pspDev.Lable = "变电站"; } else if (element.GetAttribute("xlink:href").Contains("motherlinenode")) { pspDev.Lable = "母线节点"; } else if (element.GetAttribute("xlink:href").Contains("Power")) { pspDev.Lable = "电厂"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmSubstation(pspDev); } dlg.Str_Power = str_power; dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "Use"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; (text as Text).SetAttribute("print", dlg.IsTJ ? "no" : "yes"); } pspDev.VoltR = Convert.ToDouble(dlg.VoltR); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); pspDev.Burthen = Convert.ToDecimal(dlg.Burthen); element.SetAttribute("print", dlg.IsTJ ? "no" : "yes"); pspDev.OutP = Convert.ToDouble(dlg.OutP); pspDev.OutQ = Convert.ToDouble(dlg.OutQ); ; //if (pspDev.InPutP==0) pspDev.InPutP = Convert.ToDouble(dlg.InPutP); pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); if (dlg.NodeType == "是") { pspDev.NodeType = "0"; } else { pspDev.NodeType = "1"; } Services.BaseService.Update<PSPDEV>(pspDev); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg.TYear); } } else if (element.GetAttribute("xlink:href").Contains("Power")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmSubstation dlg; if (pspDev != null) { dlg = new frmSubstation(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Use"; if (element.GetAttribute("xlink:href").Contains("Substation")) { pspDev.Lable = "变电站"; } else if (element.GetAttribute("xlink:href").Contains("motherlinenode")) { pspDev.Lable = "母线节点"; } else if (element.GetAttribute("xlink:href").Contains("Power")) { pspDev.Lable = "电厂"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmSubstation(pspDev); dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "Use"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.VoltR = Convert.ToDouble(dlg.VoltR); pspDev.Burthen = Convert.ToDecimal(dlg.Burthen); pspDev.OutP = Convert.ToDouble(dlg.OutP); pspDev.OutQ = Convert.ToDouble(dlg.OutQ); pspDev.InPutP = Convert.ToDouble(dlg.InPutP); pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); if (dlg.NodeType == "是") { pspDev.NodeType = "0"; } else { pspDev.NodeType = "2"; } Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmFadejie dlg; if (pspDev != null) { dlg = new frmFadejie(pspDev, pspDev.SvgUID); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "dynamotorline"; if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { pspDev.Lable = "发电厂支路"; } else if (element.GetAttribute("xlink:href").Contains("gndline")) { pspDev.Lable = "接地支路"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmFadejie(pspDev, pspDev.SvgUID); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "dynamotorline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; if (dlg.OutP != "") pspDev.OutP = Convert.ToDouble(dlg.OutP); if (dlg.OutQ != "") pspDev.OutQ = Convert.ToDouble(dlg.OutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); if (dlg.VoltV != "") pspDev.VoltV = Convert.ToDouble(dlg.VoltV); if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); if (dlg.NegativeTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("gndline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmFadejie dlg; if (pspDev != null) { dlg = new frmFadejie(pspDev, pspDev.SvgUID); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "gndline"; if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { pspDev.Lable = "发电厂支路"; } else if (element.GetAttribute("xlink:href").Contains("gndline")) { pspDev.Lable = "接地支路"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmFadejie(pspDev, pspDev.SvgUID); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "gndline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; if (dlg.OutP != "") pspDev.OutP = Convert.ToDouble(dlg.OutP); if (dlg.OutQ != "") pspDev.OutQ = Convert.ToDouble(dlg.OutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); if (dlg.VoltV != "") pspDev.VoltV = Convert.ToDouble(dlg.VoltV); if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); if (dlg.NegativeTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("loadline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLoad dlg; if (pspDev != null) { dlg = new frmLoad(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "loadline"; pspDev.Lable = "负荷支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmLoad(pspDev); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "loadline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.LoadSwitchState; if (dlg.InPutP != "") pspDev.InPutP = Convert.ToDouble(dlg.InPutP); if (dlg.InPutQ != "") pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("串联电容电抗器")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmCapacity dlg; if (pspDev != null) { dlg = new frmCapacity(pspDev, pspDev.SvgUID); dlg.SetEnable(true); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "串联电容电抗器"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; // pspDev.HuganLine2 = dlg.LastNodeName; if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("并联电容电抗器")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmCapacity dlg; if (pspDev != null) { dlg = new frmCapacity(pspDev, pspDev.SvgUID); dlg.SetEnable(false); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "并联电容电抗器"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; //pspDev.HuganLine2 = dlg.LastNodeName; if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("transformerthirdzu")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmThridTra dlg; if (pspDev != null) { dlg = new frmThridTra(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "transformerthirdzu"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.IName; pspDev.HuganLine2 = dlg.JName; pspDev.HuganLine3 = dlg.ISwitchState; pspDev.HuganLine4 = dlg.JSwitchState; pspDev.LineLevel = dlg.IType; pspDev.LineType = dlg.JType; pspDev.LineStatus = dlg.KType; pspDev.KName = dlg.KName; pspDev.KSwitchStatus = dlg.KSwitchState; if (dlg.IK != "") { pspDev.K = Convert.ToDouble(dlg.KK); } if (dlg.JK != "") { pspDev.G = Convert.ToDouble(dlg.JK); } if (dlg.KK != "") { pspDev.BigP = Convert.ToDouble(dlg.KK); } if (dlg.IR != "") { pspDev.HuganTQ1 = Convert.ToDouble(dlg.IR); } if (dlg.JR != "") { pspDev.HuganTQ2 = Convert.ToDouble(dlg.JR); } if (dlg.KR != "") { pspDev.HuganTQ3 = Convert.ToDouble(dlg.KR); } if (dlg.ITQ != "") { pspDev.HuganTQ4 = Convert.ToDouble(dlg.ITQ); } if (dlg.JTQ != "") { pspDev.HuganTQ5 = Convert.ToDouble(dlg.JTQ); } if (dlg.KTQ != "") { pspDev.SmallTQ = Convert.ToDouble(dlg.KTQ); } if (dlg.ZeroTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); if (dlg.NeutralNodeTQ != "") pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("transformertwozu")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmTwoTra dlg; if (pspDev != null) { dlg = new frmTwoTra(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "transformertwozu"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstName; pspDev.HuganLine2 = dlg.LastName; pspDev.HuganLine3 = dlg.FirstSwitchState; pspDev.HuganLine4 = dlg.LastSwitchState; pspDev.LineLevel = dlg.FirstType; pspDev.LineType = dlg.LastType; if (dlg.PositiveR != "") { pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR); } if (dlg.PositiveTQ != "") { pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); } if (dlg.ZeroR != "") { pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR); } if (dlg.ZeroTQ != "") { pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); } if (dlg.K != "") pspDev.K = Convert.ToDouble(dlg.K); if (dlg.NeutralNodeTQ != "") pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("1/2母联开关")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmMuLian dlg; if (pspDev != null) { dlg = new frmMuLian(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "1/2母联开关"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine2 = dlg.LastNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("2/3母联开关")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmMuLian2 dlg; if (pspDev != null) { dlg = new frmMuLian2(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "2/3母联开关"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.INodeName; pspDev.HuganLine2 = dlg.JNodeName; pspDev.HuganLine3 = dlg.ILineName; pspDev.HuganLine4 = dlg.JLineName; pspDev.KName = dlg.ILoadName; pspDev.KSwitchStatus = dlg.JLoadName; pspDev.LineLevel = dlg.SwitchStatus1; pspDev.LineType = dlg.SwitchStatus2; pspDev.LineStatus = dlg.SwitchStatus3; Services.BaseService.Update<PSPDEV>(pspDev); } } } else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType == true) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLinenew dlg2; if (pspDev != null) { dlg2 = new frmLinenew(pspDev); dlg2.derefucelineflag = Reducelineflag; } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Polyline"; pspDev.Lable = "支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg2 = new frmLinenew(pspDev); dlg2.derefucelineflag = Reducelineflag; } dlg2.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); dlg2.linevalue = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("linevalue"); //获得线路投资 if (dlg2.ShowDialog() == DialogResult.OK) { if (dlg2.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg2.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Polyline"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg2.Name; pspDev.LineLength = Convert.ToDouble(dlg2.LineLength); pspDev.LineR = Convert.ToDouble(dlg2.LineR); pspDev.LineTQ = Convert.ToDouble(dlg2.LineTQ); pspDev.LineGNDC = Convert.ToDouble(dlg2.LineGNDC); pspDev.LineLevel = dlg2.LineLevel; pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt); pspDev.LineType = dlg2.LineType; pspDev.LineStatus = dlg2.LineStatus; WireCategory wirewire = new WireCategory(); wirewire.WireType = dlg2.LineType; if (dlg2.linevalue != "") { pspDev.BigP = Convert.ToDouble(dlg2.linevalue); } if (dlg2.ReferenceVolt != "") { pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt); } WireCategory wirewire2 = new WireCategory(); wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); //if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength)*wirewire2.WireR ; //if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireTQ; //if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireGNDC; if (wirewire2 != null) pspDev.LineChange = (double)wirewire2.WireChange; string tempp = dlg2.LineLev; int tel = tempp.Length; //tempp = tempp.Substring(0, tel - 2); pspDev.VoltR = Convert.ToDouble(tempp); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg2.TYear); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("linevalue", dlg2.linevalue); //获得线路投资 //switch (dlg2.LineType) //{ // case "2*LGJ-400": // { // if (pspDev.LineR==0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.04; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.303; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.054; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.308; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.066; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.310; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.08; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.417; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} Services.BaseService.Update<PSPDEV>(pspDev); Topology2(); } } else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType != true) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLine dlg; if (pspDev != null) { dlg = new frmLine(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Polyline"; pspDev.Lable = "支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmLine(pspDev); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "Polyline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; pspDev.LineLength = Convert.ToDouble(dlg.LineLength); pspDev.LineLevel = dlg.LineLevel; pspDev.LineType = dlg.LineType; pspDev.LineStatus = dlg.LineStatus; pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR); pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR); pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); if (dlg.HuganFirst == "是") pspDev.HuganFirst = 1; else pspDev.HuganFirst = 0; pspDev.HuganLine1 = dlg.HuganLine1; pspDev.HuganLine2 = dlg.HuganLine2; pspDev.HuganLine3 = dlg.HuganLine3; pspDev.HuganLine4 = dlg.HuganLine4; pspDev.HuganTQ1 = Convert.ToDouble(dlg.HuganTQ1); pspDev.HuganTQ2 = Convert.ToDouble(dlg.HuganTQ2); pspDev.HuganTQ3 = Convert.ToDouble(dlg.HuganTQ3); pspDev.HuganTQ4 = Convert.ToDouble(dlg.HuganTQ4); pspDev.HuganTQ5 = Convert.ToDouble(dlg.HuganTQ5); string tempp = dlg.LineLev; int tel = tempp.Length; if (tel == 1) pspDev.VoltR = 0; else { //tempp = tempp.Substring(0, tel - 2); pspDev.VoltR = Convert.ToDouble(tempp); } //switch (dlg.LineType) //{ // case "2*LGJ-400": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} Services.BaseService.Update<PSPDEV>(pspDev); Topology2(); } } } tlVectorControl1.Operation = ToolOperation.Select; //contextMenuStrip1.Hide(); }
//网络N-1计算和输出 private void WebCalAndPrint() { FileStream dh; StreamReader readLine; // StreamReader readLine; ArrayList list = new ArrayList(); //用来记录线路不能解裂的位数 char[] charSplit; string strLine; string[] array1; string outputZL = null; //记录直流计算结果 线路功率和节点电压 //string outputBC = null; //记录补偿计算结果 节点电压 string[] array2; string strLine2; char[] charSplit2 = new char[] { ' ' }; List<lineclass> Overlinp = new List<lineclass>(); List<lineclass> OverVp = new List<lineclass>(); //Dictionary<int, List<lineclass>> OverPhege = new Dictionary<int, List<lineclass>>(); //为 线路功率的检验 键值为断开线路的编号,值为第几条线路出现了不合格 //Dictionary<int, List<lineclass>> OverVhege = new Dictionary<int, List<lineclass>>(); //为 节点电压的检验 键值为断开线路的编号,值为第几个节点出现了不合格 FileStream op; StreamWriter str1; FileStream dh2; StreamReader readLine2; Excel.Application ex; //Excel.Worksheet xSheet; Excel.Application result1; //Excel.Worksheet tempSheet; Excel.Worksheet newWorksheet; WebN1 webn1 = new WebN1(); webn1.ShowDialog(); if (webn1.DialogResult == DialogResult.OK) //进行全网计算 { if (!CheckN()) { return; } try { System.Windows.Forms.Clipboard.Clear(); //去掉剪切板中的数据 for (int i = 1; i <= brchcount + transcount; i++) { n1NL_DLL.ZYZ nl = new n1NL_DLL.ZYZ(); nl.jianyan(i); } //int* busnumber; //N1Test.NBcal kk = new N1Test.NBcal(); //busnumber = kk.Show_Reliability(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "可靠性计算结果.xls")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "可靠性计算结果.xls"); //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls"); } double yinzi = 0, capability = 0, volt = 0, current = 0, standvolt = 0, Rad_to_Deg = 57.29577951; PSPDEV benchmark = new PSPDEV(); benchmark.Type = "power"; benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark); if (list3 == null) { MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (PSPDEV dev in list3) { yinzi = Convert.ToDouble(dev.PowerFactor); capability = Convert.ToDouble(dev.StandardCurrent); volt = Convert.ToDouble(dev.StandardVolt); standvolt = volt; if (dev.PowerFactor == 0) { yinzi = 1; } if (dev.StandardCurrent == 0) { capability = 1; } if (dev.StandardVolt == 0) { volt = 1; standvolt = 1; } current = capability / (Math.Sqrt(3) * volt); } capability = 100; PSPDEV ct = new PSPDEV(); ct.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; ct.Type = "Use"; IList cont = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", ct); if (buscount < cont.Count) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\VandTheta.txt")) { } else { MessageBox.Show("数据不收敛,请调整参数后重新计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\lineP.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\" + "lineP.txt", FileMode.Open); dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\" + "VandTheta.txt", FileMode.Open); readLine2 = new StreamReader(dh2); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; //strLine = readLine.ReadLine(); outputZL = null; //outputBC=null; outputZL += ("全网可靠性结果报表" + "\r\n"); outputZL += ("开断支路" + "," + "剩余网络线路功率Pij和Pji的标幺值" + ",,"); for (int i = 0; i < brchcount - 1; i++) { outputZL += (",,"); } outputZL += ("是否越限" + "," + "\r\n"); outputZL += ","; int n = 0; //记录线路的行数 while ((strLine = readLine.ReadLine()) != null) { array1 = strLine.Split(charSplit); string[] devzl = new string[3 * brchcount + 1]; devzl.Initialize(); int i = 0; n++; foreach (string str in array1) { if (str != "") { devzl[i++] = str.ToString(); } } for (int j = 0; j < brchcount; j++) { outputZL += devzl[3 * j + 1] + "," + ","; } outputZL += ("," + "\r\n"); outputZL += devzl[0] + ","; bool lineflag = true; //只要有一个不合格则就为不合格 if (devzl[1] != "-1") { for (int j = 0; j < brchcount; j++) { double pij = Convert.ToDouble(devzl[j * 3 + 2].Substring(0, devzl[j * 3 + 2].IndexOf('j') - 1)) * capability; double qij = Convert.ToDouble(devzl[j * 3 + 2].Substring(devzl[j * 3 + 2].IndexOf('j') + 1)) * capability; double pji = Convert.ToDouble(devzl[j * 3 + 3].Substring(0, devzl[j * 3 + 3].IndexOf('j') - 1)) * capability; double qji = Convert.ToDouble(devzl[j * 3 + 3].Substring(devzl[j * 3 + 3].IndexOf('j') + 1)) * capability; double Sij = System.Math.Sqrt(pij * pij + qij * qij); double Sji = System.Math.Sqrt(pji * pji + qji * qji); double maxSij = (Sij > Sji) ? Sij : Sji; PSPDEV psp = new PSPDEV(); psp.Name = devzl[j * 3 + 1]; psp.Type = "Polyline"; psp.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", psp); PSPDEV pspline = (PSPDEV)listName[0]; double voltR = pspline.VoltR; WireCategory wirewire = new WireCategory(); wirewire.WireType = pspline.LineType; if (pspline.LineType == null || pspline.LineType == "") { MessageBox.Show(pspline.Name + "的线路类型没有输入,无法进行可靠性检验", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } WireCategory listware = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); double Ichange = (double)listware.WireChange; double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000; outputZL += "'" + devzl[j * 3 + 2] + "," + "'" + devzl[j * 3 + 3] + ","; if (maxSij >= linXij) { lineflag = false; lineclass _line = new lineclass(n, j); Overlinp.Add(_line); // OverPhege[n] = j; } } if (!lineflag) { outputZL += "不合格"; } else outputZL += "合格"; } else { outputZL += "该线路不可断。"; } //OverPhege[n] = Overlinp; //Overlinp.Clear(); outputZL += "\r\n"; while ((strLine = readLine.ReadLine()) != null) { array1 = strLine.Split(charSplit); string[] devzl1 = new string[3 * brchcount + 1]; devzl1.Initialize(); n++; i = 0; foreach (string str in array1) { if (str != "") { devzl1[i++] = str.ToString(); } } if (devzl1[1] != "-1") { outputZL += devzl1[0] + ","; for (int j = 0; j < brchcount; j++) { double pij = Convert.ToDouble(devzl1[j * 3 + 2].Substring(0, devzl1[j * 3 + 2].IndexOf('j') - 1)) * capability; double qij = Convert.ToDouble(devzl1[j * 3 + 2].Substring(devzl1[j * 3 + 2].IndexOf('j') + 1)) * capability; double pji = Convert.ToDouble(devzl1[j * 3 + 3].Substring(0, devzl1[j * 3 + 3].IndexOf('j') - 1)) * capability; double qji = Convert.ToDouble(devzl1[j * 3 + 3].Substring(devzl1[j * 3 + 3].IndexOf('j') + 1)) * capability; double Sij = System.Math.Sqrt(pij * pij + qij * qij); double Sji = System.Math.Sqrt(pji * pji + qji * qji); double maxSij = (Sij > Sji) ? Sij : Sji; PSPDEV psp = new PSPDEV(); psp.Name = devzl1[j * 3 + 1]; psp.Type = "Polyline"; psp.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", psp); PSPDEV pspline = (PSPDEV)listName[0]; double voltR = pspline.VoltR; WireCategory wirewire = new WireCategory(); wirewire.WireType = pspline.LineType; if (pspline.LineType == null || pspline.LineType == "") { MessageBox.Show(pspline.Name + "的线路类型没有输入,无法进行可靠性检验", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } WireCategory listware = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); double Ichange = (double)listware.WireChange; double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000; // outputZL += "'" + devzl[j * 3 + 2] + "," + "'" + devzl[j * 3 + 3] + ","; if (maxSij >= linXij) { lineflag = false; lineclass subline = new lineclass(n, j); Overlinp.Add(subline); //OverPhege[n] = j; } outputZL += "'" + devzl1[j * 3 + 2] + "," + "'" + devzl1[j * 3 + 3] + ","; //在此还可以判断线路是否超载 } if (!lineflag) { outputZL += "不合格"; } else outputZL += "合格"; outputZL += "\r\n"; //OverPhege[n] = Overlinp; //Overlinp.Clear(); } else { list.Add(n); outputZL += devzl1[0] + "," + "为不可断裂的线路"; outputZL += "\r\n"; } } } outputZL += "注视:" + "," + "红色为线路超载"; outputZL += "\r\n"; readLine.Close(); if (File.Exists("result1.csv")) { File.Delete("result1.csv"); } op = new FileStream("result1.csv", FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(outputZL); str1.Close(); outputZL = null; //将各个节点的电压写入其中 // strLine2 = readLine2.ReadLine(); n = 0; bool busvflag1 = true; outputZL += ("网络节点电压和相角" + "\r\n"); outputZL += ("开断支路名称" + ","); for (int i = 0; i < buscount; i++) { outputZL += (",,"); } outputZL += ("是否越限" + "," + "\r\n"); outputZL += ","; while ((strLine2 = readLine2.ReadLine()) != null) { array2 = strLine2.Split(charSplit); string[] devzl = new string[buscount * 3 + 1]; devzl.Initialize(); int i = 0; n++; foreach (string str in array2) { if (str != "") { devzl[i++] = str.ToString(); } } if (devzl[1] != "-1") { for (int j = 0; j < buscount; j++) { outputZL += devzl[3 * j + 1] + "," + ","; } outputZL += ("," + "\r\n"); outputZL += devzl[0] + ","; for (int j = 0; j < buscount; j++) { PSPDEV pspDev = new PSPDEV(); pspDev.Name = devzl[3 * j + 1]; pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Type = "Use"; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", pspDev); if (pspDev.ReferenceVolt != null && pspDev.ReferenceVolt != 0) { volt = pspDev.ReferenceVolt; } else volt = standvolt; outputZL += "'" + (Convert.ToDouble(devzl[j * 3 + 2]) * volt).ToString() + "," + "'" + devzl[j * 3 + 3] + ","; if (Convert.ToDouble(devzl[j * 3 + 2]) >= 1.1 || Convert.ToDouble(devzl[j * 3 + 2]) <= 0.9) { busvflag1 = false; lineclass _vtheta = new lineclass(n, j); OverVp.Add(_vtheta); //OverVhege[n] = j; } } if (busvflag1) { outputZL += "合格"; } else { outputZL += "不合格"; } } else { outputZL += "不可断裂"; } //OverVhege[n] = OverVp; //OverVp.Clear(); outputZL += "\r\n"; while ((strLine2 = readLine2.ReadLine()) != null) { busvflag1 = true; array2 = strLine2.Split(charSplit); string[] devzl1 = new string[buscount * 3 + 1]; devzl1.Initialize(); n++; i = 0; foreach (string str in array2) { if (str != "") { devzl1[i++] = str.ToString(); } } if (devzl1[1] != "-1") { outputZL += devzl1[0] + ","; for (int j = 0; j < buscount; j++) { PSPDEV pspDev = new PSPDEV(); pspDev.Name = devzl1[3 * j + 1]; pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Type = "Use"; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", pspDev); if (pspDev.ReferenceVolt != null && pspDev.ReferenceVolt != 0) { volt = pspDev.ReferenceVolt; } else volt = standvolt; outputZL += "'" + (Convert.ToDouble(devzl1[j * 3 + 2]) * volt).ToString() + "," + "'" + devzl1[j * 3 + 3] + ","; //在此还可以判断线路是否超载,如果超载加入一个标记,在excel里使其变为红色 if (Convert.ToDouble(devzl1[j * 3 + 2]) >= 1.1 || Convert.ToDouble(devzl1[j * 3 + 2]) <= 0.9) { lineclass vtheta = new lineclass(n, j); busvflag1 = false; OverVp.Add(vtheta); //OverVhege[n] = j; } } if (busvflag1) { outputZL += "合格"; } else outputZL += "不合格"; outputZL += "\r\n"; //OverPhege[n] = OverVp; //OverVp.Clear(); } else { // list.Add(n); outputZL += devzl1[0] + "," + "为不可断裂的线路" + ",,,,,,"; outputZL += "\r\n"; } } } outputZL += "注视:" + "," + "红色为线路超载" + "\r\n"; outputZL += "," + "节点电压合格范围为电压基准值的上限下限分别为1.1和0.9" + "\r\n"; readLine2.Close(); //op = new FileStream(System.Windows.Forms.Application.StartupPath + "\\" + "reli.txt", FileMode.OpenOrCreate); //str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); //str1.Write(outputZL); //str1.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + "result2.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + "result2.csv"); } op = new FileStream(System.Windows.Forms.Application.StartupPath + "\\" + "result2.csv", FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(outputZL); str1.Close(); result1 = new Excel.Application(); result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\" + "result1.csv"); newWorksheet = (Excel.Worksheet)result1.Worksheets[1]; result1.Worksheets.Add(System.Reflection.Missing.Value, newWorksheet, 1, System.Reflection.Missing.Value); Excel.Application result2 = new Excel.Application(); result2.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result2.csv"); Excel.Worksheet tempSheet = (Excel.Worksheet)result2.Worksheets.get_Item(1); Excel.Worksheet newWorksheet1 = (Excel.Worksheet)result1.Worksheets.get_Item(2); newWorksheet.Name = "一般线路可靠性"; newWorksheet1.Name = "节点电压可靠性"; result1.Visible = true; tempSheet.Cells.Select(); tempSheet.Cells.Copy(System.Reflection.Missing.Value); newWorksheet1.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value); newWorksheet.Rows.AutoFit(); newWorksheet.Columns.AutoFit(); newWorksheet1.Rows.AutoFit(); newWorksheet1.Columns.AutoFit(); newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 2 * brchcount + 2]).MergeCells = true; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体"; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; newWorksheet.get_Range(newWorksheet.Cells[2, 1], newWorksheet.Cells[3, 1]).MergeCells = true; newWorksheet.get_Range(newWorksheet.Cells[2, 2], newWorksheet.Cells[2, 2 * brchcount + 1]).MergeCells = true; newWorksheet.get_Range(newWorksheet.Cells[2, 2], newWorksheet.Cells[2, 2]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; newWorksheet.get_Range(newWorksheet.Cells[2, 2 * brchcount + 2], newWorksheet.Cells[3, 2 * brchcount + 2]).MergeCells = true; for (int i = 0; i < brchcount; i++) { newWorksheet.get_Range(newWorksheet.Cells[3, 2 * i + 2], newWorksheet.Cells[3, 2 * i + 3]).MergeCells = true; newWorksheet.get_Range(newWorksheet.Cells[3, 2 * i + 2], newWorksheet.Cells[3, 2 * i + 3]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; } // newWorksheet.get_Range(newWorksheet.Cells[4, 2], newWorksheet.Cells[4, brchcount + 1]).Interior.ColorIndex = 45; newWorksheet.get_Range(newWorksheet.Cells[4, 1], newWorksheet.Cells[3 + brchcount + transcount, 1]).Interior.ColorIndex = 6; //newWorksheet.get_Range(newWorksheet.Cells[5, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, brchcount + 1]).NumberFormat = "0.0000_ "; newWorksheet.get_Range(newWorksheet.Cells[4, 2], newWorksheet.Cells[3 + brchcount + transcount, 2 * brchcount + 1]).NumberFormat = "@"; newWorksheet.get_Range(newWorksheet.Cells[2, 1], newWorksheet.Cells[3 + brchcount + transcount, 2 * brchcount + 2]).Font.Name = "楷体_GB2312"; //在此处将其不合格的数据显示出来 //foreach (KeyValuePair<int, List<lineclass>> kvp in OverPhege) //{ for (int i = 0; i < Overlinp.Count; i++) { newWorksheet.get_Range(newWorksheet.Cells[3 + Overlinp[i].row, 2 * Overlinp[i].linenum + 2], newWorksheet.Cells[3 + Overlinp[i].row, 2 * Overlinp[i].linenum + 3]).Interior.ColorIndex = 3; } //} //补偿法中的数据处理过程 newWorksheet1.get_Range(newWorksheet1.Cells[1, 1], newWorksheet1.Cells[1, 2 * buscount + 2]).MergeCells = true; newWorksheet1.get_Range(newWorksheet1.Cells[1, 1], newWorksheet1.Cells[1, 1]).Font.Size = 20; newWorksheet1.get_Range(newWorksheet1.Cells[1, 1], newWorksheet1.Cells[1, 1]).Font.Name = "黑体"; newWorksheet1.get_Range(newWorksheet1.Cells[1, 1], newWorksheet1.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; newWorksheet1.get_Range(newWorksheet1.Cells[2, 1], newWorksheet1.Cells[3, 1]).MergeCells = true; //补偿法中前面开断合并 newWorksheet1.get_Range(newWorksheet1.Cells[2, 2], newWorksheet1.Cells[2, 2 * buscount + 1]).MergeCells = true; newWorksheet1.get_Range(newWorksheet1.Cells[2, 2 * buscount + 2], newWorksheet1.Cells[3, 2 * buscount + 2]).MergeCells = true; //合格合并 newWorksheet1.get_Range(newWorksheet1.Cells[4, 1], newWorksheet1.Cells[4 + brchcount + transcount - 1, 1]).Interior.ColorIndex = 6; for (int i = 0; i < buscount; i++) { newWorksheet1.get_Range(newWorksheet1.Cells[3, 2 * i + 2], newWorksheet1.Cells[3, 2 * i + 3]).MergeCells = true; newWorksheet1.get_Range(newWorksheet1.Cells[3, 2 * i + 2], newWorksheet1.Cells[3, 2 * i + 3]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; } //newWorksheet1.get_Range(newWorksheet1.Cells[7 + brchcount, 2], newWorksheet1.Cells[7 + brchcount, brchcount + 1]).Interior.ColorIndex = 45; //newWorksheet1.get_Range(newWorksheet1.Cells[8 + brchcount, 1], newWorksheet1.Cells[8 + 2 * brchcount, 1]).Interior.ColorIndex = 6; //newWorksheet1.get_Range(newWorksheet1.Cells[5, 2], newWorksheet1.Cells[newWorksheet1.UsedRange.Rows.Count, brchcount + 1]).NumberFormat = "0.0000_ "; newWorksheet1.get_Range(newWorksheet1.Cells[4, 2], newWorksheet1.Cells[4 + brchcount + transcount, 2 * buscount + 1]).NumberFormat = "@"; newWorksheet1.get_Range(newWorksheet1.Cells[1, 1], newWorksheet1.Cells[4 + brchcount + transcount + 1, 2 * buscount + 2]).Font.Name = "楷体_GB2312"; //foreach (KeyValuePair<int, int> kvp in OverVhege) //{ for (int i = 0; i < OverVp.Count; i++) { newWorksheet1.get_Range(newWorksheet1.Cells[3 + OverVp[i].row, 2 * OverVp[i].linenum + 2], newWorksheet1.Cells[3 + OverVp[i].row, 2 * OverVp[i].linenum + 3]).Interior.ColorIndex = 3; } //} //补偿法中的数据处理过程 newWorksheet1.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "可靠性计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null); result1.Workbooks.Close(); result1.Quit(); System.Windows.Forms.Clipboard.Clear(); //去掉剪切板中的数据 ex = new Excel.Application(); ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "可靠性计算结果.xls"); ex.Visible = true; } catch (System.Exception e1) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (webn1.DialogResult == DialogResult.Ignore) { PSPDEV pspDEV = new PSPDEV(); pspDEV.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; PartRelform selregion = new PartRelform(pspDEV); selregion.ShowDialog(); if (selregion.DialogResult == DialogResult.OK) { MessageBox.Show("请选择电网的区域的线路,然后点击鼠标右键进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Operateflag = true; tlVectorControl1.CurrentOperation = ToolOperation.Select; //MessageBox.Show("kankankanakna"); tlVectorControl1.CurrentOperation = ToolOperation.AreaSelect; } if (selregion.DialogResult == DialogResult.Ignore) { DelLinenum = selregion.lineVnumlist; //DelTransnum = null; QyRelanalyst(); } //IList list1 = Services.BaseService.GetList("SelectPSPDEVBySvgUID", psp); //将进行潮流计算的文档传到选择网络中。 else if (selregion.DialogResult == DialogResult.Yes) { DelLinenum = selregion.lineDnumlist; DelTransnum = selregion.lineVnumlist; //DelTransnum = null; QyRelanalyst(); } } //Operateflag = false; }
private void simpleButton1_Click(object sender, EventArgs e) { wireType wiretype = new wireType(wirel); if (wiretype.ShowDialog()==DialogResult.OK) { WireCategory wirewire = new WireCategory(); wirewire.WireType = wiretype.WireType; wirewire.WireR = Convert.ToDouble(wiretype.WireR); wirewire.WireTQ = Convert.ToDouble(wiretype.WireTQ); wirewire.WireGNDC = Convert.ToDouble(wiretype.WireGNDC); wirewire.WireChange = Convert.ToInt32(wiretype.WireChange); //wirewire.WireLevel = wirel; wirewire.WireLevel = wiretype.WireLevel; wirewire.SUID = Guid.NewGuid().ToString(); Services.BaseService.Create<WireCategory>(wirewire); } InitData(vri); }
protected void Init() { object o = new object(); for (int i = -30; i <= 30; i++) { o = System.DateTime.Now.Year + i; comboBoxEdit1.Properties.Items.Add(o); } string con = " where Type='05'AND ProjectID ='" + this.ProjectSUID + "' order by name"; IList list = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); foreach (PSPDEV dev in list) { if (comboBoxEdit4.Properties.Items.IndexOf(dev.Name) == -1) { comboBoxEdit4.Properties.Items.Add(dev.Name); //comboBoxEdit7.Properties.Items.Add(dev.Name); } } WireCategory wirewire = new WireCategory(); wirewire.Type = "65"; IList list1 = null; if (DeviceMx.RateVolt != 0) { wirewire.WireLevel = DeviceMx.RateVolt.ToString(); list1 = UCDeviceBase.DataService.GetList("SelectWireCategoryListBYWireLevel", wirewire); } else list1 = UCDeviceBase.DataService.GetList("SelectWireCategoryList", wirewire); foreach (WireCategory sub in list1) { if (comboBoxEdit2.Properties.Items.IndexOf(sub.WireType) == -1) { comboBoxEdit2.Properties.Items.Add(sub.WireType); } } }
protected void Init() { object o = new object(); for (int i = -10; i <= 30; i++) { o = System.DateTime.Now.Year + i; comboBoxEdit1.Properties.Items.Add(o); comboBoxEdit10.Properties.Items.Add(o); comboBoxEdit11.Properties.Items.Add(o); } comboBoxEdit10.Text = DateTime.Now.Year.ToString(); comboBoxEdit1.Text = DateTime.Now.Year.ToString(); WireCategory wirewire = new WireCategory(); wirewire.Type = "40"; IList list1 = null; if (dev.RateVolt != 0) { wirewire.WireLevel = DeviceMx.RateVolt.ToString(); list1 = UCDeviceBase.DataService.GetList("SelectWireCategoryListBYWireLevel", wirewire); } else list1 = UCDeviceBase.DataService.GetList("SelectWireCategoryList", wirewire); foreach (WireCategory sub in list1) { if (comboBoxEdit2.Properties.Items.IndexOf(sub.WireType)==-1) { comboBoxEdit2.Properties.Items.Add(sub.WireType); } } string ss = " ProjectID='" +Itop.Client.MIS.ProgUID+ "' "; IList listq = UCDeviceBase.DataService.GetList("SelectPS_Table_AreaWHByConn", ss); comboBoxEdit9.Properties.DataSource = listq; ss = " ProjectID='" + Itop.Client.MIS.ProgUID + "' "; listq = UCDeviceBase.DataService.GetList("SelectPS_Table_Area_TYPEByConn", ss); foreach (PS_Table_Area_TYPE at in listq) { comboBoxEdit8.Properties.Items.Add(at.Title); } // comboBoxEdit9.Properties.DataSource = listq; string con = " where Type='01'and ProjectID='" + this.ProjectSUID + "' order by name"; IList list = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); foreach (PSPDEV dev1 in list) { if (comboBoxEdit3.Properties.Items.IndexOf(dev.Name)==-1) { comboBoxEdit3.Properties.Items.Add(dev1.Name); comboBoxEdit4.Properties.Items.Add(dev1.Name); } } con = " where Type='07'and ProjectID='" + this.ProjectSUID + "' order by name"; list = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); foreach (PSPDEV dev1 in list) { if (comboBoxEdit5.Properties.Items.IndexOf(dev1.Name) == -1) { comboBoxEdit5.Properties.Items.Add(dev1.Name); comboBoxEdit6.Properties.Items.Add(dev1.Name); } } if (DeviceHelper.xml1 == null) { textEdit1.Properties.Buttons[0].Visible = false; } }
private void simpleButton1_MouseDown(object sender, MouseEventArgs e) { if (textBox1.Text==""||textBox1.Text==null) { MessageBox.Show("名称不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { WireCategory wirewire = new WireCategory(); wirewire.WireLevel = WireLevel; IList list = Services.BaseService.GetList("SelectWireCategoryListBYWireLevel", wirewire); foreach (WireCategory wire in list) { if (wire.WireType==textBox1.Text) { MessageBox.Show("型号不能重复。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } this.DialogResult = DialogResult.OK; } }
void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { DataTable dt = dataGridView1.DataSource as DataTable; DataRow dr = dt.Rows[e.RowIndex]; if (dr != null) { if ((e.ColumnIndex == 23) || (e.ColumnIndex == 21)||(e.ColumnIndex==22)) { string temp=dr[26].ToString(); if (temp!="") dr[16] = Convert.ToDouble(temp.Substring(0, temp.Length - 2)); WireCategory wirewire = new WireCategory(); wirewire.WireType = dr[27].ToString(); wirewire.WireLevel = dr[16].ToString()+"KV"; WireCategory wirewire2 = new WireCategory(); //wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKeyANDWireLevel", wirewire); if (wirewire2!=null) { if (dr[25].ToString()=="") dr[25] = 0; dr[18] = Convert.ToDouble(dr[25]) * wirewire2.WireR; dr[19] = Convert.ToDouble(dr[25]) * wirewire2.WireTQ; dr[20] = Convert.ToDouble(dr[25]) * wirewire2.WireGNDC; dr[21] = wirewire2.WireChange; } if (wirewire2 == null) { dr[18] = 0; dr[19] = 0; dr[20] = 0; dr[21] = 0; } //leel.LineGNDC = Convert.ToDouble(dr[25]) * wirewire2.WireGNDC; //dr[18] = 100; } PSPDEV obj = Itop.Common.DataConverter.RowToObject<PSPDEV>(dr); Services.BaseService.Update<PSPDEV>(obj); } //InitData(dr[7].ToString()); dataGridView1.Update(); Refresh(); }
public void InitCom() { comboBoxEdit9.Properties.Items.Add("新建"); comboBoxEdit9.Properties.Items.Add("扩建"); comboBoxEdit9.Properties.Items.Add("改造"); comboBoxEdit9.SelectedIndex = 0; for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++) { comboBoxEdit1.Properties.Items.Add(i.ToString()); comboBoxEdit2.Properties.Items.Add(i.ToString()); } comboBoxEdit1.Text = DateTime.Now.Year.ToString(); comboBoxEdit2.Text = DateTime.Now.AddYears(1).Year.ToString() ; IList<string> strList = oper.GetLineS1("S5='1'"); strList = oper.GetLineS1("S5='2'"); foreach (string str in strList) comboBoxEdit6.Properties.Items.Add(str); comboBoxEdit6.SelectedIndex = 0; strList = oper.GetLineName("S5='2' and S1='" + comboBoxEdit6.Text + "' and name like'%" + comboBoxEdit9.Text + "%'"); if (strList.Count != 0) { comboBoxEdit4.Text = strList[0].ToString(); } IList<string> areatyplist=null; if (Common.Services.BaseService.GetList<string>("SelectBuildProDifAreaType", "")!=null) { areatyplist=Common.Services.BaseService.GetList<string>("SelectBuildProDifAreaType", ""); for (int j = 0; j < areatyplist.Count; j++) { comboBoxEdit11.Properties.Items.Add(areatyplist[j]); } } //导线型号 WireCategory wc = new WireCategory(); wc.Type = "40"; IList<WireCategory> list = Common.Services.BaseService.GetList<WireCategory>("SelectWireCategoryList", wc); for (int k = 0; k < list.Count; k++) { comboBoxEdit14.Properties.Items.Add(list[k].WireType); } }
private void comboBox22_SelectedIndexChanged(object sender, EventArgs e) { leel.LineLength = Convert.ToDouble(textBox11.Text); leel.LineType = comboBox22.Text; leel.Name = mc.Text; leel.LineStatus = comboBox44.Text; leel.LineLevel = "����·"; WireCategory wirewire = new WireCategory(); wirewire.WireType = comboBox22.Text; WireCategory wirewire2 = new WireCategory(); wirewire.WireLevel = comboBoxEdit5.Text; wirewire2.WireType = comboBox22.Text; wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKeyANDWireLevel", wirewire); if (wirewire2 != null) { leel.LineR = Convert.ToDouble(leel.LineLength) * wirewire2.WireR; leel.LineTQ = Convert.ToDouble(leel.LineLength) * wirewire2.WireTQ; leel.LineGNDC = Convert.ToDouble(leel.LineLength) * wirewire2.WireGNDC; leel.PositiveTQ = Convert.ToDouble(leel.LineLength) * wirewire2.WireTQ; leel.ZeroTQ = leel.PositiveTQ * 3; } string tempp = comboBoxEdit5.Text; int tel = tempp.Length; //tempp = tempp.Substring(0, tel - 2); //pspDev.VoltR = Convert.ToDouble(tempp); leel.VoltR = Convert.ToDouble(tempp); //textBox2.Text= InitData(leel); }
void tlVectorControl1_RightClick(object sender, SvgElementSelectedEventArgs e) { if (Operateflag && tlVectorControl1.CurrentOperation == ToolOperation.AreaSelect) { DelLinenum.Clear(); DelTransnum.Clear(); contextMenuStrip1.Visible = false; SvgElementCollection svgelcollect = tlVectorControl1.SVGDocument.SelectCollection; if (svgelcollect.Count == 0) { MessageBox.Show("请选择区域!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } PSPDEV psp = new PSPDEV(); psp.Type = "Polyline"; psp.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; int n = 0; for (int j = 0; j < svgelcollect.Count; j++) //记录要进行断开的线路 { if (svgelcollect[j].GetType().FullName == "ItopVector.Core.Figure.Polyline") { XmlElement e1 = (XmlElement)svgelcollect[j]; string str_id = e1.GetAttribute("id"); psp.EleID = str_id; PSPDEV dlg11 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", psp); if (dlg11 != null) { if (dlg11.LineStatus == "运行") { DelLinenum.Add(dlg11.Number); } n++; } } if (svgelcollect[j].GetType().FullName == "ItopVector.Core.Figure.TransformLine") { XmlElement e1 = (XmlElement)svgelcollect[j]; string str_id = e1.GetAttribute("id"); psp.EleID = str_id; PSPDEV dlg11 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", psp); if (dlg11 != null) { DelTransnum.Add(dlg11.Number); n++; } } } if (n == 0) { MessageBox.Show("你所选择的区域没有你要断开的线路", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.CurrentOperation = ToolOperation.Select; return; } else { DelLinenum.Sort(); DelTransnum.Sort(); //进行区域N-1检验 QyRelanalyst(); tlVectorControl1.CurrentOperation = ToolOperation.Select; return; } } if ((tlVectorControl1.SVGDocument.CurrentElement is Use || tlVectorControl1.SVGDocument.CurrentElement is Polyline) && tlVectorControl1.Operation != ToolOperation.PolyLine) { contextMenuStrip1.Show(); //if (fileType == true) //{ // moveMenuItem.Enabled = false; //} //else //{ // moveMenuItem.Enabled = true; //} if (fileType == true) { printToolStripMenuItem.Visible = false; moveMenuItem.Visible = false; } else { printToolStripMenuItem.Visible = false; moveMenuItem.Visible = true; } //if (tlVectorControl1.SVGDocument.CurrentElement } else { //contextMenuStrip1.Hide(); if ((tlVectorControl1.SVGDocument.CurrentElement is RectangleElement)) { contextMenuStrip1.Show(); printToolStripMenuItem.Visible = true; moveMenuItem.Visible = false; } } if (tlVectorControl1.Operation == ToolOperation.PolyLine && tlVectorControl1.SVGDocument.CurrentElement is Polyline && fileType == true) { tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.ChangeLevel(LevelType.Bottom); PointF[] t = (tlVectorControl1.SVGDocument.CurrentElement as Polyline).Pt; PSPDEV pspDev = new PSPDEV(); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.Type = "Polyline"; pspDev.FirstNode = -1; pspDev.LastNode = -1; frmLinenew dlg = new frmLinenew(pspDev); dlg.derefucelineflag = Reducelineflag; if (dlg.ShowDialog(this) == DialogResult.OK) { XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text"); PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Polyline"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.Delete(); return; } //if (element.Count > 0) //{ // foreach (XmlNode node in element) // { // if (node.InnerText == dlg.TextInput) // { // MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // tlVectorControl1.Delete(); // return; // } // } //} pspDev.Name = dlg.Name; pspDev.Number = -1; pspDev.Type = "Polyline"; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID; pspDev.SUID = Guid.NewGuid().ToString(); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.X1 = t[0].X; pspDev.Y1 = t[0].Y; pspDev.X2 = t[1].X; pspDev.Y2 = t[1].Y; pspDev.Lable = "支路"; if (dlg.LineLength != "") pspDev.LineLength = Convert.ToDouble(dlg.LineLength); string tempp = dlg.LineLev; int tel = tempp.Length; //tempp = tempp.Substring(0, tel - 2); pspDev.VoltR = Convert.ToDouble(tempp); if (dlg.LineR != "") pspDev.LineR = Convert.ToDouble(dlg.LineR); if (dlg.LineTQ != "") pspDev.LineTQ = Convert.ToDouble(dlg.LineTQ); if (dlg.LineGNDC != "") pspDev.LineGNDC = Convert.ToDouble(dlg.LineGNDC); if (dlg.LineLevel != "") pspDev.LineLevel = dlg.LineLevel; if (dlg.LineType != "") pspDev.LineType = dlg.LineType; if (dlg.LineStatus != "") pspDev.LineStatus = dlg.LineStatus; if (dlg.linevalue != "") { pspDev.BigP = Convert.ToDouble(dlg.linevalue); } if (dlg.ReferenceVolt != "") { pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); } if (dlg.LineType != "") { WireCategory wirewire = new WireCategory(); wirewire.WireType = dlg.LineType; WireCategory wirewire2 = new WireCategory(); wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); if (wirewire2 != null) pspDev.LineChange = (double)wirewire2.WireChange; //switch (dlg.LineType) //{ // case "2*LGJ-400": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} } Services.BaseService.Create<PSPDEV>(pspDev); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg.TYear); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("linevalue", dlg.linevalue); Topology2(); } else { tlVectorControl1.Delete(); } return; } if (tlVectorControl1.Operation == ToolOperation.PolyLine && tlVectorControl1.SVGDocument.CurrentElement is Polyline && fileType != true) { tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.ChangeLevel(LevelType.Bottom); PointF[] t = (tlVectorControl1.SVGDocument.CurrentElement as Polyline).Pt; PSPDEV pspDev = new PSPDEV(); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.Type = "Polyline"; pspDev.FirstNode = -1; pspDev.LastNode = -1; frmLine dlg = new frmLine(pspDev); if (dlg.ShowDialog(this) == DialogResult.OK) { XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text"); PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Polyline"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.Delete(); return; } //if (element.Count > 0) //{ // foreach (XmlNode node in element) // { // if (node.InnerText == dlg.TextInput) // { // MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // tlVectorControl1.Delete(); // return; // } // } //} pspDev.Name = dlg.Name; pspDev.Number = -1; pspDev.Type = "Polyline"; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID; pspDev.SUID = Guid.NewGuid().ToString(); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.X1 = t[0].X; pspDev.Y1 = t[0].Y; pspDev.X2 = t[1].X; pspDev.Y2 = t[1].Y; pspDev.Lable = "支路"; if (dlg.LineLength != "") pspDev.LineLength = Convert.ToDouble(dlg.LineLength); if (dlg.LineLevel != "") pspDev.LineLevel = dlg.LineLevel; if (dlg.LineType != "") pspDev.LineType = dlg.LineType; if (dlg.LineStatus != "") pspDev.LineStatus = dlg.LineStatus; if (dlg.PositiveR != "") pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR); if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); if (dlg.PositiveES != "") { pspDev.SmallTQ = Convert.ToDouble(dlg.PositiveES); } if (dlg.ZeroR != "") pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR); if (dlg.ZeroTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); if (dlg.ZeroES != "") { pspDev.BigTQ = Convert.ToDouble(dlg.ZeroES); } if (dlg.HuganFirst == "是") pspDev.HuganFirst = 1; else pspDev.HuganFirst = 0; if (dlg.HuganLine1 != "") pspDev.HuganLine1 = dlg.HuganLine1; if (dlg.HuganLine2 != "") pspDev.HuganLine2 = dlg.HuganLine2; if (dlg.HuganLine3 != "") pspDev.HuganLine3 = dlg.HuganLine3; if (dlg.HuganLine4 != "") pspDev.HuganLine4 = dlg.HuganLine4; if (dlg.HuganTQ1 != "") pspDev.HuganTQ1 = Convert.ToDouble(dlg.HuganTQ1); if (dlg.HuganTQ2 != "") pspDev.HuganTQ2 = Convert.ToDouble(dlg.HuganTQ2); if (dlg.HuganTQ3 != "") pspDev.HuganTQ3 = Convert.ToDouble(dlg.HuganTQ3); if (dlg.HuganTQ4 != "") pspDev.HuganTQ4 = Convert.ToDouble(dlg.HuganTQ4); if (dlg.HuganTQ5 != "") pspDev.HuganTQ5 = Convert.ToDouble(dlg.HuganTQ5); pspDev.KName = dlg.ISwitchStatus; pspDev.KSwitchStatus = dlg.JSwitchStatus; if (dlg.LineType != "") { WireCategory wirewire = new WireCategory(); wirewire.WireType = dlg.LineType; WireCategory wirewire2 = new WireCategory(); wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); if (wirewire2 != null) pspDev.LineChange = (double)wirewire2.WireChange; //switch (dlg.LineType) //{ // case "2*LGJ-400": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} } string tempp = dlg.LineLev; int tel = tempp.Length; if (tel == 1) pspDev.VoltR = 0; else { // tempp = tempp.Substring(0, tel - 2); pspDev.VoltR = Convert.ToDouble(tempp); } if (pspDev.PositiveTQ == 0) pspDev.PositiveTQ = pspDev.LineTQ; Services.BaseService.Create<PSPDEV>(pspDev); Topology2(); } else { tlVectorControl1.Delete(); } return; } }
private void comboBoxEdit5_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxEdit5.Text == "") comboBoxEdit5.Text = "0"; if (comboBoxEdit5.Text == leel.VoltR.ToString()) { } else { WireCategory wirewire = new WireCategory(); wirewire.WireLevel = comboBoxEdit5.Text; IList list1 = Services.BaseService.GetList("SelectWireCategoryListBYWireLevel", wirewire); comboBox22.Properties.Items.Clear(); foreach (WireCategory sub in list1) { comboBox22.Properties.Items.Add(sub.WireType); } //if (list1.Count == 0) comboBox22.Text = ""; leel.LineLength = Convert.ToDouble(textBox11.Text); leel.LineType = comboBox22.Text; leel.Name = mc.Text; leel.LineStatus = comboBox44.Text; leel.LineLevel = "����·"; string tempp = comboBoxEdit5.Text; int tel = tempp.Length; // tempp = tempp.Substring(0, tel - 2); //pspDev.VoltR = Convert.ToDouble(tempp); leel.VoltR = Convert.ToDouble(tempp); // WireCategory wirewire = new WireCategory(); // wirewire.WireType = comboBox22.Text; // WireCategory wirewire2 = new WireCategory(); // wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); // if (wirewire2 != null) // { // leel.LineR = Convert.ToDouble(leel.LineLength) * wirewire2.WireR; // leel.LineTQ = Convert.ToDouble(leel.LineLength) * wirewire2.WireTQ; // leel.LineGNDC = Convert.ToDouble(leel.LineLength) * wirewire2.WireGNDC; // } // //textBox2.Text= InitData(leel); } }
public override void Add() { frmZXdlg dlg = new frmZXdlg(); dlg.Name = ""; dlg.ProjectID = this.ProjectID; if (!string.IsNullOrEmpty(parentid)) { dlg.AreaID = parentid; } dlg.Number = GetrowCount(); //��� Stream fs = Assembly.GetExecutingAssembly().GetManifestResourceStream("Itop.TLPSP.DEVICE.devicetypes.xml"); //Assembly.GetExecutingAssembly().GetManifestResourceStream XmlDocument xml = new XmlDocument(); xml.Load(fs); XmlNode node = xml.SelectSingleNode("devicetype/*[@id='" + ID + "']"); dlg.Text = "֧����Ϣ"; if (dlg.ShowDialog() == DialogResult.OK) { //���Ӽ�¼ PSPDEV dev = dlg.DeviceMx; dev.Type = ID; dev.ProjectID = this.ProjectID; UCDeviceBase.DataService.Create("InsertPSPDEV", dev); //������Ӧ�����߶� PSPDEV parentobj = new PSPDEV(); parentobj.SUID = dev.AreaID; parentobj = Services.BaseService.GetOneByKey<PSPDEV>(parentobj); PSPDEV firstnodeobj =null; if (parentobj!=null) { string sql = "where AreaID='" + parentobj.SUID + "'and Type='70' and projectid='" + ProjectID + "'order by number"; IList<PSPDEV> list1 = Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", sql); if (list1.Count>1) { firstnodeobj = list1[list1.Count - 2]; } } if (firstnodeobj!=null&&parentobj!=null) { PSPDEV pv = new PSPDEV(); pv.Name = parentobj.Name + "_��·��" + (dev.Number).ToString(); pv.AreaID = parentid; pv.Type = "74"; pv.OperationYear = dev.OperationYear; pv.FirstNode = firstnodeobj.Number; pv.LastNode = dev.Number; pv.IName = firstnodeobj.SUID; pv.JName = dev.SUID; pv.LineType = parentobj.LineType; pv.RateVolt=parentobj.RateVolt; pv.LineLength = 1; pv.ProjectID = ProjectID; if (!string.IsNullOrEmpty(parentobj.LineType)) { WireCategory rc = new WireCategory(); rc.WireLevel = parentobj.RateVolt.ToString(); rc.WireType = parentobj.LineType; rc.Type = "40"; rc = (WireCategory)UCDeviceBase.DataService.GetObject("SelectWireCategoryByKeyANDWireLevel", rc); if (rc != null) { pv.HuganTQ3 = rc.gzl*pv.LineLength; pv.HuganTQ4 = rc.xftime; } } Services.BaseService.Create<PSPDEV>(pv); } DataRow row=datatable1.NewRow(); Itop.Common.DataConverter.ObjectToRow(dev, row); datatable1.Rows.Add(row); } }
private void initcom() { if (type=="line") { label3.Text = "��·����"; label2.Text = "��·����"; label15.Visible = true; comboBoxEdit8.Visible = true; label1.Visible = false; spinEdit2.Visible = false; WireCategory wirewire = new WireCategory(); IList list1 = null; if (volt != 0) { wirewire.WireLevel = ((int)volt).ToString(); list1 = Services.BaseService.GetList("SelectWireCategoryListBYWireLevel", wirewire); } else list1 = Services.BaseService.GetList("SelectWireCategoryList", wirewire); foreach (WireCategory sub in list1) { comboBoxEdit8.Properties.Items.Add(sub.WireType); } } else if (type=="sub") { label3.Text = "���վ����"; label2.Text = "����"; label15.Visible = false; comboBoxEdit8.Visible = false; label1.Visible = true; spinEdit2.Visible = true; } this.gridControl1.DataSource = dt; }
private void addrightcheck() { FileStream dh; StreamReader readLine; char[] charSplit; string strLine; string[] array1; string output = null; string[] array2; string strLine2; char[] charSplit2 = new char[] { ' ' }; FileStream op; StreamWriter str1; FileStream dh2; StreamReader readLine2; //List<PSPDEV> linedengdai = new List<PSPDEV>(); //记录所有待选的线路(一次运行以后就会发生变化) if (!Check()) { return; } PSPDEV pspdev = new PSPDEV(); pspdev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspdev.LineStatus = "运行"; pspdev.Type = "Polyline"; IList list1 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndLineStatus", pspdev); double yinzi = 0, capability = 0, volt = 0, current = 0, standvolt = 0, Rad_to_Deg = 57.29577951; PSPDEV benchmark = new PSPDEV(); benchmark.Type = "power"; benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark); if (list3 == null) { MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (PSPDEV dev in list3) { yinzi = Convert.ToDouble(dev.PowerFactor); capability = Convert.ToDouble(dev.StandardCurrent); volt = Convert.ToDouble(dev.StandardVolt); if (dev.PowerFactor == 0) { yinzi = 1; } if (dev.StandardCurrent == 0) { capability = 1; } if (dev.StandardVolt == 0) { volt = 1; } standvolt = volt; current = capability / (Math.Sqrt(3) * volt); } capability = 100; ercilinedengdai.Clear();//清空之前的记录 for (int i = 0; i < list1.Count; i++) { N1Test.NBcal kk = new N1Test.NBcal(); kk.Show_ZLKMPSP(((PSPDEV)list1[i]).Number); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ZL.txt")) { } else { return; } dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ZL.txt", FileMode.Open); readLine2 = new StreamReader(dh2); charSplit2 = new char[] { ' ' }; strLine2 = readLine2.ReadLine(); output = null; bool lineflag = true; bool jielieflag = true; while (!string.IsNullOrEmpty(strLine2)) { array2 = strLine2.Split(charSplit2); string[] dev = new string[2 * brchcount + 1]; dev.Initialize(); PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; int m = 0; foreach (string str in array2) { if (str != "") { dev[m++] = str.ToString(); } } //进行解裂和负荷判断 if (dev[1] != "-1") { for (int j = 0; j < brchcount; j++) { double pij = System.Math.Abs(Convert.ToDouble(dev[j * 2 + 2])) * capability; PSPDEV psp = new PSPDEV(); psp.Name = dev[j * 2 + 1]; psp.Type = "Polyline"; psp.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", psp); PSPDEV pspline = (PSPDEV)listName[0]; if (pspline != null && !pspline.Name.Contains("虚拟线路")) { double voltR = pspline.VoltR; WireCategory wirewire = new WireCategory(); wirewire.WireType = pspline.LineType; if (pspline.LineType == null || pspline.LineType == "") { MessageBox.Show(pspline.Name + "的线路类型没有输入,无法进行可靠性检验", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } WireCategory listware = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); double Ichange = (double)listware.WireChange; double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000; if (pij >= linXij) { lineflag = false; //lineclass _line = new lineclass(n, j); //Overlinp.Add(_line); // OverPhege[n] = j; } } } } else { jielieflag = false; } strLine2 = readLine2.ReadLine(); } readLine2.Close(); if (!lineflag) { PSPDEV psperci = new PSPDEV(); psperci = (PSPDEV)list1[i]; psperci.LineStatus = "等待"; Services.BaseService.Update<PSPDEV>(psperci); ercilinedengdai.Add(psperci); break; } else //没有出现过负荷 continue; } //新添加的 如果记录二次等待的线路没有则停止下面的运行 表示断开任意一条也没有出现过负荷 if (ercilinedengdai.Count == 0) { return; } //此过程是添加一条线路使其不出现过负荷 fuhecheck(); for (int j = 0; j < linedengdai.Count; j++) { if (!Checkadd(linedengdai[j].EleID)) return; N1Test.NBcal zl = new NBcal(); //zl.Show_KmRelia(1); zl.ZLpsp(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); output = null; double sumpij = 0.0; bool lineflag = true; while (!string.IsNullOrEmpty(strLine)) { array1 = strLine.Split(charSplit); string[] dev = new string[2]; dev.Initialize(); int i = 0; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (i == 0) { dev[i++] = str.ToString(); } else { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } } CR.Name = dev[0]; CR.Type = "Polyline"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null && CR.ReferenceVolt != 0) { volt = CR.ReferenceVolt; } else volt = standvolt; current = capability / (Math.Sqrt(3) * volt); if (CR != null && !CR.Name.Contains("虚拟线路")) { double linepij = Convert.ToDouble(dev[1]) * capability; double voltR = CR.VoltR; WireCategory wirewire = new WireCategory(); wirewire.WireType = CR.LineType; if (string.IsNullOrEmpty(CR.LineType)) { MessageBox.Show(CR.Name + "的线路类型没有输入,无法进行可靠性检验", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } WireCategory listware = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); double Ichange = (double)listware.WireChange; double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000; if (linepij >= linXij) { lineflag = false; //sumpij += linepij; } for (int k = 0; k < fuheline.Count; k++) { if (CR.SUID == fuheline[k].Suid) { sumpij += System.Math.Abs(fuheline[k].linepij - linepij); } } // // //output += "'" + CR.Name.ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } strLine = readLine.ReadLine(); } readLine.Close(); //if (lineflag) //如果没有出现过负荷现象 就停止进行加线 //{ // PSPDEV pspb = (PSPDEV)linedengdai[j]; // pspb.LineStatus = "运行"; // Services.BaseService.Update<PSPDEV>(pspb); // lineyiyou.Add(pspb); // for (int i = 0; i < linedengdai.Count; i++) // { // if (linedengdai[i].SUID == pspb.SUID) // { // linedengdai.RemoveAt(j); // } // } // return; //} //else //{ XmlNode el = tlVectorControl1.SVGDocument.SelectSingleNode("svg/polyline[@layer='" + tlVectorControl1.SVGDocument.CurrentLayer.ID + "' and @id='" + linedengdai[j].EleID + "']"); double linevalue = 0; if (!string.IsNullOrEmpty(((XmlElement)el).GetAttribute("linevalue"))) { linevalue = Convert.ToDouble(((XmlElement)el).GetAttribute("linevalue")); } else linevalue = 1; linedaixuan linedai = new linedaixuan(linedengdai[j].Number, linedengdai[j].SUID, linedengdai[j].Name); linedai.linepij = sumpij; linedai.linevalue = linevalue; linedai.linetouzilv = sumpij / linevalue; waitlineindex.Add(linedai); //} } waitlineindex.Sort(); //在此处获得指标最大的线路 将其线路的状态变为 运行并且在运行的集合里面记录 在等待的集合里将其线路去掉 重新进行下一轮的操作 PSPDEV pspbianhua = new PSPDEV(); if (waitlineindex.Count > 0) { pspbianhua.SUID = waitlineindex[waitlineindex.Count - 1].Suid; } else { //MessageBox.Show("没有出现过负荷的线路集,请查看一下线路参数是否设定正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspbianhua = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", pspbianhua); pspbianhua.LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(pspbianhua); lineyiyou.Add(pspbianhua); for (int i = 0; i < linedengdai.Count; i++) { if (linedengdai[i].SUID == pspbianhua.SUID) { linedengdai.RemoveAt(i); } } waitlineindex.Clear(); }
protected void setXL() { WireCategory rc = new WireCategory(); rc.WireLevel = dev.RateVolt.ToString(); rc.WireType = dev.LineType; rc.Type = "40"; rc = (WireCategory)UCDeviceBase.DataService.GetObject("SelectWireCategoryByKeyANDWireLevel", rc); if (rc!=null) { spinEdit1.Value = (decimal)rc.WireR; spinEdit7.Value = (decimal)rc.WireTQ; spinEdit9.Value = (decimal)rc.WireGNDC; spinEdit13.Value = (decimal)rc.ZeroR; spinEdit12.Value = (decimal)rc.ZeroTQ; spinEdit10.Value = (decimal)rc.ZeroGNDC; spinEdit17.Value = (decimal)rc.WireChange; spinEdit19.Value = (decimal)rc.gzl; spinEdit20.Value = (decimal)rc.xftime; } }
private void spinEdit6_EditValueChanged(object sender, EventArgs e) { //��ʾ����λ�õ����� object obj=null; if (string.IsNullOrEmpty(dev.AreaID)&&!string.IsNullOrEmpty(parentid)) { obj = DeviceHelper.GetDevice<PSPDEV>(parentid); dev.AreaID = parentid; } else obj = DeviceHelper.GetDevice<PSPDEV>(dev.AreaID); if (obj != null) { spinEdit19.Value = (decimal)((PSPDEV)obj).HuganTQ4 * spinEdit6.Value; spinEdit20.Value = (decimal)((PSPDEV)obj).HuganTQ5; } WireCategory rc = new WireCategory(); rc.WireLevel = dev.RateVolt.ToString(); rc.WireType = dev.LineType; rc.Type = "40"; rc = (WireCategory)UCDeviceBase.DataService.GetObject("SelectWireCategoryByKeyANDWireLevel", rc); if (rc != null) { spinEdit19.Value = (decimal)(rc.gzl) * spinEdit6.Value; spinEdit20.Value = (decimal)rc.xftime; } }