Beispiel #1
0
        /// <summary>
        /// 开始接收队列中的消息
        /// </summary>
        public void StartReceive()
        {
            m_StopFlag       = false;
            m_ProcessMessage = false;
            do
            {
                try
                {
                    Message myMessage = m_MessageQueue.Receive(); //当消息队列空时,线程会挂起
                    m_ProcessMessage = true;

                    AuditBusiness log = (AuditBusiness)myMessage.Body;
                    if (log != null)
                    {
                        log.Insert();
                    }

                    m_ProcessMessage = false;
                }
                catch (Exception ex) {
                    XTrace.WriteLine("接收消息时发生异常:{0},服务将忽略此消息并继续运行!", ex.ToString());
                }
            } while (m_StopFlag == false);

            XTrace.WriteLine("服务已经停止接收消息!");
        }
Beispiel #2
0
        /// <summary>
        /// 接收一条审计记录
        /// </summary>
        /// <param name="?"></param>
        public void Push(AuditBusiness ab)
        {
            String serviceName = ab.ServiceName;

            ServiceMonitor[]     serviceMonitorArray;
            MonitorStatDimension msDimension = GetMonitorStatDimension(ab);

            //--如果统计中没有相应维度的数据,则创建
            if (msDimension == null)
            {
                serviceMonitorArray = new ServiceMonitor[60];
                msDimension         = new MonitorStatDimension()
                {
                    ServiceName    = ab.ServiceName,
                    BindingAddress = ab.BindingAddress,
                    MethodName     = ab.RowMethodName
                };
                m_ServiceMonitor.Add(msDimension, serviceMonitorArray);
            }
            else
            {
                serviceMonitorArray = m_ServiceMonitor[msDimension];
            }

            RecordItem(ab, serviceMonitorArray);
        }
Beispiel #3
0
        public void ExceptionPigeonhole(String messageID)
        {
            AuditBusiness audit = AuditBusiness.Find(AuditBusiness._.OID, messageID);

            if (audit != null)
            {
                audit.Status = 9;
                audit.Update();
            }
        }
Beispiel #4
0
        /// <summary>
        /// 重新发送消息
        /// </summary>
        private void ResendMessage()
        {
            lock (m_ResendLock)
            {
                //--检测成功消息,并重新发送
                String[] successFiles = Directory.GetFiles(m_SuccessPath);
                if (successFiles.Length > 0)
                {
                    for (int i = 0; i < successFiles.Length; i++)
                    {
                        String        message = File.ReadAllText(successFiles[i]);
                        AuditBusiness ab      = XmlUtil.LoadObjFromXML <AuditBusiness>(message);

                        m_MonitorClient.SendAuditMessage(ab);

                        File.Delete(successFiles[i]);
                    }
                }

                //--检测异常消息,并重新发送
                String[] failureFiles = Directory.GetFiles(m_FailurePath);
                if (failureFiles.Length > 0)
                {
                    for (int i = 0; i < failureFiles.Length; i++)
                    {
                        String          message = File.ReadAllText(failureFiles[i]);
                        ExceptionCoreTb ab      = XmlUtil.LoadObjFromXML <ExceptionCoreTb>(message);

                        m_MonitorClient.SendExceptionMessage(ab);

                        File.Delete(failureFiles[i]);
                    }
                }

                //--检测调用队列,并重新发送
                String[] invokeQueue = Directory.GetFiles(m_InvokeQueuePath);
                if (invokeQueue.Length > 0)
                {
                    for (int i = 0; i < invokeQueue.Length; i++)
                    {
                        String       message = File.ReadAllText(invokeQueue[i]);
                        QueueMessage qm      = XmlUtil.LoadObjFromXML <QueueMessage>(message);

                        m_MonitorClient.SendToInvokeQueue(qm);

                        File.Delete(invokeQueue[i]);
                    }
                }
            }
        }
Beispiel #5
0
        public List <AuditBusiness> GetAuditListByTraceID(String traceID)
        {
            AuditBusiness audit = AuditBusiness.Find(AuditBusiness._.OID, traceID);

            List <AuditBusiness> lstAuditBusiness = AuditBusiness.FindAllByTraceID(audit.TraceID);

            foreach (var item in lstAuditBusiness)
            {
                item.ReqBeginTime = item.ReqBeginTime.Substring(11);
                item.ReqEndTime   = item.ReqEndTime.Substring(11);
            }

            return(lstAuditBusiness);
        }
