/// <summary> /// 插入包含表数据 /// </summary> /// <param name="newObject"></param> /// <param name="newG3e_fid"></param> /// <param name="flag">true清空G3E_OWNERFID值,反之 </param> private void SetContainTable(ICloneable newObject, long newG3e_fid, bool flag) { var contain = newObject.Clone() as Contain_n; contain.G3E_ID = CYZCommonFunc.getid(); contain.G3E_FID = newG3e_fid; contain.G3E_CID = 1; contain.G3E_CNO = 38; contain.EntityState = EntityState.Insert; contain.EntityState2 = EntityState2.Copy; contain.SetValue("LTT_ID", (decimal)MapConfig.Instance.LTTID); if (flag) { contain.G3E_OWNERFID = 0; } DBManager.Instance.Insert(contain); var value = newObject as Contain_n; switch (contain.G3E_FNO) { case 141: _containDxTableData.Add(contain); break; case 201: _containDgTableData.Add(value.G3E_FID, contain); break; } }
private static void SetContainTable(ICloneable dbEntity, long newG3e_fid, bool flag) { var contain = dbEntity.Clone() as Contain_n; if (contain == null) { return; } contain.G3E_FID = newG3e_fid; contain.G3E_ID = CYZCommonFunc.getid(); contain.EntityState = EntityState.Insert; contain.SetValue("LTT_ID", (decimal)MapConfig.Instance.LTTID); DBManager.Instance.Insert(contain); if (flag) { contain.G3E_OWNERFID = 0; } var value = dbEntity as Contain_n; switch (contain.G3E_FNO) { case 141: DBEntityCopy.Instance._containDxTableData.Add(contain); break; case 201: if (value != null) { DBEntityCopy.Instance._containDgTableData.Add(value.G3E_FID, contain); } break; } }
private long Add_Gg_jx_shbd_pt(long g3efid) { //增加Gg_jx_shbd_pt表 var detail = DBManager.Instance.GetEntity <Detailreference_n>(o => o.G3E_FID == FID); var t2 = new Gg_jx_shbd_pt { G3E_DETAILID = detail.G3E_DETAILID, G3E_FNO = 160, G3E_CNO = 16004, G3E_FID = g3efid, G3E_ALIGNMENT = 0, G3E_ID = CYZCommonFunc.getid(), G3E_CID = 1, LTT_ID = MapConfig.Instance.LTTID, EntityState = EntityState.Insert }; if (false == DBManager.Instance.Insert(t2)) { throw new Exception("Add_Gg_jx_shbd_pt: 插入失败!"); } if (detail.DETAIL_USERNAME == null) { detail.DETAIL_USERNAME = detail.G3E_FID.ToString(); DBManager.Instance.Update(detail); } return(t2.G3E_ID); }
/// <summary> /// 生成新的G3E系列ID /// </summary> /// <param name="OldG3e_fid"></param> /// <param name="OldG3e_id"> </param> /// <param name="newObjectId"> </param> public void CreateG3EFID(long OldG3e_fid, long OldG3e_id, ObjectId newObjectId) { var entity = PublicMethod.Instance.GetObject(newObjectId, OpenMode.ForRead); if (!_G3EIdMapping.ContainsKey(OldG3e_fid)) { var ed = new ExpandsData { newG3e_id = CYZCommonFunc.getid(), newG3e_fid = CYZCommonFunc.getid(), oldG3e_id = OldG3e_id, oldG3e_fid = OldG3e_fid, newObjectId = newObjectId }; _G3EIdMapping.Add(OldG3e_fid, ed); } else { //只存储点符号的对象ID(不存储标注) if (entity is BlockReference) { var aa = _G3EIdMapping[OldG3e_fid]; aa.newObjectId = newObjectId; } } }
private void Add_Gg_jx_shbd_lb(long g3efid) { //增加Gg_jx_shbd_lb var t = DBManager.Instance.GetEntity <Detailreference_n>(o => o.G3E_FID == FID); var shblb = new Gg_jx_shbd_lb { G3E_ALIGNMENT = 5, G3E_ID = CYZCommonFunc.getid(), G3E_FNO = 160, G3E_CNO = 16005, G3E_FID = g3efid, G3E_CID = 1, G3E_DETAILID = t.G3E_DETAILID, LTT_ID = MapConfig.Instance.LTTID, EntityState = EntityState.Insert }; if (false == DBManager.Instance.Insert(shblb)) { throw new Exception("Add_Gg_jx_shbd_lb: 插入失败!"); } #region //GDO_GID //G3E_GEOMETRY //CD_SSDW //LTT_TID //LTT_STATUS //LTT_DATE #endregion }
/// <summary> /// 新增受电馈线 /// </summary> /// <param name="dbEntity"></param> /// <returns>返回G3e_id</returns> public static long InsertSDKX(Common_n dbEntity) { try { var cid = DBEntityFinder.Instance.GetSdkxCount(dbEntity.G3E_FID); cid++; var g3eid = CYZCommonFunc.getid(); var newEnt = new Gg_pd_sdkx_ac { G3E_ID = g3eid, G3E_FID = dbEntity.G3E_FID, G3E_FNO = dbEntity.G3E_FNO, G3E_CID = cid, G3E_CNO = 14904, LTT_DATE = dbEntity.LTT_DATE, LTT_ID = MapConfig.Instance.LTTID, LTT_STATUS = dbEntity.LTT_STATUS, LTT_TID = dbEntity.LTT_TID, SCM_DID = dbEntity.SCM_DID, GDBDZ = dbEntity.CD_SSBDZ, KXH = dbEntity.CD_SSXL, EntityState = EntityState.Insert }; DBManager.Instance.Insert(newEnt); return(newEnt.G3E_ID); } catch (Exception ex) { LogManager.Instance.Error(ex); } return(0); }
/// <summary> /// 添加包含关系 /// </summary> /// <param name="cid"></param> /// <param name="dgG3e_fid"></param> /// <param name="dxPt"></param> public static int AddContain(int cid, long dgG3e_fid, ElectronSymbol dxPt) { try { cid++; var g3e_id = CYZCommonFunc.getid(); var contain = new Contain_n { G3E_CID = cid, G3E_FNO = dxPt.G3E_FNO, G3E_FID = dxPt.G3E_FID, G3E_CNO = 38, G3E_ID = g3e_id, G3E_OWNERFID = dgG3e_fid, G3E_OWNERFNO = 201, EntityState = EntityState.Insert, LTT_ID = MapConfig.Instance.LTTID }; DBManager.Instance.Insert(contain); } catch (Exception ex) { LogManager.Instance.Error(ex); } return(cid); }
private IEnumerable <Gg_pd_jlb_n> GetJLB_NS() { try { var jlbs = new List <Gg_pd_jlb_n>(); var detail = DBManager.Instance.GetEntities <Detailreference_n>(o => o.G3E_FID == detail_fid && o.EntityState != EntityState.Delete).FirstOrDefault();//为空 if (detail == null) { var df = new Detailreference_n { G3E_CID = 1, G3E_ID = detail_id, G3E_CNO = 35, G3E_FID = detail_fid, G3E_FNO = (int)detail_fno, LTT_ID = MapConfig.Instance.LTTID, EntityState = EntityState.Insert, G3E_DETAILID = CYZCommonFunc.getid() }; DBManager.Instance.Insert(df); return(null); } var jxjlbs = DBManager.Instance.GetEntities <Gg_jx_jlb_pt>(o => o.G3E_DETAILID == detail.G3E_DETAILID && o.EntityState != EntityState.Delete); if (jxjlbs == null) { return(null); } foreach (var jlb in jxjlbs) { jlbs.Add(GetJLB_N(jlb.G3E_FID)); } return(jlbs); } catch (NotExistException ex) { if (ex.Message == "Detailreference_n不存在") { var type = TypeCache.Instance.GetTypeFromCache(typeof(DBEntity), "Detailreference_n"); var connectn = ReflectionUtils.CreateObject(new { }, type) as DBEntity; DBManager.Instance.Insert(connectn); // 插入变压器数据 } else if (ex.Message == "Gg_jx_jlb_pt不存在") { var type = TypeCache.Instance.GetTypeFromCache(typeof(DBEntity), "Gg_jx_jlb_pt"); var connectn = ReflectionUtils.CreateObject(new { }, type) as DBEntity; DBManager.Instance.Insert(connectn); } else { PublicMethod.Instance.AlertDialog(ex.Message); } return(null); } catch (Exception) { return(null); } }
/// <summary> /// 添加组件表 /// </summary> /// <param name="className"></param> /// <param name="dbEntity"></param> /// <param name="es"></param> public void InsertBrotherTable(string className, DBEntity dbEntity, ElectronSymbol es) { try { var newObject_n = dbEntity.Clone() as ElectronBase; switch (className) { case "Connectivity_n": _connectionTableData.Add(newObject_n as Connectivity_n); newObject_n.EntityState = EntityState.Add_Nal_Nal; break; case "Common_n": //存储电房的G3E_ID if (es.G3E_GEOMETRY is Polygon) { _subordinateDfTableData.Add((dbEntity as ElectronBase).G3E_ID, newObject_n as Common_n); } else { var comm = newObject_n as Common_n; _subordinateSbTableData.Add(comm.G3E_ID, comm); } //清空设备名称 ClearCommon(newObject_n); newObject_n.EntityState = EntityState.Insert; break; case "Detailreference_n": var detailref = newObject_n as Detailreference_n; detailref.G3E_DETAILID = CYZCommonFunc.getid(); detailref.EntityState = EntityState.Insert; detailref.DETAIL_USERNAME = es.G3E_FID.ToString(); newObject_n = detailref; break; case "Gg_pd_gnwzmc_n": ClearGnwzmcn(newObject_n); newObject_n.EntityState = EntityState.Insert; break; default: newObject_n.EntityState = EntityState.Insert; break; } newObject_n.G3E_FID = es.G3E_FID; newObject_n.G3E_ID = es.G3E_ID; newObject_n.SetValue("LTT_ID", (decimal)MapConfig.Instance.LTTID); DBManager.Instance.Insert(newObject_n); }catch (Exception ex) { LogManager.Instance.Error(ex); } }
/// <summary> /// 生成新的G3E系列ID /// </summary> /// <param name="OldG3e_fid"></param> /// <param name="oldParentG3e_id"> </param> /// <param name="g3e_IdMapping"></param> /// <returns></returns> public Dictionary <long, ExpandsData> CreateG3EFID(long OldG3e_fid, long oldParentG3e_id, Dictionary <long, ExpandsData> g3e_IdMapping) { if (!g3e_IdMapping.ContainsKey(OldG3e_fid)) { var ed = new ExpandsData { newG3e_id = CYZCommonFunc.getid(), newG3e_fid = CYZCommonFunc.getid(), oldG3e_fid = OldG3e_fid, oldParentG3e_Id = oldParentG3e_id }; g3e_IdMapping.Add(OldG3e_fid, ed); } return(g3e_IdMapping); }
/// <summary> /// 新增杂项标注 /// </summary> /// <param name="parentfid">关联设备G3e_fid</param> /// <param name="text">标注内容</param> /// <param name="bzlx">标注类型</param> /// <param name="ssdw">所属单位</param> /// <param name="mpt">标注坐标</param> /// <param name="pt">返回标注坐标表对象</param> /// <returns>true成功,反之</returns> public static bool InsertZXBZ(long parentfid, string text, string bzlx, string ssdw, Multipoint mpt, ref ElectronSymbol pt) { try { var g3e_id = CYZCommonFunc.getid(); var g3e_fid = CYZCommonFunc.getid(); InsertZXBZN(g3e_id, g3e_fid, parentfid, text, bzlx, ssdw); InsertZXBZLB(g3e_id, g3e_fid); pt = InsertZXBZLBSDOGEOM(g3e_id, g3e_fid, mpt); return(true); }catch (Exception ex) { LogManager.Instance.Error("新增杂项标注错误!" + ex); } return(false); }
/// <summary> /// 判断新增设备 打开台账编辑页面 /// </summary> public static string IsNewEquipmentAndURL(ObjectId objectId) { var urlstr = string.Empty; long id = 0, fid = 0, fno = 0; try { var selectedEntity = PublicMethod.Instance.GetObject(objectId, OpenMode.ForRead); if (selectedEntity is DBText) { PublicMethod.Instance.ShowMessage("你选择的是设备标注,请重新选择!"); return(null); } if (DBEntityFinder.Instance.GetG3EIds(selectedEntity.ObjectId, ref id, ref fid, ref fno)) { var ptVlaue = PublicMethod.Instance.GetDBSymbolFinder(objectId) as ElectronSymbol; var com = CYZCommonFunc.GetModelEntity(fid) as Common_n; if (ptVlaue == null || com == null) { return(string.Empty); } //获取gis工单ID var ltt_id = ptVlaue.GetValue("LTT_ID").ToString(); var sbmc = string.Empty; if (!string.IsNullOrEmpty(com.SBMC)) { sbmc = BitConverter.ToString(Encoding.UTF8.GetBytes(com.SBMC)).Replace("-", "<M>"); } //获取FID 新增设备需加a var g3efid = ptVlaue.EntityState == EntityState.Insert ? string.Format("a{0}", fid) : fid.ToString(); //编辑设备台帐信息默认为'Y' urlstr = string.Format( "http://localhost:9090/emmis/equipGisMappingTemp/getInstallEquipments.gis?" + "g3e_fid={0}&" + "jobId={1}&" + "g3e_fno={2}&editAble=Y&" + "funcplaceName={3}&jgdh=009", g3efid, ltt_id, fno, sbmc); } } catch (System.Exception ex) { LogManager.Instance.Error(ex); } return(urlstr); }
private void Add_Gg_pd_dyshb_n(long g3efid) { //插入Gg_pd_dyshb_n表 var newEnt = new Gg_pd_dyshb_n { G3E_FID = g3efid, G3E_ID = CYZCommonFunc.getid(), G3E_FNO = 160, G3E_CNO = 16001, G3E_CID = 1, YDH = tbYDH.Text, YHXM = tbYHXM.Text, BH = tbBH.Text, GDH = tbGDH.Text, HBLX = tbHBLX.Text, DZJL = tbDZJL.Text, AZDZ = tbAZDZ.Text, CD_SSDW = tbCD_SSDW.Text, BXH = tbBXH.Text, YDLB = (String)(cbYDLB.SelectedItem), YHLX = (String)(cbYHLX.SelectedItem), SMZQ = (String)(cbSMZQ.SelectedItem), MBH = tbMBH.Text, BZ = tbBZ.Text, GZZT = (String)(cbGZZT.SelectedItem), CD_SSXL = tbCD_SSXL.Text, HH = tbHH.Text, XS = (String)(cbXS.SelectedItem), QT = tbQT.Text, SFYHYB = tbSFYHYB.Text, //BZ1 = String.Format("{0}@1@{1}", tbYDH.Text, tbBH.Text), //协议号需要配网去填 KHXYH = tbXYH.Text, LTT_ID = MapConfig.Instance.LTTID, EntityState = EntityState.Insert }; //newEnt.LTT_DATE; //newEnt.LTT_STATUS; //newEnt.LTT_TID; //newEnt.DWFX_SFSDY; //newEnt.CD_SSBDZ; if (false == DBManager.Instance.Insert(newEnt)) { throw new Exception("Add_Gg_pd_dyshb_n: 插入失败!"); } }
private void Add_Connectivity_n(long g3efid) { // 插入Connectivity_n var shbconn = new Connectivity_n { G3E_ID = CYZCommonFunc.getid(), G3E_FNO = 160, G3E_CNO = 31, G3E_FID = g3efid, G3E_CID = 1, NODE1_ID = 0, NODE2_ID = 0, LTT_ID = MapConfig.Instance.LTTID, EntityState = EntityState.Add_Nal_Nal }; if (false == DBManager.Instance.Insert(shbconn)) { throw new Exception("Add_Connectivity_n: 插入失败!"); } }
private static ElectronSymbol GetTjDBEntity(long oldG3e_fid, ElectronSymbol newObject_pt) { var parentGnwz = xmlDBManager.GetEntity <Gg_pd_gnwzmc_n>(oldG3e_fid); if (parentGnwz != null) { if (parentGnwz.GNWZ_FL2.Equals("台架")) { var comTJ = xmlDBManager.GetEntity <Common_n>(o => o.G3E_FNO == 199 && o.G3E_FID.ToString().Equals(parentGnwz.GNWZ_SSTJ)); if (comTJ != null) { var newG3e_id = CYZCommonFunc.getid(); var newG3e_fid = CYZCommonFunc.getid(); var com = xmlDBManager.GetEntity <Common_n>(comTJ.G3E_FID); InsertElectronBase(com, newG3e_id, newG3e_fid); var self = xmlDBManager.GetEntity <Gg_gz_tj_n>(comTJ.G3E_FID); if (self != null) { //更新变压器的fid self.GNWZ_FID = newObject_pt.G3E_FID.ToString(); InsertElectronBase(self, newG3e_id, newG3e_fid); } var gnwz = xmlDBManager.GetEntity <Gg_pd_gnwzmc_n>(comTJ.G3E_FID); if (gnwz != null) { InsertElectronBase(gnwz, newG3e_id, newG3e_fid); //更新父设备的所属台架 DBEntityCopy.Instance.UpdateGnwzSstj(newObject_pt.G3E_FID, newG3e_fid); } } } } return(newObject_pt); }
/// <summary> /// 点击确定按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OkButton_Click(object sender, EventArgs e) { DialogResult = DialogResult.OK; try { if (string.IsNullOrEmpty(FidText.Text)) { MessageBox.Show("FID不能为空!!!"); return; } if (string.IsNullOrEmpty(NameText.Text.Trim())) { MessageBox.Show("名称不能为空!!!"); return; } var sbmc = NameText.Text.Trim(); var com = DBManager.Instance.GetEntity <Common_n>(o => o.G3E_FID == long.Parse(FidText.Text)); if (com == null) { return; } if (m_ft == formType.regionAdd)//添加操作 { //查看是否重复添加 var kxNode = RegionalManagement.GetSeleteKX(); if (kxNode == null) { PublicMethod.Instance.ShowMessage("没有选择馈线,请再重试一遍\n"); //显示支线管理窗体 Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(RegionalManagement.GetCurActionForm()); return; } if (kxNode.Nodes.Cast <TreeNode>().Any(zx => zx.Name == FidText.Text)) { PublicMethod.Instance.ShowMessage("支线已经存在\n"); return; } //获取属性 if (String.IsNullOrEmpty(FidText.Text)) { throw new Exception(); } //查看是否删除状态 Gnwz_tz_zx newEnt = null; var tmp = DBEntityFinder.Instance.GetGnwzTzZx(long.Parse(FidText.Text)); if (tmp != null && tmp.EntityState == EntityState.Delete)//删除状态,恢复数据 { tmp.EntityState = EntityState.Update; DBManager.Instance.Update(tmp); } else//否则 { //插入支线表 newEnt = new Gnwz_tz_zx { ID = CYZCommonFunc.getid(), G3E_FID = com.G3E_FID, IN_TIME = DateTime.Now, EntityState = EntityState.Insert }; } if (!com.Equals(sbmc)) { //更新支线名称 com.SBMC = NameText.Text; com.EntityState = EntityState.Update; DBManager.Instance.Update(com); } //把支线添加入TreeView中 kxNode.Nodes.Add(newEnt.G3E_FID.ToString(), sbmc); DBManager.Instance.Insert(newEnt); //如果是原始的电缆或导线变成了支线也要更新公共表的备注字段 var propertyName = GenerateHelper.QueryZXField(com.G3E_FNO); if (!string.IsNullOrEmpty(propertyName)) { if (com.EntityState == EntityState.None) { com.EntityState = EntityState.Update; } com.SetAttribute(propertyName, com.G3E_FID.ToString()); DBManager.Instance.Update(com); } } else//编辑操作 { //更新支线名称 com.SBMC = NameText.Text; if (com.EntityState != EntityState.Insert) //如果之前不是insert { com.EntityState = EntityState.Update; //修改成update } DBManager.Instance.Update(com); //更新TreeView中支线名称 var kxNode = RegionalManagement.GetSeleteKX(); if (kxNode != null) { kxNode.Nodes.Find(FidText.Text, true)[0].Text = sbmc; } else { PublicMethod.Instance.ShowMessage("没有正确选择支线"); } } } catch (Exception exception) { PublicMethod.Instance.ShowMessage("操作过程中出现错误" + exception); } finally { this.Close(); } }
/// <summary> /// 添加属性表数据 /// </summary> /// <param name="cso"></param> /// <param name="es"></param> /// <returns></returns> private ElectronSymbol InsertElectronBase(CopySymbolObject cso, ElectronSymbol es) { var flag = false; var otherIdMapping = new Dictionary <long, ExpandsData>(); foreach (var dbEntity in cso.hsDBEntity) { var newObject = dbEntity.dbEntity as ElectronBase; if (dbEntity.className.Contains("Contain")) { //如果电杆存在,则根据电杆的FID去导线的包含关系表去查询, //根据导线的包含关系表中的G3E_OWNERFID是否等于电杆的FID, //反之只有导线复制的话,则取导线的任意一条对应的包含关系清空G3E_OWNERFID值即可。 if (es.G3E_FNO != 141) { SetContainTable(newObject, es.G3E_FID, false); } else { var bl = HasDg(cso.hsDBEntity); if (bl) { //判断当前数据是否有被电杆包含 if (HasDg(dbEntity.dbEntity)) { SetContainTable(newObject, es.G3E_FID, false); } } else { //导线有被电杆包含,但是当前没有拷贝电杆,所以只取其中任意一条包含数据,清空G3E_OWNERFID值即可。 if (!flag) { SetContainTable(newObject, es.G3E_FID, true); flag = true; } } } } else if (dbEntity.className.Equals("Gg_pd_sdkx_ac")) { var g3d_id = CYZCommonFunc.getid(); var sdkxac = newObject as Gg_pd_sdkx_ac; sdkxac.G3E_ID = g3d_id; sdkxac.G3E_FID = es.G3E_FID; sdkxac.EntityState = EntityState.Insert; sdkxac.SetValue("LTT_ID", (decimal)MapConfig.Instance.LTTID); DBManager.Instance.Insert(sdkxac); } else { //台架和开关柜 if (newObject.G3E_FNO == 198 || newObject.G3E_FNO == 199) { otherIdMapping = CreateG3EFID(newObject.G3E_FID, es.G3E_ID, otherIdMapping); AddKggDBEntity(es.G3E_FID, newObject, otherIdMapping); } else { InsertBrotherTable(dbEntity.className, newObject, es); } } } return(es); }
private void Add_Gg_jx_shbd_pt_sdogeom(long sdogid, long g3efid) { var shbsdo = new Gg_jx_shbd_pt_sdogeom { G3E_FID = g3efid, G3E_FNO = 160, G3E_ID = CYZCommonFunc.getid(), SDO_GID = sdogid, G3E_CNO = 16004, G3E_CID = 1, LTT_ID = MapConfig.Instance.LTTID, EntityState = EntityState.Insert }; double x, y; // 获取坐标 if (shbPositon != Point3d.Origin) { x = shbPositon.X; y = shbPositon.Y; } else { x = (MapConfig.Instance.ProjectionMaxX + MapConfig.Instance.ProjectionMinX) / 2; y = (MapConfig.Instance.ProjectionMaxY + MapConfig.Instance.ProjectionMinY) / 2; } var mpValue = new Multipoint(); mpValue.Points.Add(new Point(new[] { x, y, 0 })); mpValue.Points.Add(new Point(new[] { Math.Cos(0.0), Math.Sin(0.0), 0 })); shbsdo.G3E_GEOMETRY = mpValue; if (false == DBManager.Instance.Insert(shbsdo)) { throw new Exception("Add_Gg_jx_shbd_pt_sdogeom: 插入失败!"); } #region //shbsdo.SDO_ESEQ //SDO_ETYPE //SDO_SEQ //GDO_ATTRIBUTES //GDO_NORMAL1 //GDO_NORMAL2 //GDO_NORMAL3 //GDO_RADIUS //SDO_ORIENTATION //SDO_X1 //SDO_Y1 //SDO_X2 //SDO_Y2 //SDO_X3 //SDO_Y3 //SDO_X4 //SDO_Y4 //G3E_ID //G3E_FNO //G3E_FID //LTT_STATUS //LTT_DATE //LTT_TID #endregion }
/// <summary> /// 更新连接关系表 /// 把node1、node2相同的值更新 /// 把不相同的赋0 /// </summary> public void UpdateConnectionData() { var g3enode_cadnode = new Dictionary <string, string>(); var compare = _connectionTableData.Select(item => item.Clone() as Connectivity_n).ToList(); try { if (compare.Count > 0) { var nodes = GetNodes(compare); foreach (var item in compare) { bool bNode1 = false, bNode2 = false; if (g3enode_cadnode.ContainsKey(item.NODE1_ID.ToString())) { item.NODE1_ID = long.Parse(g3enode_cadnode[item.NODE1_ID.ToString()]); bNode1 = true; } else { Connectivity_n item1 = item; if (nodes.Count(o => o == item1.NODE1_ID.ToString()) > 1) { string nodeId = CYZCommonFunc.getid().ToString(); g3enode_cadnode.Add(item.NODE1_ID.ToString(), nodeId); item.NODE1_ID = long.Parse(nodeId); bNode1 = true; } else { item.NODE1_ID = 0; } } if (g3enode_cadnode.ContainsKey(item.NODE2_ID.ToString())) { item.NODE2_ID = long.Parse(g3enode_cadnode[item.NODE2_ID.ToString()]); bNode2 = true; } else { Connectivity_n item1 = item; if (nodes.Count(o => o == item1.NODE2_ID.ToString()) > 1) { string nodeId = CYZCommonFunc.getid().ToString(); g3enode_cadnode.Add(item.NODE2_ID.ToString(), nodeId); item.NODE2_ID = long.Parse(nodeId); bNode2 = true; } else { item.NODE2_ID = 0; } } if (bNode1 && bNode2) { item.EntityState = EntityState.Add_Add_Add; } else if (!bNode1 && bNode2) { item.EntityState = EntityState.Add_Nal_Add; } else if (!bNode1 && !bNode2) { item.EntityState = EntityState.Add_Nal_Nal; } else if (bNode1 && !bNode2) { item.EntityState = EntityState.Add_Add_Nal; } } compare.ForEach(o => DBManager.Instance.Update(o)); //处理从属关系 UpdateSubordinateTable(); //处理包含关系 UpdateContainTable(); } } catch (Exception ex) { LogManager.Instance.Error(ex); } finally { _connectionTableData.Clear(); _subordinateSbTableData.Clear(); _containDxTableData.Clear(); _containDgTableData.Clear(); _subordinateDfTableData.Clear(); } }
/// <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); }
private void btnOK_Click(object sender, EventArgs e) { try { //判断输入的属性规范 if (hasError()) { return; } if (Ft == formType.regionAdd)//添加操作 { //检查户表是否存在 var tmp = GetDYSHB_N(); if (tmp != null)//存在 { #region //如状态是Delete,则改回None if (tmp.EntityState == EntityState.Delete) { tmp.EntityState = EntityState.None; DBManager.Instance.Update(tmp); } //检查从属关系是否存在 var v = DBManager.Instance.GetEntity <Gg_jx_shbd_pt>(o => o.G3E_FID == FID); if (v != null)//存在 { //如状态是Delete,则改回None if (v.EntityState == EntityState.Delete) { v.EntityState = EntityState.None; DBManager.Instance.Update(v); } } else//不存在则插入 { var t = DBManager.Instance.GetEntity <Detailreference_n>(o => o.G3E_FID == FID); Gg_jx_shbd_pt t2 = new Gg_jx_shbd_pt(); t2.G3E_DETAILID = t.G3E_DETAILID; t2.G3E_FNO = 160; t2.G3E_CNO = 16004; t2.G3E_FID = tmp.G3E_FID; t2.G3E_ALIGNMENT = 0; t2.G3E_ID = CYZCommonFunc.getid(); t2.G3E_CID = 1; t2.LTT_ID = MapConfig.Instance.LTTID; t2.EntityState = EntityState.Insert; DBManager.Instance.Insert(t2); } #endregion } else//不存在 { var g3efid = CYZCommonFunc.getid(); //插入Gg_pd_dyshb_n表 Add_Gg_pd_dyshb_n(g3efid); //增加Gg_jx_shbd_pt表 var sdogid = Add_Gg_jx_shbd_pt(g3efid); //增加Gg_jx_shbd_pt_sdogeom Add_Gg_jx_shbd_pt_sdogeom(sdogid, g3efid); //增加Gg_jx_shbd_lb Add_Gg_jx_shbd_lb(g3efid); //增加Connectivity_n //Add_Connectivity_n(g3efid); g_newFid = g3efid; } } else//编辑操作 { //更新表数据 UpdateDYSHB(); } AZDZ = tbAZDZ.Text; DialogResult = DialogResult.OK; Close(); } catch (Exception ee) { PublicMethod.Instance.ShowMessage(String.Format("操作过程中出现错误:{0}", ee.Message)); } }
/// <summary> /// 得到当前集抄箱的户表集合 /// </summary> /// <returns>户表集合</returns> private IEnumerable <Gg_pd_dyshb_n> GetSHB_NS() { try { string alertMessage = ""; var shbs = new List <Gg_pd_dyshb_n>(); var detail = DBManager.Instance.GetEntities <Detailreference_n>(o => o.G3E_FID == detail_fid && o.EntityState != EntityState.Delete).FirstOrDefault(); if (detail == null) { PublicMethod.Instance.Add_Detailreference_n(detail_id, detail_fid, detail_fno); return(null); } // 更正详图信息 if (detail.DETAIL_USERNAME == null) { detail.DETAIL_USERNAME = detail.G3E_FID.ToString(); } if (detail.G3E_DETAILID == null) { detail.G3E_DETAILID = CYZCommonFunc.getid(); } if (detail.EntityState != EntityState.Insert) { detail.EntityState = EntityState.Update; } var jxshbs = DBManager.Instance.GetEntities <Gg_jx_shbd_pt>(o => o.G3E_DETAILID == detail.G3E_DETAILID && o.EntityState != EntityState.Delete); if (jxshbs == null) { return(null); } foreach (var shb in jxshbs) { var s = GetSHB_N(shb.G3E_FID); if (s == null) { alertMessage += " " + shb.G3E_FID; continue; } shbs.Add(s); } if (!string.IsNullOrEmpty(alertMessage)) { PublicMethod.Instance.AlertDialog("在Gg_pd_dyshb_n表没有FID为" + alertMessage + " 的数据."); } return(shbs); } catch (NotExistException ex) { if (ex.Message.Contains("不存在")) { var strlx = ex.Message.Replace("不存在", ""); var type = TypeCache.Instance.GetTypeFromCache(typeof(DBEntity), strlx); var connectn = ReflectionUtils.CreateObject(new {}, type) as DBEntity; DBManager.Instance.Insert(connectn); } else { PublicMethod.Instance.AlertDialog(ex.Message); } return(null); } catch (Exception ex) { PublicMethod.Instance.AlertDialog(ex.Message); return(null); } }
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"); } }
private IEnumerable <Gg_pd_jlb_n> GetJLB_NS() { try { string alertMessage = ""; var detail = DBManager.Instance.GetEntities <Detailreference_n>( o => o.G3E_FID == detail_fid && o.EntityState != EntityState.Delete).FirstOrDefault(); //为空 if (detail == null) { // 添加详图数据 PublicMethod.Instance.Add_Detailreference_n(detail_id, detail_fid, detail_fno); return(null); } if (detail.DETAIL_USERNAME == null) { detail.DETAIL_USERNAME = detail.G3E_FID.ToString(); } if (detail.G3E_DETAILID == null) { detail.G3E_DETAILID = CYZCommonFunc.getid(); } if (detail.EntityState != EntityState.Insert) { detail.EntityState = EntityState.Update; } DBManager.Instance.Update(detail); var jlbs = new List <Gg_pd_jlb_n>(); var jxjlbs = DBManager.Instance.GetEntities <Gg_jx_jlb_pt>( o => o.G3E_DETAILID == detail.G3E_DETAILID && o.EntityState != EntityState.Delete); if (jxjlbs == null) { return(null); } foreach (var jlb in jxjlbs) { var s = GetJLB_N(jlb.G3E_FID); if (s == null) { alertMessage += " " + jlb.G3E_FID; continue; } jlbs.Add(s); } if (!string.IsNullOrEmpty(alertMessage)) { PublicMethod.Instance.AlertDialog("在Gg_pd_jlb_n表没有FID为" + alertMessage + " 的数据."); } return(jlbs); } catch (NotExistException ex) { PublicMethod.Instance.NotExistTable(ex); return(null); } catch (Exception) { return(null); } }
/// <summary> /// 更新变压器的详图设备馈线属性 /// </summary> /// <param name="detail_fid">变压器G3E_FID</param> /// <returns></returns> public void UpdateJLB(long detail_fid) { try { var detail = DBManager.Instance.GetEntities <Detailreference_n>(o => o.G3E_FID == detail_fid && o.EntityState != EntityState.Delete).FirstOrDefault(); if (detail == null) { return; } // 更正详图信息 if (detail.DETAIL_USERNAME == null) { detail.DETAIL_USERNAME = detail.G3E_FID.ToString(); } if (detail.G3E_DETAILID == null) { detail.G3E_DETAILID = CYZCommonFunc.getid(); } if (detail.EntityState != EntityState.Insert) { detail.EntityState = EntityState.Update; } DBManager.Instance.Update(detail); // 得到 详图设备 var jxjlbs = DBManager.Instance.GetEntities <Gg_jx_jlb_pt>(o => o.G3E_DETAILID == detail.G3E_DETAILID && o.EntityState != EntityState.Delete); if (jxjlbs == null) { return; } // 得到 计量表 或 变压器 公共属性 var detail_com = DBManager.Instance.GetEntity <Common_n>(detail_fid); if (detail_com == null) { return; } // 更新详图设备馈线属性 foreach (var jlb in jxjlbs) { var s = GetDEV_COM(jlb.G3E_FID); if (s == null) { continue; } s.CD_SSDW = detail_com.CD_SSDW; s.CD_SSXL = detail_com.CD_SSXL; s.CD_SSBDZ = detail_com.CD_SSBDZ; //s.GNWZ_SSGDS = detail_com.GNWZ_SSGDS; if (s.EntityState != EntityState.Insert) { s.EntityState = EntityState.Update; } DBManager.Instance.Update(s); } } catch (NotExistException ex) { PublicMethod.Instance.NotExistTable(ex); } catch (Exception) { } }
public void autoc() { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Database db = HostApplicationServices.WorkingDatabase; Editor ed = doc.Editor; try { PublicMethod.Instance.AlertDialog("请选择第一个设备:"); PromptEntityResult per1 = ed.GetEntity(""); if (per1.Status != PromptStatus.OK) { return; } // 工单判断 if (DBEntityFinder.Instance.VerifyLTTID(per1.ObjectId) == false) { PublicMethod.Instance.ShowMessage("您选择的设备没有被锁定,请重新选择\n"); return; } long fid = 0, id = 0, fno = 0; DBEntityFinder.Instance.GetG3EIds(per1.ObjectId, ref id, ref fid, ref fno); var conn = DBManager.Instance.GetEntity <Connectivity_n>(fid); if (conn == null) { ed.WriteMessageWithReturn("该设备没有连接关系,Connectivity_n表的数据。\n"); return; } if (conn.NODE2_ID != 0) { PublicMethod.Instance.AlertDialog("该设备已有连接关系。"); return; } long[] sdarr = { 11, 72, 79, 85, 120, 143, 167, 173 }; if (sdarr.Contains(conn.G3E_FNO)) { PublicMethod.Instance.AlertDialog("第一个设备不能是仅有一个连接点的设备,如: 接地刀闸,母线"); return; } changCol(per1.ObjectId); PublicMethod.Instance.AlertDialog("请选择第二个设备:"); PromptEntityResult per2 = ed.GetEntity(""); if (per2.Status != PromptStatus.OK || per1.ObjectId == per2.ObjectId) { return; } // 工单判断 if (DBEntityFinder.Instance.VerifyLTTID(per2.ObjectId) == false) { PublicMethod.Instance.ShowMessage("您选择的设备没有被锁定,请重新选择\n"); return; } // 把两个设备放进要过滤的列表 if (!serobjs.Contains(per1.ObjectId)) { serobjs.Add(per1.ObjectId); } if (!serobjs.Contains(per2.ObjectId)) { serobjs.Add(per2.ObjectId); } // 得到当前视图 ViewTableRecord view = ed.GetCurrentView(); // 获取一个新的id int nodeid = CYZCommonFunc.getid(); DCadApi.isModifySymbol = true; // 判断前两个设备是否能相连 if (obj21obj(nodeid, per1.ObjectId, per2.ObjectId)) { using (doc.LockDocument()) { db.UpdateExt(true); ed.ZoomExtents(); // 视图最大化 autoconn(per2.ObjectId); ed.SetCurrentView(view); // 还原视图 } TopologyMethods.bChangeTopo = true; PublicMethod.Instance.AlertDialog("连接结束!"); } } catch (Exception ex) { ed.WriteMessageWithReturn(ex); } finally { DCadApi.isModifySymbol = false; clearCol(); serobjs.Clear(); } }
/// <summary> /// 更新集抄箱的详图设备馈线属性 /// </summary> /// <param name="detail_fid">集抄箱G3E_FID</param> /// <returns></returns> public void UpdateSHB(long detail_fid) { try { var detail = DBManager.Instance.GetEntities <Detailreference_n>(o => o.G3E_FID == detail_fid && o.EntityState != EntityState.Delete).FirstOrDefault(); if (detail == null) { return; } // 更正详图信息 if (detail.DETAIL_USERNAME == null) { detail.DETAIL_USERNAME = detail.G3E_FID.ToString(); } if (detail.G3E_DETAILID == null) { detail.G3E_DETAILID = CYZCommonFunc.getid(); } if (detail.EntityState != EntityState.Insert) { detail.EntityState = EntityState.Update; } // 得到 详图设备 var jxshbs = DBManager.Instance.GetEntities <Gg_jx_shbd_pt>(o => o.G3E_DETAILID == detail.G3E_DETAILID && o.EntityState != EntityState.Delete); if (jxshbs == null) { return; } // 得到集抄箱的自身属性 var shb_n = DBManager.Instance.GetEntity <Gg_pd_cbx_n>(detail_fid); foreach (var shb in jxshbs) { var s = DBManager.Instance.GetEntity <Gg_pd_dyshb_n>(shb.G3E_FID); if (s == null) { continue; } s.CD_SSDW = shb_n.CD_SSDW; s.CD_SSXL = shb_n.CD_SSXL; if (s.EntityState != EntityState.Insert) { s.EntityState = EntityState.Update; } DBManager.Instance.Update(s); } } catch (NotExistException ex) { if (ex.Message.Contains("不存在")) { var strlx = ex.Message.Replace("不存在", ""); var type = TypeCache.Instance.GetTypeFromCache(typeof(DBEntity), strlx); var connectn = ReflectionUtils.CreateObject(new { }, type) as DBEntity; DBManager.Instance.Insert(connectn); } else { PublicMethod.Instance.AlertDialog(ex.Message); } } catch (Exception ex) { PublicMethod.Instance.AlertDialog(ex.Message); } }
/// <summary> /// 添加线 /// </summary> /// <param name="fid">杆的Fid</param> /// <param name="selFid">线的Fid</param> public static void addLine(long fid, long selFid) { // 判断杆在contain表中是否有数据 //var role = DBManager.Instance.GetEntities<Contain_n>(o => o.G3E_FID == fid && o.EntityState != EntityState.Delete).FirstOrDefault(); //if (null == role) //{ // LogManager.Instance.Error(String.Format("Contain_n 没有此杆的数据,不能做包含关系.杆G3e_Fid = {0}\n", fid)); // PublicMethod.Instance.AlertDialog(String.Format("Contain_n 没有此杆的数据,不能做包含关系.杆G3e_Fid = {0}\n", fid)); // return; //} // 工单判断 if (false == DBEntityFinder.Instance.VerifyLTTID(selFid)) { PublicMethod.Instance.AlertDialog(selFid + " 10kV 导线没有被工单锁定,不能包含."); return; } // 判断是否已经被此线重复包含 var v = DBManager.Instance.GetEntity <Contain_n>(o => o.G3E_FID == selFid && o.EntityState != EntityState.Delete && o.EntityState != EntityState.InsertDelete && o.G3E_OWNERFID == fid); if (null != v) { PublicMethod.Instance.AlertDialog(selFid + " 10kV 导线已经被此杆包含.\n"); return; } // 获取实体对象 var _v = DBManager.Instance.GetEntities <Contain_n>(o => o.G3E_FID == selFid).Where(o => o.EntityState != EntityState.Delete); var nv = new Contain_n { G3E_FNO = 141, G3E_FID = selFid, G3E_CNO = 38, G3E_ID = CYZCommonFunc.getid(), G3E_OWNERFID = fid, G3E_OWNERFNO = 201, LTT_ID = MapConfig.Instance.LTTID, LTT_DATE = null, LTT_STATUS = null }; if (_v.Any()) { v = _v.OrderBy(o => o.G3E_CID).Last(); if (0 == v.G3E_OWNERFID) { v.G3E_OWNERFID = fid; v.G3E_OWNERFNO = 201; if (v.EntityState == EntityState.None) { v.EntityState = EntityState.Update; } DBManager.Instance.Update(v); } else { nv.G3E_CID = v.G3E_CID + 1; // 更新实体ownerid nv.EntityState = EntityState.Insert; DBManager.Instance.Insert(nv); } } else { nv.G3E_CID = 1; // 更新实体ownerid nv.EntityState = EntityState.Insert; DBManager.Instance.Insert(nv); if (DBManager.Instance.GetEntities <Contain_n>(o => o.G3E_FID == fid).All(o => o.EntityState == EntityState.Delete)) { var onv = new Contain_n { G3E_FNO = 201, G3E_FID = fid, G3E_CNO = 38, G3E_CID = 1, G3E_ID = CYZCommonFunc.getid(), G3E_OWNERFID = 0, G3E_OWNERFNO = 0, LTT_ID = MapConfig.Instance.LTTID, LTT_DATE = null, LTT_STATUS = null, EntityState = EntityState.Insert }; DBManager.Instance.Insert(onv); } } }
/// <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> /// <param name="fid">线的FID</param> /// <param name="selFid">杆的FID</param> public static void addRole(long fid, long selFid) { // 判断杆在contain表中是否有数据 //var role = // DBManager.Instance.GetEntities<Contain_n>( // o => o.G3E_FID == selFid && o.EntityState != EntityState.Delete).FirstOrDefault(); //if (null == role) //{ // PublicMethod.Instance.AlertDialog(String.Format("Contain_n 没有此杆的数据,不能做包含关系.杆G3e_Fid = {0}\n", selFid)); // return; //} // 获取实体对象(线与杆) var _s = DBManager.Instance.GetEntity <Contain_n>( o => o.G3E_FID == fid && o.G3E_OWNERFID == selFid && o.EntityState != EntityState.Delete); // 判断是否已经被此杆重复包含 if (null != _s) { PublicMethod.Instance.AlertDialog("10kV 导线已经被此杆包含.\n"); return; } var __s = DBManager.Instance.GetEntities <Contain_n>(o => o.G3E_FID == fid && o.EntityState != EntityState.Delete); var _nv = new Contain_n { G3E_FNO = 141, G3E_FID = fid, G3E_CNO = 38, G3E_ID = CYZCommonFunc.getid(), G3E_OWNERFID = selFid, G3E_OWNERFNO = 201, LTT_ID = MapConfig.Instance.LTTID, LTT_DATE = null, LTT_STATUS = null }; if (__s.Any()) { _s = __s.OrderBy(o => o.G3E_CID).Last(); // 更改实体信息 if (0 == _s.G3E_OWNERFID) { if (_s.EntityState == EntityState.None) { _s.EntityState = EntityState.Update; } _s.G3E_OWNERFID = selFid; _s.G3E_OWNERFNO = 201; DBManager.Instance.Update(_s); } else { _nv.G3E_CID = _s.G3E_CID + 1; // 更新实体ownerid _nv.EntityState = EntityState.Insert; DBManager.Instance.Insert(_nv); } } else { _nv.G3E_CID = 1; // 更新实体ownerid _nv.EntityState = EntityState.Insert; DBManager.Instance.Insert(_nv); //DBManager.Instance.Update(_nv); } }