public async Task <IActionResult> Get([FromBody] ObjectIdList systemIds) { //Service to get GenericSystem var genericSystem = await _genericSystemService.GetByIdList(systemIds.ObjectIds); return(Ok(genericSystem)); }
private void Set_View(ObjectIdList objs) { YxlistView.BeginUpdate(); ObjectId objid; long fno = 0, fid = 0, id = 0; string typeName; YxlistView.Clear(); for (var i = 0; i < objs.Count; i++) { var lvi = new ListViewItem(); objid = objs.ElementAt(i); DBEntityFinder.Instance.GetG3EIds(objid, ref id, ref fid, ref fno); if (FeatureMapping.instance.features.Keys.Contains(fno.ToString())) { typeName = FeatureMapping.instance.features[fno.ToString()]; } else { typeName = "xxxxx"; PublicMethod.Instance.Editor.WriteMessageWithReturn("FeatureMapping字典没有此fno" + fno + "设备"); } var devName = DCadApi.getDevNamebyfidfno(fid, fno); lvi.Tag = objid; lvi.ImageIndex = i; lvi.Text = (i + 1) + @" " + typeName + @" " + devName; YxlistView.Items.Add(lvi); } YxlistView.EndUpdate(); }
private void btn_ok_Click(object sender, EventArgs e) { try { var IdListFromView = new ObjectIdList(); foreach (ListViewItem item in ConnlistView.Items) { item.ForeColor = Color.Black; IdListFromView.Add((ObjectId)item.Tag); } if (IdListFromView.Any()) { var b = buildConnByObjIdList(IdListFromView); if (b) { PublicMethod.Instance.AlertDialog("连接有错误,请检查设备的连接顺序!"); } else { TopologyMethods.bChangeTopo = true; PublicMethod.Instance.AlertDialog("连接全部建立成功!"); } } } catch (Exception exception) { if (exception.Message != "cancel") { PublicMethod.Instance.AlertDialog(exception.Message); } } }
public void EntityTools() { Database db = HostApplicationServices.WorkingDatabase; Line l = new Line(Point3d.Origin, new Point3d(100, 100, 0)); Circle c = new Circle(); c.CreateCircle(new Point3d(50, 50, 0), new Point3d(50, 100, 0)); ObjectIdList ids = new ObjectIdList(); using (var tr = db.TransactionManager.StartTransaction()) { ////添加到模型空间 //ids = db.AddToModelSpace(l, c); ////添加到布局空间 //ids = db.AddToPaperSpace(l, c); //添加到当前空间 ids = db.AddToCurrentSpace(l, c); //高亮 ids.HighlightEntities(); //ids.UnHighlightEntities(); tr.Commit(); } if (ids.Count > 0) { Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor; using (var tr = db.TransactionManager.StartTransaction()) { //选择一条直线 var peo = new PromptEntityOptions("\n选择一条直线"); peo.SetRejectMessage("选择直线"); peo.AddAllowedClass(typeof(Line), true); var per = ed.GetEntity(peo); if (per.Status == PromptStatus.OK) { var line = (Line)per.ObjectId.GetObject(OpenMode.ForRead); //移动 //ids.Move(line.StartPoint, line.EndPoint); //拷贝 //var copyIds = db.Copy(line.EndPoint, line.StartPoint, ids); //foreach (var cid in copyIds) //{ // var ent = (Entity)cid.Value.GetObject(OpenMode.ForWrite); // ent.ColorIndex = 1; // ent.DowngradeOpen(); //} //旋转 //ids.Rotate(line.StartPoint, line.Angle); //缩放 //ids.Scale(line.StartPoint, 2); //镜像 EntTools.Mirror(line.EndPoint, line.StartPoint, false, ids.ToArray()); } tr.Commit(); } } }
public override void WriteToStream(IndentStream stream) { stream.Write("DBCC UPDATEUSAGE("); ObjectIdList.WriteToStreamWithComma(stream); stream.Write(")"); if (WithList != null && WithList.Count > 0) { stream.Write(" WITH("); WithList.WriteToStreamWithComma(stream); stream.Write(")"); } }
static public void breakall() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ed.SetImpliedSelection(new ObjectId[0]); PublicMethod.Instance.AlertDialog("请选择要打断的设备"); PromptSelectionResult psr = ed.GetSelection(); if (psr.Status != PromptStatus.OK) { return; } ObjectIdList objlist = psr.Value.GetObjectIds(); breakall(objlist); }
/// <summary> /// 还原指定字典里实体颜色 /// </summary> /// <param name="nodeList">实体列表</param> /// <param name="dict"></param> private void cleanObjCol(ObjectIdList nodeList, Dictionary <ObjectId, int> dict) { DCadApi.isModifySymbol = true; var db = HostApplicationServices.WorkingDatabase; if (db == null) { return; } try { using (db.GetDocument().LockDocument()) { using (var tr = db.TransactionManager.StartTransaction()) { for (var i = 0; i < nodeList.Count(); i++) { if (nodeList[i].IsErased || nodeList[i].IsNull) { continue; } var ent = tr.GetObject(nodeList[i], OpenMode.ForWrite) as Entity; if (ent == null) { continue; } if (!dict.Keys.Contains(ent.ObjectId)) { continue; } ent.ColorIndex = dict[ent.ObjectId]; } tr.Commit(); } } } catch (Exception ex) { PublicMethod.Instance.AlertDialog("cleanObjCol: " + ex.Message); } finally { DCadApi.isModifySymbol = false; } }
/// <summary> /// 对objid 的对象作空间分析 /// </summary> /// <param name="objid">对象ObjectId</param> public void autoconn(ObjectId objid) { // 工单判断 if (DBEntityFinder.Instance.VerifyLTTID(objid) == false) { return; } var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; var ed = doc.Editor; var autoconns = new ObjectIdList(); var nodeid = CYZCommonFunc.getid(); var objs = new List <ObjectId>(); long[] mxarr = { 11, 120, 143, 167, 79 }; long idd = 0, fidd = 0, fnoo = 0; //ObjectIdList dxIdList = new ObjectIdList(); try { DCadApi.isModifySymbol = true; Entity ent; using (Transaction tr = doc.TransactionManager.StartTransaction()) { ent = tr.GetObject(objid, OpenMode.ForWrite) as Entity; if (ent == null) { return; } bakdict.Add(ent.ObjectId, ent.ColorIndex); ent.ColorIndex = 4; PromptSelectionResult psr; Point3dCollection p3dcc; if (ent is BlockReference) { string[] dltArr = { "147_1", "151_1", "169_1", "173_0_0", "173_0_1" }; var brf = ent as BlockReference; if (dltArr.Contains(brf.Name)) /*PublicMethod.Instance.Editor.WriteMessageWithReturn("遇上双电缆头,连接终止.\n"); */ return { ; } var ext = ent.GeometricExtents; //brf.Rotation = 0; var leftup = new Point3d(ext.MinPoint.X, ext.MaxPoint.Y, 0); var leftdown = ext.MinPoint; var rightup = ext.MaxPoint; var rightdown = new Point3d(ext.MaxPoint.X, ext.MinPoint.Y, 0); p3dcc = new Point3dCollection(new[] { leftup, leftdown, rightdown, rightup, leftup }); psr = ed.SelectCrossingPolygon(p3dcc); objs.AddRange(psr.Value.GetObjectIds()); } else if (ent is Polyline) { var entpoly = ent as Polyline; if (entpoly.NumberOfVertices < 2) { return; } Point3d[] startendpt = { entpoly.StartPoint, entpoly.EndPoint }; for (int i = 0; i < 2; i++) { const double lenght = 0.00000040; p3dcc = new Point3dCollection(new[] { new Point3d(startendpt[i].X - lenght, startendpt[i].Y + lenght, 0), new Point3d(startendpt[i].X - lenght, startendpt[i].Y - lenght, 0), new Point3d(startendpt[i].X + lenght, startendpt[i].Y - lenght, 0), new Point3d(startendpt[i].X + lenght, startendpt[i].Y + lenght, 0), new Point3d(startendpt[i].X - lenght, startendpt[i].Y + lenght, 0) }); psr = ed.SelectCrossingPolygon(p3dcc); if (psr.Status == PromptStatus.OK) { objs.AddRange(psr.Value.GetObjectIds()); } } } tr.Commit(); }
/// <summary> /// 拖曳的执行过程 /// </summary> public void doit(XProps dg, XProps dx, bool dxStatus) { //如果杆塔ID是空,退出程序 if (entid == ObjectId.Null) { return; } Editor ed = PublicMethod.Instance.Editor; DCadApi.isInsertSymbol = true; DCadApi.isModifySymbol = true; try { dgObjIdList = new ObjectIdList(); //获取杆的层ID var pointLaryerId = GetDGLayerID(); //获取导线的层ID var lineLaryerId = GetDXLayerID(); //获取导线宽度 var lineStyle = GetDxStyle(dx); //获取符号颜色 var pointStyle = GetDgStyle(dg); pline.AddVertexAt(pline.NumberOfVertices, new Point2d(m_fistPnt.X, m_fistPnt.Y), 0, lineStyle.lineWidth, lineStyle.lineWidth); PromptResult res = ed.Drag(this); if (res.Status == PromptStatus.OK) { if (pline.NumberOfVertices == 1) { SetPolyLine(pline, lineStyle.symbolColor, lineLaryerId); } m_startPnt = m_lastPnt; m_status = CommandStatus.kWatiForOtherPnt; AddLineSymbol(m_lastPnt, lineStyle.lineWidth); if (!haspole(m_lastPnt, ed)) { AddPointSymbol(pointStyle, pointLaryerId); } } while (m_status == CommandStatus.kWatiForOtherPnt) { res = ed.Drag(this); if (res.Status == PromptStatus.OK) { m_startPnt = m_lastPnt; if (pline.NumberOfVertices == 1) { id = SetPolyLine(pline, lineStyle.symbolColor, lineLaryerId); } AddLineSymbol(m_lastPnt, lineStyle.lineWidth); //判断是否存在杆塔 if (!haspole(m_lastPnt, ed)) { AddPointSymbol(pointStyle, pointLaryerId); } } //var bKeyword = res.Status == PromptStatus.Keyword; //if (bKeyword) //{ // try // { // pl.RemoveVertexAt(pl.NumberOfVertices - 1); // } // catch (Exception ex) // { // PublicMethod.Instance.ShowMessage(ex.ToString()); // } //} if (res.Status == PromptStatus.None) { m_status = CommandStatus.kCancelAndStop; if (!dxStatus) { AddPolyline(id, lineLaryerId, lineStyle.symbolColor, lineStyle.lineWidth); } else { AddPolyline(id); } } } } catch (CADException eex) { LogManager.Instance.Error(eex.ToString()); } catch (Exception ex) { LogManager.Instance.Error(ex.ToString()); } finally { DCadApi.isInsertSymbol = false; DCadApi.isModifySymbol = false; } }
/// <summary> /// 添加从属设备自动 /// </summary> /// <param name="parentfid">面设备Fid</param> public static void addDev2AreaAuto(long parentfid) { try { var db = HostApplicationServices.WorkingDatabase; var ed = db.GetEditor(); // 取出电房的点坐标 var parentId = DBEntityFinder.Instance.GetObjectIdByFid(parentfid); var pts = new Point3dCollection(); using (var tr = db.TransactionManager.StartTransaction()) { var pl = tr.GetObject(parentId, OpenMode.ForRead) as Polyline; // 如果设备不是多段线,退出 if (pl == null) { return; } // 如果线是闭合的 if (pl.Closed) { for (var index = 0; index < pl.NumberOfVertices; index++) { pts.Add(pl.GetPoint3dAt(index)); } } tr.Commit(); } // 根据 点坐标 求范围内设备 var ids = new ObjectIdList(); if (pts.Count != 0) { using (Application.DocumentManager.MdiActiveDocument.LockDocument()) { // 得到当前视图 ViewTableRecord view = ed.GetCurrentView(); db.UpdateExt(true); //ed.ZoomExtents(); // 视图最大化 ed.ZoomObject(parentId); // 视图定位到对象 var ress = ed.SelectCrossingPolygon(pts); ed.SetCurrentView(view); // 还原视图 if (ress.Status == PromptStatus.OK) { var tempids = ress.Value.GetObjectIds(); ids = new ObjectIdList(tempids); // 存储房内设备的ObjectId ids.Remove(parentId); // 去除自身 } } } if (ids.Count != 0) { DCadApi.isModifySymbol = true; using (Application.DocumentManager.MdiActiveDocument.LockDocument()) { using (var tr = db.TransactionManager.StartTransaction()) { foreach (var id in ids) { var ent = tr.GetObject(id, OpenMode.ForRead) as Entity; if (ent != null) { if (ent is DBText) { continue; } G3EObject sonObj = null; DBEntityFinder.Instance.GetG3EIds(id, ref sonObj); if (sonObj == null) { continue; } DevBelong2Area(parentfid, sonObj.G3E_FID); } } tr.Commit(); } } } } catch (System.Exception e) { LogManager.Instance.Error(e.Message); PublicMethod.Instance.ShowMessage(e.Message); } }
// 建立 与 线 相交的杆 的包含关系 public static bool AutoContainByPline(ObjectId plid) { var db = HostApplicationServices.WorkingDatabase; var ed = db.GetEditor(); long lineid = 0, linefid = 0, linefno = 0; var b = DBEntityFinder.Instance.GetG3EIds(plid, ref lineid, ref linefid, ref linefno); if (b == false) { return(false); } var pts = new Point3dCollection(); // 取出多段线的点坐标 using (var tr = db.TransactionManager.StartTransaction()) { var ent = tr.GetObject(plid, OpenMode.ForRead) as Entity; var pl = ent as Polyline; if (pl != null && linefno == 141) { for (var index = 0; index < pl.NumberOfVertices; index++) { pts.Add(pl.GetPoint3dAt(index)); } } tr.Commit(); } // 根据 点坐标 求相交设备 var ids = new ObjectIdList(); if (pts.Count != 0) { using (Application.DocumentManager.MdiActiveDocument.LockDocument()) { // 得到当前视图 ViewTableRecord view = ed.GetCurrentView(); db.UpdateExt(true); ed.ZoomExtents(); // 视图最大化 var ress = ed.SelectFence(pts); ed.SetCurrentView(view); // 还原视图 if (ress.Status == PromptStatus.OK) { var tempids = ress.Value.GetObjectIds(); //ed.WriteMessageWithReturn(ress.Value.Count); ids = new ObjectIdList(tempids); ids.Remove(plid); } } } // 只取出 杆设备 做操作 if (ids.Count != 0) { DCadApi.isModifySymbol = true; using (Application.DocumentManager.MdiActiveDocument.LockDocument()) { using (var tr = db.TransactionManager.StartTransaction()) { foreach (var id in ids) { var ent = tr.GetObject(id, OpenMode.ForRead) as Entity; if (ent != null) { if (ent is DBText) { continue; } long roleid = 0, rolefid = 0, rolefno = 0; DBEntityFinder.Instance.GetG3EIds(id, ref roleid, ref rolefid, ref rolefno); if (rolefno != 201) { continue; } addRole(linefid, rolefid); } } tr.Commit(); } } } return(true); }
static public void breakall(ObjectIdList objIdList) { DCadApi.isModifySymbol = true; Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; try { long g3eid = 0, g3efid = 0, g3efno = 0; using (Transaction tr = doc.TransactionManager.StartTransaction()) { var breObjsNodList = new List <long>(); 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 == null) { continue; } if (DBEntityFinder.Instance.VerifyLTTID(conn.G3E_FID) == false) { continue; } if (conn.NODE1_ID != 0) { if (conn.NODE1_ID != null) { breObjsNodList.Add((long)conn.NODE1_ID); } } conn.NODE1_ID = 0; if (conn.NODE2_ID != 0) { if (conn.NODE2_ID != null) { breObjsNodList.Add((long)conn.NODE2_ID); } } conn.NODE2_ID = 0; string strr = conn.EntityState.ToString().Substring(0, 3); if (strr == "Ins" || strr == "Add") { conn.EntityState = EntityState.Add_Del_Del; } else { conn.EntityState = EntityState.Old_Del_Del; } DBManager.Instance.Update(conn); } foreach (var nod in breObjsNodList.Distinct()) { long nod1 = nod; var conns1 = DBManager.Instance.GetEntities <Connectivity_n>(o => o.NODE1_ID == nod1).Where(o => o.EntityState != EntityState.Delete && o.EntityState != EntityState.InsertDelete); long nod2 = nod; var conns2 = DBManager.Instance.GetEntities <Connectivity_n>(o => o.NODE2_ID == nod2).Where(o => o.EntityState != EntityState.Delete && o.EntityState != EntityState.InsertDelete); conns1 = conns1.Concat(conns2).Distinct(new ElectronBaseCompare <Connectivity_n>()); if (conns1.Count() == 1) { var conn = conns1.FirstOrDefault(); if (conn != null && DBEntityFinder.Instance.VerifyLTTID(conn.G3E_FID)) { if (conn.NODE1_ID == nod) { conn.NODE1_ID = 0; ChangEntStatus(conn, 1, "Del"); } else { conn.NODE2_ID = 0; ChangEntStatus(conn, 2, "Del"); } } DBManager.Instance.Update(conn); } } tr.Commit(); } PublicMethod.Instance.AlertDialog("打断结束!\n"); PublicMethod.Instance.SendCommend("re\n"); } catch (Autodesk.AutoCAD.Runtime.Exception ex) { ed.WriteMessageWithReturn(ex); } finally { DCadApi.isModifySymbol = false; } }
public void InsertLateral(Dictionary <ObjectId, LateralLineData> dxObjIdList, ObjectIdList dgObjIdList) { GenerateHelper.SetPropertyValue(dxXprops, "Common_n", "SBMC", LateralName); var ghStr = GenerateHelper.GetPropertyValue(dgXprops, "Gg_gz_dg_n", "GH").ToString(); var sbGh = ghStr.Substring(1, ghStr.Length - 1); //添加导线 AddDX(dxObjIdList); //添加电杆 AddDG(dgObjIdList, sbGh); //设置记忆值 DBEntityFinder.Instance.GetMemoryDevice(141, dxXprops); DBEntityFinder.Instance.GetMemoryDevice(201, dgXprops); GenerateHelper.SetPropertyValue(dgXprops, "Common_n", "SBMC", string.Format("{0}{1}{2}", LateralName, ghStr, DevStr)); //Nametext.Text = string.Empty; }
private void SelYxbtn_Click(object sender, EventArgs e) { try { if (MxName_textBox.Tag == null || MxFid_textBox.Tag == null) { PublicMethod.Instance.AlertDialog("请先选择母线"); return; } Visible = false; long g3eid = 0, g3efid = 0, g3efno = 0; var mxFno = (long)MxName_textBox.Tag; // 要先选择了母线才能进行过滤 PromptSelectionResult selper; var pso = new PromptSelectionOptions(); var selFilObjs = new ObjectIdList(); ed.SetImpliedSelection(new ObjectId[0]); do { selper = ed.GetSelection(pso); if (selper.Status == PromptStatus.OK) { ed.WriteMessageWithReturn(selper.Value.Count); } } while (selper.Status == PromptStatus.Error || selper.Status == PromptStatus.None); DCadApi.isModifySymbol = true; using (doc.LockDocument()) { using (var tr = db.TransactionManager.StartTransaction()) { foreach (var id in selper.Value.GetObjectIds()) { if (false == DBEntityFinder.Instance.VerifyLTTID(id)) { continue; } var ent = tr.GetObject(id, OpenMode.ForRead) as Entity; if (ent is DBText) { continue; } if (ent is MText) { continue; } DBEntityFinder.Instance.GetG3EIds(id, ref g3eid, ref g3efid, ref g3efno); if (g3efid == (long)MxFid_textBox.Tag) { continue; } var bcon = CDDBManager.Instance.GetEntities <G3e_nodeedgeconnectivity>(o => o.G3E_SOURCEFNO == mxFno).Select(o => o.G3E_CONNECTINGFNO).Contains((int)g3efno); if (bcon) { selFilObjs.Add(id); } } ed.SetImpliedSelection(selFilObjs); SelYxCount_Lab.Text = selFilObjs.Count.ToString(); Set_View(selFilObjs); tr.Commit(); } } } catch (Exception ex) { ed.WriteMessageWithReturn(ex.Message + "\n"); } finally { DCadApi.isModifySymbol = false; Visible = true; } }
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); }