Beispiel #6
0
        /// <summary>
        /// 从监控数据中查找是否有审计日志对应维度的数据
        /// </summary>
        /// <param name="ab"></param>
        /// <returns></returns>
        private MonitorStatDimension GetMonitorStatDimension(AuditBusiness ab)
        {
            String methodName = ab.RowMethodName;

            foreach (var item in m_ServiceMonitor.Keys)
            {
                if (item.ServiceName == ab.ServiceName && item.MethodName == methodName && item.BindingAddress == ab.BindingAddress)
                {
                    return(item);
                }
            }

            return(null);
        }
Beispiel #7
0
        public void AddAuditBusiness(string hostName, string messageBody, string messageID, string methodName, string reqBeginTime, string serviceName, int status, string callBeginTime, string callEndTime)
        {
            AuditBusiness business   = new AuditBusiness();
            AuditLogic    auditLogic = new AuditLogic();

            business.HostName      = hostName;
            business.MessageID     = messageID;
            business.MethodName    = methodName;
            business.ReqBeginTime  = reqBeginTime;
            business.ReqEndTime    = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            business.ServiceName   = serviceName;
            business.Status        = status;
            business.CallBeginTime = callBeginTime;
            business.CallEndTime   = callEndTime;

            auditLogic.AddAuditBusiness(business);
        }
Beispiel #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string oid     = Request["ID"];
        string type    = Request["Type"];
        string msgBody = "";

        AuditServcie  auditService  = new AuditServcie();
        AuditBusiness auditBusiness = auditService.GetAuditBusinessByOID(new Guid(oid));

        if (type == "Req")
        {
            if (!(String.IsNullOrEmpty(auditBusiness.MessageBody)))
            {
                msgBody = auditBusiness.MessageBody;
            }
            else
            {
                msgBody = "请求消息体为空!";
            }
        }
        else
        if (!(String.IsNullOrEmpty(auditBusiness.ReturnMessageBody)))
        {
            msgBody = auditBusiness.ReturnMessageBody;
        }
        else
        {
            msgBody = "响应消息体为空!";
        }
        string fileName = type + auditBusiness.HostName + "-" + auditBusiness.ServiceName + auditBusiness.ReqBeginTime + ".txt";

        Response.Clear();
        Response.Buffer      = true;
        Response.Expires     = 0;
        Response.ContentType = "application/octet-stream";
        Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
        Response.Write(msgBody);
        Response.End();
    }
Beispiel #9
0
        /// <summary>
        /// 增加审计日志
        /// </summary>
        public static String AddAuditLog(int status
            , String bindingTemplateID
            , String serviceID
            , String address
            , DateTime reqBeginTime
            , DateTime reqEndTime
            , DateTime callBeginTime
            , DateTime callEndTime
            , String message
            , ESB.Core.Schema.服务请求 request)
        {
            AuditBusiness log = new AuditBusiness()
            {
                OID = Guid.NewGuid().ToString(),
                HostName = request.主机名称,
                ServiceName = request.服务名称,
                MethodName = request.方法名称,
                ReqBeginTime = reqBeginTime.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                ReqEndTime = reqEndTime.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                Status = status,
                MessageID = Guid.NewGuid().ToString(),
                MessageBody = request.消息内容,
                CallBeginTime = callBeginTime.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                CallEndTime = callEndTime.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                BindingTemplateID = bindingTemplateID,
                ServiceID = serviceID,
                BindingAddress = address,
                ReturnMessageBody = message,
                BusinessName = "",
                BusinessID = ""
            };

            //log.Insert();

            MQUtil.SendMessage<AuditBusiness>(log, @"WIN-02UQME9JGZD\Private$\EsbAuditQueue");

            return log.MessageID;
        }
