using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Web.Mvc; using Abp.Application.Services.Dto; using Abp.Auditing; using Abp.Authorization; using Abp.Domain.Repositories; using Abp.Runtime.Caching; using WeApp.Authorization; using WeApp.BaseSystem.AuditLog.Dto; using IwbZero.AppServiceBase; using IwbZero.Auditing; using IwbZero.Authorization.Base.SystemInfo; using IwbZero.ToolCommon.Lambda; using IwbZero.ToolCommon.StringModel; using WeApp.Configuration; namespace WeApp.BaseSystem.AuditLog { [AbpAuthorize, AuditLog("系统日志", "日志")] public class AuditLogsAppService : IwbAsyncCrudAppService, IAuditLogsAppService { public AuditLogsAppService(ICacheManager cacheManager, IRepository repository) : base(repository) { CacheManager = cacheManager; } protected override string GetPermissionName { get; set; } = PermissionNames.PagesSystemMgLogMg; protected override string GetAllPermissionName { get; set; } = PermissionNames.PagesSystemMgLogMg; //protected override string CreatePermissionName { get; set; } = PermissionNames.PagesSystemMgLogMgCreate; //protected override string UpdatePermissionName { get; set; } = PermissionNames.PagesSystemMgLogMgUpdate; //protected override string DeletePermissionName { get; set; } = PermissionNames.PagesSystemMgLogMgDelete; #region GetSelectList [DisableAuditing, AbpAllowAnonymous] public List GetLogServiceSelectLists() { var sList = new List(); var list = Repository.GetAll().Where(a => a.LogType != 0).GroupBy(a => a.ServiceName).Select(a => a.Key); foreach (var l in list) { sList.Add(new SelectListItem { Text = l, Value = l }); } return sList; } [DisableAuditing, AbpAllowAnonymous] public string GetLogServiceSelectListStrs() { var options = ""; var list = Repository.GetAll().Where(a => a.LogType != 0).GroupBy(a => a.ServiceName).Select(a => a.Key); foreach (var l in list) { options += $""; } return options; } [DisableAuditing, AbpAllowAnonymous] public List GetLogMethodSelectLists(QueryMethodName input) { var sList = new List(); var list = Repository.GetAll().Where(a => a.LogType != 0 && (string.IsNullOrEmpty(input.ServiceName) || a.ServiceName == input.ServiceName)).GroupBy(a => a.MethodName).Select(a => a.Key); foreach (var l in list) { sList.Add(new SelectListItem { Text = l, Value = l }); } return sList; } [DisableAuditing, AbpAllowAnonymous] public string GetLogMethodSelectListStrs(QueryMethodName input) { string options = ""; var list = Repository.GetAll().Where(a => a.LogType != 0 && (string.IsNullOrEmpty(input.ServiceName) || a.ServiceName == input.ServiceName)).GroupBy(a => a.MethodName).Select(a => a.Key); foreach (var l in list) { options += $""; } return options; } #endregion [DisableAuditing] public override async Task> GetAll(IwbPagedRequestDto input) { CheckGetAllPermission(); var query = CreateFilteredQuery(input).Where(a => a.LogType != 0); if (input.SearchList != null && input.SearchList.Count > 0) { List objList = new List(); foreach (var o in input.SearchList) { if (o.KeyWords.IsEmpty()) continue; object keyWords = o.KeyWords; objList.Add(new LambdaObject { FieldType = (LambdaFieldType)o.FieldType, FieldName = o.KeyField, FieldValue = keyWords, ExpType = (LambdaExpType)o.ExpType }); } var exp = objList.GetExp(); query = query.Where(exp); } var totalCount = await AsyncQueryableExecuter.CountAsync(query); query = query.OrderByDescending(a=>a.Id); query = ApplyPaging(query, input); var entities = await AsyncQueryableExecuter.ToListAsync(query); var dtos = new PagedResultDto( totalCount, entities.Select(MapToEntityDto).ToList() ); return dtos; } } }