Пример #1
0
 private void DisconnectEventHandler(object sender, DisconnectEventArgs args)
 {
     try
     {
         CurrentConnection.Disconnect();
         //Global.Report.WriteAppLog(string.Format("ThreadId = {0} disconnected", args.ThreadId));
     }
     catch
     {
     }
 }
Пример #2
0
        private void ReceiveError(Exception e)
        {
            if (e is Hubble.Framework.Threading.MQAbortException)
            {
                if (_Args != null)
                {
                    _Pool.ExecuteFinished(this);

                    _Args.ReturnMsg = e;
                    CurrentConnection.Disconnect(_ManagedThreadId);
                    TcpServer.ReturnMessage(_Args);
                }
            }
        }
Пример #3
0
        object ReceiveMessage(int evt, MessageQueue.MessageFlag flag, object data)
        {
            if (evt == (int)SQLClient.ConnectEvent.ExcuteSql)
            {
                try
                {
                    _Args = data as MessageReceiveEventArgs;
                    CurrentConnection currentConnection = new CurrentConnection(
                        _Args.ConnectionInfo as ConnectionInformation);

                    CurrentConnection.ConnectionInfo.QueryThread = this;
                    _ManagedThreadId = this.ManagedThreadId;

                    if (!_Args.QueryStoreProcedure)
                    {
                        int queryQueueWaitingTimeout = Global.Setting.Config.QueryQueueWaitingTimeout;

                        if (queryQueueWaitingTimeout > 0)
                        {
                            TimeSpan timeSpan = DateTime.Now - _Args.StartTime;
                            if (timeSpan.TotalSeconds > queryQueueWaitingTimeout)
                            {
                                throw new Hubble.Core.Query.QueryException("Timeout during sql was waiting in Query Queue.");
                            }
                        }
                    }

                    HubbleTask.ExcuteSqlMessageProcess(_Args);

                    _Args = null;
                }
                catch (Exception e)
                {
                    _Args.ReturnMsg = e;
                    TcpServer.ReturnMessage(_Args);
                }
                finally
                {
                    _Pool.ExecuteFinished(this);
                    CurrentConnection.Disconnect();
                }
            }

            return(null);
        }
Пример #4
0
        private void MessageReceiveEventHandler(object sender, MessageReceiveEventArgs args)
        {
            lock (_LockObj)
            {
                if (_Closing)
                {
                    throw new Exception("Hubble task closing!");
                }
            }

            switch ((SQLClient.ConnectEvent)args.MsgHead.Event)
            {
            case SQLClient.ConnectEvent.Connect:      //Connecting
                CurrentConnection currentConnection = new CurrentConnection(
                    new ConnectionInformation(args.InMessage as string));

                if (Global.Setting.Config.SqlTrace)
                {
                    Global.Report.WriteAppLog(string.Format("Connected, remain:{0}",
                                                            _Server.ConnectionRemain));
                }

                break;

            case ConnectEvent.ExcuteSql:     //excute sql
                if ((args.MsgHead.Flag & MessageFlag.ASyncMessage) != 0)
                {
                    args.ConnectionInfo = CurrentConnection.ConnectionInfo.Clone();
                    QueryThreadManager.ExcuteSql(args);
                }
                else
                {
                    ExcuteSqlMessageProcess(args);
                }
                break;

            case ConnectEvent.Exit:     //quit

                string startTimeStr = (string)args.InMessage;

                if (startTimeStr == null)
                {
                    throw new Exception("StartTime is null!");
                }

                DateTime startTime = DateTime.ParseExact(startTimeStr, "yyyy-MM-dd HH:mm:ss", null);

                if (!startTimeStr.Equals(_StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                                         StringComparison.CurrentCultureIgnoreCase))
                {
                    throw new Exception("Invalid startTime!");
                }

                lock (_LockObj)
                {
                    if (_Closing)
                    {
                        throw new Exception("Hubble task closing!");
                    }

                    _Closing = true;
                }

                System.Threading.ThreadPool.QueueUserWorkItem(Close);

                break;
            }
        }