Пример #1
0
        private void VerimatrixTcpSender_BeforeSending(object sender, TcpSenderEventArgs e)
        {
            ISendLogHandler sendLog = new VerimatrixLogHandler();

            if (IsRegistered && IsConnected)
            {
                //con current dic check expire
                VerimatrixMessageDataAccess.Inspection(tcpSenderParameter.Timeout);

                if (!this.IsSendingHoldShutdownCommand(e.Request))
                {
                    VerimatrixMessageDataAccess.LogRequestMessage(e.Request, this.GetLogEntity(e.Request));

                    this.LogSendMessage(sendLog.GetSendLog(e.Request, this.GetHostName(), this.CommandName));

                    //Logger.Info(string.Format("Message sent: {0}", e.Request));
                }
                else
                {
                    //hold & shutdown
                    this.WriteLog(sendLog.GetConnectionLog(e.Request, this.GetHostName(), this.CommandName));
                }
            }
            else
            {
                //register
                this.WriteLog(sendLog.GetConnectionLog(e.Request, this.GetHostName(), this.CommandName));
            }
        }
Пример #2
0
        private void ProcessMessage(string messageResponse)
        {
            var response = new VerimatrixResponse(messageResponse);

            try
            {
                if (!IsRegistered)
                {
                    if (response.Status == Enums.Status.Register)
                    {
                        this.IsRegistered = true;
                        this.registerWaitHandler.Set();
                    }
                    // registation failed
                    else
                    {
                        this.registerWaitHandler.Set();
                    }
                }
                else
                {
                    //Logger.Info(string.Format("Message received: {0}", messageResponse));

                    var logEntity = VerimatrixMessageDataAccess.GetRequestData(messageResponse);
                    IReceiveLogHandler logHandler = new VerimatrixLogHandler(this.ComponentCtx, response, logEntity);

                    // hold command doesn't has response
                    if (HoldtlTimer != null)
                    {
                        HoldtlTimer.Change(this.tcpSenderParameter.HoldCommandIntervalms,
                                           this.tcpSenderParameter.HoldCommandIntervalms);
                    }

                    if (response.Status == Enums.Status.Success || response.Status == Enums.Status.Error)
                    {
                        this.LogReceiveMessage(logHandler.GetReceiveLog(), this.GetAsyncLogDictionary(logEntity));
                    }

                    if (response.Status == Enums.Status.Shutdown)
                    {
                        this.IsShutdown = true;
                    }
                }
            }
            catch (Exception ex)
            {
                var log = new Log()
                {
                    MessageText       = ex.Message,
                    MessageQualifier  = (int)CommunicationLogEntryMessageQualifier.Error,
                    Host              = this.HostName,
                    MessageTrackingId = this.CommandName
                };
                ComponentCtx.WriteInfo(log);
            }
        }