Пример #1
0
        /// <summary>
        /// 消息处理
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static void process(StateObject request)
        {
            //哈希表存放包体内容
            Hashtable _hashtable_Package = new Hashtable();
            string    _ID    = "";
            string    _TYPE  = "";
            string    _STATE = "";

            try
            {
                if (request != null)
                {
                    #region 包体解析
                    short cmd1 = 0; //主命令字
                    short cmd2 = 0; //子命令字
                    cmd1 = OMSCmd.RspGetServState;
                    cmd2 = ErrCommon.Success;
                    byte[]    ByteResult = null;
                    DataTable dt         = new DataTable();
                    Commonality.CommClass.ReadXML(request.receiveFileTemporarily, ref dt);

                    if (dt.Rows.Count <= 0)
                    {
                        cmd2 = -101;//解包失败
                        //哈希表存放包体内容
                        Hashtable _hashtable_Package_Temp = new Hashtable();
                        _hashtable_Package_Temp.Add("1", request);//...連結位置
                        _hashtable_Package_Temp.Add("2", cmd1);
                        _hashtable_Package_Temp.Add("3", cmd2);
                        ByteResult = null;
                        _hashtable_Package_Temp.Add("4", ByteResult);
                        ThreadPool.QueueUserWorkItem(new WaitCallback(CommonFunction.SendDatas), _hashtable_Package_Temp);
                        Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious,
                                                        "KOIPMonitor>>RspGetServState>>process>>", "消息体内容有误");
                        return;
                    }

                    _ID    = dt.Rows[0]["ID"].ToString();
                    _TYPE  = dt.Rows[0]["TYPE"].ToString();
                    _STATE = dt.Rows[0]["STATE"].ToString();
                    CommClass.DevObj _DevObj = new CommClass.DevObj();
                    //_DevObj.DevID = _ID;
                    _DevObj.IsLocal = 1;
                    _DevObj.request = request;
                    CommClass.AddDevObjList(_ID, _DevObj);
                    ServMonitor_AlarmHandlingEvent.NoticeDevState(_ID, _TYPE, _STATE);
                    ServMonitor_AlarmHandlingEvent.UpdateServState(_ID, _TYPE, _STATE);

                    #endregion
                }
                else
                {
                    Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious, "KOIPMonitor>>RspGetServState>>process>>", "TCPClientStateObject request==null");
                }
            }
            catch (Exception ex)
            {
                Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious, "KOIPMonitor>>RspGetServState>>process>>", ex.Message);
            }
            finally
            {
                //删除文件
                //if (!string.IsNullOrEmpty(request.receiveFileTemporarily))
                //    ThreadPool.QueueUserWorkItem(new WaitCallback(DiskIO.Del), request.receiveFileTemporarily);

                //GC.Collect();
            }
        }
Пример #2
0
        public static void AlarmEvent(ServInfoState sender)
        {
            try
            {
                Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious, "sender", "\n" + sender.ToString());

                short cmd1 = 0; //主命令字
                short cmd2 = 0; //子命令字
                cmd1 = OMSCmd.RspGetServState;
                cmd2 = ErrCommon.Success;
                byte[] ByteResult = null;

                //List表内容
                List <Commonality.CommClass.TTable> ListTtable = new List <Commonality.CommClass.TTable>();
                //Table属性内容
                Commonality.CommClass.TTable Ttable = new Commonality.CommClass.TTable();

                Ttable.FieldName  = "ID";
                Ttable.FieldValue = sender.ID;
                ListTtable.Add(Ttable);

                Ttable.FieldName  = "TYPE";
                Ttable.FieldValue = sender.TYPE;
                ListTtable.Add(Ttable);

                Ttable.FieldName  = "STATE";
                Ttable.FieldValue = sender.STATE;
                ListTtable.Add(Ttable);
                Commonality.CommClass.TableToByteArry(ListTtable, ref ByteResult);

                if (CommClass.ISCONUP == "0")
                {
                    UpdateServState(sender.ID, sender.TYPE, sender.STATE);
                    string strDescr = "";
                    switch (sender.STATE)
                    {
                    case "1":
                        strDescr = "设备启动";
                        break;

                    case "2":
                        strDescr = "设备故障";
                        break;

                    case "3":
                        strDescr = "状态未知";
                        break;

                    default:
                        strDescr = "状态未知";
                        break;
                    }
                    int Ret = -1;
                    if (sender.STATE != "1")
                    {
                        CommonFunction.Alarm_Add(sender.ID, sender.TYPE, strDescr, ref Ret);
                    }
                    CommClass.DevObj _DevObj = new CommClass.DevObj();
                    //_DevObj.DevID = sender.ID;
                    _DevObj.IsLocal = 0;
                    _DevObj.request = null;
                    CommClass.AddDevObjList(sender.ID, _DevObj);
                    foreach (KeyValuePair <string, Kernel.StateObject> a in CommClass.ClientConnList)
                    {
                        Hashtable _hashtable_Package = new Hashtable();
                        _hashtable_Package.Add("1", a.Value);//...連結位置
                        _hashtable_Package.Add("2", cmd1);
                        _hashtable_Package.Add("3", cmd2);
                        _hashtable_Package.Add("4", ByteResult);
                        ThreadPool.QueueUserWorkItem(new WaitCallback(CommonFunction.SendDatas), _hashtable_Package);
                    }
                }
                else
                {
                    cmd1 = OMSCmd.UpDevState;
                    cmd2 = ErrCommon.Success;
                    Hashtable _hashtable_Package = new Hashtable();
                    _hashtable_Package.Add("1", ConnectUpServ.tcpClient);//...連結位置
                    _hashtable_Package.Add("2", cmd1);
                    _hashtable_Package.Add("3", cmd2);
                    _hashtable_Package.Add("4", ByteResult);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(CommonFunction.UnGzipTcpClientSend), _hashtable_Package);
                }
            }
            catch (Exception ex)
            {
                //Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious, "BusinessDAL.KNS>>tcpClient_ExceptionHandlingEvent>>ReceiveEvent>>", ex.Message);
            }
            finally
            {
            }
        }