Beispiel #10
0
        /// <summary>
        /// 增加审计日志
        /// </summary>
        public static String AddAuditLog(int status
                                         , String bindingTemplateID
                                         , String serviceID
                                         , String address
                                         , DateTime reqBeginTime
                                         , DateTime reqEndTime
                                         , DateTime callBeginTime
                                         , DateTime callEndTime
                                         , String message
                                         , ESB.Core.Schema.务请求 request)
        {
            AuditBusiness log = new AuditBusiness()
            {
                OID               = Guid.NewGuid().ToString(),
                HostName          = request.主机名称,
                ServiceName       = request.务名称,
                MethodName        = request.方法名称,
                ReqBeginTime      = reqBeginTime.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                ReqEndTime        = reqEndTime.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                Status            = status,
                MessageID         = Guid.NewGuid().ToString(),
                MessageBody       = request.消息内容,
                CallBeginTime     = callBeginTime.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                CallEndTime       = callEndTime.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                BindingTemplateID = bindingTemplateID,
                ServiceID         = serviceID,
                BindingAddress    = address,
                ReturnMessageBody = message,
                BusinessName      = "",
                BusinessID        = ""
            };

            //log.Insert();

            MQUtil.SendMessage <AuditBusiness>(log, @"WIN-02UQME9JGZD\Private$\EsbAuditQueue");

            return(log.MessageID);
        }
Beispiel #11
0
 /// <summary>
 /// 记录一条记录
 /// </summary>
 /// <param name="auditBusiness"></param>
 public void Record(AuditBusiness auditBusiness)
 {
     m_MonitorStatData.Push(auditBusiness);
 }
        public DataSet GetAFTAuditTrailReport(DateTime fromDate, DateTime toDate)
        {
            AuditBusiness AB = new AuditBusiness();

            return(AB.GetAFTAuditTrailReport(fromDate, toDate));
        }
        public DataSet GetAuditTrailReport(DateTime fromDate, DateTime toDate, string sModuleName)
        {
            AuditBusiness AB = new AuditBusiness();

            return(AB.GetAuditTrailReport(fromDate, toDate, sModuleName));
        }
 public DataSet GetAFTAuditTrailReport(DateTime fromDate, DateTime toDate)
 {
     AuditBusiness AB = new AuditBusiness();
     return AB.GetAFTAuditTrailReport(fromDate, toDate);
 }
Beispiel #15
0
 public List <AuditBusiness> AuditBusinessSearch(AuditBusinessSearchCondition condition, int pageIndex, int pageSize)
 {
     return(AuditBusiness.AuditBusinessSearch(condition, pageIndex, pageSize));
 }
Beispiel #16
0
 /// <summary>
 /// 记录一条记录
 /// </summary>
 /// <param name="auditBusiness"></param>
 public void Record(AuditBusiness auditBusiness)
 {
     m_MonitorStatData.Push(auditBusiness);
 }
Beispiel #17
0
 public DataSet GetDashboardOverview(String businessID)
 {
     return(AuditBusiness.GetDashboardOverview(businessID));
 }
Beispiel #18
0
        /// <summary>
        /// 增加审计日志
        /// </summary>
        public static String AddAuditLog(int status
            , String bindingTemplateID
            , String serviceID
            , String address
            , CallState callState
            , String message
            , ESB.Core.Schema.服务请求 request
            , Int32 isCache = 0)
        {
            callState.RequestEndTime = DateTime.Now;
            TimeSpan ReqTimeSpan = callState.RequestEndTime.Subtract(callState.RequestBeginTime);

            ConfigurationManager cm = ConfigurationManager.GetInstance();
            String consumerIP = cm.LocalIP;
            if (callState.InvokeParam != null && !String.IsNullOrWhiteSpace(callState.InvokeParam.ConsumerIP))
                consumerIP = callState.InvokeParam.ConsumerIP;

            Int32 isQueue = 0;
            if (callState.InvokeParam != null)
                isQueue = callState.InvokeParam.IsQueue;

            AuditBusiness log = new AuditBusiness()
            {
                OID = Guid.NewGuid().ToString(),
                HostName = request.主机名称,
                ServiceName = request.服务名称,
                MethodName = request.方法名称,
                ReqBeginTime = callState.RequestBeginTime.ToString("yyyy-MM-dd HH:mm:ss.ffffff"),
                ReqEndTime = callState.RequestEndTime.ToString("yyyy-MM-dd HH:mm:ss.ffffff"),
                Status = status,
                MessageID = callState.MessageID,
                MessageBody = request.消息内容,
                CallBeginTime = callState.CallBeginTime.ToString("yyyy-MM-dd HH:mm:ss.ffffff"),
                CallEndTime = callState.CallEndTime.ToString("yyyy-MM-dd HH:mm:ss.ffffff"),
                BindingTemplateID = bindingTemplateID,
                ServiceID = serviceID,
                BindingAddress = address,
                ReturnMessageBody = message,
                BusinessName = "",
                BusinessID = "",
                ServiceBeginTime = callState.ServiceBeginTime,
                ServiceEndTime = callState.ServiceEndTime,
                TraceID = callState.TraceContext.TraceID,
                InvokeLevel = callState.TraceContext.InvokeLevel,
                InvokeOrder = callState.TraceContext.InvokeOrder,
                InvokeID = callState.TraceContext.InvokeID,
                InvokeTimeSpan = ReqTimeSpan.TotalMilliseconds,
                ConsumerIP = consumerIP,
                Version = callState.ServiceVersion,
                IsCache = isCache,
                IsQueue = isQueue
            };

            //log.Insert();
            //String mqHost = ESBProxy.GetInstance().ESBConfig.Monitor[0].Uri;
            //MSMQUtil.SendMessage<AuditBusiness>(log, String.Format(@"FormatName:DIRECT=TCP:{0}\Private$\EsbAuditQueue", "192.168.56.2"));

            ESBProxy.GetInstance().MessageQueueClient.SendAuditMessage(log);

            //--每调用完一次需要增加调用次数
            callState.TraceContext.IncreaseInvokeOrder();

            return log.OID;
        }
