public void Pldd() { if (!IsLoadDataSource()) { return; } if (!PublicMethod.Instance.IsExecuteSystemCMD("pldd")) { TopologyMethods.breakall(); } }
private void ToolSMI_Pldd_Click(object sender, EventArgs e) { if (!IsLoadDataSource()) { return; } if (!PublicMethod.Instance.IsExecuteSystemCMD("")) { TopologyMethods.breakall(); } }
private void Ok_Btn_Click(object sender, EventArgs e) { try { // 是否已选择了母线 if (MxName_textBox.Tag == null || MxFid_textBox.Tag == null) { PublicMethod.Instance.AlertDialog("请先选择母线"); return; } // 是否已选择了上下游设备 if (SelYxCount_Lab.Text == "0") { PublicMethod.Instance.AlertDialog("请先选择上下游设备"); return; } // 是否已确定上下游方向 if (InRadBtn.Checked == false && OutRadBtn.Checked == false) { PublicMethod.Instance.AlertDialog("请先选择上下游方向"); return; } var IdListFromView = new ObjectIdList(); IdListFromView.AddRange(from ListViewItem item in YxlistView.Items select(ObjectId) item.Tag); long g3eid = 0, g3efid = 0, g3efno = 0; var mxfid = (long)MxFid_textBox.Tag; var nodeid = CYZCommonFunc.getid(); var strNodC = ""; using (doc.LockDocument()) { using (db.TransactionManager.StartTransaction()) { var conn = DBManager.Instance.GetEntity <Connectivity_n>(mxfid); var dlgRes = DialogResult.Yes; if ((conn.NODE1_ID != 0 && InRadBtn.Checked) || (conn.NODE2_ID != 0 && OutRadBtn.Checked) || (conn.NODE1_ID != 0 && conn.G3E_FNO == 143)) { dlgRes = MessageBox.Show( "已有连接关系" + "\n 是 连接已有 " + "\n 否 打断重建 ", "AutoCad", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (!(dlgRes == DialogResult.Yes || dlgRes == DialogResult.No)) { return; } if (dlgRes == DialogResult.Yes) { if (InRadBtn.Checked) { if (conn.NODE1_ID != null) { nodeid = (int)conn.NODE1_ID; } } else { if (conn.NODE2_ID != null) { nodeid = (int)conn.NODE2_ID; } } var tempstr = conn.EntityState.ToString(); if (tempstr.Length > 7) { tempstr = tempstr.Substring(4, 3); } switch (tempstr) { case "None": strNodC = "Old"; break; case "Update": strNodC = "Old"; break; default: strNodC = tempstr; break; } } } if (dlgRes == DialogResult.No || conn.NODE1_ID == 0) { strNodC = "Add"; if (conn.G3E_FNO == 143) { conn.NODE1_ID = conn.NODE2_ID = nodeid; /*改变母线状态*/ TopologyMethods.ChangEntStatus(conn, 1, "Add"); TopologyMethods.ChangEntStatus(conn, 2, "Add"); } else { if (OutRadBtn.Checked) { conn.NODE2_ID = nodeid; TopologyMethods.ChangEntStatus(conn, 2, "Add"); } else { conn.NODE1_ID = nodeid; TopologyMethods.ChangEntStatus(conn, 1, "Add"); } } } //int[] sinNodDevArr = new int[] { 11, 72, 79, 85, 120, 143, 167, 173 }; foreach (var id in IdListFromView) { DBEntityFinder.Instance.GetG3EIds(id, ref g3eid, ref g3efid, ref g3efno); conn = DBManager.Instance.GetEntity <Connectivity_n>(g3efid); if (OutRadBtn.Checked || PublicMethod.Instance.N2is0.Concat(PublicMethod.Instance.N1isN2).Contains(conn.G3E_FNO)) { conn.NODE1_ID = nodeid; TopologyMethods.ChangEntStatus(conn, 1, strNodC); } else { conn.NODE2_ID = nodeid; TopologyMethods.ChangEntStatus(conn, 2, strNodC); } sinNodDevJudge(conn); } } } TopologyMethods.bChangeTopo = true; PublicMethod.Instance.AlertDialog("建立完成"); } catch (Exception ex) { ed.WriteMessageWithReturn(ex.Message + "\n"); } }
/// <summary> /// 建立连接关系 /// </summary> /// <param name="objIdList">需要建立连接的设备列表</param> /// <returns>成功返回true,失败返回false</returns> bool buildConnByObjIdList(ObjectIdList objIdList) { var hasEr = false; var db = HostApplicationServices.WorkingDatabase; var connList = new List <Connectivity_n>(); long g3eid = 0, g3efid = 0, g3efno = 0; var hasConn = false; // 判断已选择的设备是否已经存在连接关系 foreach (var id in objIdList) { DBEntityFinder.Instance.GetG3EIds(id, ref g3eid, ref g3efid, ref g3efno); var conn = DBManager.Instance.GetEntity <Connectivity_n>(g3efid); if (conn.NODE1_ID != 0 || conn.NODE2_ID != 0) { hasConn = true; } connList.Add(conn); } var dlgRes = DialogResult.Yes; if (hasConn) { dlgRes = MessageBox.Show(@"选择中的设备已有连接关系。 是否打断重新建立?", @"AutoCad", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dlgRes != DialogResult.Yes) { throw new Exception("cancel"); } // 打断关系 TopologyMethods.breakall(objIdList); } using (var tr = db.TransactionManager.StartTransaction()) { // 建立关系 for (var i = 0; i < connList.Count - 1; i++) { var newNode = CYZCommonFunc.getid(); if (accordConnCrom(connList[i].G3E_FNO, connList[i + 1].G3E_FNO)) { // 判断设备是否只有一个连接点 143-站房母线 159-低压集中抄表箱 79-低压母线 151-10kV电缆终端头 74-低压终端 72-接地挂环 85-PT柜 清空节点2 if (PublicMethod.Instance.N2is0.Concat(PublicMethod.Instance.N1isN2).Contains(connList[i].G3E_FNO)) { if (connList[i].NODE1_ID == 0) // 若果母线连接1为0 { if (PublicMethod.Instance.N1isN2.Contains(connList[i].G3E_FNO)) { connList[i].NODE1_ID = connList[i].NODE2_ID = connList[i + 1].NODE1_ID = newNode; TopologyMethods.ChangEntStatus(connList[i], 2, "Add"); } else { connList[i].NODE1_ID = connList[i + 1].NODE1_ID = newNode; } TopologyMethods.ChangEntStatus(connList[i], 1, "Add"); } else // 否则直接将母线连接1赋值给下一个设备 { if (PublicMethod.Instance.N1isN2.Contains(connList[i].G3E_FNO)) { connList[i + 1].NODE1_ID = connList[i].NODE2_ID = connList[i].NODE1_ID; TopologyMethods.ChangEntStatus(connList[i], 2, "Add"); } else { connList[i + 1].NODE1_ID = connList[i].NODE1_ID; } } } else/* if (sinNodDevArr.Contains(connList[i + 1].G3E_FNO))*/ { connList[i].NODE2_ID = connList[i + 1].NODE1_ID = newNode; TopologyMethods.ChangEntStatus(connList[i], 2, "Add"); if (PublicMethod.Instance.N1isN2.Contains(connList[i + 1].G3E_FNO)) { connList[i + 1].NODE2_ID = newNode; TopologyMethods.ChangEntStatus(connList[i + 1], 2, "Add"); } } TopologyMethods.ChangEntStatus(connList[i + 1], 1, "Add"); DBManager.Instance.Update(connList[i]);// 改变状态 } else { hasEr = true; ConnlistView.Items[i].ForeColor = Color.Red; ConnlistView.Items[i + 1].ForeColor = Color.Red; } } // 更新列表最后一个设备连接状态 DBManager.Instance.Update(connList[connList.Count - 1]); tr.Commit(); } return(hasEr); }