Esempio n. 1
0
        public IQueryable <AdminLogResponseModel> GetAdminLogs(AdminLogRequestModel request)
        {
            var events = new List <string>();

            if (request.SelectLogin)
            {
                events.Add(AdminLogType.Login.GetDescription());
            }
            if (request.SelectLogout)
            {
                events.Add(AdminLogType.Logout.GetDescription());
            }
            if (request.SelectGiftLog)
            {
                events.Add(AdminLogType.GiftLog.GetDescription());
            }
            if (request.SelectExpertApprove)
            {
                events.Add(AdminLogType.ExpertApprove.GetDescription());
            }
            if (request.SelectExpertManage)
            {
                events.Add(AdminLogType.ExpertManage.GetDescription());
            }
            if (request.SelectQAlog)
            {
                events.Add(AdminLogType.QALog.GetDescription());
            }

            var _endDate = request.EndDate;

            if (_endDate != null)
            {
                _endDate = new DateTime((int)_endDate?.Year, (int)_endDate?.Month, (int)_endDate?.Day, 23, 59, 59); //搜尋範圍是到當天的最後一秒
            }

            var res = db.TblOperationLog
                      .Join(db.TblAdmin, a => a.Operator, b => b.Id, (a, b) => new { TblOperationLog = a, TblAdmin = b })
                      .Where(a => (request.StartDate == null) ? true : a.TblOperationLog.RequestTime >= request.StartDate)
                      .Where(a => (request.EndDate == null) ? true : a.TblOperationLog.RequestTime <= _endDate)
                      .Where(a => (string.IsNullOrEmpty(request.Operator)) ? true : a.TblAdmin.Name.Contains(request.Operator))
                      .Where(a => (string.IsNullOrEmpty(request.Ip)) ? true : a.TblOperationLog.Ip.Contains(request.Ip))
                      .Where(a => (string.IsNullOrEmpty(request.Remark)) ? true : a.TblOperationLog.Remark.Contains(request.Remark))
                      .Where(a => events.Contains(a.TblOperationLog.Type))
                      .Select(a => new AdminLogResponseModel
            {
                Id          = a.TblOperationLog.Id,
                Operator    = a.TblAdmin.Name,
                Event       = a.TblOperationLog.Name,
                Ip          = a.TblOperationLog.Ip,
                Remark      = a.TblOperationLog.Remark,
                RequestTime = a.TblOperationLog.RequestTime
            })
                      .OrderByDescending(a => a.RequestTime)
                      .ThenByDescending(a => a.Event)
                      .ThenByDescending(a => a.Id);

            return(res);
        }
Esempio n. 2
0
        public IQueryable <AdminLogResponseModel> GetAdminLogs(AdminLogRequestModel requestModel)
        {
            var adminLogs = adminLogService.GetAdminLogs(requestModel);

            return(adminLogs);
        }