Beispiel #19
0
        /// <summary>
        /// 记录一条监控日志,统计维度已经在Push方法中划分好了
        /// </summary>
        /// <param name="ab"></param>
        /// <param name="serviceMonitorArray"></param>
        private void RecordItem(AuditBusiness ab, ServiceMonitor[] serviceMonitorArray)
        {
            // DateTime serviceBeginTime = DateTime.ParseExact(ab.ServiceBeginTime, "yyyy-MM-dd HH:mm:ss.ffffff", null);
            DateTime       monitorStamp   = DateTime.Now;
            Int32          second         = monitorStamp.Second;
            ServiceMonitor serviceMonitor = serviceMonitorArray[second];


            //XTrace.WriteLine("第{0}秒记录。", second);

            if (serviceMonitor == null)
            {
                serviceMonitor = new ServiceMonitor()
                {
                    OID               = Guid.NewGuid().ToString(),
                    ServiceName       = ab.ServiceName,
                    MethodName        = ab.RowMethodName,
                    MonitorStamp      = monitorStamp,
                    ConsumerIP        = ab.ConsumerIP,
                    BindingAddress    = ab.BindingAddress,
                    CallSuccessNum    = (ab.Status == 1) ? 1 : 0,
                    CallFailureNum    = (ab.Status == 1) ? 0 : 1,
                    CallLevel1Num     = (ab.InvokeTimeSpan > 20 && ab.InvokeTimeSpan < 100) ? 1 : 0,
                    CallLevel2Num     = (ab.InvokeTimeSpan > 100 && ab.InvokeTimeSpan < 200) ? 1 : 0,
                    CallLevel3Num     = (ab.InvokeTimeSpan > 200) ? 1 : 0,
                    CallHitCacheNum   = ab.IsCache,
                    InBytes           = ab.InBytes,
                    OutBytes          = ab.OutBytes,
                    TpsPeak           = 1,
                    CallQueueNum      = ab.IsQueue,
                    MaxInovkeTimeSpan = ab.InvokeTimeSpan,
                    BusinessID        = ab.BusinessID
                };
                serviceMonitorArray[second] = serviceMonitor;
            }
            else
            {
                if (ab.Status == 1)
                {
                    serviceMonitor.CallSuccessNum++;
                }
                else
                {
                    serviceMonitor.CallFailureNum++;
                }

                if (ab.InvokeTimeSpan > 200)
                {
                    serviceMonitor.CallLevel3Num++;
                }
                else if (ab.InvokeTimeSpan > 100 && ab.InvokeTimeSpan <= 200)
                {
                    serviceMonitor.CallLevel2Num++;
                }
                else if (ab.InvokeTimeSpan > 20 && ab.InvokeTimeSpan <= 100)
                {
                    serviceMonitor.CallLevel1Num++;
                }

                serviceMonitor.InBytes         += ab.InBytes;
                serviceMonitor.OutBytes        += ab.OutBytes;
                serviceMonitor.CallHitCacheNum += ab.IsCache;
                serviceMonitor.CallQueueNum    += ab.IsQueue;
                serviceMonitor.TpsPeak++;

                if (ab.InvokeTimeSpan > serviceMonitor.MaxInovkeTimeSpan)
                {
                    serviceMonitor.MaxInovkeTimeSpan = ab.InvokeTimeSpan;
                }
            }
        }
Beispiel #20
0
        /// <summary>
        /// 从监控数据中查找是否有审计日志对应维度的数据
        /// </summary>
        /// <param name="ab"></param>
        /// <returns></returns>
        private MonitorStatDimension GetMonitorStatDimension(AuditBusiness ab)
        {
            String methodName = ab.RowMethodName;

            foreach (var item in m_ServiceMonitor.Keys)
            {
                if (item.ServiceName == ab.ServiceName && item.MethodName == methodName && item.BindingAddress == ab.BindingAddress)
                {
                    return item;
                }
            }

            return null;
        }
Beispiel #21
0
 /// <summary>
 /// 发送审计消息
 /// </summary>
 public void SendAuditMessage(AuditBusiness auditBussiness)
 {
     SendMessage <AuditBusiness>(Constant.ESB_AUDIT_QUEUE, auditBussiness);
 }
Beispiel #22
0
 public int GetAuditBusinessCount(AuditBusinessSearchCondition condition)
 {
     return(AuditBusiness.GetAuditBusinessCount(condition));
 }
Beispiel #23
0
 /// <summary>
 /// 添加审计日志
 /// </summary>
 /// <param name="business"></param>
 public void AddAuditBusiness(AuditBusiness business)
 {
     dataAccess.AddAuditBusiness(business);
 }
Beispiel #24
0
        public static DA_LOGIN_AUDIT GetLogUser(SessionInfo sessioninfo)
        {
            AuditBusiness _auditBusiness = new AuditBusiness();

            return(_auditBusiness.GetUserLogged(sessioninfo));
        }
Beispiel #25
0
        /// <summary>
        /// 根据日志OID获取到单条审计日志
        /// </summary>
        /// <param name="oid"></param>
        /// <returns></returns>
        public AuditBusiness GetAuditBusinessByOID(Guid oid)
        {
            AuditBusiness ab = dataAccess.GetAuditBusinessByOID(oid);

            return(ab);
        }
 public DataSet GetAuditTrailReport(DateTime fromDate, DateTime toDate, string sModuleName)
 {
     AuditBusiness AB = new AuditBusiness();
     return AB.GetAuditTrailReport(fromDate, toDate, sModuleName);
 }
Beispiel #27
0
        /// <summary>
        /// 记录一条监控日志,统计维度已经在Push方法中划分好了
        /// </summary>
        /// <param name="ab"></param>
        /// <param name="serviceMonitorArray"></param>
        private void RecordItem(AuditBusiness ab, ServiceMonitor[] serviceMonitorArray)
        {
           // DateTime serviceBeginTime = DateTime.ParseExact(ab.ServiceBeginTime, "yyyy-MM-dd HH:mm:ss.ffffff", null);
            DateTime monitorStamp = DateTime.Now;
            Int32 second = monitorStamp.Second;
            ServiceMonitor serviceMonitor = serviceMonitorArray[second];


            //XTrace.WriteLine("第{0}秒记录。", second);

            if (serviceMonitor == null)
            {
                serviceMonitor = new ServiceMonitor(){
                    OID = Guid.NewGuid().ToString(),
                    ServiceName = ab.ServiceName,
                    MethodName = ab.RowMethodName,
                    MonitorStamp = monitorStamp,
                    ConsumerIP = ab.ConsumerIP,
                    BindingAddress = ab.BindingAddress,
                    CallSuccessNum = (ab.Status == 1) ? 1 : 0,
                    CallFailureNum =  (ab.Status == 1) ? 0 : 1,
                    CallLevel1Num = (ab.InvokeTimeSpan > 20 && ab.InvokeTimeSpan < 100) ? 1 : 0,
                    CallLevel2Num = (ab.InvokeTimeSpan > 100 && ab.InvokeTimeSpan < 200) ? 1 : 0,
                    CallLevel3Num = (ab.InvokeTimeSpan > 200) ? 1 : 0,
                    CallHitCacheNum = ab.IsCache,
                    InBytes = ab.InBytes,
                    OutBytes = ab.OutBytes,
                    TpsPeak = 1,
                    CallQueueNum = ab.IsQueue,
                    MaxInovkeTimeSpan = ab.InvokeTimeSpan,
                    BusinessID = ab.BusinessID
                };
                serviceMonitorArray[second] = serviceMonitor;
            }
            else
            {
                if (ab.Status == 1)
                    serviceMonitor.CallSuccessNum++;
                else
                    serviceMonitor.CallFailureNum++;

                if (ab.InvokeTimeSpan > 200)
                    serviceMonitor.CallLevel3Num++;
                else if (ab.InvokeTimeSpan > 100 && ab.InvokeTimeSpan <= 200)
                    serviceMonitor.CallLevel2Num++;
                else if(ab.InvokeTimeSpan > 20 && ab.InvokeTimeSpan <= 100)
                    serviceMonitor.CallLevel1Num++;

                serviceMonitor.InBytes += ab.InBytes;
                serviceMonitor.OutBytes += ab.OutBytes;
                serviceMonitor.CallHitCacheNum += ab.IsCache;
                serviceMonitor.CallQueueNum += ab.IsQueue;
                serviceMonitor.TpsPeak++;

                if (ab.InvokeTimeSpan > serviceMonitor.MaxInovkeTimeSpan)
                    serviceMonitor.MaxInovkeTimeSpan = ab.InvokeTimeSpan;
            }
        }
Beispiel #28
0
 public AuditBusiness GetAuditBusinessByOID(String auditID)
 {
     return(AuditBusiness.GetAuditBusinessByOID(auditID));
 }
Beispiel #29
0
        /// <summary>
        /// 接收一条审计记录
        /// </summary>
        /// <param name="?"></param>
        public void Push(AuditBusiness ab)
        {
            String serviceName = ab.ServiceName;
            ServiceMonitor[] serviceMonitorArray;
            MonitorStatDimension msDimension = GetMonitorStatDimension(ab);

            //--如果统计中没有相应维度的数据,则创建
            if (msDimension == null)
            {
                serviceMonitorArray = new ServiceMonitor[60];
                msDimension = new MonitorStatDimension()
                {
                    ServiceName = ab.ServiceName,
                    BindingAddress = ab.BindingAddress,
                    MethodName = ab.RowMethodName
                };
                m_ServiceMonitor.Add(msDimension, serviceMonitorArray);
            }
            else
            {
                serviceMonitorArray = m_ServiceMonitor[msDimension];
            }

            RecordItem(ab, serviceMonitorArray);
        }
Beispiel #30
0
        public static void LogOut(SessionInfo sessioninfo)
        {
            AuditBusiness _auditBusiness = new AuditBusiness();

            _auditBusiness.TraceAuditLogoutUser(sessioninfo);
        }
Beispiel #31
0
    protected void grid_OnHtmlEditFormCreated(object sender, ASPxGridViewEditFormEventArgs e)
    {
        Control       pc    = grid.FindEditFormTemplateControl("pageControl");
        Control       tbl   = grid.FindEditFormTemplateControl("tblDownload");
        Control       cMB   = pc.FindControl("txtMessageBody");
        Control       cRMB  = pc.FindControl("txtReturnMessageBody");
        ASPxHyperLink hlReq = tbl.FindControl("lnkReq") as ASPxHyperLink;
        ASPxHyperLink hlRes = tbl.FindControl("lnkRes") as ASPxHyperLink;

        if (cMB != null && cRMB != null)
        {
            ASPxMemo txtMB  = cMB as ASPxMemo;
            ASPxMemo txtRMB = cRMB as ASPxMemo;

            string msgBody    = "无法寻找请求消息体!";
            string retMsgBody = "无法寻找响应消息体!";
            string oid        = txtMB.Text;

            try
            {
                Guid g = new Guid(oid);
            }
            catch
            {
                return;
            }

            hlReq.NavigateUrl += oid;
            hlRes.NavigateUrl += oid;

            AuditService  auditService  = new AuditService();
            AuditBusiness auditBusiness = auditService.GetAuditBusinessByOID(oid);

            if (!(String.IsNullOrEmpty(auditBusiness.MessageBody)))
            {
                String msgContent = auditBusiness.MessageBody;
                if (msgContent.Length > 102400)
                {
                    msgBody = msgContent.Substring(0, 102400) + "(只显示100K数据,剩余数据隐藏)";
                }
                else
                {
                    msgBody = msgContent;
                }
            }
            else
            {
                msgBody = "请求消息体为空!";
            }

            if (!(String.IsNullOrEmpty(auditBusiness.ReturnMessageBody)))
            {
                String msgContent = auditBusiness.ReturnMessageBody;
                if (msgContent.Length > 102400)
                {
                    retMsgBody = msgContent.Substring(0, 102400) + "(只显示100K数据,剩余数据隐藏)";
                }
                else
                {
                    retMsgBody = msgContent;
                }
            }
            else
            {
                retMsgBody = "响应消息体为空!";
            }

            txtMB.Text  = msgBody;
            txtRMB.Text = retMsgBody;
        }
    }
