Esempio n. 1
0
 private void UpdateConnectionData(long?NODE_ID, Connectivity_n newConn)
 {
     try
     {
         if (NODE_ID == 0)
         {
             return;
         }
         var entityState = newConn.EntityState.ToString();
         //站房母线不更改单个节点
         if (newConn.G3E_FNO == 143)
         {
             return;
         }
         if (newConn.NODE1_ID == NODE_ID)
         {
             newConn.NODE1_ID = 0;
             if (newConn.EntityState == EntityState.None || newConn.EntityState == EntityState.Update)
             {
                 newConn.EntityState = EntityState.Old_Del_Old;
             }
             else
             {
                 var strEntityState = entityState.Remove(4, 3).Insert(4, "Del");
                 newConn.EntityState =
                     (EntityState)Enum.Parse(typeof(EntityState), strEntityState);
             }
         }
         else
         {
             newConn.NODE2_ID = 0;
             if (newConn.EntityState == EntityState.None || newConn.EntityState == EntityState.Update)
             {
                 newConn.EntityState = EntityState.Old_Old_Del;
             }
             else
             {
                 var strEntityState = entityState.Remove(8, 3).Insert(8, "Del");
                 newConn.EntityState =
                     (EntityState)Enum.Parse(typeof(EntityState), strEntityState);
             }
         }
         DBManager.Instance.Update(newConn);
     }
     catch (Exception ex)
     {
         LogManager.Instance.Error(ex);
     }
 }
Esempio n. 2
0
 public static void sinNodDevJudge(Connectivity_n conn)
 {
     if (PublicMethod.Instance.N2is0.Contains(conn.G3E_FNO))
     {
         conn.NODE2_ID = 0;
     }
     else if (PublicMethod.Instance.N1isN2.Contains(conn.G3E_FNO))
     {
         conn.NODE2_ID = conn.NODE1_ID;
         //  是否对2头的EntityState作操作
         if (conn.EntityState.ToString().Length > 8)
         {
             ChangEntStatus(conn, 2, conn.EntityState.ToString().Substring(4, 3));
         }
     }
 }
Esempio n. 3
0
 public static void ChangEntStatus(Connectivity_n dest_conn, int dest_index, Connectivity_n source_conn, int source_index)
 {
     if (source_conn.EntityState == EntityState.None ||
         source_conn.EntityState == EntityState.Update ||
         source_conn.EntityState == EntityState.Insert)
     {
         ChangEntStatus(dest_conn, dest_index, "Nal");
     }
     else
     {
         if (source_index == 1)
         {
             ChangEntStatus(dest_conn, dest_index, (source_conn.EntityState.ToString().Substring(4, 3)));
         }
         else if (source_index == 2)
         {
             ChangEntStatus(dest_conn, dest_index, (source_conn.EntityState.ToString().Substring(8, 3)));
         }
     }
 }
Esempio n. 4
0
 // 一个连接点的设备特殊处理
 void sinNodDevJudge(Connectivity_n conn)
 {
     int[] sinNodDevArr = { 11, 72, 79, 85, 120, 143, 167, 173 };
     if (!sinNodDevArr.Contains(conn.G3E_FNO))
     {
         return;
     }
     if (conn.NODE1_ID == 0 && conn.NODE2_ID != 0)
     {
         conn.NODE1_ID = conn.NODE2_ID;
     }
     else if (conn.NODE2_ID == 0 && conn.NODE1_ID != 0)
     {
         conn.NODE2_ID = conn.NODE1_ID;
     }
     else
     {
         PublicMethod.Instance.Editor.WriteMessageWithReturn("数据出错!");
     }
 }
Esempio n. 5
0
        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: 插入失败!");
            }
        }
