上线前 整理代码
parent
7ace793235
commit
bd44ac3b2c
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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<PaymentModel>(queryParam.PageIndex, queryParam.PageSize, count, costStatisticsList);
|
||||
|
||||
|
||||
#region 增加调整费用总计字段之前
|
||||
|
@ -167,7 +169,6 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
#endregion
|
||||
|
||||
return new PageOutput<PaymentModel>(queryParam.PageIndex, queryParam.PageSize, count, costStatisticsList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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<MonthlyPaymentDTO>(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<MonthlyPaymentDTO>(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)
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using AutoMapper;
|
||||
using IRaCIS.Core.Infrastructure.ExpressionExtend;
|
||||
using IRaCIS.Application.Interfaces;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using System.Linq.Expressions;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using AutoMapper;
|
||||
using IRaCIS.Core.Infrastructure.ExpressionExtend;
|
||||
using IRaCIS.Application.Interfaces;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using System.Linq.Expressions;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace IRaCIS.Application.Interfaces
|
|||
{
|
||||
public interface IStatisticsService
|
||||
{
|
||||
PageOutput<WorkloadByTrialAndReviewerDTO> GetWorkloadByTrialAndReviewer(StatisticsWorkloadQueryParam param);
|
||||
Task<PageOutput<WorkloadByTrialAndReviewerDTO>> GetWorkloadByTrialAndReviewer(StatisticsWorkloadQueryParam param);
|
||||
|
||||
PageOutput<EnrollStatByTrialDTO> GetEnrollStatByTrial(EnrollStatByTrialQueryDTO param);
|
||||
|
||||
|
@ -38,6 +38,6 @@ namespace IRaCIS.Application.Interfaces
|
|||
List<LatestWorkLoadDTO> GetLatestWorkLoadList( int searchCount);
|
||||
#endregion
|
||||
|
||||
PageOutput<EnrollStatByReviewerDTO> GetEnrollStatByReviewer(EnrollStatByReviewerQueryDTO enrollTrialStatisticsQueryParam);
|
||||
Task<PageOutput<EnrollStatByReviewerDTO>> GetEnrollStatByReviewer(EnrollStatByReviewerQueryDTO enrollTrialStatisticsQueryParam);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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统计、全局工作量统计、入组两个维度统计(按照项目、按照人)
|
||||
/// </summary>
|
||||
|
||||
[ ApiExplorerSettings(GroupName = "Dashboard&Statistics")]
|
||||
[ApiExplorerSettings(GroupName = "Dashboard&Statistics")]
|
||||
public class StatisticsService : BaseService, IStatisticsService
|
||||
{
|
||||
private readonly IRepository<Doctor> _doctorRepository;
|
||||
private readonly IRepository<Trial> _trialRepository;
|
||||
private readonly IRepository<Enroll> _enrollRepository;
|
||||
private readonly IRepository<Enroll> _enrollRepository;
|
||||
private readonly IRepository<Workload> _workloadRepository;
|
||||
private readonly IRepository<CRO> _croCompanyRepository;
|
||||
private readonly IRepository<Dictionary> _dictionaryRepository;
|
||||
|
@ -27,7 +24,7 @@ namespace IRaCIS.Application.Services
|
|||
private readonly IRepository<EnrollDetail> _enrollDetailRepository;
|
||||
private readonly IRepository<User> _userRepository;
|
||||
private readonly IRepository<TrialUser> _userTrialRepository;
|
||||
|
||||
|
||||
|
||||
public StatisticsService(IRepository<Doctor> doctorRepository, IRepository<Trial> trialRepository,
|
||||
IRepository<Enroll> intoGroupRepository, IRepository<Workload> workloadRepository,
|
||||
|
@ -47,16 +44,16 @@ namespace IRaCIS.Application.Services
|
|||
_enrollDetailRepository = enrollDetailRepository;
|
||||
_userRepository = userRepository;
|
||||
_userTrialRepository = userTrialRepository;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary> 根据项目和医生,分页获取工作量统计[New] </summary>
|
||||
[HttpPost]
|
||||
public PageOutput<WorkloadByTrialAndReviewerDTO> GetWorkloadByTrialAndReviewer(
|
||||
public async Task<PageOutput<WorkloadByTrialAndReviewerDTO>> 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<Func<Trial, bool>> 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<Guid> 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<WorkloadByTrialAndReviewerDTO>(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<WorkloadByTrialAndReviewerDTO>(param.PageIndex, param.PageSize, count, doctorViewList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary> 项目入组 医生维度统计[New] </summary>
|
||||
[HttpPost]
|
||||
public PageOutput<EnrollStatByReviewerDTO> GetEnrollStatByReviewer(EnrollStatByReviewerQueryDTO param)
|
||||
public async Task<PageOutput<EnrollStatByReviewerDTO>> 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<EnrollStatByReviewerDTO>(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<EnrollStatByReviewerDTO>(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<Func<User, bool>> userLambda = x => true;
|
||||
Expression<Func<TrialUser, bool>> userTrialLambda = x =>true;
|
||||
Expression<Func<TrialUser, bool>> 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<UserParticipateTrialDetail> GetParticipateTrialList(Guid userId)
|
||||
{
|
||||
|
||||
Expression<Func<TrialUser, bool>> userTrialLambda = x => x.UserId== userId;
|
||||
|
||||
Expression<Func<TrialUser, bool>> 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 数据统计
|
||||
/// <summary> 读片数分类统计[New] </summary>
|
||||
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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<WorkLoadAndAgreementDTO>(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<WorkLoadAndAgreementDTO>(doctorSearchModel.PageIndex,
|
||||
// doctorSearchModel.PageSize, count, intoGroupList);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
||||
|
|
|
@ -971,7 +971,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
|
||||
var inspectionData = new InspectionJsonDetail()
|
||||
{
|
||||
//稽查实体,加上扩充的信息
|
||||
Data = AddJsonItem(data, otherItem),
|
||||
|
||||
//通用信息
|
||||
Inspection = generalData
|
||||
};
|
||||
add.JsonDetail = inspectionData.ToJsonStr();
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
//using System;
|
||||
//using System.Linq.Expressions;
|
||||
|
||||
//namespace IRaCIS.Core.Infrastructure.ExpressionExtend
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 合并表达式 And Or Not扩展
|
||||
// /// </summary>
|
||||
// public static class ExpressionExtend
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 合并表达式 expr1 AND expr2
|
||||
// /// </summary>
|
||||
// /// <typeparam name="T"></typeparam>
|
||||
// /// <param name="expr1"></param>
|
||||
// /// <param name="expr2"></param>
|
||||
// /// <returns></returns>
|
||||
// public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> expr1, Expression<Func<T, bool>> expr2)
|
||||
// {
|
||||
// if (expr1 == null) return expr2;
|
||||
// else if (expr2 == null) return expr1;
|
||||
|
||||
// //return Expression.Lambda<Func<T, bool>>(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<Func<T, bool>>(body, newParameter);
|
||||
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// 合并表达式 expr1 or expr2
|
||||
// /// </summary>
|
||||
// /// <typeparam name="T"></typeparam>
|
||||
// /// <param name="expr1"></param>
|
||||
// /// <param name="expr2"></param>
|
||||
// /// <returns></returns>
|
||||
// public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> expr1, Expression<Func<T, bool>> 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<Func<T, bool>>(body, newParameter);
|
||||
// }
|
||||
// public static Expression<Func<T, bool>> Not<T>(this Expression<Func<T, bool>> expr)
|
||||
// {
|
||||
// if (expr == null) return null;
|
||||
// var candidateExpr = expr.Parameters[0];
|
||||
// var body = Expression.Not(expr.Body);
|
||||
// return Expression.Lambda<Func<T, bool>>(body, candidateExpr);
|
||||
// }
|
||||
// }
|
||||
//}
|
|
@ -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<T> where T : class, new()
|
||||
{
|
||||
Expression<Func<T, bool>> _exp = null;
|
||||
|
||||
public Expressionable<T> And(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T> AndIF(bool isAnd, Expression<Func<T, bool>> exp)
|
||||
{
|
||||
if (isAnd)
|
||||
And(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T> Or(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T> OrIF(bool isOr, Expression<Func<T, bool>> exp)
|
||||
{
|
||||
if (isOr)
|
||||
Or(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Expression<Func<T, bool>> ToExpression()
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = it => true;
|
||||
return _exp;
|
||||
}
|
||||
}
|
||||
public class Expressionable<T, T2> where T : class, new() where T2 : class, new()
|
||||
{
|
||||
Expression<Func<T, T2, bool>> _exp = null;
|
||||
|
||||
public Expressionable<T, T2> And(Expression<Func<T, T2, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2> AndIF(bool isAnd, Expression<Func<T, T2, bool>> exp)
|
||||
{
|
||||
if (isAnd)
|
||||
And(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2> Or(Expression<Func<T, T2, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2> OrIF(bool isOr, Expression<Func<T, T2, bool>> exp)
|
||||
{
|
||||
if (isOr)
|
||||
Or(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Expression<Func<T, T2, bool>> ToExpression()
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = (it, t2) => true;
|
||||
return _exp;
|
||||
}
|
||||
}
|
||||
public class Expressionable<T, T2, T3> where T : class, new() where T2 : class, new() where T3 : class, new()
|
||||
{
|
||||
Expression<Func<T, T2, T3, bool>> _exp = null;
|
||||
|
||||
public Expressionable<T, T2, T3> And(Expression<Func<T, T2, T3, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3> AndIF(bool isAnd, Expression<Func<T, T2, T3, bool>> exp)
|
||||
{
|
||||
if (isAnd)
|
||||
And(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3> Or(Expression<Func<T, T2, T3, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3> OrIF(bool isOr, Expression<Func<T, T2, T3, bool>> exp)
|
||||
{
|
||||
if (isOr)
|
||||
Or(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Expression<Func<T, T2, T3, bool>> ToExpression()
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = (it, t2, t3) => true;
|
||||
return _exp;
|
||||
}
|
||||
}
|
||||
public class Expressionable<T, T2, T3, T4> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new()
|
||||
{
|
||||
Expression<Func<T, T2, T3, T4, bool>> _exp = null;
|
||||
|
||||
public Expressionable<T, T2, T3, T4> And(Expression<Func<T, T2, T3, T4, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, T4, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, bool>> exp)
|
||||
{
|
||||
if (isAnd)
|
||||
And(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4> Or(Expression<Func<T, T2, T3, T4, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, T4, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, bool>> exp)
|
||||
{
|
||||
if (isOr)
|
||||
Or(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Expression<Func<T, T2, T3, T4, bool>> ToExpression()
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = (it, t2, t3, t4) => true;
|
||||
return _exp;
|
||||
}
|
||||
}
|
||||
public class Expressionable<T, T2, T3, T4, T5> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new()
|
||||
{
|
||||
Expression<Func<T, T2, T3, T4, T5, bool>> _exp = null;
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5> And(Expression<Func<T, T2, T3, T4, T5, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, bool>> exp)
|
||||
{
|
||||
if (isAnd)
|
||||
And(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5> Or(Expression<Func<T, T2, T3, T4, T5, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, bool>> exp)
|
||||
{
|
||||
if (isOr)
|
||||
Or(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Expression<Func<T, T2, T3, T4, T5, bool>> ToExpression()
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = (it, t2, t3, t4, T5) => true;
|
||||
return _exp;
|
||||
}
|
||||
}
|
||||
|
||||
public class Expressionable<T, T2, T3, T4, T5, T6> 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<Func<T, T2, T3, T4, T5, T6, bool>> _exp = null;
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6> And(Expression<Func<T, T2, T3, T4, T5, T6, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, bool>> exp)
|
||||
{
|
||||
if (isAnd)
|
||||
And(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6> Or(Expression<Func<T, T2, T3, T4, T5, T6, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, bool>> exp)
|
||||
{
|
||||
if (isOr)
|
||||
Or(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Expression<Func<T, T2, T3, T4, T5, T6, bool>> ToExpression()
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = (it, t2, t3, t4, T5, t6) => true;
|
||||
return _exp;
|
||||
}
|
||||
}
|
||||
public class Expressionable<T, T2, T3, T4, T5, T6, T7> 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<Func<T, T2, T3, T4, T5, T6, T7, bool>> _exp = null;
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6, T7> And(Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6, T7> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> exp)
|
||||
{
|
||||
if (isAnd)
|
||||
And(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6, T7> Or(Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6, T7> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> exp)
|
||||
{
|
||||
if (isOr)
|
||||
Or(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> ToExpression()
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = (it, t2, t3, t4, T5, t6, t7) => true;
|
||||
return _exp;
|
||||
}
|
||||
}
|
||||
public class Expressionable<T, T2, T3, T4, T5, T6, T7, T8> 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<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> _exp = null;
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8> And(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> exp)
|
||||
{
|
||||
if (isAnd)
|
||||
And(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8> Or(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> exp)
|
||||
{
|
||||
if (isOr)
|
||||
Or(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> ToExpression()
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = (it, t2, t3, t4, T5, t6, t7, t8) => true;
|
||||
return _exp;
|
||||
}
|
||||
}
|
||||
public class Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9> 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<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> _exp = null;
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9> And(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp)
|
||||
{
|
||||
if (isAnd)
|
||||
And(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9> Or(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp)
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = exp;
|
||||
else
|
||||
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp)
|
||||
{
|
||||
if (isOr)
|
||||
Or(exp);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> ToExpression()
|
||||
{
|
||||
if (_exp == null)
|
||||
_exp = (it, t2, t3, t4, T5, t6, t7, t8, t9) => true;
|
||||
return _exp;
|
||||
}
|
||||
}
|
||||
public class Expressionable
|
||||
{
|
||||
public static Expressionable<T> Create<T>() where T : class, new()
|
||||
{
|
||||
return new Expressionable<T>();
|
||||
}
|
||||
public static Expressionable<T, T2> Create<T, T2>() where T : class, new() where T2 : class, new()
|
||||
{
|
||||
return new Expressionable<T, T2>();
|
||||
}
|
||||
public static Expressionable<T, T2, T3> Create<T, T2, T3>() where T : class, new() where T2 : class, new() where T3 : class, new()
|
||||
{
|
||||
return new Expressionable<T, T2, T3>();
|
||||
}
|
||||
public static Expressionable<T, T2, T3, T4> Create<T, T2, T3, T4>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new()
|
||||
{
|
||||
return new Expressionable<T, T2, T3, T4>();
|
||||
}
|
||||
public static Expressionable<T, T2, T3, T4, T5> Create<T, T2, T3, T4, T5>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new()
|
||||
{
|
||||
return new Expressionable<T, T2, T3, T4, T5>();
|
||||
}
|
||||
public static Expressionable<T, T2, T3, T4, T5, T6> Create<T, T2, T3, T4, T5, T6>() 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<T, T2, T3, T4, T5, T6>();
|
||||
}
|
||||
public static Expressionable<T, T2, T3, T4, T5, T6, T7> Create<T, T2, T3, T4, T5, T6, T7>() 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<T, T2, T3, T4, T5, T6, T7>();
|
||||
}
|
||||
public static Expressionable<T, T2, T3, T4, T5, T6, T7, T8> Create<T, T2, T3, T4, T5, T6, T7, T8>() 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<T, T2, T3, T4, T5, T6, T7, T8>();
|
||||
}
|
||||
public static Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9> Create<T, T2, T3, T4, T5, T6, T7, T8, T9>() 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<T, T2, T3, T4, T5, T6, T7, T8, T9>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
using System.Linq.Expressions;
|
||||
|
||||
namespace IRaCIS.Core.Infrastructure.ExpressionExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// 建立新表达式
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<T> OrderBy<T>(this IQueryable<T> 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<T> OrderByDescending<T>(this IQueryable<T> 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<T> OrderBy<T>(IQueryable<T> 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<T>)method.Invoke(null, new object[] { query, memberProp });
|
||||
}
|
||||
|
||||
public static IOrderedQueryable<T> OrderByInternal<T, TProp>(IQueryable<T> query, PropertyInfo memberProperty)
|
||||
{
|
||||
return query.OrderBy(_GetLamba<T, TProp>(memberProperty));
|
||||
}
|
||||
|
||||
public static IOrderedQueryable<T> OrderByDescendingInternal<T, TProp>(IQueryable<T> query, PropertyInfo memberProperty)
|
||||
{
|
||||
return query.OrderByDescending(_GetLamba<T, TProp>(memberProperty));
|
||||
}
|
||||
|
||||
static Expression<Func<T, TProp>> _GetLamba<T, TProp>(PropertyInfo memberProperty)
|
||||
{
|
||||
if (memberProperty.PropertyType != typeof(TProp)) throw new Exception();
|
||||
|
||||
var thisArg = Expression.Parameter(typeof(T));
|
||||
var lamba = Expression.Lambda<Func<T, TProp>>(Expression.Property(thisArg, memberProperty), thisArg);
|
||||
return lamba;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue