diff --git a/IRaCIS.Core.Application/Service/Financial/CalculateService.cs b/IRaCIS.Core.Application/Service/Financial/CalculateService.cs index cff4301c..d4c4c1c5 100644 --- a/IRaCIS.Core.Application/Service/Financial/CalculateService.cs +++ b/IRaCIS.Core.Application/Service/Financial/CalculateService.cs @@ -3,7 +3,6 @@ using IRaCIS.Application.Interfaces; using IRaCIS.Application.Contracts; using IRaCIS.Application.Contracts.Pay; using IRaCIS.Core.Domain.Share; -using IRaCIS.Core.Infrastructure.ExpressionExtend; using System.Linq.Expressions; using IRaCIS.Core.Infra.EFCore; using IRaCIS.Core.Domain.Models; diff --git a/IRaCIS.Core.Application/Service/Financial/DTO/PaymentDetailModel.cs b/IRaCIS.Core.Application/Service/Financial/DTO/PaymentDetailModel.cs index 0a9821ad..ae8aaa05 100644 --- a/IRaCIS.Core.Application/Service/Financial/DTO/PaymentDetailModel.cs +++ b/IRaCIS.Core.Application/Service/Financial/DTO/PaymentDetailModel.cs @@ -117,6 +117,8 @@ namespace IRaCIS.Application.Contracts.Pay public string FirstName { get; set; } = String.Empty; public string LastName { get; set; } = String.Empty; + public string FullName { get; set; } = String.Empty; + public decimal AdjustmentUSD { get; set; } public decimal AdjustmentCNY { get; set; } public decimal PaymentUSD { get; set; } diff --git a/IRaCIS.Core.Application/Service/Financial/FinancialService.cs b/IRaCIS.Core.Application/Service/Financial/FinancialService.cs index 1b009205..d47b6a4f 100644 --- a/IRaCIS.Core.Application/Service/Financial/FinancialService.cs +++ b/IRaCIS.Core.Application/Service/Financial/FinancialService.cs @@ -1,14 +1,11 @@ -using IRaCIS.Core.Infrastructure.ExpressionExtend; -using IRaCIS.Application.Interfaces; +using IRaCIS.Application.Interfaces; using IRaCIS.Application.Contracts; using IRaCIS.Application.Contracts.Pay; using IRaCIS.Core.Domain.Share; using System.Linq.Expressions; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Models; -using IRaCIS.Core.Infrastructure.Extention; using Microsoft.AspNetCore.Mvc; using Panda.DynamicWebApi.Attributes; +using System.Linq.Dynamic.Core; namespace IRaCIS.Application.Services { @@ -133,12 +130,17 @@ namespace IRaCIS.Application.Services BankName = payInfo.BankName }; - var propName = string.IsNullOrWhiteSpace(queryParam.SortField) ? "Code" : queryParam.SortField; - costStatisticsQueryable = queryParam.Asc ? costStatisticsQueryable.OrderBy(propName).ThenBy(u => u.Code) - : costStatisticsQueryable.OrderByDescending(propName).ThenBy(u => u.Code); - var count = costStatisticsQueryable.Count(); - costStatisticsQueryable = costStatisticsQueryable.Skip((queryParam.PageIndex - 1) * queryParam.PageSize).Take(queryParam.PageSize); - var costStatisticsList = await costStatisticsQueryable.ToListAsync(); + + + return await costStatisticsQueryable.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, string.IsNullOrWhiteSpace(queryParam.SortField) ? "Code" : queryParam.SortField, queryParam.Asc); + + //var propName = string.IsNullOrWhiteSpace(queryParam.SortField) ? "Code" : queryParam.SortField; + //costStatisticsQueryable = queryParam.Asc ? costStatisticsQueryable.OrderBy(propName).ThenBy(u => u.Code) + // : costStatisticsQueryable.OrderByDescending(propName).ThenBy(u => u.Code); + //var count = costStatisticsQueryable.Count(); + //costStatisticsQueryable = costStatisticsQueryable.Skip((queryParam.PageIndex - 1) * queryParam.PageSize).Take(queryParam.PageSize); + //var costStatisticsList = await costStatisticsQueryable.ToListAsync(); + //return new PageOutput(queryParam.PageIndex, queryParam.PageSize, count, costStatisticsList); #region 增加调整费用总计字段之前 @@ -167,7 +169,6 @@ namespace IRaCIS.Application.Services #endregion - return new PageOutput(queryParam.PageIndex, queryParam.PageSize, count, costStatisticsList); } /// @@ -405,6 +406,7 @@ namespace IRaCIS.Application.Services ChineseName = doctor.ChineseName, FirstName = doctor.FirstName, LastName = doctor.LastName, + FullName= doctor.FullName, ReviewerCode = doctor.ReviewerCode, PaymentUSD = monthlyPay.PaymentUSD, PaymentCNY = monthlyPay.PaymentCNY, @@ -413,17 +415,20 @@ namespace IRaCIS.Application.Services TotalCNY = monthlyPay.AdjustmentCNY + monthlyPay.PaymentCNY, TotalUSD = monthlyPay.AdjustmentUSD + monthlyPay.PaymentUSD }; - var propName = queryParam.SortField == string.Empty ? "ReviewerCode" : queryParam.SortField; - query = queryParam.Asc ? query.OrderBy(propName).ThenBy(u => u.ReviewerCode) : query.OrderByDescending(propName).ThenBy(u => u.ReviewerCode); - if (propName == "FirstName" || propName == "LastName") - { - query = queryParam.Asc ? query.OrderBy(t => t.LastName).ThenBy(t => t.FirstName) - : query.OrderByDescending(t => t.LastName).ThenBy(t => t.FirstName); - } - var count = await query.CountAsync(); - query = query.Skip((queryParam.PageIndex - 1) * queryParam.PageSize).Take(queryParam.PageSize); - var list = await query.ToListAsync(); - return new PageOutput(queryParam.PageIndex, queryParam.PageSize, count, list); + + return await query.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, string.IsNullOrWhiteSpace(queryParam.SortField) ? "ReviewerCode" : queryParam.SortField, queryParam.Asc); + + //var propName = queryParam.SortField == string.Empty ? "ReviewerCode" : queryParam.SortField; + //query = queryParam.Asc ? query.OrderBy(propName).ThenBy(u => u.ReviewerCode) : query.OrderByDescending(propName).ThenBy(u => u.ReviewerCode); + //if (propName == "FirstName" || propName == "LastName") + //{ + // query = queryParam.Asc ? query.OrderBy(t => t.LastName).ThenBy(t => t.FirstName) + // : query.OrderByDescending(t => t.LastName).ThenBy(t => t.FirstName); + //} + //var count = await query.CountAsync(); + //query = query.Skip((queryParam.PageIndex - 1) * queryParam.PageSize).Take(queryParam.PageSize); + //var list = await query.ToListAsync(); + //return new PageOutput(queryParam.PageIndex, queryParam.PageSize, count, list); } @@ -833,13 +838,13 @@ namespace IRaCIS.Application.Services //非详细 只用单字段排序 if (queryParam.StatType != 0) { - query = queryParam.Asc ? query.OrderBy(propName) : query.OrderByDescending(propName); + query = queryParam.Asc ? query.OrderBy(propName) : query.OrderBy(propName + " desc"); } //详情 多字段排序 if (queryParam.StatType == 0) { query = queryParam.Asc ? query.OrderBy(propName).ThenBy(t => t.TrialId).ThenBy(t => t.YearMonth).ThenBy(t => t.ReviewerCode) : - query.OrderByDescending(propName).ThenBy(t => t.TrialId).ThenBy(t => t.YearMonth).ThenBy(t => t.ReviewerCode) + query.OrderBy(propName + " desc").ThenBy(t => t.TrialId).ThenBy(t => t.YearMonth).ThenBy(t => t.ReviewerCode) ; } diff --git a/IRaCIS.Core.Application/Service/Financial/ReviewerPayInfoService.cs b/IRaCIS.Core.Application/Service/Financial/ReviewerPayInfoService.cs index 9a002e74..3f12a31f 100644 --- a/IRaCIS.Core.Application/Service/Financial/ReviewerPayInfoService.cs +++ b/IRaCIS.Core.Application/Service/Financial/ReviewerPayInfoService.cs @@ -1,5 +1,4 @@ using AutoMapper; -using IRaCIS.Core.Infrastructure.ExpressionExtend; using IRaCIS.Application.Interfaces; using IRaCIS.Application.Contracts; using System.Linq.Expressions; diff --git a/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs b/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs index adb00b5a..48968b75 100644 --- a/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs +++ b/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs @@ -1,5 +1,4 @@ using AutoMapper; -using IRaCIS.Core.Infrastructure.ExpressionExtend; using IRaCIS.Application.Interfaces; using IRaCIS.Application.Contracts; using System.Linq.Expressions; diff --git a/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs b/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs index 362e8ed7..35fc890d 100644 --- a/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs +++ b/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs @@ -1,6 +1,5 @@ using AutoMapper; using AutoMapper.QueryableExtensions; -using IRaCIS.Core.Infrastructure.ExpressionExtend; using IRaCIS.Application.Interfaces; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infra.EFCore; diff --git a/IRaCIS.Core.Application/Service/Management/UserTypeService.cs b/IRaCIS.Core.Application/Service/Management/UserTypeService.cs index 7beae32c..48f05561 100644 --- a/IRaCIS.Core.Application/Service/Management/UserTypeService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserTypeService.cs @@ -5,7 +5,6 @@ //-------------------------------------------------------------------- using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Domain.Share; -using IRaCIS.Core.Infrastructure.ExpressionExtend; using IRaCIS.Core.Infra.EFCore; namespace IRaCIS.Core.Application.Contracts diff --git a/IRaCIS.Core.Application/Service/Stat/DTO/StatisticsViewModel.cs b/IRaCIS.Core.Application/Service/Stat/DTO/StatisticsViewModel.cs index 8ad98e37..126b2426 100644 --- a/IRaCIS.Core.Application/Service/Stat/DTO/StatisticsViewModel.cs +++ b/IRaCIS.Core.Application/Service/Stat/DTO/StatisticsViewModel.cs @@ -13,6 +13,8 @@ namespace IRaCIS.Application.Contracts public string FirstName { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty; + + public string FullName { get; set; } = string.Empty; public string ReviewerCode { get; set; } = string.Empty; public int Pending { get; set; } @@ -114,6 +116,8 @@ namespace IRaCIS.Application.Contracts public string FirstName { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty; + + public string FullName { get; set; } = string.Empty; public string ReviewerCode { get; set; } = string.Empty; public int Training { get; set; } diff --git a/IRaCIS.Core.Application/Service/Stat/IStatisticsService.cs b/IRaCIS.Core.Application/Service/Stat/IStatisticsService.cs index b5a80c5e..c597a322 100644 --- a/IRaCIS.Core.Application/Service/Stat/IStatisticsService.cs +++ b/IRaCIS.Core.Application/Service/Stat/IStatisticsService.cs @@ -7,7 +7,7 @@ namespace IRaCIS.Application.Interfaces { public interface IStatisticsService { - PageOutput GetWorkloadByTrialAndReviewer(StatisticsWorkloadQueryParam param); + Task> GetWorkloadByTrialAndReviewer(StatisticsWorkloadQueryParam param); PageOutput GetEnrollStatByTrial(EnrollStatByTrialQueryDTO param); @@ -38,6 +38,6 @@ namespace IRaCIS.Application.Interfaces List GetLatestWorkLoadList( int searchCount); #endregion - PageOutput GetEnrollStatByReviewer(EnrollStatByReviewerQueryDTO enrollTrialStatisticsQueryParam); + Task> GetEnrollStatByReviewer(EnrollStatByReviewerQueryDTO enrollTrialStatisticsQueryParam); } } diff --git a/IRaCIS.Core.Application/Service/Stat/StatisticsService.cs b/IRaCIS.Core.Application/Service/Stat/StatisticsService.cs index 21b97e3e..0c555f44 100644 --- a/IRaCIS.Core.Application/Service/Stat/StatisticsService.cs +++ b/IRaCIS.Core.Application/Service/Stat/StatisticsService.cs @@ -1,12 +1,9 @@ -using IRaCIS.Core.Infrastructure.ExpressionExtend; -using IRaCIS.Application.Interfaces; +using IRaCIS.Application.Interfaces; using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Share; using System.Linq.Expressions; +using System.Linq.Dynamic.Core; -using IRaCIS.Core.Infrastructure.Extention; using Microsoft.AspNetCore.Mvc; namespace IRaCIS.Application.Services @@ -14,12 +11,12 @@ namespace IRaCIS.Application.Services /// Dashboard统计、全局工作量统计、入组两个维度统计(按照项目、按照人) /// - [ ApiExplorerSettings(GroupName = "Dashboard&Statistics")] + [ApiExplorerSettings(GroupName = "Dashboard&Statistics")] public class StatisticsService : BaseService, IStatisticsService { private readonly IRepository _doctorRepository; private readonly IRepository _trialRepository; - private readonly IRepository _enrollRepository; + private readonly IRepository _enrollRepository; private readonly IRepository _workloadRepository; private readonly IRepository _croCompanyRepository; private readonly IRepository _dictionaryRepository; @@ -27,7 +24,7 @@ namespace IRaCIS.Application.Services private readonly IRepository _enrollDetailRepository; private readonly IRepository _userRepository; private readonly IRepository _userTrialRepository; - + public StatisticsService(IRepository doctorRepository, IRepository trialRepository, IRepository intoGroupRepository, IRepository workloadRepository, @@ -47,16 +44,16 @@ namespace IRaCIS.Application.Services _enrollDetailRepository = enrollDetailRepository; _userRepository = userRepository; _userTrialRepository = userTrialRepository; - + } /// 根据项目和医生,分页获取工作量统计[New] [HttpPost] - public PageOutput GetWorkloadByTrialAndReviewer( + public async Task> GetWorkloadByTrialAndReviewer( StatisticsWorkloadQueryParam param) { - + var bDate = new DateTime(param.BeginDate.Year, param.BeginDate.Month, param.BeginDate.Day); var eDate = new DateTime(param.EndDate.Year, param.EndDate.Month, param.EndDate.Day); @@ -65,14 +62,14 @@ namespace IRaCIS.Application.Services workloadLambda = workloadLambda.And(x => x.WorkTime >= bDate && x.WorkTime < eDate); Expression> trialLambda = x => true; - if (_userInfo.UserTypeEnumInt ==(int) UserTypeEnum.SuperAdmin) //超级管理员按照条件查询所有 + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin) //超级管理员按照条件查询所有 { - if ( param.CroId != null) + if (param.CroId != null) { trialLambda = trialLambda.And(u => u.CROId == param.CroId); } } - + else //不管是精鼎的pm还是我们的pm 还是运维人员 只能看到自己参与项目的统计 { List trialIdList = _userTrialRepository.Where(u => u.UserId == _userInfo.Id).Select(u => u.TrialId).ToList(); @@ -140,6 +137,7 @@ namespace IRaCIS.Application.Services ChineseName = doctorItem.ChineseName, FirstName = doctorItem.FirstName, LastName = doctorItem.LastName, + FullName = doctorItem.FullName, Training = w.Training, Timepoint = w.Timepoint, TimepointIn24H = w.TimepointIn24H, @@ -155,31 +153,36 @@ namespace IRaCIS.Application.Services w.AdjudicationIn48H + w.Global }; - var propName = param.SortField == "" ? "ReviewerCode" : param.SortField; - query = param.Asc - ? query.OrderBy(propName).ThenBy(t => t.TrialCode).ThenBy(u => u.ReviewerCode) - : query.OrderByDescending(propName).ThenBy(t => t.TrialCode).ThenBy(u => u.ReviewerCode); - if (propName == "FirstName" || propName == "LastName") - { - query = param.Asc - ? query.OrderBy(t => t.LastName).ThenBy(t => t.FirstName) - : query.OrderByDescending(t => t.LastName).ThenBy(t => t.FirstName); - } - var count = query.Count(); - query = query - .Skip((param.PageIndex - 1) * param.PageSize) - .Take(param.PageSize); - var doctorViewList = query.ToList(); + return await query.ToPagedListAsync(param.PageIndex, param.PageSize, string.IsNullOrWhiteSpace(param.SortField) ? "ReviewerCode" : param.SortField, param.Asc); - return new PageOutput(param.PageIndex, param.PageSize, count, doctorViewList); + //var propName = param.SortField == "" ? "ReviewerCode" : param.SortField; + //query = param.Asc + // ? query.OrderBy(propName).ThenBy(t => t.TrialCode).ThenBy(u => u.ReviewerCode) + // : query.OrderByDescending(propName).ThenBy(t => t.TrialCode).ThenBy(u => u.ReviewerCode); + + + //if (propName == "FirstName" || propName == "LastName") + //{ + // query = param.Asc + // ? query.OrderBy(t => t.LastName).ThenBy(t => t.FirstName) + // : query.OrderByDescending(t => t.LastName).ThenBy(t => t.FirstName); + //} + //var count = query.Count(); + + //query = query + // .Skip((param.PageIndex - 1) * param.PageSize) + // .Take(param.PageSize); + //var doctorViewList = query.ToList(); + + //return new PageOutput(param.PageIndex, param.PageSize, count, doctorViewList); } /// 项目入组 医生维度统计[New] [HttpPost] - public PageOutput GetEnrollStatByReviewer(EnrollStatByReviewerQueryDTO param) + public async Task> GetEnrollStatByReviewer(EnrollStatByReviewerQueryDTO param) { var bDate = new DateTime(param.BeginDate.Year, param.BeginDate.Month, 1); var eDate = new DateTime(param.EndDate.Year, param.EndDate.Month, 1); @@ -236,6 +239,7 @@ namespace IRaCIS.Application.Services ChineseName = doctor.ChineseName, FirstName = doctor.FirstName, LastName = doctor.LastName, + FullName = doctor.FullName, Pending = w.Submitted, Approved = w.Approved, Reading = w.Reading, @@ -244,35 +248,30 @@ namespace IRaCIS.Application.Services Total = w.Submitted + w.Approved + w.Reading + w.Finished }; - if (param.SortField != "EntryRate") - { - var propName = param.SortField == "" ? "ReviewerCode" : param.SortField; - query = param.Asc - ? query.OrderBy(propName).ThenBy(u => u.ReviewerCode) - : query.OrderByDescending(propName).ThenBy(u => u.ReviewerCode); - if (propName == "FirstName" || propName == "LastName") - { - query = param.Asc - ? query.OrderBy(t => t.LastName).ThenBy(t => t.FirstName) - : query.OrderByDescending(t => t.LastName).ThenBy(t => t.FirstName); - } - } - - var count = query.Count(); - query = query - .Skip((param.PageIndex - 1) * param.PageSize) - .Take(param.PageSize); - var list = query.ToList(); + var pageData = await query.ToPagedListAsync(param.PageIndex, param.PageIndex, param.SortField == "" ? "ReviewerCode" : param.SortField, param.Asc); if (param.SortField == "EntryRate") { - list = param.Asc - ? list.OrderBy(t => t.EntryRate).ToList() - : list.OrderByDescending(t => t.EntryRate).ToList(); + pageData.CurrentPageData.OrderBy(t => t.EntryRate); } - return new PageOutput(param.PageIndex, param.PageSize, count, list); + return pageData; + + //var count = query.Count(); + //query = query + // .Skip((param.PageIndex - 1) * param.PageSize) + // .Take(param.PageSize); + //var list = query.ToList(); + + //if (param.SortField == "EntryRate") + //{ + // list = param.Asc + // ? list.OrderBy(t => t.EntryRate).ToList() + // : list.OrderByDescending(t => t.EntryRate).ToList(); + //} + + //return new PageOutput(param.PageIndex, param.PageSize, count, list); } [HttpPost] @@ -300,7 +299,7 @@ namespace IRaCIS.Application.Services trialLambda = trialLambda.And(o => o.Indication.Contains(indication)); } - if ( param.CROId != null) + if (param.CROId != null) { trialLambda = trialLambda.And(o => o.CROId == param.CROId); } @@ -344,7 +343,7 @@ namespace IRaCIS.Application.Services var propName = param.SortField == "" ? "TrialCode" : param.SortField; trialQuery = param.Asc ? trialQuery.OrderBy(propName) - : trialQuery.OrderByDescending(propName); + : trialQuery.OrderBy(propName + " desc"); var count = trialQuery.Count(); @@ -396,7 +395,7 @@ namespace IRaCIS.Application.Services { Expression> userLambda = x => true; - Expression> userTrialLambda = x =>true; + Expression> userTrialLambda = x => true; if (!string.IsNullOrEmpty(param.UserInfo)) { var userInfo = param.UserInfo.Trim(); @@ -417,9 +416,9 @@ namespace IRaCIS.Application.Services if (userTypeEnumStr == UserTypeEnum.ProjectManager.ToString()) { //参与到的项目 - var trialFilter = _userTrialRepository.Where(t => t.UserId == userId) - .Select(u => u.TrialId); - userTrialLambda = userTrialLambda.And(t => trialFilter.Contains(t.TrialId)); + var trialFilter = _userTrialRepository.Where(t => t.UserId == userId) + .Select(u => u.TrialId); + userTrialLambda = userTrialLambda.And(t => trialFilter.Contains(t.TrialId)); } //.Select(u => new { u.TrialId, u.UserId }).Distinct() var trialStatQuery = _userTrialRepository.Where(userTrialLambda) @@ -431,23 +430,23 @@ namespace IRaCIS.Application.Services }); var userQuery = from trialStat in trialStatQuery - join user in _userRepository.Where(userLambda) on trialStat.UserId equals user.Id - select new UserParticipateTrialStat - { - Email = user.EMail, - Name = user.LastName + ' ' + user.FirstName, - UserName = user.UserName, - OrganizationName = user.OrganizationName, - Phone = user.Phone, - TrialCount = trialStat.TrialCount, - UserCode = user.UserCode, - UserId = user.Id - }; + join user in _userRepository.Where(userLambda) on trialStat.UserId equals user.Id + select new UserParticipateTrialStat + { + Email = user.EMail, + Name = user.LastName + ' ' + user.FirstName, + UserName = user.UserName, + OrganizationName = user.OrganizationName, + Phone = user.Phone, + TrialCount = trialStat.TrialCount, + UserCode = user.UserCode, + UserId = user.Id + }; var propName = param.SortField == "" ? "OrganizationName" : param.SortField; userQuery = param.Asc ? userQuery.OrderBy(propName) - : userQuery.OrderByDescending(propName); + : userQuery.OrderBy(propName + " desc"); var count = userQuery.Count(); @@ -462,8 +461,8 @@ namespace IRaCIS.Application.Services [HttpGet("{userId:guid}")] public List GetParticipateTrialList(Guid userId) { - - Expression> userTrialLambda = x => x.UserId== userId; + + Expression> userTrialLambda = x => x.UserId == userId; var userTypeEnum = _userInfo.UserTypeEnumStr; var loginUserId = _userInfo.Id; @@ -473,29 +472,29 @@ namespace IRaCIS.Application.Services if (userTypeEnum == UserTypeEnum.ProjectManager.ToString()) { //参与到的项目 - var trialFilter = _userTrialRepository.Where(t => t.UserId == loginUserId) - .Select(u => u.TrialId); + var trialFilter = _userTrialRepository.Where(t => t.UserId == loginUserId) + .Select(u => u.TrialId); userTrialLambda = userTrialLambda.And(t => trialFilter.Contains(t.TrialId)); } var query = from userTrial in _userTrialRepository.Where(userTrialLambda) - join trial in _trialRepository.AsQueryable() on userTrial.TrialId equals trial.Id - join cro in _croCompanyRepository.AsQueryable() on trial.CROId equals cro.Id into cc - from cro in cc.DefaultIfEmpty() - select new UserParticipateTrialDetail() - { - Code = trial.TrialCode, - CROName = cro.CROName, - Expedited = trial.Expedited, - Indication = trial.Indication, - UserType = userTrial.User.UserTypeRole.UserTypeShortName, - TrialId = trial.Id + join trial in _trialRepository.AsQueryable() on userTrial.TrialId equals trial.Id + join cro in _croCompanyRepository.AsQueryable() on trial.CROId equals cro.Id into cc + from cro in cc.DefaultIfEmpty() + select new UserParticipateTrialDetail() + { + Code = trial.TrialCode, + CROName = cro.CROName, + Expedited = trial.Expedited, + Indication = trial.Indication, + UserType = userTrial.User.UserTypeRole.UserTypeShortName, + TrialId = trial.Id - }; + }; return query.ToList(); } - + #region Dashboard 数据统计 /// 读片数分类统计[New] @@ -604,10 +603,10 @@ namespace IRaCIS.Application.Services Timepoint = w.Timepoint, Adjudication = w.Adjudication, Global = w.Global, - ReviewerCode = doctorItem.ReviewerCode, + ReviewerCode = doctorItem.ReviewerCode, FirstName = doctorItem.FirstName, - LastName = doctorItem.LastName, - ChineseName = doctorItem.ChineseName + LastName = doctorItem.LastName, + ChineseName = doctorItem.ChineseName }; return reviewerList.ToList(); } @@ -835,8 +834,8 @@ namespace IRaCIS.Application.Services Global = w.Global, ReviewerCode = doctorItem.ReviewerCode, FirstName = doctorItem.FirstName, - LastName = doctorItem.LastName, - ChineseName = doctorItem.ChineseName, + LastName = doctorItem.LastName, + ChineseName = doctorItem.ChineseName, TrialCode = trialItem.TrialCode }; diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index a8afa86e..0bca3bbd 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -1,5 +1,4 @@ -using IRaCIS.Core.Infrastructure.ExpressionExtend; -using IRaCIS.Core.Application.Filter; +using IRaCIS.Core.Application.Filter; using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Application.Contracts.Dicom.DTO; diff --git a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs index 1ef66b7b..eb4d2e5f 100644 --- a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs +++ b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs @@ -1,5 +1,4 @@ -using IRaCIS.Core.Infrastructure.ExpressionExtend; -using IRaCIS.Application.Interfaces; +using IRaCIS.Application.Interfaces; using IRaCIS.Application.Contracts; using IRaCIS.Core.Application.Filter; using Microsoft.AspNetCore.Mvc; diff --git a/IRaCIS.Core.Application/Service/WorkLoad/DTO/DoctorWorkLoadViewModel.cs b/IRaCIS.Core.Application/Service/WorkLoad/DTO/DoctorWorkLoadViewModel.cs index e7eebc3e..40f4edc1 100644 --- a/IRaCIS.Core.Application/Service/WorkLoad/DTO/DoctorWorkLoadViewModel.cs +++ b/IRaCIS.Core.Application/Service/WorkLoad/DTO/DoctorWorkLoadViewModel.cs @@ -179,6 +179,8 @@ namespace IRaCIS.Application.Contracts public string Code { get; set; } = String.Empty; public string FirstName { get; set; } = String.Empty; public string LastName { get; set; } = String.Empty; + + public string FullName { get; set; } = String.Empty; public string ChineseName { get; set; } = String.Empty; public DateTime? EnrollTime { get; set; } diff --git a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs index c36243fa..0963b20e 100644 --- a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs +++ b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs @@ -1,13 +1,12 @@ using AutoMapper; -using IRaCIS.Core.Infrastructure.ExpressionExtend; using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infra.EFCore; using IRaCIS.Core.Domain.Share; using System.Linq.Expressions; using IRaCIS.Core.Application.Filter; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; using IRaCIS.Core.Application.Auth; +using System.Linq.Dynamic.Core; namespace IRaCIS.Application.Services { @@ -154,6 +153,8 @@ namespace IRaCIS.Application.Services Code = doctor.ReviewerCode, FirstName = doctor.FirstName, LastName = doctor.LastName, + FullName=doctor.FullName, + ChineseName = doctor.ChineseName, OutEnrollTime = intoGroup.OutEnrollTime, @@ -178,41 +179,44 @@ namespace IRaCIS.Application.Services }; - var count = await doctorIntoGroupQueryable.CountAsync(); - if (string.IsNullOrWhiteSpace(doctorSearchModel.SortField)) - { - doctorIntoGroupQueryable = doctorIntoGroupQueryable.OrderByDescending("EnrollTime").ThenBy(u => u.Code); - } - else - { - if (doctorSearchModel.SortField == "FirstName" || doctorSearchModel.SortField == "LastName") - { - if (doctorSearchModel.Asc) - { - doctorIntoGroupQueryable = doctorIntoGroupQueryable.OrderBy("LastName").ThenBy(u => u.FirstName); - } - else - { - doctorIntoGroupQueryable = doctorIntoGroupQueryable.OrderByDescending("LastName").ThenByDescending(u => u.FirstName); - } - } - else - { - var propName = doctorSearchModel.SortField == "" ? "EnrollTime" : doctorSearchModel.SortField; - doctorIntoGroupQueryable = doctorSearchModel.Asc - ? doctorIntoGroupQueryable.OrderBy(propName) - : doctorIntoGroupQueryable.OrderByDescending(propName); - } - } - //分页 - doctorIntoGroupQueryable = doctorIntoGroupQueryable - .Skip((doctorSearchModel.PageIndex - 1) * doctorSearchModel.PageSize) - .Take(doctorSearchModel.PageSize); - //从数据库提取数据 - var intoGroupList = doctorIntoGroupQueryable.ToList(); + return await doctorIntoGroupQueryable.ToPagedListAsync(doctorSearchModel.PageIndex, doctorSearchModel.PageSize, doctorSearchModel.SortField == "" ? "EnrollTime" : doctorSearchModel.SortField, doctorSearchModel.Asc); - return new PageOutput(doctorSearchModel.PageIndex, - doctorSearchModel.PageSize, count, intoGroupList); + //var count = await doctorIntoGroupQueryable.CountAsync(); + + //if (string.IsNullOrWhiteSpace(doctorSearchModel.SortField)) + //{ + // doctorIntoGroupQueryable = doctorIntoGroupQueryable.OrderByDescending("EnrollTime").ThenBy(u => u.Code); + //} + //else + //{ + // if (doctorSearchModel.SortField == "FirstName" || doctorSearchModel.SortField == "LastName") + // { + // if (doctorSearchModel.Asc) + // { + // doctorIntoGroupQueryable = doctorIntoGroupQueryable.OrderBy("LastName").ThenBy(u => u.FirstName); + // } + // else + // { + // doctorIntoGroupQueryable = doctorIntoGroupQueryable.OrderByDescending("LastName").ThenByDescending(u => u.FirstName); + // } + // } + // else + // { + // var propName = doctorSearchModel.SortField == "" ? "EnrollTime" : doctorSearchModel.SortField; + // doctorIntoGroupQueryable = doctorSearchModel.Asc + // ? doctorIntoGroupQueryable.OrderBy(propName) + // : doctorIntoGroupQueryable.OrderBy(propName + " desc"); + // } + //} + ////分页 + //doctorIntoGroupQueryable = doctorIntoGroupQueryable + // .Skip((doctorSearchModel.PageIndex - 1) * doctorSearchModel.PageSize) + // .Take(doctorSearchModel.PageSize); + ////从数据库提取数据 + //var intoGroupList = doctorIntoGroupQueryable.ToList(); + + //return new PageOutput(doctorSearchModel.PageIndex, + // doctorSearchModel.PageSize, count, intoGroupList); } diff --git a/IRaCIS.Core.Domain/Dcotor/Doctor.cs b/IRaCIS.Core.Domain/Dcotor/Doctor.cs index 723a128f..10e83375 100644 --- a/IRaCIS.Core.Domain/Dcotor/Doctor.cs +++ b/IRaCIS.Core.Domain/Dcotor/Doctor.cs @@ -1,3 +1,4 @@ +using EntityFrameworkCore.Projectables; using IRaCIS.Core.Domain.Share; using System; using System.Collections.Generic; @@ -48,6 +49,9 @@ namespace IRaCIS.Core.Domain.Models [StringLength(100)] public string LastName { get; set; } = string.Empty; + [Projectable] + public string FullName => LastName + " / " + FirstName; + public int Sex { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 55487288..eebf4ac3 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -971,7 +971,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common var inspectionData = new InspectionJsonDetail() { + //稽查实体,加上扩充的信息 Data = AddJsonItem(data, otherItem), + + //通用信息 Inspection = generalData }; add.JsonDetail = inspectionData.ToJsonStr(); diff --git a/IRaCIS.Core.Infrastructure/Abandon/Expression/ExpressionExtend.cs b/IRaCIS.Core.Infrastructure/Abandon/Expression/ExpressionExtend.cs deleted file mode 100644 index f5a4d64b..00000000 --- a/IRaCIS.Core.Infrastructure/Abandon/Expression/ExpressionExtend.cs +++ /dev/null @@ -1,61 +0,0 @@ -//using System; -//using System.Linq.Expressions; - -//namespace IRaCIS.Core.Infrastructure.ExpressionExtend -//{ -// /// -// /// 合并表达式 And Or Not扩展 -// /// -// public static class ExpressionExtend -// { -// /// -// /// 合并表达式 expr1 AND expr2 -// /// -// /// -// /// -// /// -// /// -// public static Expression> And(this Expression> expr1, Expression> expr2) -// { -// if (expr1 == null) return expr2; -// else if (expr2 == null) return expr1; - -// //return Expression.Lambda>(Expression.AndAlso(expr1.Body, expr2.Body), expr1.Parameters); -// ParameterExpression newParameter = Expression.Parameter(typeof(T), "c"); -// NewExpressionVisitor visitor = new NewExpressionVisitor(newParameter); - -// var left = visitor.Replace(expr1.Body); -// var right = visitor.Replace(expr2.Body); -// var body = Expression.And(left, right); -// return Expression.Lambda>(body, newParameter); - -// } -// /// -// /// 合并表达式 expr1 or expr2 -// /// -// /// -// /// -// /// -// /// -// public static Expression> Or(this Expression> expr1, Expression> expr2) -// { -// if (expr1 == null) return expr2; -// else if (expr2 == null) return expr1; - -// ParameterExpression newParameter = Expression.Parameter(typeof(T), "c"); -// NewExpressionVisitor visitor = new NewExpressionVisitor(newParameter); - -// var left = visitor.Replace(expr1.Body); -// var right = visitor.Replace(expr2.Body); -// var body = Expression.Or(left, right); -// return Expression.Lambda>(body, newParameter); -// } -// public static Expression> Not(this Expression> expr) -// { -// if (expr == null) return null; -// var candidateExpr = expr.Parameters[0]; -// var body = Expression.Not(expr.Body); -// return Expression.Lambda>(body, candidateExpr); -// } -// } -//} diff --git a/IRaCIS.Core.Infrastructure/Abandon/Expression/Expressionable.cs b/IRaCIS.Core.Infrastructure/Abandon/Expression/Expressionable.cs deleted file mode 100644 index 61f5a91d..00000000 --- a/IRaCIS.Core.Infrastructure/Abandon/Expression/Expressionable.cs +++ /dev/null @@ -1,447 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Text; -using System.Threading.Tasks; - -namespace IRaCIS.Core.Infrastructure.Extention -{ - public class Expressionable where T : class, new() - { - Expression> _exp = null; - - public Expressionable And(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable AndIF(bool isAnd, Expression> exp) - { - if (isAnd) - And(exp); - return this; - } - - public Expressionable Or(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable OrIF(bool isOr, Expression> exp) - { - if (isOr) - Or(exp); - return this; - } - - - public Expression> ToExpression() - { - if (_exp == null) - _exp = it => true; - return _exp; - } - } - public class Expressionable where T : class, new() where T2 : class, new() - { - Expression> _exp = null; - - public Expressionable And(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable AndIF(bool isAnd, Expression> exp) - { - if (isAnd) - And(exp); - return this; - } - - public Expressionable Or(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable OrIF(bool isOr, Expression> exp) - { - if (isOr) - Or(exp); - return this; - } - - - public Expression> ToExpression() - { - if (_exp == null) - _exp = (it, t2) => true; - return _exp; - } - } - public class Expressionable where T : class, new() where T2 : class, new() where T3 : class, new() - { - Expression> _exp = null; - - public Expressionable And(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable AndIF(bool isAnd, Expression> exp) - { - if (isAnd) - And(exp); - return this; - } - - public Expressionable Or(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable OrIF(bool isOr, Expression> exp) - { - if (isOr) - Or(exp); - return this; - } - - - public Expression> ToExpression() - { - if (_exp == null) - _exp = (it, t2, t3) => true; - return _exp; - } - } - public class Expressionable where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() - { - Expression> _exp = null; - - public Expressionable And(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable AndIF(bool isAnd, Expression> exp) - { - if (isAnd) - And(exp); - return this; - } - - public Expressionable Or(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable OrIF(bool isOr, Expression> exp) - { - if (isOr) - Or(exp); - return this; - } - - - public Expression> ToExpression() - { - if (_exp == null) - _exp = (it, t2, t3, t4) => true; - return _exp; - } - } - public class Expressionable where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() - { - Expression> _exp = null; - - public Expressionable And(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable AndIF(bool isAnd, Expression> exp) - { - if (isAnd) - And(exp); - return this; - } - - public Expressionable Or(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable OrIF(bool isOr, Expression> exp) - { - if (isOr) - Or(exp); - return this; - } - - - public Expression> ToExpression() - { - if (_exp == null) - _exp = (it, t2, t3, t4, T5) => true; - return _exp; - } - } - - public class Expressionable where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() - { - Expression> _exp = null; - - public Expressionable And(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable AndIF(bool isAnd, Expression> exp) - { - if (isAnd) - And(exp); - return this; - } - - public Expressionable Or(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable OrIF(bool isOr, Expression> exp) - { - if (isOr) - Or(exp); - return this; - } - - - public Expression> ToExpression() - { - if (_exp == null) - _exp = (it, t2, t3, t4, T5, t6) => true; - return _exp; - } - } - public class Expressionable where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() - { - Expression> _exp = null; - - public Expressionable And(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable AndIF(bool isAnd, Expression> exp) - { - if (isAnd) - And(exp); - return this; - } - - public Expressionable Or(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable OrIF(bool isOr, Expression> exp) - { - if (isOr) - Or(exp); - return this; - } - - - public Expression> ToExpression() - { - if (_exp == null) - _exp = (it, t2, t3, t4, T5, t6, t7) => true; - return _exp; - } - } - public class Expressionable where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() - { - Expression> _exp = null; - - public Expressionable And(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable AndIF(bool isAnd, Expression> exp) - { - if (isAnd) - And(exp); - return this; - } - - public Expressionable Or(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable OrIF(bool isOr, Expression> exp) - { - if (isOr) - Or(exp); - return this; - } - - - public Expression> ToExpression() - { - if (_exp == null) - _exp = (it, t2, t3, t4, T5, t6, t7, t8) => true; - return _exp; - } - } - public class Expressionable where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() where T9 : class, new() - { - Expression> _exp = null; - - public Expressionable And(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable AndIF(bool isAnd, Expression> exp) - { - if (isAnd) - And(exp); - return this; - } - - public Expressionable Or(Expression> exp) - { - if (_exp == null) - _exp = exp; - else - _exp = Expression.Lambda>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); - return this; - } - - public Expressionable OrIF(bool isOr, Expression> exp) - { - if (isOr) - Or(exp); - return this; - } - - - public Expression> ToExpression() - { - if (_exp == null) - _exp = (it, t2, t3, t4, T5, t6, t7, t8, t9) => true; - return _exp; - } - } - public class Expressionable - { - public static Expressionable Create() where T : class, new() - { - return new Expressionable(); - } - public static Expressionable Create() where T : class, new() where T2 : class, new() - { - return new Expressionable(); - } - public static Expressionable Create() where T : class, new() where T2 : class, new() where T3 : class, new() - { - return new Expressionable(); - } - public static Expressionable Create() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() - { - return new Expressionable(); - } - public static Expressionable Create() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() - { - return new Expressionable(); - } - public static Expressionable Create() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() - { - return new Expressionable(); - } - public static Expressionable Create() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() - { - return new Expressionable(); - } - public static Expressionable Create() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() - { - return new Expressionable(); - } - public static Expressionable Create() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() where T9 : class, new() - { - return new Expressionable(); - } - - } -} diff --git a/IRaCIS.Core.Infrastructure/Abandon/Expression/NewExpressionVisitor.cs b/IRaCIS.Core.Infrastructure/Abandon/Expression/NewExpressionVisitor.cs deleted file mode 100644 index 164aee24..00000000 --- a/IRaCIS.Core.Infrastructure/Abandon/Expression/NewExpressionVisitor.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Linq.Expressions; - -namespace IRaCIS.Core.Infrastructure.ExpressionExtend -{ - /// - /// 建立新表达式 - /// - internal class NewExpressionVisitor : ExpressionVisitor - { - public ParameterExpression _NewParameter { get; private set; } - public NewExpressionVisitor(ParameterExpression param) - { - this._NewParameter = param; - } - public Expression Replace(Expression exp) - { - return this.Visit(exp); - } - protected override Expression VisitParameter(ParameterExpression node) - { - return this._NewParameter; - } - } -} diff --git a/IRaCIS.Core.Infrastructure/Abandon/QueryableExtension.cs b/IRaCIS.Core.Infrastructure/Abandon/QueryableExtension.cs deleted file mode 100644 index aa2d942f..00000000 --- a/IRaCIS.Core.Infrastructure/Abandon/QueryableExtension.cs +++ /dev/null @@ -1,66 +0,0 @@ -using IRaCIS.Core.Infrastructure.ExpressionExtend; -using System; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; - -namespace IRaCIS.Core.Infrastructure.ExpressionExtend -{ - public static class QueryableExtension - { - public static IOrderedQueryable OrderBy(this IQueryable query, string propertyName) - { - Type type = typeof(T); - - PropertyInfo property = type.GetProperty(propertyName); - if (property == null) - throw new ArgumentException(propertyName, "Not Exist"); - - return OrderBy(query, propertyName, false); - } - - public static IOrderedQueryable OrderByDescending(this IQueryable query, string propertyName) - { - Type type = typeof(T); - - PropertyInfo property = type.GetProperty(propertyName); - if (property == null) - throw new ArgumentException(propertyName, "Not Exist"); - - return OrderBy(query, propertyName, true); - } - - static IOrderedQueryable OrderBy(IQueryable query, string propertyName, bool isDesc) - { - string methodName = isDesc ? "OrderByDescendingInternal" : "OrderByInternal"; - - var memberProp = typeof(T).GetProperty(propertyName); - - var method = typeof(QueryableExtension).GetMethod(methodName) - - .MakeGenericMethod(typeof(T), memberProp.PropertyType); - - return (IOrderedQueryable)method.Invoke(null, new object[] { query, memberProp }); - } - - public static IOrderedQueryable OrderByInternal(IQueryable query, PropertyInfo memberProperty) - { - return query.OrderBy(_GetLamba(memberProperty)); - } - - public static IOrderedQueryable OrderByDescendingInternal(IQueryable query, PropertyInfo memberProperty) - { - return query.OrderByDescending(_GetLamba(memberProperty)); - } - - static Expression> _GetLamba(PropertyInfo memberProperty) - { - if (memberProperty.PropertyType != typeof(TProp)) throw new Exception(); - - var thisArg = Expression.Parameter(typeof(T)); - var lamba = Expression.Lambda>(Expression.Property(thisArg, memberProperty), thisArg); - return lamba; - } - - } -} \ No newline at end of file