Ejemplo n.º 1
0
        /// <summary>
        /// 服务器列表更新通知
        /// </summary>
        public static void NoticeServerList()
        {
            try
            {
                short cmd1 = 0; //主命令字
                short cmd2 = 0; //子命令字
                cmd1 = OMSCmd.RspGetServList;
                cmd2 = ErrCommon.Success;
                byte[]    ByteResult = null;
                DataTable dt         = new DataTable();
                dt = CommClass.DtServList.Copy();
                Commonality.CommClass.OutputBody(dt);
                CommClass.DataTableToByteArry(dt, ref ByteResult);


                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);
                }
            }
            catch (Exception ex)
            {
                Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious, "KOIPMonitor>>NoticeServerList>>", ex.Message);
            }
        }
        public static void ReceiveEvent(StateObject requset)
        {
            try
            {
                if (requset == null)
                {
                    ConsoleManage.Write(Commonality.ErrorLevel.Response, "", "requset is null");
                    return;
                }
                int ret = 0;
                ret = CommClass.GetDownLineType(requset);
                switch (ret)
                {
                case 1:
                    CommClass.RemoveClientConnList(requset);
                    break;

                case 2:
                    CommClass.RevDevObjList(requset);
                    break;
                }
            }
            catch (Exception ex)
            {
                ConsoleManage.Write(Commonality.ErrorLevel.Response, "tcpServer_ExceptionHandlingEvent>>ReceiveEvent>>", ex.Message);
                return;
            }
        }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 消息处理
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static void process(StateObject request)
        {
            //哈希表存放包体内容
            Hashtable _hashtable_Package = new Hashtable();

            try
            {
                if (request != null)
                {
                    #region 包体解析
                    short cmd1 = 0;    //主命令字
                    short cmd2 = 0;    //子命令字
                    cmd1 = OMSCmd.RspGetServList;
                    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;
                    //}

                    //sessionid = dt.Rows[0]["SESSIONID"].ToString();
                    //RoomId = dt.Rows[0]["ROOMID"].ToString();
                    //UserID = sessionid;

                    #endregion

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

                    //Ttable.FieldName = "MYLANAUDIO";
                    //Ttable.FieldValue = "";
                    //ListTtable.Add(Ttable);

                    //Commonality.CommClass.TableToByteArry(ListTtable, ref ByteResult);
                    DataTable dt = new DataTable();
                    dt = CommClass.DtServList.Copy();
                    Commonality.CommClass.OutputBody(dt);
                    CommClass.DataTableToByteArry(dt, ref ByteResult);

                    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, "RspGetServList>>process>>", "StateObject request==null");
                }
            }
            catch (Exception ex)
            {
                Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious, "RspGetServList>>process>>", ex.Message);
            }
            finally
            {
                //删除文件
                //if (!string.IsNullOrEmpty(request.receiveFileTemporarily))
                //    ThreadPool.QueueUserWorkItem(new WaitCallback(DiskIO.Del), request.receiveFileTemporarily);

                //GC.Collect();
            }
        }
Ejemplo n.º 5
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();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 消息处理
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static void process(StateObject request)
        {
            //哈希表存放包体内容
            Hashtable _hashtable_Package = new Hashtable();
            string    UserId             = ""; //用户ID
            string    UserPwd            = ""; //用户密码


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

                    UserId  = dt.Rows[0]["USERID"].ToString();
                    UserPwd = dt.Rows[0]["USERPWD"].ToString();
                    //UserId = Guid.NewGuid().ToString();
                    int    Ret   = -1;
                    string Roles = "";
                    int    RetID = 0;;
                    RspUserLogin.LoginVerification(UserId, UserPwd, ref Ret, ref Roles, ref RetID);
                    switch (Ret)
                    {
                    case -1:
                        cmd2 = -8010;
                        break;

                    case -2:
                        cmd2 = -8011;
                        break;

                    case 0:
                        if (CommClass.GetUserIsLogin(UserId) == 0)
                        {
                            cmd2 = ErrCommon.Success;
                        }
                        else
                        {
                            cmd2 = -8032;
                        }
                        CommClass.AddClientConnList(UserId, request);
                        //List表内容
                        List <Commonality.CommClass.TTable> ListTtable = new List <Commonality.CommClass.TTable>();
                        //Table属性内容
                        Commonality.CommClass.TTable Ttable = new Commonality.CommClass.TTable();
                        Ttable.FieldName  = "ROLES";
                        Ttable.FieldValue = Roles;
                        ListTtable.Add(Ttable);
                        Ttable.FieldName  = "ID";
                        Ttable.FieldValue = RetID.ToString();
                        ListTtable.Add(Ttable);
                        Commonality.CommClass.TableToByteArry(ListTtable, ref ByteResult);
                        break;
                    }


                    #endregion

                    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, "KOIPMonitor>>RspUserLogin>>process>>", "StateObject request==null");
                }
            }
            catch (Exception ex)
            {
                Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious, "KOIPMonitor>>RspUserLogin>>process>>", ex.Message);
            }
            finally
            {
                //删除文件
                //if (!string.IsNullOrEmpty(request.receiveFileTemporarily))
                //    ThreadPool.QueueUserWorkItem(new WaitCallback(DiskIO.Del), request.receiveFileTemporarily);

                //GC.Collect();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 消息处理
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static void process(StateObject request)
        {
            //哈希表存放包体内容
            Hashtable _hashtable_Package = new Hashtable();
            string    DEVID     = ""; //设备信息编号
            string    DEVNAME   = ""; //设备名称
            string    DEVTYPE   = ""; //设备类型;
            int       PageCount = 0;  //单页记录数
            int       CurrPage  = 0;  //当前页
            int       ID        = 0;  //自动增量编号

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



                    if (dt.Columns["DEVID"] != null)
                    {
                        DEVID = dt.Rows[0]["DEVID"].ToString();
                    }
                    else
                    {
                        DEVID = null;
                    }

                    if (dt.Columns["DEVTYPE"] != null)
                    {
                        DEVTYPE = dt.Rows[0]["DEVTYPE"].ToString();
                    }
                    else
                    {
                        DEVTYPE = null;
                    }
                    if (dt.Columns["DEVNAME"] != null)
                    {
                        DEVNAME = dt.Rows[0]["DEVNAME"].ToString();
                    }
                    else
                    {
                        DEVNAME = null;
                    }

                    try
                    {
                        ID = Convert.ToInt32(dt.Rows[0]["ID"].ToString());
                    }
                    catch
                    {
                        ID = 0;
                    }

                    try
                    {
                        PageCount = Convert.ToInt32(dt.Rows[0]["PAGECOUNT"].ToString());
                    }
                    catch
                    {
                        PageCount = 0;
                    }
                    try
                    {
                        CurrPage = Convert.ToInt32(dt.Rows[0]["CURRPAGE"].ToString());
                    }
                    catch
                    {
                        CurrPage = 0;
                    }



                    #endregion
                    DataTable dtRet     = null;
                    DataTable dtRetInfo = null;
                    Devinfo_Query(ID, DEVID, DEVNAME, DEVTYPE, PageCount, CurrPage, ref dtRet, ref dtRetInfo);

                    if (dtRet != null)
                    {
                        int TotalRecords = Convert.ToInt32(dtRetInfo.Rows[0][0].ToString());
                        int TotalPage    = Convert.ToInt32(dtRetInfo.Rows[0][1].ToString());;//总记录数
                        _hashtable_Package.Add("1", request);
                        _hashtable_Package.Add("3", TotalPage);
                        _hashtable_Package.Add("4", CurrPage);
                        _hashtable_Package.Add("5", TotalRecords);
                        _hashtable_Package.Add("6", cmd1);
                        CommClass.DataTableToByteArry(dtRet, ref ByteResult);
                        _hashtable_Package.Add("2", ByteResult);
                        ThreadPool.QueueUserWorkItem(new WaitCallback(CommonFunction.SendDatasPage), _hashtable_Package);
                    }
                    else
                    {
                        cmd2 = -8019;
                        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, "KOIPMonitor>>DevInfoQuery>>process>>", "StateObject request==null");
                }
            }
            catch (Exception ex)
            {
                Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious, "KOIPMonitor>>DevTypeQuery>>process>>", ex.Message);
            }
            finally
            {
                //删除文件
                //if (!string.IsNullOrEmpty(request.receiveFileTemporarily))
                //    ThreadPool.QueueUserWorkItem(new WaitCallback(DiskIO.Del), request.receiveFileTemporarily);

                //GC.Collect();
            }
        }
Ejemplo n.º 8
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
            {
            }
        }
