/// <summary>
        /// Mq消费者client status
        /// </summary>
        /// <param name="limit"></param>
        /// <param name="offset"></param>
        /// <param name="search"></param>
        /// <returns></returns>
        public ActionResult ConsumerInfo(int limit, int offset, string search = null)
        {
            var query = Query.Null;

            if (!string.IsNullOrEmpty(search))
            {
                query = Query.Matches("ip", BsonRegularExpression.Create($"/{search}/"));
            }
            var total = dataOp.FindCount(MQConsumerInfo, query);
            var rows  = new List <dynamic>();

            if (total > 0)
            {
                var sortBy = new SortByDocument {
                    { "isStart", -1 }, { "lastStartTime", -1 }, { "lastEndTime", -1 }, { "ip", 1 }
                };
                var docs = dataOp.FindLimitByQuery(MQConsumerInfo, query, sortBy, offset, limit);
                foreach (var doc in docs)
                {
                    var consumerId = doc.Int("consumerId");
                    var ip         = doc.String("ip");
                    var queueType  = doc.String("queueType");
                    var isStart    = doc.Int("isStart");
                    if (isStart > 0)
                    {
                        SystemMonitorBll._().SetIp(ip);
                    }
                    var lastStartTime = doc.String("lastStartTime");
                    var lastEndTime   = doc.String("lastEndTime");
                    var lastExecTime  = doc.String("lastExecTime");
                    rows.Add(new { consumerId, ip, queueType, isStart, lastStartTime, lastEndTime, lastExecTime });
                }
            }
            return(Json(new { total, rows }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// Mq consume failed log
        /// </summary>
        /// <param name="limit"></param>
        /// <param name="offset"></param>
        /// <param name="search"></param>
        /// <returns></returns>
        public ActionResult ConsumerLogInfo(int limit, int offset, string search = null)
        {
            var query = Query.Null;

            if (!string.IsNullOrEmpty(search))
            {
            }
            var total = dataOp.FindCount(MQConsumerLog, query);
            var rows  = new List <dynamic>();

            if (total > 0)
            {
                var sortBy = new SortByDocument {
                    { "time", -1 }
                };
                var docs = dataOp.FindLimitByQuery(MQConsumerLog, query, sortBy, offset, limit);
                foreach (var doc in docs)
                {
                    var logId      = doc.Int("logId");
                    var consumerId = doc.String("consumerId");
                    var info       = SystemMonitorBll._().GetConsumerInfo(consumerId);
                    var ip         = info?.ip;
                    var queueType  = info?.queueType;
                    var type       = doc.Int("type");
                    var msg        = doc.String("msg");
                    var sourceData = doc.String("sourceData");
                    if (sourceData.Length > 2500)
                    {
                        sourceData = RemoveRunLog(sourceData);
                    }
                    var time     = doc.String("time");
                    var customer = SystemMonitorBll._().GetCustomerNameByJobId(GetJobId(sourceData));
                    rows.Add(new { logId, ip, queueType, type, msg, sourceData, time, customer });
                }
            }
            return(Json(new { total, rows }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
 protected void Application_End()
 {
     SystemMonitorBll._().Stop();
 }