Ejemplo n.º 1
0
        /// <summary>
        /// 根据查询条件获取运行日志记录
        /// </summary>
        /// <param name="Runlogrequest"></param>
        /// <returns></returns>
        public BasicResponse <List <RunlogInfo> > GetRunlogs(RunlogGetByConditionsRequest runlogrequest)
        {
            BasicResponse <List <RunlogInfo> > Result = new BasicResponse <List <RunlogInfo> >();
            List <RunlogInfo> operateList             = new List <RunlogInfo>();

            try
            {
                if (runlogrequest.dtStart != new DateTime(1, 1, 1, 0, 0, 0) && runlogrequest.dtEnd != new DateTime(1, 1, 1, 0, 0, 0) &&
                    runlogrequest.dtStart != null && runlogrequest.dtEnd != null)
                {
                    if (runlogrequest.dtStart > runlogrequest.dtEnd)
                    {
                        //throw new BusinessException(String.Format("开始日期不能大于结束日期!"));
                        ThrowException("GetRunlogs", new Exception("开始日期不能大于结束日期!"));
                    }
                }

                var RunlogModelLists = _Repository.GetRunlogList();
                var RunlogInfoLists  = new List <RunlogInfo>();
                foreach (var item in RunlogModelLists)
                {
                    var RunlogInfo = ObjectConverter.Copy <RunlogModel, RunlogInfo>(item);
                    RunlogInfoLists.Add(RunlogInfo);
                }

                //根据条件筛选
                if (runlogrequest.dtStart != new DateTime(1, 1, 1, 0, 0, 0) && runlogrequest.dtStart != null)
                {
                    RunlogInfoLists = RunlogInfoLists.FindAll(a => a.CreateDate >= runlogrequest.dtStart).ToList();
                }
                if (runlogrequest.dtEnd != new DateTime(1, 1, 1, 0, 0, 0) && runlogrequest.dtEnd != null)
                {
                    RunlogInfoLists = RunlogInfoLists.FindAll(a => a.CreateDate <= runlogrequest.dtEnd).ToList();
                }
                if (!string.IsNullOrEmpty(runlogrequest.loglevel.ToString()))
                {
                    RunlogInfoLists = RunlogInfoLists.FindAll(a => a.LogLevel == runlogrequest.loglevel.ToString()).ToList();
                }
                if (!string.IsNullOrEmpty(runlogrequest.context))
                {
                    RunlogInfoLists = RunlogInfoLists.FindAll(a => a.MessageContent.Contains(runlogrequest.context)).ToList();
                }
                if (runlogrequest.pageNumber > 0 && runlogrequest.pageSize > 0)
                {
                    int pageIndex = runlogrequest.pageNumber - 1;
                    int pageSize  = runlogrequest.pageSize;
                    RunlogInfoLists = RunlogInfoLists.Skip(pageIndex * pageSize).Take(pageSize).ToList();
                }
            }
            catch (Exception ex)
            {
                ThrowException("GetRunlogs", ex);
            }
            return(Result);
        }
Ejemplo n.º 2
0
 public BasicResponse <List <RunlogInfo> > GetRunlogs(RunlogGetByConditionsRequest runlogrequest)
 {
     return(_runlogService.GetRunlogs(runlogrequest));
 }
        /// <summary>
        /// 根据查询条件获取运行日志记录
        /// </summary>
        /// <param name="runlogrequest"></param>
        /// <returns></returns>
        public BasicResponse <List <RunlogInfo> > GetRunlogs(RunlogGetByConditionsRequest runlogrequest)
        {
            var responseStr = HttpClientHelper.Post(Webapi + "/v1/Runlog/GetRunlogsByConditions?token=" + Token, JSONHelper.ToJSONString(runlogrequest));

            return(JSONHelper.ParseJSONString <BasicResponse <List <RunlogInfo> > >(responseStr));
        }