Esempio n. 1
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);
 }
Esempio n. 2
0
        /// <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);
            }
        }
Esempio n. 3
0
        /// <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);
                }
            }
        }