Exemplo n.º 1
0
        public static void Email()
        {
            var         searchLogs    = getSearchLog();
            EmailSender sender        = new EmailSender();
            var         recipentEmail = ConfigurationManager.AppSettings["recipentEmail"];

            sender.Send(recipentEmail, SearchLogModel.Printify(searchLogs));
            markLogsDone();
        }
Exemplo n.º 2
0
        public async Task <IActionResult> FindWithPagerSearchAsync(SearchLogModel search)
        {
            CommonResult <PageResult <LogOutputDto> > result = new CommonResult <PageResult <LogOutputDto> >();

            result.ResData = await iService.FindWithPagerSearchAsync(search);

            result.ErrCode = ErrCode.successCode;
            return(ToJsonContent(result));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据条件查询数据库,并返回对象集合(用于分页数据显示)
        /// </summary>
        /// <param name="search">查询的条件</param>
        /// <returns>指定对象的集合</returns>
        public async Task <PageResult <LogOutputDto> > FindWithPagerSearchAsync(SearchLogModel search)
        {
            bool order = search.Order == "asc" ? false : true;

            string where = GetDataPrivilege(false);
            if (!string.IsNullOrEmpty(search.CreatorTime1))
            {
                where += " and CreatorTime >='" + search.CreatorTime1.ToDateTime() + "'";
            }
            if (!string.IsNullOrEmpty(search.CreatorTime2))
            {
                where += " and CreatorTime <='" + search.CreatorTime2.ToDateTime() + "'";
            }
            if (!string.IsNullOrEmpty(search.Filter.Type))
            {
                where += " and Type='" + search.Filter.Type + "'";
            }
            if (!string.IsNullOrEmpty(search.Filter.IPAddress))
            {
                where += string.Format(" and IPAddress = '{0}'", search.Filter.IPAddress);
            }
            ;
            if (!string.IsNullOrEmpty(search.Filter.Account))
            {
                where += string.Format(" and Account = '{0}'", search.Filter.Account);
            }
            ;
            PagerInfo pagerInfo = new PagerInfo
            {
                CurrenetPageIndex = search.CurrenetPageIndex,
                PageSize          = search.PageSize
            };

            //Expression<Func<Log, bool>> filter = log => true;
            //if (!string.IsNullOrEmpty(search.Keywords))
            //{
            //    filter = filter.And(log => log.Account.StartsWith(search.Keywords) || log.ModuleName.StartsWith(search.Keywords) || log.IPAddress.StartsWith(search.Keywords)
            // || log.IPAddressName.StartsWith(search.Keywords) || log.Description.StartsWith(search.Keywords));
            //}
            //if (!string.IsNullOrEmpty(search.EnCode))
            //{
            //    filter = filter.And(log=>search.EnCode.Contains(log.Type));
            //}
            List <Log> list = await _iLogRepository.FindWithPagerAsync(where, pagerInfo, search.Sort, order);

            PageResult <LogOutputDto> pageResult = new PageResult <LogOutputDto>
            {
                CurrentPage  = pagerInfo.CurrenetPageIndex,
                Items        = list.MapTo <LogOutputDto>(),
                ItemsPerPage = pagerInfo.PageSize,
                TotalItems   = pagerInfo.RecordCount
            };

            return(pageResult);
        }
Exemplo n.º 4
0
        public IHttpActionResult GetChunk(long chunk, string tableType, SearchLogModel model)
        {
            var result = new ResultMessage <IEnumerable <TblDbLogDto> >();

            try
            {
                result = this.dbLogService.GetChunk(chunk, tableType, model);
            }
            catch (Exception ex)
            {
                this.LoggerService.LogException(ex);
                result.Messages.Add(new Message(null, ex.Message));
            }

            return(this.CreateCustomResponse(result));
        }
Exemplo n.º 5
0
        public IHttpActionResult GetDataWithInDateTimeRange(SearchLogModel model)
        {
            var result = new ResultMessage <IEnumerable <TblDbLogDto> >();

            try
            {
                result = this.dbLogService.GetDataWithInDateTimeRange(model.StartDate, model.EndDate);
            }
            catch (Exception ex)
            {
                this.LoggerService.LogException(ex);
                result.Messages.Add(new Message(null, ex.Message));
            }

            return(this.CreateCustomResponse(result));
        }
Exemplo n.º 6
0
        public LogModelList SelectLogList(SearchLogModel request)
        {
            var cs = "Server=localhost\\SQLEXPRESS;Database=HospitalDB;Trusted_Connection=True;";

            using var con = new SqlConnection(cs);
            con.Open();

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            string defaultQuery = "SELECT Id, Action, TargetName, CreateName, CreateDate FROM LogTbl";

            string ActionQuery     = request.Action == null ? "" : string.Format(" AND Action = '{0}'", request.Action);
            string CreateNameQuery = request.CreateName == null ? "" : string.Format(" AND CreateName = '{0}'", request.CreateName);
            string targetNameQuery = request.TargetName == null ? "" : string.Format(" AND TargetName = '{0}'", request.TargetName);

            string sql = string.Format("{0} WHERE CreateDate BETWEEN '{1}' AND '{2}' {3}{4}{5};"
                                       , defaultQuery
                                       , request.StartDate.ToString("yyyy-MM-dd HH:mm:ss")
                                       , request.EndDate.ToString("yyyy-MM-dd HH:mm:ss")
                                       , ActionQuery
                                       , CreateNameQuery
                                       , targetNameQuery
                                       );

            using var cmd = new SqlCommand(sql, con);

            using SqlDataReader rdr = cmd.ExecuteReader();

            LogModelList output = new LogModelList();

            output.Logtable = new List <LogModel>();

            while (rdr.Read())
            {
                output.Logtable.Add(
                    new LogModel()
                {
                    Id         = rdr.GetInt32(0),
                    Action     = rdr.GetString(1),
                    TargetName = rdr.GetString(2),
                    CreateName = rdr.GetString(3),
                    CreateDate = rdr.GetDateTime(4),
                }
                    );
            }
            return(output);
        }
Exemplo n.º 7
0
        public (List <LogModel> data, long total) Get(SearchLogModel model)
        {
            var filters = FilterDefinition <LogModel> .Empty;
            var appName = Builders <LogModel> .Filter.Eq("AppName", model.AppName);

            filters = Builders <LogModel> .Filter.And(filters, appName);

            if (!string.IsNullOrEmpty(model.Level))
            {
                var level = Builders <LogModel> .Filter.Eq("LogLevel", model.Level);

                filters = Builders <LogModel> .Filter.And(filters, level);
            }

            if (model.ValidFrom.HasValue)
            {
                var validFrom = Builders <LogModel> .Filter.Gte("LogTime", model.ValidFrom);

                filters = Builders <LogModel> .Filter.And(filters, validFrom);
            }

            if (model.ValidTo.HasValue)
            {
                var validTo = Builders <LogModel> .Filter.Lte("LogTime", model.ValidTo);

                filters = Builders <LogModel> .Filter.And(filters, validTo);
            }

            var skip = (model.PageIndex - 1) * 10;

            skip = skip < 0 ? 0 : skip;
            var logs  = Collection.Find(filters).SortByDescending(p => p.AddTime).Skip(skip).Limit(10).ToList();
            var count = Collection.Find(filters).CountDocuments();

            return(logs, count);
        }
Exemplo n.º 8
0
        public LogModelList SelectLogList(SearchLogModel request)
        {
            LogModelList result = _logRepository.SelectLogList(request);

            return(result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Get Data in chunks of 50
        /// </summary>
        /// <param name="chunk">last chunk identifier</param>
        /// <param name="tableType">Table type filter</param>
        /// <param name="model">date range filter</param>
        /// <returns>TblDbLog List filtered object</returns>
        public ResultMessage <IEnumerable <TblDbLogDto> > GetChunk(long chunk, string tableType, SearchLogModel model)
        {
            var result = new ResultMessage <IEnumerable <TblDbLogDto> >();

            List <TblDbLog> entities;

            if (chunk == 0)
            {
                if (tableType == "All")
                {
                    entities = model.StartDate == DateTime.MinValue ? this.Table.GetAll().OrderByDescending(m => m.Id).Take(50).ToList() : this.Table.Find(m => m.CreatedOn >= model.StartDate && m.CreatedOn <= model.EndDate).OrderByDescending(m => m.Id).Take(50).ToList();
                }
                else
                {
                    entities = model.StartDate == DateTime.MinValue ? this.Table.Find(m => m.TableType == tableType).OrderByDescending(m => m.Id).Take(50).ToList() : this.Table.Find(m => m.TableType == tableType && m.CreatedOn >= model.StartDate && m.CreatedOn <= model.EndDate).OrderByDescending(m => m.Id).Take(50).ToList();
                }
            }
            else
            {
                if (tableType == "All")
                {
                    entities = model.StartDate == DateTime.MinValue ? this.Table.Find(m => m.Id < chunk).OrderByDescending(m => m.Id).Take(50).ToList() : this.Table.Find(m => m.Id < chunk && m.CreatedOn >= model.StartDate && m.CreatedOn <= model.EndDate).OrderByDescending(m => m.Id).Take(50).ToList();
                }
                else
                {
                    entities = model.StartDate == DateTime.MinValue ? this.Table.Find(m => m.Id < chunk && m.TableType == tableType).OrderByDescending(m => m.Id).Take(50).ToList() : this.Table.Find(m => m.Id < chunk && m.TableType == tableType && m.CreatedOn >= model.StartDate && m.CreatedOn <= model.EndDate).OrderByDescending(m => m.Id).Take(50).ToList();
                }
            }

            if (!entities.Any())
            {
                result.Messages.Add(new Message(null, "Record not found!"));
            }
            else
            {
                var mapper = this.mapperFactory.GetMapper <TblDbLog, TblDbLogDto>();
                result.Item = entities.Select(mapper.Map).OrderBy(x => x.Id);
            }

            return(result);
        }
Exemplo n.º 10
0
        public IActionResult List([FromBody] SearchLogModel model)
        {
            var data = _logService.Get(model);

            return(Json(data));
        }
Exemplo n.º 11
0
        public LogModelList SelectLog([FromQuery] SearchLogModel request)
        {
            LogModelList result = _logService.SelectLogList(request);

            return(result);
        }