示例#1
0
        /// <summary>
        /// 添加设备对像
        /// </summary>
        /// <param name="_DevObj"></param>
        public static void AddDevObjList(DevObj _DevObj)
        {
            try
            {
                //if (!DevObjList.ContainsKey(DevID))
                //{
                //    DevObjList.Add(DevID, _DevObj);
                //}
                //else
                //{
                //    //KoIp.BusinessDAL.CommonList.KnsUserList[usersession.UID] = usersession
                //    DevObjList[DevID] = _DevObj;
                //}


                //for (int i = 0; i < DevObjList.Count; i++)
                //{
                //    if ((DevObjList[i].DevID == _DevObj.DevID))
                //    {
                //        //DevObjList.Add(DevID, _DevObj);
                //        DevObjList.RemoveAt(i);

                //    }

                //}
                //DevObjList.Add(_DevObj);
            }
            catch (Exception ex)
            {
                Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious,
                                                "KOIPMonitor>>CommClass>>AddDevObjList>>",
                                                ex.Message);
                return;
            }
        }
示例#2
0
 /// <summary>
 /// 获取服务器对像管理连接地址
 /// </summary>
 /// <param name="DevID">设备编号</param>
 /// <param name="Request">连接对像</param>
 public static void GetDevMagObj(string DevID, ref DevObj _DevObj)
 {
     try
     {
         foreach (KeyValuePair <string, DevObj> a in DevObjList)
         {
             if (a.Key.ToString() == DevID.ToString())
             {
                 //a.Value.States.workSocket.Shutdown(System.Net.Sockets.SocketShutdown.Both);
                 _DevObj = DevObjList[DevID];
                 return;
             }
         }
         //for (int i = 0; i < DevObjList.Count; i++)
         //{
         //    if (DevObjList[i].DevID==DevID)
         //    {
         //        _DevObj = DevObjList[i];
         //        return;
         //    }
         //}
         if (CommClass.ISCONUP == "0")
         {
             _DevObj.IsLocal = -1;
             _DevObj.request = null;
         }
     }
     catch (Exception ex)
     {
         Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious,
                                         "KOIPMonitor>>CommClass>>GetDevMagObj>>",
                                         ex.Message);
         return;
     }
 }
示例#3
0
        /// <summary>
        /// 移除设备连接列表
        /// </summary>
        /// <param name="DevID">设备编号</param>
        public static void RevDevObjList(StateObject Request)
        {
            try
            {
                string[] DevObjKey = new string[DevObjList.Count];
                int      i         = 0;
                foreach (KeyValuePair <string, DevObj> a in DevObjList)
                {
                    if (a.Value.request != null)
                    {
                        if (a.Value.request.ConnectionSession == Request.ConnectionSession)
                        {
                            //a.Value.States.workSocket.Shutdown(System.Net.Sockets.SocketShutdown.Both);
                            //DevObjList.Remove(a.Key);
                            //DevObj _DevObj = new DevObj();
                            //_DevObj.IsLocal = a.Value.IsLocal;
                            //_DevObj.request = null;
                            //DevObjList[a.Key] = _DevObj;
                            DevObjKey[i] = a.Key;
                            ServMonitor_AlarmHandlingEvent.UpdateServState(a.Key, "3");
                            i++;
                        }
                    }
                }
                for (int j = 0; j < DevObjKey.Length; j++)
                {
                    //if (String.IsNullOrEmpty( DevObjKey[j]))
                    //{
                    DevObj _DevObj = new DevObj();
                    _DevObj.IsLocal          = -1;
                    _DevObj.request          = null;
                    DevObjList[DevObjKey[j]] = _DevObj;
                    //}
                }
                //for (int i = 0; i < DevObjList.Count; i++)
                //{
                //    if (DevObjList[i].request!=null)
                //    {
                //        if (DevObjList[i].request.ConnectionSession==Request.ConnectionSession)
                //        {
                //            //DevObjList[i].request = null;
                //            ServMonitor_AlarmHandlingEvent.UpdateServState(DevObjList[i].DevID, "3");
                //            DevObjList.RemoveAt(i);

                //        }
                //    }
                //}

                ServMonitor_AlarmHandlingEvent.NoticeDevState();

                Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious,
                                                "KOIPMonitor>>CommClass>>RevDevObjList>>", "Node Server is Down!~~");
            }
            catch (Exception ex)
            {
                Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious,
                                                "KOIPMonitor>>CommClass>>RevDevObjList>>",
                                                ex.Message);
                return;
            }
        }