Beispiel #32
0
        /// <summary>
        /// 增加审计日志
        /// </summary>
        public static String AddAuditLog(int status
                                         , String bindingTemplateID
                                         , String serviceID
                                         , String address
                                         , CallState callState
                                         , String message
                                         , ESB.Core.Schema.务请求 request
                                         , Int32 isCache = 0)
        {
            callState.RequestEndTime = DateTime.Now;
            TimeSpan ReqTimeSpan = callState.RequestEndTime.Subtract(callState.RequestBeginTime);

            ConfigurationManager cm = ConfigurationManager.GetInstance();
            String consumerIP       = cm.LocalIP;

            if (callState.InvokeParam != null && !String.IsNullOrWhiteSpace(callState.InvokeParam.ConsumerIP))
            {
                consumerIP = callState.InvokeParam.ConsumerIP;
            }

            Int32 isQueue = 0;

            if (callState.InvokeParam != null)
            {
                isQueue = callState.InvokeParam.IsQueue;
            }

            AuditBusiness log = new AuditBusiness()
            {
                OID               = Guid.NewGuid().ToString(),
                HostName          = request.主机名称,
                ServiceName       = request.务名称,
                MethodName        = request.方法名称,
                ReqBeginTime      = callState.RequestBeginTime.ToString("yyyy-MM-dd HH:mm:ss.ffffff"),
                ReqEndTime        = callState.RequestEndTime.ToString("yyyy-MM-dd HH:mm:ss.ffffff"),
                Status            = status,
                MessageID         = callState.MessageID,
                MessageBody       = request.消息内容,
                CallBeginTime     = callState.CallBeginTime.ToString("yyyy-MM-dd HH:mm:ss.ffffff"),
                CallEndTime       = callState.CallEndTime.ToString("yyyy-MM-dd HH:mm:ss.ffffff"),
                BindingTemplateID = bindingTemplateID,
                ServiceID         = serviceID,
                BindingAddress    = address,
                ReturnMessageBody = message,
                BusinessName      = "",
                BusinessID        = "",
                ServiceBeginTime  = callState.ServiceBeginTime,
                ServiceEndTime    = callState.ServiceEndTime,
                TraceID           = callState.TraceContext.TraceID,
                InvokeLevel       = callState.TraceContext.InvokeLevel,
                InvokeOrder       = callState.TraceContext.InvokeOrder,
                InvokeID          = callState.TraceContext.InvokeID,
                InvokeTimeSpan    = ReqTimeSpan.TotalMilliseconds,
                ConsumerIP        = consumerIP,
                Version           = callState.ServiceVersion,
                IsCache           = isCache,
                IsQueue           = isQueue
            };

            //log.Insert();
            //String mqHost = ESBProxy.GetInstance().ESBConfig.Monitor[0].Uri;
            //MSMQUtil.SendMessage<AuditBusiness>(log, String.Format(@"FormatName:DIRECT=TCP:{0}\Private$\EsbAuditQueue", "192.168.56.2"));

            ESBProxy.GetInstance().MessageQueueClient.SendAuditMessage(log);

            //--每调用完一次需要增加调用次数
            callState.TraceContext.IncreaseInvokeOrder();

            return(log.OID);
        }