示例#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
        /// <summary>
        /// 消息处理
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static void process(StateObject request)
        {
            //哈希表存放包体内容
            Hashtable _hashtable_Package = new Hashtable();
            string    _ID      = "";
            string    _TYPE    = "";
            string    _OPTTYPE = "";

            try
            {
                if (request != null)
                {
                    #region 包体解析
                    short cmd1 = 0; //主命令字
                    short cmd2 = 0; //子命令字
                    cmd1 = OMSCmd.RspServOpt;
                    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,
                                                        "BusinessDAL.KNS.server>>SuperaddSingSongList>>process>>", "消息体内容有误");
                        return;
                    }

                    _ID      = dt.Rows[0]["ID"].ToString();
                    _TYPE    = dt.Rows[0]["TYPE"].ToString();
                    _OPTTYPE = dt.Rows[0]["OPTTYPE"].ToString();

                    ByteResult = File.ReadAllBytes(request.receiveFileTemporarily);
                    CommClass.DevObj _DevObj = new CommClass.DevObj();

                    CommClass.GetDevMagObj(_ID, ref _DevObj);

                    if (_DevObj.IsLocal == 0)
                    {
                        switch (_OPTTYPE)
                        {
                        case "1":
                            ServMonitor.MonitorInterface.ServStop(_ID, _TYPE);
                            break;

                        case "2":
                            ServMonitor.MonitorInterface.ServStart(_ID, _TYPE);
                            break;

                        case "3":
                            ServMonitor.MonitorInterface.ServRestart(_ID, _TYPE);
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        if ((_DevObj.request == null) || (_DevObj.IsLocal == -1))
                        {
                            cmd2 = -8033;
                            cmd1 = OMSCmd.RspServOpt;
                            //哈希表存放包体内容
                            Hashtable _hashtable_Package_Temp = new Hashtable();
                            _hashtable_Package_Temp.Add("1", request);//...連結位置
                            _hashtable_Package_Temp.Add("2", cmd1);
                            _hashtable_Package_Temp.Add("3", cmd2);
                            _hashtable_Package_Temp.Add("4", ByteResult);
                            ThreadPool.QueueUserWorkItem(new WaitCallback(CommonFunction.SendDatas), _hashtable_Package_Temp);
                            return;
                        }
                        else
                        {
                            cmd1 = OMSCmd.ReqServOpt;
                            //哈希表存放包体内容
                            Hashtable _hashtable_Package_Temp = new Hashtable();
                            _hashtable_Package_Temp.Add("1", _DevObj.request);//...連結位置
                            _hashtable_Package_Temp.Add("2", cmd1);
                            _hashtable_Package_Temp.Add("3", cmd2);
                            _hashtable_Package_Temp.Add("4", ByteResult);
                            ThreadPool.QueueUserWorkItem(new WaitCallback(CommonFunction.SendDatas), _hashtable_Package_Temp);
                        }
                    }

                    //for (int i = 0; i < dt.Rows.Count; i++)
                    //{
                    //    if ((dt.Rows[i]["ID"] == _ID) && (dt.Rows[i]["TYPE"] == _TYPE))
                    //    {
                    //        _STATE = dt.Rows[i]["STATE"].ToString();
                    //        break;
                    //    }
                    //}


                    #endregion

                    //short cmd1 = 0;//主命令字
                    //short cmd2 = 0;//子命令字
                    //cmd1 = OMSCmd.RspServOpt;
                    //cmd2 = ErrCommon.Success;
                    //byte[] ByteResult = null;
                    //Hashtable _hashtable_PackageArry = new Hashtable();
                    //_hashtable_PackageArry.Add("1", request);//...連結位置
                    //_hashtable_PackageArry.Add("2", cmd1);
                    //_hashtable_PackageArry.Add("3", cmd2);
                    //_hashtable_PackageArry.Add("4", ByteResult);
                    //ThreadPool.QueueUserWorkItem(new WaitCallback(CommonFunction.SendDatas), _hashtable_PackageArry);
                }
                else
                {
                    Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious, "RspGetServState>>process>>", "StateObject request==null");
                }
            }
            catch (Exception ex)
            {
                Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious, "RspGetServState>>process>>", ex.Message);
            }
            finally
            {
                //删除文件
                //if (!string.IsNullOrEmpty(request.receiveFileTemporarily))
                //    ThreadPool.QueueUserWorkItem(new WaitCallback(DiskIO.Del), request.receiveFileTemporarily);

                //GC.Collect();
            }
        }
示例#3
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
            {
            }
        }