Esempio n. 6
0
        public static void ChangEntStatus(Connectivity_n conn, int nodindx, string DelOrAdd)
        {
            switch (conn.EntityState)
            {
            case EntityState.Insert:
                conn.EntityState = ChangEntStatus(EntityState.Add_Nal_Nal, nodindx, DelOrAdd);
                break;

            case EntityState.None:
                conn.EntityState = ChangEntStatus(EntityState.Old_Nal_Nal, nodindx, DelOrAdd);
                break;

            case EntityState.Update:
                conn.EntityState = ChangEntStatus(EntityState.Old_Nal_Nal, nodindx, DelOrAdd);
                break;

            default:
                conn.EntityState = ChangEntStatus(conn.EntityState, nodindx, DelOrAdd);
                break;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 删除与fid连接的brefid的设备(打断列表中单个设备)
        /// </summary>
        /// <param name="fid"></param>
        /// <param name="brefid"></param>
        /// <param name="txnod">与fid连接的端</param>
        public static void BreakNodeByFid(long fid, long brefid, string txnod)
        {
            bool ismx = false;
            var  conn =
                DBManager.Instance.GetEntities <Connectivity_n>(
                    o => o.G3E_FID == fid && o.EntityState != EntityState.Delete).FirstOrDefault();

            if (conn == null)
            {
                PublicMethod.Instance.AlertDialog(String.Format("Connectivity_n 没有 {0} 数据!", fid));
            }
            Connectivity_n node1;
            Connectivity_n node2 = null;

            if (txnod == "连接1")  // 获取与当前设备节点1相连的设备
            {
                node1 =
                    DBManager.Instance.GetEntities <Connectivity_n>(
                        o => o.NODE1_ID == conn.NODE1_ID && o.EntityState != EntityState.Delete && o.G3E_FID == brefid)
                    .FirstOrDefault();
                if (node1 == null)
                {
                    node2 =
                        DBManager.Instance.GetEntities <Connectivity_n>(
                            o => o.NODE2_ID == conn.NODE1_ID && o.EntityState != EntityState.Delete && o.G3E_FID == brefid)
                        .FirstOrDefault();
                }
            }
            else
            {
                node1 =
                    DBManager.Instance.GetEntities <Connectivity_n>(
                        o => o.NODE1_ID == conn.NODE2_ID && o.EntityState != EntityState.Delete && o.G3E_FID == brefid)
                    .FirstOrDefault();
                if (node1 == null)
                {
                    node2 =
                        DBManager.Instance.GetEntities <Connectivity_n>(
                            o => o.NODE2_ID == conn.NODE2_ID && o.EntityState != EntityState.Delete && o.G3E_FID == brefid)
                        .FirstOrDefault();
                }
            }
            long node1id = 0;
            long node2id = 0;

            #region 非母线

            if (node1 != null)
            {
                // 母线特殊处理
                if (node1.G3E_FNO != 143)
                {
                    if (node1.NODE1_ID != null)
                    {
                        node1id = (long)node1.NODE1_ID;
                    }
                    node1.NODE1_ID = 0;
                    ChangEntStatus(node1, 1, "Del");
                    sinNodDevJudge(node1);
                    DBManager.Instance.Update(node1);
                }
                else
                {
                    ismx = true;
                }
            }
            else if (node2 != null)
            {
                if (node2.NODE2_ID != null)
                {
                    node2id = (long)node2.NODE2_ID;
                }
                node2.NODE2_ID = 0;
                ChangEntStatus(node2, 2, "Del");
                sinNodDevJudge(node2);
                DBManager.Instance.Update(node2);
            }
            // 单个设备相连处理
            if (node1id != 0)
            {
                var sigconn =
                    DBManager.Instance.GetEntities <Connectivity_n>(
                        o => o.NODE1_ID == node1id && o.EntityState != EntityState.Delete);
                if (sigconn.Count() == 1)
                {
                    var temsig = sigconn.FirstOrDefault();
                    if (temsig != null)
                    {
                        temsig.NODE1_ID = 0;
                        ChangEntStatus(temsig, 1, "Del");
                        sinNodDevJudge(temsig);
                        DBManager.Instance.Update(temsig);
                    }
                }
                sigconn =
                    DBManager.Instance.GetEntities <Connectivity_n>(
                        o => o.NODE2_ID == node1id && o.EntityState != EntityState.Delete);
                if (sigconn.Count() == 1)
                {
                    var temsig = sigconn.FirstOrDefault();
                    if (temsig != null)
                    {
                        temsig.NODE2_ID = 0;
                        ChangEntStatus(temsig, 2, "Del");
                        sinNodDevJudge(temsig);
                        DBManager.Instance.Update(temsig);
                    }
                }
            }
            else if (node2id != 0)
            {
                var sigconn =
                    DBManager.Instance.GetEntities <Connectivity_n>(
                        o => o.NODE1_ID == node2id && o.EntityState != EntityState.Delete);
                if (sigconn.Count() == 1)
                {
                    var temsig = sigconn.FirstOrDefault();
                    if (temsig != null)
                    {
                        temsig.NODE1_ID = 0;
                        ChangEntStatus(temsig, 1, "Del");
                        sinNodDevJudge(temsig);
                        DBManager.Instance.Update(temsig);
                    }
                }
                sigconn =
                    DBManager.Instance.GetEntities <Connectivity_n>(
                        o => o.NODE2_ID == node2id && o.EntityState != EntityState.Delete);
                if (sigconn.Count() == 1)
                {
                    var temsig = sigconn.FirstOrDefault();
                    if (temsig != null)
                    {
                        temsig.NODE2_ID = 0;
                        ChangEntStatus(temsig, 2, "Del");
                        sinNodDevJudge(temsig);
                        DBManager.Instance.Update(temsig);
                    }
                }
            }

            #endregion

            #region 母线特殊处理

            if (ismx)
            {
                long nodeidd = 0;
                if (txnod == "连接1")
                {
                    if (conn != null)
                    {
                        if (conn.NODE1_ID != null)
                        {
                            nodeidd = (long)conn.NODE1_ID;
                        }
                        conn.NODE1_ID = 0;
                        ChangEntStatus(conn, 1, "Del");
                        sinNodDevJudge(conn);
                        DBManager.Instance.Update(conn);
                    }
                }
                else
                {
                    if (conn != null)
                    {
                        if (conn.NODE2_ID != null)
                        {
                            nodeidd = (long)conn.NODE2_ID;
                        }
                        conn.NODE2_ID = 0;
                        ChangEntStatus(conn, 2, "Del");
                        sinNodDevJudge(conn);
                        DBManager.Instance.Update(conn);
                    }
                }
                int count = 0;
                var d2m1  =
                    DBManager.Instance.GetEntities <Connectivity_n>(
                        o => o.NODE1_ID == nodeidd && o.G3E_FID != brefid && o.EntityState != EntityState.Delete);
                if (d2m1 != null)
                {
                    count += d2m1.Count();
                }
                var d2m2 =
                    DBManager.Instance.GetEntities <Connectivity_n>(
                        o => o.NODE2_ID == nodeidd && o.G3E_FID != brefid && o.EntityState != EntityState.Delete);
                if (d2m2 != null)
                {
                    count += d2m2.Count();
                }
                if (count == 0)
                {
                    var mxconn =
                        DBManager.Instance.GetEntities <Connectivity_n>(
                            o => o.G3E_FID == brefid && o.EntityState != EntityState.Delete).FirstOrDefault();
                    if (mxconn != null)
                    {
                        mxconn.NODE1_ID = 0;
                        ChangEntStatus(mxconn, 1, "Del");
                        sinNodDevJudge(mxconn);
                        DBManager.Instance.Update(mxconn);
                    }
                }
            }
            #endregion
        }
Esempio n. 8
0
        /// <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();
            }
        }