public async Task <IDataSourceResult <ActivityLog> > GetActivityLogsAsync( int skip, int take, string ipAddress = "", string message = "", string userId = null, ActivityTypeEnum?activityType = null, DateTime?startCreatedTime = null, DateTime?endCreatedTime = null) { BaseSpecification <ActivityLog> activityLogSpecification = new BaseSpecification <ActivityLog>(q => (string.IsNullOrEmpty(message) || EF.Functions.Contains(q.Message, message)) && (string.IsNullOrEmpty(userId) || q.UserId == userId) && (string.IsNullOrEmpty(ipAddress) || q.IpAddress == ipAddress) && (!startCreatedTime.HasValue || q.CreatedTime >= startCreatedTime) && (!endCreatedTime.HasValue || q.CreatedTime <= endCreatedTime) && (!activityType.HasValue || q.Type == activityType)); activityLogSpecification.ApplyOrderByDescending(q => q.Id); activityLogSpecification.ApplySelector(q => new ActivityLog { Id = q.Id, CreatedTime = q.CreatedTime, UserId = q.UserId, Message = q.Message, Type = q.Type, ObjectType = q.ObjectType, IpAddress = q.IpAddress, Complete = q.Complete }); activityLogSpecification.ApplyPaging(skip, take); return(await ToDataSourceResultAsync(activityLogSpecification)); }
/// <summary> /// Hàm lấy danh sách giá trị config hệ thống theo key /// </summary> /// <param name="skip">Số bản ghi bỏ qua</param> /// <param name="take">Số bản ghi cần lấy</param> /// <param name="key">Key code</param> /// <returns>IDataSourceResult</returns> public async Task <IDataSourceResult <SystemValue> > GetSystemValuesAsync(int skip, int take, string key = "") { BaseSpecification <SystemValue> systemValueSpecification = new BaseSpecification <SystemValue>(q => (string.IsNullOrEmpty(key) || EF.Functions.Contains(q.Key, key))); systemValueSpecification.ApplyOrderByDescending(q => q.Id); systemValueSpecification.ApplyPaging(skip, take); return(await ToDataSourceResultAsync(systemValueSpecification)); }
/// <summary> /// Lấy danh sách UserGroupMapping /// </summary> /// <param name="skip">skip row value</param> /// <param name="take">take row value</param> /// <param name="userId">Id người dùng</param> /// <param name="groupId">Id ngóm</param> /// <returns>Danh sách mapping</returns> public async Task <IDataSourceResult <UserGroupMapping> > GetUserGroupMappingsAsync(int skip, int take, string userId = null, string groupId = null) { BaseSpecification <UserGroupMapping> baseSpecification = new BaseSpecification <UserGroupMapping>(q => (string.IsNullOrEmpty(userId) || q.UserId == userId) && (string.IsNullOrEmpty(groupId) || q.UserGroupId == groupId)); baseSpecification.ApplyOrderByDescending(q => q.Id); baseSpecification.ApplyPaging(skip, take); return(await ToDataSourceResultAsync(baseSpecification)); }
public async Task <IDataSourceResult <ScheduleTask> > GetScheduleTasksAsync(int skip, int take, string name = "", ScheduleType?type = null, bool?enabled = null, bool?stopOnError = null) { BaseSpecification <ScheduleTask> baseSpecification = new BaseSpecification <ScheduleTask>(q => (string.IsNullOrEmpty(name) || EF.Functions.Contains(q.Name, name)) && (!type.HasValue || q.Type == type) && (!enabled.HasValue || q.Enabled == enabled) && (!stopOnError.HasValue || q.StopOnError == stopOnError)); baseSpecification.ApplyOrderByDescending(q => q.Id); baseSpecification.ApplyPaging(skip, take); return(await ToDataSourceResultAsync(baseSpecification)); }
public virtual async Task <IDataSourceResult <EmailAccount> > GetEmailAccountsAsync(int skip, int take, bool?useDefault = null, string name = "", string email = "", string host = "", string userName = "", int?port = null) { BaseSpecification <EmailAccount> emailAccountSpecification = new BaseSpecification <EmailAccount>(q => (string.IsNullOrEmpty(name) || EF.Functions.Contains(q.Name, name)) && (string.IsNullOrEmpty(email) || q.Email == email) && (string.IsNullOrEmpty(host) || q.Host == host) && (string.IsNullOrEmpty(userName) || q.UserName == userName) && (!useDefault.HasValue || q.UseDefault == useDefault) && (!port.HasValue || q.Port == port)); emailAccountSpecification.ApplyOrderByDescending(q => q.Id); emailAccountSpecification.ApplyPaging(skip, take); return(await ToDataSourceResultAsync(emailAccountSpecification)); }
public async Task <IList <ResponsibleResponseTO> > ListAsync(ResponsibleFilterTO filterTO) { var responsibleSpecification = new BaseSpecification <ResponsibleEntity>(); responsibleSpecification.AddCriteria(filterTO.UnifiedProcessNumber, responsible => responsible.ProcessResponsible.Any(processResponsible => processResponsible.Process != null && !string.IsNullOrEmpty(processResponsible.Process.UnifiedProcessNumber) && processResponsible.Process.UnifiedProcessNumber.Replace("-", string.Empty).Replace(".", string.Empty).Contains(filterTO.UnifiedProcessNumber.Replace("-", string.Empty).Replace(".", string.Empty)))); responsibleSpecification.AddCriteria(filterTO.Cpf, responsible => responsible.Cpf == Convert.ToInt64(filterTO.Cpf.Replace(".", string.Empty).Replace("-", string.Empty))); responsibleSpecification.AddCriteria(filterTO.Name, responsible => responsible.Name.Trim().ToUpper().Contains(filterTO.Name.Trim().ToUpper())); responsibleSpecification.ApplyOrderByDescending(responsible => responsible.Name); responsibleSpecification.ApplyPaging(filterTO.Page.GetValueOrDefault(), filterTO.PerPage.GetValueOrDefault()); var listResponsible = await _responsibleRepository.ListAsync(responsibleSpecification); return(listResponsible.ToList().ToListResponsibleResponseTO()); }
public async Task <IDataSourceResult <Language> > GetLanguagesAsync( int skip, int take, string name = "", bool?published = null, bool?displayDefault = null) { BaseSpecification <Language> baseSpecification = new BaseSpecification <Language>(q => (string.IsNullOrEmpty(name) || EF.Functions.Contains(q.Name, name)) && (!displayDefault.HasValue || q.DisplayDefault == displayDefault) && (!published.HasValue || q.Published == published)); baseSpecification.ApplyOrderByDescending(q => q.Id); baseSpecification.ApplyPaging(skip, take); return(await ToDataSourceResultAsync(baseSpecification)); }
public async Task <IDataSourceResult <LanguageResource> > GetLanguageResources( int skip, int take, string culture = null, string key = null, string value = null) { BaseSpecification <LanguageResource> baseSpecification = new BaseSpecification <LanguageResource>(q => (string.IsNullOrEmpty(value) || EF.Functions.Contains(q.Value, value)) && (string.IsNullOrEmpty(key) || q.Key == key) && (string.IsNullOrEmpty(culture) || q.Culture == culture)); baseSpecification.ApplyOrderByDescending(q => q.Id); baseSpecification.ApplyPaging(skip, take); return(await ToDataSourceResultAsync(baseSpecification)); }
public virtual async Task <IDataSourceResult <MessageTemplate> > GetMessageTemplatesAsync(int skip, int take, string name = "", string title = "") { BaseSpecification <MessageTemplate> messageTemplateSpecification = new BaseSpecification <MessageTemplate>(q => (string.IsNullOrEmpty(name) || EF.Functions.Contains(q.Name, name)) && (string.IsNullOrEmpty(title) || EF.Functions.Contains(q.Title, title))); messageTemplateSpecification.ApplyOrderByDescending(q => q.Id); messageTemplateSpecification.ApplySelector(q => new MessageTemplate() { Id = q.Id, Name = q.Name, Title = q.Title, UpdatedTime = q.UpdatedTime }); messageTemplateSpecification.ApplyPaging(skip, take); return(await ToDataSourceResultAsync(messageTemplateSpecification)); }
public async Task <IList <ProcessResponseTO> > ListAsync(ProcessFilterTO filterTO) { var processSpecification = new BaseSpecification <ProcessEntity>(); processSpecification.AddCriteria(filterTO.UnifiedProcessNumber, process => process.UnifiedProcessNumber.Replace("-", string.Empty).Replace(".", string.Empty) == filterTO.UnifiedProcessNumber.Replace("-", string.Empty).Replace(".", string.Empty)); processSpecification.AddCriteria(filterTO.DistributionDateStart, process => process.DistributionDate >= filterTO.DistributionDateStart); processSpecification.AddCriteria(filterTO.DistributionDateEnd, process => process.DistributionDate <= filterTO.DistributionDateEnd); processSpecification.AddCriteria(filterTO.JusticeSecret, process => process.JusticeSecret == filterTO.JusticeSecret); processSpecification.AddCriteria(filterTO.ClientPhysicalFolder, process => process.ClientPhysicalFolder.Trim().ToUpper().Contains(filterTO.ClientPhysicalFolder.Trim().ToUpper())); processSpecification.AddCriteria(filterTO.SituationId, process => process.SituationId == filterTO.SituationId); processSpecification.AddCriteria(filterTO.ResponsibleName, process => process.ProcessResponsible.Any(processResponsible => processResponsible.Responsible != null && !string.IsNullOrEmpty(processResponsible.Responsible.Name) && processResponsible.Responsible.Name.Trim().ToUpper().Contains(filterTO.ResponsibleName.Trim().ToUpper()))); processSpecification.ApplyOrderByDescending(responsible => responsible.UnifiedProcessNumber); processSpecification.ApplyPaging(filterTO.Page.GetValueOrDefault(), filterTO.PerPage.GetValueOrDefault()); var listProcess = await _processRepository.ListAsync(processSpecification); return(listProcess.ToList().ToListProcessResponseTO()); }
public async Task <IEnumerable <TreeItem <CmsMenu> > > GetMenusAsync(string position = "", bool?active = null, string parentId = null, string excludeId = null) { BaseSpecification <CmsMenu> baseSpecification = new BaseSpecification <CmsMenu>(q => (string.IsNullOrEmpty(position) || q.Position == position) && (string.IsNullOrEmpty(position) || q.ParentId == parentId) && (string.IsNullOrEmpty(excludeId) || q.Id != excludeId) && (!active.HasValue || q.Active == active)); baseSpecification.ApplyOrderByDescending(q => q.Id); baseSpecification.ApplySelector(q => new CmsMenu() { Id = q.Id, Name = q.Name, ParentId = q.ParentId, DisplayOrder = q.DisplayOrder }); var menus = await FindAllNoTrackingAsync(baseSpecification); return(menus.GenerateTree(q => q.Id, q => q.ParentId, q => q.DisplayOrder, string.Empty)); }
/// <summary> /// Lấy danh sách thư viên tệp tin theo nhiều tham số /// </summary> /// <param name="skip">Số bản ghi bỏ qua</param> /// <param name="take">Số bản ghi cần lấy</param> /// <param name="description">Mô tả cho file</param> /// <param name="type">Loại resource</param> /// <param name="userId">Người tạo tệp tin</param> /// <param name="startDate">Bắt đầu ngày tạo</param> /// <param name="endDate">Kết thúc ngày tạo</param> /// <returns>IDataSourceResult Media</returns> public async Task <IDataSourceResult <FileResource> > GetFileResourcesAsync( int skip, int take, string description = "", ResourceType?type = null, string userId = null, DateTime?startDate = null, DateTime?endDate = null) { BaseSpecification <FileResource> resourceSpecification = new BaseSpecification <FileResource>(q => (string.IsNullOrEmpty(description) || EF.Functions.Contains(q.Description, description)) && (string.IsNullOrEmpty(userId) || q.UserId == userId) && (!startDate.HasValue || q.CreatedTime >= startDate) && (!endDate.HasValue || q.CreatedTime <= endDate) && (!type.HasValue || q.Type == type)); resourceSpecification.ApplyOrderByDescending(q => q.Id); resourceSpecification.ApplyPaging(skip, take); return(await ToDataSourceResultAsync(resourceSpecification)); }
public async Task <IDataSourceResult <SystemLog> > GetErrorLogsAsync( int skip, int take, LogLevel?logLevelId = null, string shortMessage = "", string ipAdress = "", DateTime?startDate = null, DateTime?endDate = null) { BaseSpecification <SystemLog> errorLogSpecification = new BaseSpecification <SystemLog>(q => (string.IsNullOrEmpty(shortMessage) || EF.Functions.Contains(q.Message, shortMessage)) && (string.IsNullOrEmpty(ipAdress) || q.IpAddress == ipAdress) && (!startDate.HasValue || q.CreatedTime >= startDate) && (!endDate.HasValue || q.CreatedTime <= endDate) && (!logLevelId.HasValue || q.Level == logLevelId)); errorLogSpecification.ApplyOrderByDescending(q => q.Id); errorLogSpecification.ApplyPaging(skip, take); return(await ToDataSourceResultAsync(errorLogSpecification)); }
/// <summary> /// Lấy email trong queued theo nhiều tham số /// </summary> /// <param name="skip">Số bản ghi bỏ qua</param> /// <param name="take">Số bản ghi cần lấy</param> /// <param name="title">Tiêu đề email</param> /// <param name="to">Gửi đến</param> /// <param name="submitted">Đã gửi hay chưa</param> /// <param name="emailAccouantId">Tài khoản gửi. Chỉ có khi đã gửi</param> /// <param name="fromDate">Từ Ngày tạo email trong queued</param> /// <param name="toDate">Đến Ngày tạo email trong queued</param> /// <returns>Task IDataSourceResult QueuedEmail</returns> public virtual async Task <IDataSourceResult <QueuedEmail> > GetQueuedEmailsAsync( int skip, int take, string title = "", string toEmail = "", bool?submitted = null, string emailAccouantId = null, DateTime?fromDate = null, DateTime?toDate = null) { BaseSpecification <QueuedEmail> queuedEmailSpecification = new BaseSpecification <QueuedEmail>(q => (string.IsNullOrEmpty(title) || EF.Functions.Contains(q.Title, title)) && (string.IsNullOrEmpty(toEmail) || q.To == toEmail) && (!submitted.HasValue || (submitted == true && q.SendTime != null) || (submitted != true && q.SendTime == null)) && (string.IsNullOrEmpty(emailAccouantId) || q.EmailAccountId == emailAccouantId) && (!fromDate.HasValue || q.CreatedTime >= fromDate) && (!toDate.HasValue || q.CreatedTime <= toDate)); queuedEmailSpecification.ApplyOrderByDescending(q => q.Id); queuedEmailSpecification.ApplyPaging(skip, take); return(await ToDataSourceResultAsync(queuedEmailSpecification)); }
public async Task <IDataSourceResult <User> > GetUsersAsync( int skip, int take, string groupId = null, string email = null, string userName = null, string displayName = null, bool?active = null, Gender?gender = null, string languageCulture = null, string currencyCulture = null, DateTime?fromBirthDay = null, DateTime?toBirthDay = null, DateTime?fromLastLoginTime = null, DateTime?toLastLoginTime = null, DateTime?fromCreatedTime = null, DateTime?toCreatedTime = null) { IQueryable <User> userQuery = DbContext.Set <User>().AsNoTracking(); if (!string.IsNullOrEmpty(groupId)) { IQueryable <UserGroupMapping> mappingQuery = DbContext.Set <UserGroupMapping>().Where(q => q.UserGroupId == groupId); userQuery = from user in userQuery join mapping in mappingQuery on user.Id equals mapping.UserId where mapping.UserGroupId == groupId select user; } BaseSpecification <User> baseSpecification = new BaseSpecification <User>(q => !q.Deleted && (string.IsNullOrEmpty(userName) || q.UserName.Contains(userName)) && (string.IsNullOrEmpty(displayName) || q.DisplayName.Contains(displayName)) && (string.IsNullOrEmpty(email) || q.Email == email) && (string.IsNullOrEmpty(languageCulture) || q.LanguageCulture == languageCulture) && (string.IsNullOrEmpty(currencyCulture) || q.CurrencyCode == currencyCulture) && (!active.HasValue || q.Active == active) && (!gender.HasValue || q.Gender == gender) && (!fromBirthDay.HasValue || q.BirthDay >= fromBirthDay) && (!toBirthDay.HasValue || q.BirthDay <= toBirthDay) && (!fromLastLoginTime.HasValue || q.LastLoginTime >= fromLastLoginTime) && (!toLastLoginTime.HasValue || q.LastLoginTime <= toLastLoginTime) && (!fromCreatedTime.HasValue || q.CreatedTime >= fromCreatedTime) && (!toCreatedTime.HasValue || q.CreatedTime <= toCreatedTime)); baseSpecification.ApplyOrderByDescending(q => q.CreatedTime); baseSpecification.ApplySelector(x => new User { Id = x.Id, AvatarImage = x.AvatarImage, Email = x.Email, DisplayName = x.DisplayName, Active = x.Active, CreatedTime = x.CreatedTime, UpdatedTime = x.UpdatedTime, LastLoginTime = x.LastLoginTime }); baseSpecification.ApplyPaging(skip, take); return(await userQuery.ToDataSourceResultAsync(baseSpecification)); }