Ejemplo n.º 9
0
        //private static ManualResetEvent _allDone = new ManualResetEvent(false);
        static void Main(string[] args)
        {
            //ServiceBase[] ServicesToRun;
            //ServicesToRun = new ServiceBase[]{
            //   new ServiceKOIPM(args)
            //};
            //ServiceBase.Run(ServicesToRun);

            try
            {
                CommClass.OStype = Convert.ToInt32(args[0].ToString());
            }
            catch
            {
                CommClass.OStype = 0;
            }
            CommClass.OStype = 1;


            CommClass.SetPubPath();
            Commonality.ConsoleManage.objectTime();

            CommClass.CreateConfig();

            //CommClass.CreateServListTable();
            //CommClass.CreateServList();

            //CommClass.ReadXML(CommClass.ServListPath, ref CommClass.DtServList);

            DataTable dt = new DataTable();

            CommClass.ReadXML(CommClass.ConfigFilePath, ref dt);

            if (dt.Rows.Count != 0)
            {
                #region 读取KMS配置相关信息
                //读取数据库连接
                CommClass.DBCONN = dt.Rows[0]["DBCONN"].ToString();
                //本地服务器ID
                CommClass.ID = dt.Rows[0]["ID"].ToString();
                //本地服务IP地址
                CommClass.IP = dt.Rows[0]["IP"].ToString();
                //是否启用自动启动
                CommClass.ISAUTOSTART = dt.Rows[0]["ISAUTOSTART"].ToString();

                //本地服务端口号

                try
                {
                    CommClass.PORT = Convert.ToInt32(dt.Rows[0]["PORT"].ToString());
                }
                catch
                {
                    CommClass.PORT = 0;
                }


                //上级服务ID
                CommClass.UPID = dt.Rows[0]["UPID"].ToString();

                //上级服务IP地址
                CommClass.UPIP = dt.Rows[0]["UPIP"].ToString();

                //上级服务端口号
                try
                {
                    CommClass.UPPORT = Convert.ToInt32(dt.Rows[0]["UPPORT"].ToString());
                }
                catch
                {
                    CommClass.UPPORT = 0;
                }

                //数据库连接字符串
                CommClass.DBCONN = dt.Rows[0]["DBCONN"].ToString();

                //是否连接上级服务{0:不连接;1:连接}
                CommClass.ISCONUP = dt.Rows[0]["ISCONUP"].ToString();

                #endregion

                if (CommClass.ISCONUP == "0")
                {
                    CommonFunction.GetServerList();
                }
                else
                {
                    ThreadPool.QueueUserWorkItem(new WaitCallback(ConnectUpServ.HeartSocketobjectTime), null);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(ConnectUpServ.Start), null);//连接上级服务器
                }

                AsynTCPSocket listener = new AsynTCPSocket(CommClass.OStype.ToString());
                listener.listenerAddress         = CommClass.IP;
                listener.listenerPort            = CommClass.PORT;
                listener.ReceiveEvent           += new AsynchronousSocketListenerReceiveEvent(tcpServer_ReceiveEvent.ReceiveEvent);
                listener.ExceptionHandlingEvent += new AsynchronousServerExceptionHandlingEvent(tcpServer_ExceptionHandlingEvent.ReceiveEvent);
                listener.Start();
                while (!listener.IsBound)
                {
                    Thread.Sleep(500);
                }

                if (listener.IsBound)
                {
                    Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious, "KOIPMonitor:SOCKET=" + CommClass.IP + ":" + CommClass.PORT.ToString() + "  TCP服務啟動成功", "");
                }
                else
                {
                    Commonality.ConsoleManage.Write(Commonality.ErrorLevel.Serious, "KOIPMonitor:SOCKET=" + CommClass.IP + ":" + CommClass.PORT.ToString() + "   TCP服務啟動失敗", "");
                }

                MonitorInterface.AlarmEvent += new ServMonitorAlarmHandlingEvent(ServMonitor_AlarmHandlingEvent.AlarmEvent);
                MonitorInterface.OptEvent   += new ServMonitorOptHandlingEvent(ServMonitor_OptHandlingEvent.OptEvent);
                MonitorInterface MonInterface = new MonitorInterface();
                MonInterface.Start(CommClass.OStype.ToString(), CommClass.ISAUTOSTART);
            }
        }