diff --git a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs index 75226646d..db073ace2 100644 --- a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs +++ b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs @@ -104,7 +104,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("This item is referenced by content of the trial infomation."); } - var success = await _dicRepository.BatchDeleteAsync(t => t.Id == id); + var success = await _dicRepository.BatchDeleteNoTrackingAsync(t => t.Id == id); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Common/EmailNoticeConfigService.cs b/IRaCIS.Core.Application/Service/Common/EmailNoticeConfigService.cs index 3ed94e835..d76b8bee7 100644 --- a/IRaCIS.Core.Application/Service/Common/EmailNoticeConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/EmailNoticeConfigService.cs @@ -50,7 +50,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{emailNoticeConfigId:guid}")] public async Task DeleteEmailNoticeConfig(Guid emailNoticeConfigId) { - var success = await repository.BatchDeleteAsync(t => t.Id == emailNoticeConfigId); + var success = await repository.BatchDeleteNoTrackingAsync(t => t.Id == emailNoticeConfigId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs index 76e92273b..bc5c1dc1a 100644 --- a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs @@ -223,7 +223,7 @@ namespace IRaCIS.Core.Application.Service { foreach (var item in sortDto.SortData) { - await _frontAuditConfigRepository.BatchUpdateAsync(x => x.Id == item.Id, x => new FrontAuditConfig + await _frontAuditConfigRepository.BatchUpdateNoTrackingAsync(x => x.Id == item.Id, x => new FrontAuditConfig { Sort = item.Sort }); diff --git a/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs b/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs index 6ec8aca4b..0d1f65194 100644 --- a/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs @@ -42,7 +42,7 @@ namespace IRaCIS.Application.Services // File.Delete(temp); //} - var success =await _attachmentrepository.BatchDeleteAsync(a => a.Id == param.Id); + var success =await _attachmentrepository.BatchDeleteNoTrackingAsync(a => a.Id == param.Id); return ResponseOutput.Result(success); } @@ -139,7 +139,7 @@ namespace IRaCIS.Application.Services //重传的时候,发现 相同语言的官方简历数量为2 那么将重传的简历设置为非官方 if (attachments.Count(t => t.Language == reUpload.Language && t.IsOfficial) == 2) { - await _attachmentrepository.BatchUpdateAsync(t => t.Id == reUpload.Id, u => new Attachment() + await _attachmentrepository.BatchUpdateNoTrackingAsync(t => t.Id == reUpload.Id, u => new Attachment() { Path = reUpload.Path, CreateTime = DateTime.Now, @@ -150,7 +150,7 @@ namespace IRaCIS.Application.Services } else //相同语言的重传 { - await _attachmentrepository.BatchUpdateAsync(t => t.Id == reUpload.Id, u => new Attachment() + await _attachmentrepository.BatchUpdateNoTrackingAsync(t => t.Id == reUpload.Id, u => new Attachment() { Path = reUpload.Path, CreateTime = DateTime.Now, @@ -241,7 +241,7 @@ namespace IRaCIS.Application.Services [HttpPost("{doctorId:guid}/{attachmentId:guid}/{language}")] public async Task SetLanguage(Guid doctorId, Guid attachmentId, int language) { - bool result =await _attachmentrepository.BatchUpdateAsync(t => t.Id == attachmentId, a => new Attachment + bool result =await _attachmentrepository.BatchUpdateNoTrackingAsync(t => t.Id == attachmentId, a => new Attachment { Language = language, IsOfficial = false diff --git a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs index 4409a47be..039aa4477 100644 --- a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs @@ -431,7 +431,7 @@ namespace IRaCIS.Application.Services { return ResponseOutput.NotOk("Resume & Consultant Agreement must be upload "); } - var success = await _doctorRepository.BatchUpdateAsync(o => o.Id == auditResumeParam.Id, u => new Doctor() + var success = await _doctorRepository.BatchUpdateNoTrackingAsync(o => o.Id == auditResumeParam.Id, u => new Doctor() { CooperateStatus = auditResumeParam.CooperateStatus, ResumeStatus = auditResumeParam.ResumeStatus, diff --git a/IRaCIS.Core.Application/Service/Doctor/EducationService.cs b/IRaCIS.Core.Application/Service/Doctor/EducationService.cs index 6f0e63e6f..9e7af546c 100644 --- a/IRaCIS.Core.Application/Service/Doctor/EducationService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/EducationService.cs @@ -92,7 +92,7 @@ namespace IRaCIS.Application.Services [HttpDelete, Route("{doctorId:guid}")] public async Task DeleteEducationInfo(Guid id) { - var success = await _educationRepository.BatchDeleteAsync(o => o.Id == id); + var success = await _educationRepository.BatchDeleteNoTrackingAsync(o => o.Id == id); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Doctor/VacationService.cs b/IRaCIS.Core.Application/Service/Doctor/VacationService.cs index 4d4fb9d5a..54f7b4ba0 100644 --- a/IRaCIS.Core.Application/Service/Doctor/VacationService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/VacationService.cs @@ -35,7 +35,7 @@ namespace IRaCIS.Application.Services } else { - var success = await _vacationRepository.BatchUpdateAsync(u => u.Id == param.Id, + var success = await _vacationRepository.BatchUpdateNoTrackingAsync(u => u.Id == param.Id, h => new Vacation { StartDate = param.StartDate, @@ -56,7 +56,7 @@ namespace IRaCIS.Application.Services [HttpDelete("{holidayId:guid}")] public async Task DeleteVacation(Guid holidayId) { - var success = await _vacationRepository.BatchDeleteAsync(u => u.Id == holidayId); + var success = await _vacationRepository.BatchDeleteNoTrackingAsync(u => u.Id == holidayId); return ResponseOutput.Result(success); diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index e4a1c4572..0ec098e5b 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -466,7 +466,7 @@ namespace IRaCIS.Core.Application.Services return ResponseOutput.NotOk("该文档,已有用户签名 不允许删除"); } - var success = await _trialDocumentRepository.BatchDeleteAsync(t => t.Id == trialDocumentId); + var success = await _trialDocumentRepository.BatchDeleteNoTrackingAsync(t => t.Id == trialDocumentId); return ResponseOutput.Result(success); } @@ -586,7 +586,7 @@ namespace IRaCIS.Core.Application.Services } else { - await _trialDocumentRepository.BatchUpdateAsync(t => t.Id == documentId, u => new TrialDocument() { IsDeleted = true }); + await _trialDocumentRepository.BatchUpdateNoTrackingAsync(t => t.Id == documentId, u => new TrialDocument() { IsDeleted = true }); } return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Application/Service/Financial/CalculateService.cs b/IRaCIS.Core.Application/Service/Financial/CalculateService.cs index 6432f953d..cff4301cf 100644 --- a/IRaCIS.Core.Application/Service/Financial/CalculateService.cs +++ b/IRaCIS.Core.Application/Service/Financial/CalculateService.cs @@ -595,7 +595,7 @@ namespace IRaCIS.Application.Services foreach (var reviewer in needUpdatePayment) { - await _paymentRepository.BatchUpdateAsync(u => u.YearMonth == yearMonth && + await _paymentRepository.BatchUpdateNoTrackingAsync(u => u.YearMonth == yearMonth && !u.IsLock && u.DoctorId == reviewer.ReviewerId, t => new Payment() { AdjustmentUSD = reviewer.AdjustUSD, @@ -638,12 +638,12 @@ namespace IRaCIS.Application.Services // 如果是 当月计算的工作量费用 和 调整费用都为0,则删除该行记录 if (addOrUpdateModel.PaymentUSD == 0 && paymentModel.AdjustmentUSD == 0) { - success =await _paymentRepository.BatchDeleteAsync(u => u.Id == paymentModel.Id); + success =await _paymentRepository.BatchDeleteNoTrackingAsync(u => u.Id == paymentModel.Id); //_paymentDetailRepository.Delete(u=>u.PaymentId==paymentModel.Id); } else { - success = await _paymentRepository.BatchUpdateAsync(t => t.Id == paymentModel.Id, u => new Payment() + success = await _paymentRepository.BatchUpdateNoTrackingAsync(t => t.Id == paymentModel.Id, u => new Payment() { PaymentUSD = addOrUpdateModel.PaymentUSD, CalculateTime = addOrUpdateModel.CalculateTime, @@ -670,7 +670,7 @@ namespace IRaCIS.Application.Services private async Task AddOrUpdateMonthlyPaymentDetail(List addOrUpdateList, Guid paymentId) { //var paymentDetailIds = addOrUpdateList.Select(t => t.PaymentId).ToList(); - await _paymentDetailRepository.BatchDeleteAsync(t => t.PaymentId == paymentId); + await _paymentDetailRepository.BatchDeleteNoTrackingAsync(t => t.PaymentId == paymentId); await _paymentDetailRepository.AddRangeAsync(_mapper.Map>(addOrUpdateList)); return await _paymentDetailRepository.SaveChangesAsync(); } diff --git a/IRaCIS.Core.Application/Service/Financial/ExchangeRateService.cs b/IRaCIS.Core.Application/Service/Financial/ExchangeRateService.cs index 17b04fe3a..6f11fccbc 100644 --- a/IRaCIS.Core.Application/Service/Financial/ExchangeRateService.cs +++ b/IRaCIS.Core.Application/Service/Financial/ExchangeRateService.cs @@ -46,7 +46,7 @@ namespace IRaCIS.Application.Services } else { - var success = await _exchangeRateRepository.BatchUpdateAsync(t => t.Id == model.Id, u => new ExchangeRate() + var success = await _exchangeRateRepository.BatchUpdateNoTrackingAsync(t => t.Id == model.Id, u => new ExchangeRate() { //YearMonth = model.YearMonth, Rate = model.Rate, @@ -72,7 +72,7 @@ namespace IRaCIS.Application.Services } - var success = await _exchangeRateRepository.BatchDeleteAsync(t => t.Id == id); + var success = await _exchangeRateRepository.BatchDeleteNoTrackingAsync(t => t.Id == id); return ResponseOutput.Ok(success); } diff --git a/IRaCIS.Core.Application/Service/Financial/FinancialService.cs b/IRaCIS.Core.Application/Service/Financial/FinancialService.cs index 191a6314c..1b0092053 100644 --- a/IRaCIS.Core.Application/Service/Financial/FinancialService.cs +++ b/IRaCIS.Core.Application/Service/Financial/FinancialService.cs @@ -1256,18 +1256,18 @@ namespace IRaCIS.Application.Services var isLock = param.IsLock; - var paymentLockSuccess = await _paymentRepository.BatchUpdateAsync(u => reviewerIds.Contains(u.DoctorId) && u.YearMonth == yearMonth, t => new Payment + var paymentLockSuccess = await _paymentRepository.BatchUpdateNoTrackingAsync(u => reviewerIds.Contains(u.DoctorId) && u.YearMonth == yearMonth, t => new Payment { IsLock = isLock }); - var adjustmentLockSuccess = await _payAdjustmentRepository.BatchUpdateAsync( + var adjustmentLockSuccess = await _payAdjustmentRepository.BatchUpdateNoTrackingAsync( t => t.YearMonth == yearMonth && reviewerIds.Contains(t.ReviewerId), u => new PaymentAdjustment() { IsLock = true }); - await _doctorWorkloadRepository.BatchUpdateAsync(u => reviewerIds.Contains(u.DoctorId) && u.YearMonth == yearMonth, + await _doctorWorkloadRepository.BatchUpdateNoTrackingAsync(u => reviewerIds.Contains(u.DoctorId) && u.YearMonth == yearMonth, t => new Workload { IsLock = true }); return ResponseOutput.Result(paymentLockSuccess || adjustmentLockSuccess); diff --git a/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs b/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs index 5a2642d50..1935003e4 100644 --- a/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs +++ b/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs @@ -255,7 +255,7 @@ namespace IRaCIS.Application.Services { //如果是double 不会保留两位小数 - await _payAdjustmentRepository.BatchUpdateAsync(u => u.YearMonth == yearMonth && + await _payAdjustmentRepository.BatchUpdateNoTrackingAsync(u => u.YearMonth == yearMonth && !u.IsLock, t => new PaymentAdjustment { AdjustmentCNY = t.AdjustmentUSD * rate, @@ -277,7 +277,7 @@ namespace IRaCIS.Application.Services foreach (var reviewer in needUpdatePayment) { - await _paymentRepository.BatchUpdateAsync(u => u.YearMonth == yearMonth && + await _paymentRepository.BatchUpdateNoTrackingAsync(u => u.YearMonth == yearMonth && !u.IsLock && u.DoctorId == reviewer.ReviewerId, t => new Payment() { AdjustmentUSD = reviewer.AdjustUSD, diff --git a/IRaCIS.Core.Application/Service/Financial/RankPriceService.cs b/IRaCIS.Core.Application/Service/Financial/RankPriceService.cs index 9768ec39c..6ec703692 100644 --- a/IRaCIS.Core.Application/Service/Financial/RankPriceService.cs +++ b/IRaCIS.Core.Application/Service/Financial/RankPriceService.cs @@ -43,7 +43,7 @@ namespace IRaCIS.Application.Services } else { - var success =await _rankPriceRepository.BatchUpdateAsync(t => t.Id == addOrUpdateModel.Id, u => new RankPrice() + var success =await _rankPriceRepository.BatchUpdateNoTrackingAsync(t => t.Id == addOrUpdateModel.Id, u => new RankPrice() { UpdateUserId = userId, UpdateTime = DateTime.Now, @@ -76,7 +76,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("This title has been used by reviewer payment information"); } - var success = await _rankPriceRepository.BatchDeleteAsync(t => t.Id == id); + var success = await _rankPriceRepository.BatchDeleteNoTrackingAsync(t => t.Id == id); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs b/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs index 32262dd57..7e36a2e0a 100644 --- a/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs +++ b/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs @@ -78,7 +78,7 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task DeleteTrialSOW(DeleteSowPathDTO trialSowPath) { - var success = await _trialExtRepository.BatchUpdateAsync(u => u.TrialId == trialSowPath.TrialId, s => new TrialPaymentPrice + var success = await _trialExtRepository.BatchUpdateNoTrackingAsync(u => u.TrialId == trialSowPath.TrialId, s => new TrialPaymentPrice { SowPath = "", SowName = "", diff --git a/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs b/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs index 5b7b6074b..705a04b46 100644 --- a/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs +++ b/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs @@ -63,7 +63,7 @@ namespace IRaCIS.Application.Services // 完善价格的 将对应的列设置为true 变更为有价格了 - var aaa = await _trialRevenuesPriceVerificationRepository.BatchUpdateAsync(t => t.TrialId == model.TrialId, u => new TrialRevenuesPriceVerification() + var aaa = await _trialRevenuesPriceVerificationRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == model.TrialId, u => new TrialRevenuesPriceVerification() { //有价格 则设置为true 否则 该列不变 Timepoint = model.Timepoint > 0 || u.Timepoint, @@ -81,7 +81,7 @@ namespace IRaCIS.Application.Services }); //删除所有有价格的记录 为true 表示有价格或者不需要价格 缺价格的为false - await _trialRevenuesPriceVerificationRepository.BatchDeleteAsync(t => t.TrialId == model.TrialId && + await _trialRevenuesPriceVerificationRepository.BatchDeleteNoTrackingAsync(t => t.TrialId == model.TrialId && t.Timepoint&& t.TimepointIn24H&& t.TimepointIn48H && @@ -101,7 +101,7 @@ namespace IRaCIS.Application.Services [NonDynamicMethod] public async Task DeleteTrialCost(Guid id) { - return await _trialRevenuesPriceRepository.BatchDeleteAsync(u => u.Id == id); + return await _trialRevenuesPriceRepository.BatchDeleteNoTrackingAsync(u => u.Id == id); } /// diff --git a/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs b/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs index 742d8da2c..362e8ed76 100644 --- a/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs +++ b/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs @@ -28,7 +28,7 @@ namespace IRaCIS.Application.Services [NonDynamicMethod] public async Task AddOrUpdateVolumeRewardPriceList(IEnumerable addOrUpdateModel) { - await _volumeRewardRepository.BatchDeleteAsync(t => t.Id != Guid.Empty); + await _volumeRewardRepository.BatchDeleteNoTrackingAsync(t => t.Id != Guid.Empty); var temp = _mapper.Map>(addOrUpdateModel); await _volumeRewardRepository.AddRangeAsync(temp); diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/SystemAnonymizationService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/SystemAnonymizationService.cs index 3492b9f22..791f5e997 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/SystemAnonymizationService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/SystemAnonymizationService.cs @@ -57,7 +57,7 @@ namespace IRaCIS.Core.Application.Service [HttpDelete("{systemAnonymizationId:guid}")] public async Task DeleteSystemAnonymization(Guid systemAnonymizationId) { - var success = await systemAnonymizationRepository.BatchDeleteAsync(t => t.Id == systemAnonymizationId); + var success = await systemAnonymizationRepository.BatchDeleteNoTrackingAsync(t => t.Id == systemAnonymizationId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Institution/CROService.cs b/IRaCIS.Core.Application/Service/Institution/CROService.cs index 9fea6a0bb..4c588c5fd 100644 --- a/IRaCIS.Core.Application/Service/Institution/CROService.cs +++ b/IRaCIS.Core.Application/Service/Institution/CROService.cs @@ -70,7 +70,7 @@ namespace IRaCIS.Application.Services //{ // return ResponseOutput.NotOk("该CRO下存在用户,暂时无法删除。"); //} - var success = await _croRepository.BatchDeleteAsync(x=>x.Id== cROCompanyId); + var success = await _croRepository.BatchDeleteNoTrackingAsync(x=>x.Id== cROCompanyId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Institution/HospitalService.cs b/IRaCIS.Core.Application/Service/Institution/HospitalService.cs index 4884b0638..e200970e1 100644 --- a/IRaCIS.Core.Application/Service/Institution/HospitalService.cs +++ b/IRaCIS.Core.Application/Service/Institution/HospitalService.cs @@ -54,7 +54,7 @@ namespace IRaCIS.Application.Services // return ResponseOutput.NotOk("该医院下存在用户,暂时无法删除。"); //} - var success = await _hospitalRepository.BatchDeleteAsync(x => x.Id == hospitalId); + var success = await _hospitalRepository.BatchDeleteNoTrackingAsync(x => x.Id == hospitalId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Institution/SiteService.cs b/IRaCIS.Core.Application/Service/Institution/SiteService.cs index c4113ed98..3d068996f 100644 --- a/IRaCIS.Core.Application/Service/Institution/SiteService.cs +++ b/IRaCIS.Core.Application/Service/Institution/SiteService.cs @@ -69,7 +69,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("This site has participated in the trial and couldn't be deleted."); } - var success = await _siteRepository.BatchDeleteAsync(x => x.Id == siteId); + var success = await _siteRepository.BatchDeleteNoTrackingAsync(x => x.Id == siteId); return ResponseOutput.Result(success); } } diff --git a/IRaCIS.Core.Application/Service/Institution/SponsorService.cs b/IRaCIS.Core.Application/Service/Institution/SponsorService.cs index 215755a03..1c5e9ab44 100644 --- a/IRaCIS.Core.Application/Service/Institution/SponsorService.cs +++ b/IRaCIS.Core.Application/Service/Institution/SponsorService.cs @@ -75,7 +75,7 @@ namespace IRaCIS.Application.Services //} - var success = await _sponsorRepository.BatchDeleteAsync(x => x.Id == sponsorId); + var success = await _sponsorRepository.BatchDeleteNoTrackingAsync(x => x.Id == sponsorId); return ResponseOutput.Result(success); } } diff --git a/IRaCIS.Core.Application/Service/Management/MenuService.cs b/IRaCIS.Core.Application/Service/Management/MenuService.cs index 4c22c9922..7a611318c 100644 --- a/IRaCIS.Core.Application/Service/Management/MenuService.cs +++ b/IRaCIS.Core.Application/Service/Management/MenuService.cs @@ -93,7 +93,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("不允许直接删除父节点"); } - var success =await menuRepository.BatchDeleteAsync(u => u.Id == menuId); + var success =await menuRepository.BatchDeleteNoTrackingAsync(u => u.Id == menuId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Management/SystemNoticeService.cs b/IRaCIS.Core.Application/Service/Management/SystemNoticeService.cs index a9641d088..ba694b757 100644 --- a/IRaCIS.Core.Application/Service/Management/SystemNoticeService.cs +++ b/IRaCIS.Core.Application/Service/Management/SystemNoticeService.cs @@ -73,7 +73,7 @@ namespace IRaCIS.Core.Application.Service [HttpDelete("{systemNoticeId:guid}")] public async Task DeleteSystemNotice(Guid systemNoticeId) { - var success = await _systemNoticeRepository.BatchDeleteAsync(t => t.Id == systemNoticeId); + var success = await _systemNoticeRepository.BatchDeleteNoTrackingAsync(t => t.Id == systemNoticeId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index e3e188a1b..0b51f1ccf 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -93,13 +93,13 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("The mailbox for this user type already exists"); } - await _userRepository.UpdatePartialFieldsNowAsync(_userInfo.Id, u => new User() + await _userRepository.UpdateNowNoQueryAsync(_userInfo.Id, u => new User() { EMail = newEmail }); //删除验证码历史记录 - await _verificationCodeRepository.BatchDeleteAsync(t => t.UserId == _userInfo.Id && t.CodeType == 0); + await _verificationCodeRepository.BatchDeleteNoTrackingAsync(t => t.UserId == _userInfo.Id && t.CodeType == 0); return ResponseOutput.Ok(); @@ -113,7 +113,7 @@ namespace IRaCIS.Application.Services { - await _userRepository.UpdatePartialFieldsNowAsync(_userInfo.Id, u => new User() + await _userRepository.UpdateNowNoQueryAsync(_userInfo.Id, u => new User() { Phone = newPhone }); @@ -130,7 +130,7 @@ namespace IRaCIS.Application.Services { return ResponseOutput.NotOk("UserId already exists"); } - await _userRepository.UpdatePartialFieldsNowAsync(_userInfo.Id, u => new User() + await _userRepository.UpdateNowNoQueryAsync(_userInfo.Id, u => new User() { UserName = newUserName }); @@ -148,7 +148,7 @@ namespace IRaCIS.Application.Services public async Task ResetPassword(Guid userId) { - await _userRepository.UpdatePartialFieldsNowAsync(userId, u => new User() + await _userRepository.UpdateNowNoQueryAsync(userId, u => new User() { Password = MD5Helper.Md5(StaticData.DefaultPassword), IsFirstAdd = true @@ -228,7 +228,7 @@ namespace IRaCIS.Application.Services { //删除验证码历史记录 - await _verificationCodeRepository.BatchDeleteAsync(t => t.Id == verificationRecord.Id); + await _verificationCodeRepository.BatchDeleteNoTrackingAsync(t => t.Id == verificationRecord.Id); } } @@ -260,7 +260,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("password not change"); } - var success = await _userRepository.BatchUpdateAsync(t => t.Id == userId, u => new User() + var success = await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Password = newPwd, IsFirstAdd = false @@ -297,14 +297,14 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("UserId already exists"); } - await _userRepository.BatchUpdateAsync(t => t.Id == _userInfo.Id, u => new User() + await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == _userInfo.Id, u => new User() { UserName = editPwModel.NewUserName, }); } - var success = await _userRepository.BatchUpdateAsync(t => t.Id == _userInfo.Id, u => new User() + var success = await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == _userInfo.Id, u => new User() { Password = editPwModel.NewPassWord, IsFirstAdd = false @@ -318,7 +318,7 @@ namespace IRaCIS.Application.Services //医生密码 if (await _doctorRepository.AnyAsync(t => t.Id == _userInfo.Id && t.Password == editPwModel.OldPassWord)) { - var success = await _doctorRepository.BatchUpdateAsync(t => t.Id == _userInfo.Id, u => new Doctor() + var success = await _doctorRepository.BatchUpdateNoTrackingAsync(t => t.Id == _userInfo.Id, u => new Doctor() { Password = editPwModel.NewPassWord @@ -445,7 +445,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("This user has participated in the trial and couldn't be deleted"); } - var success = await _userRepository.BatchDeleteAsync(t => t.Id == userId); + var success = await _userRepository.BatchDeleteNoTrackingAsync(t => t.Id == userId); return ResponseOutput.Result(success); } @@ -460,7 +460,7 @@ namespace IRaCIS.Application.Services [HttpPost("{userId:guid}/{state:int}")] public async Task UpdateUserState(Guid userId, UserStateEnum state) { - var success = await _userRepository.BatchUpdateAsync(u => u.Id == userId, t => new User + var success = await _userRepository.BatchUpdateNoTrackingAsync(u => u.Id == userId, t => new User { Status = state }); diff --git a/IRaCIS.Core.Application/Service/Management/UserTypeService.cs b/IRaCIS.Core.Application/Service/Management/UserTypeService.cs index 7ad3d0187..3611fc917 100644 --- a/IRaCIS.Core.Application/Service/Management/UserTypeService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserTypeService.cs @@ -83,7 +83,7 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.NotOk("该用户类型,被某些用户已使用,不能删除"); } - var success = await userTypeServiceRepository.BatchDeleteAsync(t => t.Id == userTypeId); + var success = await userTypeServiceRepository.BatchDeleteNoTrackingAsync(t => t.Id == userTypeId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/QC/ClinicalDataService.cs b/IRaCIS.Core.Application/Service/QC/ClinicalDataService.cs index dc0ff0b1d..beae239ae 100644 --- a/IRaCIS.Core.Application/Service/QC/ClinicalDataService.cs +++ b/IRaCIS.Core.Application/Service/QC/ClinicalDataService.cs @@ -166,7 +166,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{trialId:guid}/{previousHistoryId:guid}")] public async Task DeletePreviousHistory(Guid previousHistoryId) { - var success = await _previousHistoryRepository.BatchDeleteAsync(t => t.Id == previousHistoryId); + var success = await _previousHistoryRepository.BatchDeleteNoTrackingAsync(t => t.Id == previousHistoryId); return ResponseOutput.Result(success); } @@ -191,7 +191,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{trialId:guid}/{previousOtherId:guid}")] public async Task DeletePreviousOther(Guid previousOtherId) { - var success = await _previousOtherRepository.BatchDeleteAsync(t => t.Id == previousOtherId); + var success = await _previousOtherRepository.BatchDeleteNoTrackingAsync(t => t.Id == previousOtherId); return ResponseOutput.Result(success); } @@ -216,7 +216,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{trialId:guid}/{previousSurgeryId:guid}")] public async Task DeletePreviousSurgery(Guid previousSurgeryId) { - var success = await _previousSurgeryRepository.BatchDeleteAsync(t => t.Id == previousSurgeryId); + var success = await _previousSurgeryRepository.BatchDeleteNoTrackingAsync(t => t.Id == previousSurgeryId); return ResponseOutput.Result(success); } @@ -242,7 +242,7 @@ namespace IRaCIS.Core.Application.Contracts public async Task DeletePreviousPDF(Guid previousPDFId) { - var success = await _previousPdfRepository.BatchDeleteAsync(t => t.Id == previousPDFId); + var success = await _previousPdfRepository.BatchDeleteNoTrackingAsync(t => t.Id == previousPDFId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs index 7dddd0bf7..66cabccb0 100644 --- a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs +++ b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs @@ -115,7 +115,7 @@ namespace IRaCIS.Core.Application.Contracts await _noneDicomStudyRepository.DeleteAsync(noneDicomStudy); - await _noneDicomStudyFileRepository.BatchDeleteAsync(t => t.NoneDicomStudyId == noneDicomStudyId); + await _noneDicomStudyFileRepository.BatchDeleteNoTrackingAsync(t => t.NoneDicomStudyId == noneDicomStudyId); await _repository.BatchDeleteAsync(t => t.StudyId == noneDicomStudyId); @@ -128,7 +128,7 @@ namespace IRaCIS.Core.Application.Contracts { var subjectVisitId = await _noneDicomStudyFileRepository.Where(t => t.Id == noneDicomStudyFileId).Select(t => t.NoneDicomStudy.SubjectVisitId).FirstOrDefaultAsync(); - var success = await _noneDicomStudyFileRepository.BatchDeleteAsync(t => t.Id == noneDicomStudyFileId); + var success = await _noneDicomStudyFileRepository.BatchDeleteNoTrackingAsync(t => t.Id == noneDicomStudyFileId); var subvisit = await _repository.GetQueryable().FirstOrDefaultAsync(x => x.Id == subjectVisitId); diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 11050de27..7d9f4bfa2 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -408,7 +408,7 @@ namespace IRaCIS.Core.Application.Image.QA { return ResponseOutput.NotOk("核查通过的数据不允许申请回退"); } - await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { RequestBackState = RequestBackStateEnum.CRC_RequestBack }); + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { RequestBackState = RequestBackStateEnum.CRC_RequestBack }); return ResponseOutput.Ok(); @@ -1685,7 +1685,7 @@ namespace IRaCIS.Core.Application.Image.QA qcChallenge.LatestMsgTime = DateTime.Now; qcChallenge.LatestReplyUserId = _userInfo.Id; - await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == qcChallenge.SubjectVisitId, c => new SubjectVisit() { IsQCConfirmedReupload = true }); + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == qcChallenge.SubjectVisitId, c => new SubjectVisit() { IsQCConfirmedReupload = true }); qcChallenge.DialogList.Add(new QCChallengeDialog() { @@ -1790,7 +1790,7 @@ namespace IRaCIS.Core.Application.Image.QA var dbSubjectVisit = await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == qcChallenge.SubjectVisitId).IfNullThrowException(); - await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == qcChallenge.SubjectVisitId, c => new SubjectVisit() { IsQCConfirmedReupload = false }); + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == qcChallenge.SubjectVisitId, c => new SubjectVisit() { IsQCConfirmedReupload = false }); qcChallenge.DialogList.Add(new QCChallengeDialog() { @@ -2023,7 +2023,7 @@ namespace IRaCIS.Core.Application.Image.QA if (!result.IsSuccess) { - await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId, + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { ForwardState = ForwardStateEnum.ForwardFailed }); return ResponseOutput.NotOk("Forward Failed" + result.Failures.ToString() + result.ToJson()); @@ -2033,7 +2033,7 @@ namespace IRaCIS.Core.Application.Image.QA } } - await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId, + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { ForwardState = ForwardStateEnum.Forwarded, ForwardUserId = _userInfo.Id, ForwardTime = DateTime.Now }); keyValuePairs["ForwardState"] = ForwardStateEnum.Forwarded; @@ -2041,7 +2041,7 @@ namespace IRaCIS.Core.Application.Image.QA catch (Exception e) { - await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId, + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { ForwardState = ForwardStateEnum.ForwardFailed }); keyValuePairs["ForwardState"] = ForwardStateEnum.ForwardFailed; } diff --git a/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs b/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs index 644c07fe8..701fb596c 100644 --- a/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs @@ -46,7 +46,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{qCQuestionConfigureId:guid}")] public async Task DeleteQCQuestionConfigure(Guid qCQuestionConfigureId) { - var success = await _qcQuestionRepository.BatchDeleteAsync(t => t.Id == qCQuestionConfigureId); + var success = await _qcQuestionRepository.BatchDeleteNoTrackingAsync(t => t.Id == qCQuestionConfigureId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs b/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs index dc75eb9b8..131c3e1b3 100644 --- a/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs +++ b/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs @@ -151,7 +151,7 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.NotOk("已有QC审核记录,不允许删除问题项"); } - var success = await _trialQcQuestionRepository.BatchDeleteAsync(t => t.Id == trialQCQuestionConfigureId); + var success = await _trialQcQuestionRepository.BatchDeleteNoTrackingAsync(t => t.Id == trialQCQuestionConfigureId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs index 2924197ba..5b70e31fc 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs @@ -72,7 +72,7 @@ namespace IRaCIS.Core.Application.Contracts { return ResponseOutput.NotOk("已锁定,不允许操作"); } - var success = await _trialSiteEquipmentSurveyRepository.BatchDeleteAsync(t => t.Id == trialSiteEquipmentSurveyId); + var success = await _trialSiteEquipmentSurveyRepository.BatchDeleteNoTrackingAsync(t => t.Id == trialSiteEquipmentSurveyId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 494155967..d1e1034fc 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -375,7 +375,7 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.NotOk("已锁定,不允许操作"); } - var success = await _trialSiteSurveyRepository.BatchDeleteAsync(t => t.Id == trialSiteSurveyId); + var success = await _trialSiteSurveyRepository.BatchDeleteNoTrackingAsync(t => t.Id == trialSiteSurveyId); return ResponseOutput.Result(success); } @@ -634,12 +634,12 @@ namespace IRaCIS.Core.Application.Contracts if (hasSPMOrCPM) { - await _trialSiteSurveyRepository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); + await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); } else { - await _trialSiteSurveyRepository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.ToSubmit }); + await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.ToSubmit }); } } return ResponseOutput.Ok(); @@ -751,7 +751,7 @@ namespace IRaCIS.Core.Application.Contracts smtp.MessageSent += (sender, args) => { - _ = _trialSiteUserSurveyRepository.BatchUpdateAsync(t => t.Id == item.Id, u => new TrialSiteUserSurvey() { IsGenerateSuccess = true, InviteState = TrialSiteUserStateEnum.HasSend, IsJoin = null, ConfirmTime = null, RejectReason = String.Empty, SystemUserId = sysUserInfo.Id, ExpireTime = DateTime.Now.AddDays(7) }).Result; + _ = _trialSiteUserSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new TrialSiteUserSurvey() { IsGenerateSuccess = true, InviteState = TrialSiteUserStateEnum.HasSend, IsJoin = null, ConfirmTime = null, RejectReason = String.Empty, SystemUserId = sysUserInfo.Id, ExpireTime = DateTime.Now.AddDays(7) }).Result; }; @@ -799,12 +799,12 @@ namespace IRaCIS.Core.Application.Contracts if (hasSPMOrCPM) { - await _trialSiteSurveyRepository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); + await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); } else { - await _trialSiteSurveyRepository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved }); + await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved }); } @@ -812,7 +812,7 @@ namespace IRaCIS.Core.Application.Contracts else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) { - await _trialSiteSurveyRepository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.CRCSubmitted, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved, PreliminaryUserId = _userInfo.Id, PreliminaryTime = DateTime.Now }); + await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.CRCSubmitted, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved, PreliminaryUserId = _userInfo.Id, PreliminaryTime = DateTime.Now }); } else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) @@ -829,7 +829,7 @@ namespace IRaCIS.Core.Application.Contracts await SendInviteEmail(new InviteEmailCommand() { TrialId = trialId, RouteUrl = siteSurvyeSubmit.RouteUrl, UserList = needGenerateList }); - await _trialSiteSurveyRepository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime = DateTime.Now }); + await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime = DateTime.Now }); } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs index dcde55b10..9a9ad2776 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs @@ -81,7 +81,7 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.NotOk("已锁定,不允许操作"); } - var success = await _trialSiteUserSurveyRepository.BatchDeleteAsync(t => t.Id == trialSiteUserSurveyId); + var success = await _trialSiteUserSurveyRepository.BatchDeleteNoTrackingAsync(t => t.Id == trialSiteUserSurveyId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs index f0baa3705..c961ccd29 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs @@ -114,15 +114,15 @@ namespace IRaCIS.Core.Application if (signConfirmDTO.SignCode == ((int)SignEnum.TrialLogicConfim).ToString()) { - await _trialRepository.BatchUpdateAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { IsTrialBasicLogicConfirmed = true }); + await _trialRepository.BatchUpdateNoTrackingAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { IsTrialBasicLogicConfirmed = true }); } else if (signConfirmDTO.SignCode == ((int)SignEnum.TrialProcessConfim).ToString()) { - await _trialRepository.BatchUpdateAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { IsTrialProcessConfirmed = true }); + await _trialRepository.BatchUpdateNoTrackingAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { IsTrialProcessConfirmed = true }); } else if (signConfirmDTO.SignCode == ((int)SignEnum.TrialUrgentConfim).ToString()) { - await _trialRepository.BatchUpdateAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { IsTrialUrgentConfirmed = true }); + await _trialRepository.BatchUpdateNoTrackingAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { IsTrialUrgentConfirmed = true }); } else if (signConfirmDTO.SignCode == ((int)SignEnum.TrialQCQuestionConfirm).ToString()) @@ -158,7 +158,7 @@ namespace IRaCIS.Core.Application throw new BusinessValidationFailedException("父问题的序号要比子问题序号小,请确认"); } - await _trialRepository.BatchUpdateAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { QCQuestionConfirmedTime = DateTime.Now, QCQuestionConfirmedUserId = _userInfo.Id, IsQCQuestionConfirmed = true }); + await _trialRepository.BatchUpdateNoTrackingAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { QCQuestionConfirmedTime = DateTime.Now, QCQuestionConfirmedUserId = _userInfo.Id, IsQCQuestionConfirmed = true }); } @@ -241,7 +241,7 @@ namespace IRaCIS.Core.Application EnrollStatus = (int)EnrollStatus.Finished }); - await _trialRepository.BatchUpdateAsync(u => u.Id == trialId, s => new Trial { TrialFinishedTime = DateTime.UtcNow.AddHours(8) }); + await _trialRepository.BatchUpdateNoTrackingAsync(u => u.Id == trialId, s => new Trial { TrialFinishedTime = DateTime.UtcNow.AddHours(8) }); } @@ -279,11 +279,9 @@ namespace IRaCIS.Core.Application [HttpPut("{trialId:guid}/{isAbandon:bool}")] public async Task AbandonTrial(Guid trialId, /*Guid? signId,*/ bool isAbandon) { + await _trialRepository.UpdateNowNoQueryAsync(trialId, u => new Trial() { IsDeleted = isAbandon }); - await _trialRepository.UpdatePartialFieldsNowAsync(trialId, u => new Trial() { IsDeleted = isAbandon }); - - - //var success = await _repository.BatchUpdateAsync(t => t.Id == signId, u => new TrialSign() { IsCompleted = true }); + return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs index 0bb923bbf..c8c0fd0a7 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs @@ -193,11 +193,11 @@ namespace IRaCIS.Core.Application.Service [HttpDelete("{trialExternalUserId:guid}/{isSystemUser:bool}/{systemUserId}")] public async Task DeleteTrialExternalUser(Guid trialExternalUserId, bool isSystemUser, Guid systemUserId) { - var success = await _trialExternalUseRepository.BatchDeleteAsync(t => t.Id == trialExternalUserId); + var success = await _trialExternalUseRepository.BatchDeleteNoTrackingAsync(t => t.Id == trialExternalUserId); if (isSystemUser == false) { - await _userRepository.BatchDeleteAsync(t => t.Id == systemUserId); + await _userRepository.BatchDeleteNoTrackingAsync(t => t.Id == systemUserId); } return ResponseOutput.Result(success); @@ -263,7 +263,7 @@ namespace IRaCIS.Core.Application.Service smtp.MessageSent += (sender, args) => { - _ = _trialExternalUseRepository.BatchUpdateAsync(t => t.Id == userInfo.Id, u => new TrialExternalUser() { InviteState = TrialExternalUserStateEnum.HasSend, IsJoin = null, ConfirmTime = null, RejectReason = String.Empty, ExpireTime = DateTime.Now.AddDays(7) }).Result; + _ = _trialExternalUseRepository.BatchUpdateNoTrackingAsync(t => t.Id == userInfo.Id, u => new TrialExternalUser() { InviteState = TrialExternalUserStateEnum.HasSend, IsJoin = null, ConfirmTime = null, RejectReason = String.Empty, ExpireTime = DateTime.Now.AddDays(7) }).Result; }; @@ -344,7 +344,7 @@ namespace IRaCIS.Core.Application.Service if (sysUserInfo.IsFirstAdd) { - await _userRepository.BatchUpdateAsync(t => t.Id == sysUserInfo.Id, + await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { Password = MD5Helper.Md5(verificationCode.ToString()) }); } @@ -401,7 +401,7 @@ namespace IRaCIS.Core.Application.Service await smtp.DisconnectAsync(true); } - await _userRepository.BatchUpdateAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable }); + await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable }); } @@ -487,7 +487,7 @@ namespace IRaCIS.Core.Application.Service await _trialSiteUserRepository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId }); - await _userRepository.BatchUpdateAsync(t => t.Id == needUpdate.SystemUserId, u => new User() { Status = UserStateEnum.Enable }); + await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == needUpdate.SystemUserId, u => new User() { Status = UserStateEnum.Enable }); } @@ -515,7 +515,7 @@ namespace IRaCIS.Core.Application.Service if (sysUserInfo.IsFirstAdd) { - await _userRepository.BatchUpdateAsync(t => t.Id == sysUserInfo.Id, + await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { Password = MD5Helper.Md5(verificationCode.ToString()) }); } @@ -666,10 +666,10 @@ namespace IRaCIS.Core.Application.Service { await _repository.AddAsync(new TrialUser() { TrialId = trialId, UserId = (Guid)externalUser.SystemUserId }); - await _trialExternalUseRepository.BatchUpdateAsync(t => t.Id == trialExternalUserId, + await _trialExternalUseRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialExternalUserId, u => new TrialExternalUser() { InviteState = TrialExternalUserStateEnum.UserConfirmed }); - await _userRepository.BatchUpdateAsync(t => t.Id == externalUser.SystemUserId, u => new User() { Status = UserStateEnum.Enable }); + await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == externalUser.SystemUserId, u => new User() { Status = UserStateEnum.Enable }); await _userRepository.SaveChangesAsync(); } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs index 5c05d7e3b..fe1e37ff3 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs @@ -204,7 +204,7 @@ namespace IRaCIS.Application.Services await _repository.BatchUpdateAsync(t => t.CurrentActionUserId == trialUser.UserId && t.TrialId == trialUser.TrialId && t.IsTake, u => new SubjectVisit() { CurrentActionUserId = null, CurrentActionUserExpireTime = null, IsTake = false }); } - await _trialUseRepository.BatchUpdateAsync(t => t.Id == id, u => new TrialUser() { IsDeleted = isDelete, RemoveTime = isDelete ? DateTime.Now : null }); + await _trialUseRepository.BatchUpdateNoTrackingAsync(t => t.Id == id, u => new TrialUser() { IsDeleted = isDelete, RemoveTime = isDelete ? DateTime.Now : null }); await _repository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index c24686a44..393a8d69d 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -438,7 +438,7 @@ namespace IRaCIS.Application.Services } } - await _trialRepository.BatchUpdateAsync(u => u.Id == trialId, t => new Trial() { VisitPlanConfirmed = confirmOrCancel }); + await _trialRepository.BatchUpdateNoTrackingAsync(u => u.Id == trialId, t => new Trial() { VisitPlanConfirmed = confirmOrCancel }); await _repository.BatchUpdateAsync(u => u.Id == trialId, t => new VisitStage() { IsConfirmed = true }); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs index c84dc9098..67e6b247e 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs @@ -299,7 +299,7 @@ namespace IRaCIS.Core.Application.Services { - var isSuccess = await _trialSiteUserRepository.BatchUpdateAsync(u => u.Id == id, u => new TrialSiteUser() + var isSuccess = await _trialSiteUserRepository.BatchUpdateNoTrackingAsync(u => u.Id == id, u => new TrialSiteUser() { IsDeleted = isDelete, DeletedTime = isDelete ? DateTime.Now : null }); return ResponseOutput.Ok(isSuccess); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialUserPreparationService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialUserPreparationService.cs index 360eae1cf..989e53f5b 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialUserPreparationService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialUserPreparationService.cs @@ -100,7 +100,7 @@ namespace IRaCIS.Core.Application.Service await _trialUserRepository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId }); - await _trialExternalUseRepository.BatchUpdateAsync(t => t.TrialId == trialId && t.SystemUserId == userId, + await _trialExternalUseRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.SystemUserId == userId, u => new TrialExternalUser() { InviteState = TrialExternalUserStateEnum.UserConfirmed }); @@ -122,7 +122,7 @@ namespace IRaCIS.Core.Application.Service } } - await _userRepository.BatchUpdateAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable }); + await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable }); return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectService.cs index 7f3dbec5a..9f1a26a52 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectService.cs @@ -190,8 +190,8 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("This subject has executed a visit with uploading study images,and couldn't be deleted."); } - var isSuccess = await _subjectRepository.BatchDeleteAsync(u => u.Id == id); - await _subjectVisitRepository.TrackingDeleteFromQueryAsync(u => u.SubjectId == id); + var isSuccess = await _subjectRepository.BatchDeleteNoTrackingAsync(u => u.Id == id); + await _subjectVisitRepository.DeleteFromQueryAsync(u => u.SubjectId == id); var subvisit = await _subjectVisitRepository.Where(x => x.SubjectId == id).ToListAsync(); diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index dc9d2c138..a59464315 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -161,7 +161,7 @@ namespace IRaCIS.Core.Application.Services [HttpPut("{trialId:guid}/{subjectVisitId:guid}/{isUrgent:bool}")] public async Task SetSubjectVisitUrgent(Guid subjectVisitId, bool isUrgent) { - await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { IsUrgent = isUrgent }); + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { IsUrgent = isUrgent }); return ResponseOutput.Ok(); } @@ -197,7 +197,7 @@ namespace IRaCIS.Core.Application.Services [TypeFilter(typeof(TrialResourceFilter))] public async Task SetSVExecuted(Guid subjectVisitId) { - return ResponseOutput.Result(await _subjectVisitRepository.BatchUpdateAsync(s => s.Id == subjectVisitId, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Executed })); + return ResponseOutput.Result(await _subjectVisitRepository.BatchUpdateNoTrackingAsync(s => s.Id == subjectVisitId, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Executed })); } diff --git a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs index dd1d38ffe..e88441e3d 100644 --- a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs +++ b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs @@ -248,7 +248,7 @@ namespace IRaCIS.Application.Services //更新项目访视计划状态为已确认 必定生成更新的sql 通过状态改变 触发操作 - await _trialRepository.UpdatePartialFieldsNowAsync(trialId, t => new Trial() { VisitPlanConfirmed = true }); + await _trialRepository.UpdateNowNoQueryAsync(trialId, t => new Trial() { VisitPlanConfirmed = true }); //找到访视计划修改的Item @@ -449,7 +449,7 @@ namespace IRaCIS.Application.Services await _repository.AddRangeAsync(subjectVisits); //访视计划 整体状态变更为 确认 - await _visitStageRepository.BatchUpdateAsync(u => u.TrialId == trialId, t => new VisitStage() { IsConfirmed = true, IsHaveFirstConfirmed = true }); + await _visitStageRepository.BatchUpdateNoTrackingAsync(u => u.TrialId == trialId, t => new VisitStage() { IsConfirmed = true, IsHaveFirstConfirmed = true }); await _repository.SaveChangesAsync(); return ResponseOutput.Ok(); @@ -504,7 +504,7 @@ namespace IRaCIS.Application.Services await _repository.BatchDeleteAsync(t => t.TrialId == visitPlan.TrialId && t.VisitName == visitPlan.VisitName); - var result = await _visitStageRepository.BatchDeleteAsync(u => u.Id == id); + var result = await _visitStageRepository.BatchDeleteNoTrackingAsync(u => u.Id == id); return ResponseOutput.Result(result); } diff --git a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs index f4f9c605f..e0b325fa8 100644 --- a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs +++ b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs @@ -60,7 +60,7 @@ namespace IRaCIS.Application.Services if (attachmentViewModel.Id != Guid.Empty) { - await _attachmentRepository.BatchDeleteAsync(t => t.Id == attachmentViewModel.Id); + await _attachmentRepository.BatchDeleteNoTrackingAsync(t => t.Id == attachmentViewModel.Id); } var attach = _mapper.Map(attachmentViewModel); @@ -83,8 +83,8 @@ namespace IRaCIS.Application.Services [TypeFilter(typeof(TrialResourceFilter))] public async Task DeleteReviewerAckSOW(Guid trialId, Guid doctorId, Guid attachmentId) { - var success1 = await _attachmentRepository.BatchDeleteAsync(a => a.Id == attachmentId); - var success2 = await _enrollRepository.BatchUpdateAsync(t => t.TrialId == trialId && t.DoctorId == doctorId, u => + var success1 = await _attachmentRepository.BatchDeleteNoTrackingAsync(a => a.Id == attachmentId); + var success2 = await _enrollRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.DoctorId == doctorId, u => new Enroll() { AttachmentId = Guid.Empty @@ -100,7 +100,7 @@ namespace IRaCIS.Application.Services [TypeFilter(typeof(TrialResourceFilter))] public async Task UpdateReviewerReadingType(Guid trialId, Guid doctorId, int type) { - var success2 = await _enrollRepository.BatchUpdateAsync(t => t.TrialId == trialId && t.DoctorId == doctorId, u => + var success2 = await _enrollRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.DoctorId == doctorId, u => new Enroll() { ReviewerReadingType = type @@ -625,7 +625,7 @@ namespace IRaCIS.Application.Services await _doctorWorkloadRepository.AddAsync(workLoad); - await _enrollRepository.BatchUpdateAsync( + await _enrollRepository.BatchUpdateNoTrackingAsync( t => t.DoctorId == workLoadAddOrUpdateModel.DoctorId && t.TrialId == workLoadAddOrUpdateModel.TrialId, u => new Enroll() { EnrollStatus = (int)EnrollStatus.DoctorReading, @@ -648,7 +648,7 @@ namespace IRaCIS.Application.Services } - var success = await _doctorWorkloadRepository.BatchUpdateAsync(t => t.Id == workLoadAddOrUpdateModel.Id, + var success = await _doctorWorkloadRepository.BatchUpdateNoTrackingAsync(t => t.Id == workLoadAddOrUpdateModel.Id, u => new Workload() { Timepoint = workLoadAddOrUpdateModel.Timepoint, @@ -678,7 +678,7 @@ namespace IRaCIS.Application.Services /// public async Task DeleteWorkload(Guid workloadId) { - return ResponseOutput.Result(await _doctorWorkloadRepository.BatchDeleteAsync(t => t.Id == workloadId)); + return ResponseOutput.Result(await _doctorWorkloadRepository.BatchDeleteNoTrackingAsync(t => t.Id == workloadId)); } /// diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index dcb75eadc..d4a22f9cd 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -23,7 +23,7 @@ namespace IRaCIS.Application.Services public string Get(testModel testModel) { - var tt= _dicRepository.TrackingUpdateFromQueryAsync(Guid.Parse("e2b97a6c-35a6-4aa3-7f27-08da13ab33ff"), t => new Dictionary() { Description = "xxxxx" }, true).Result; + var tt= _dicRepository.UpdateFromQueryAsync(Guid.Parse("e2b97a6c-35a6-4aa3-7f27-08da13ab33ff"), t => new Dictionary() { Description = "xxxxx" }, true).Result; //var d = _repository.Where(t => t.FullName.Contains("cc")).Select(t => t.FullName).FirstOrDefault(); @@ -33,7 +33,7 @@ namespace IRaCIS.Application.Services //var dd = _dicRepository.UpdatePartialFields(Guid.Parse("8a90c96e-0776-4f7b-82a6-18933d339584"), // u => new Dictionary() { ParentId = null, Code = "test" }, true); - var aaaa = _dicRepository.BatchDeleteAsync(t => t.Id == Guid.Empty).Result; + var aaaa = _dicRepository.BatchDeleteNoTrackingAsync(t => t.Id == Guid.Empty).Result; //var ggggg = _dicRepository.UpdateFromQueryAsync(t => t.ParentId == Guid.Parse("8a90c96e-0776-4f7b-82a6-18933d339584"), u=>new Dictionary(){Code = "test"}).Result; diff --git a/IRaCIS.Core.Application/Triggers/SubjectStateTrigger.cs b/IRaCIS.Core.Application/Triggers/SubjectStateTrigger.cs index 5844943d0..b952f1c88 100644 --- a/IRaCIS.Core.Application/Triggers/SubjectStateTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/SubjectStateTrigger.cs @@ -83,7 +83,7 @@ namespace IRaCIS.Core.Application.Triggers sv.IsFinalVisit = true; //末次访视后的 访视设置为不可用 - await _subjectVisitRepository.BatchUpdateAsync(t => t.SubjectId == dbSubject.Id && t.VisitNum > sv.VisitNum, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Unavailable }); + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == dbSubject.Id && t.VisitNum > sv.VisitNum, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Unavailable }); } } diff --git a/IRaCIS.Core.Application/Triggers/SubjectVisitFinalVisitTrigger.cs b/IRaCIS.Core.Application/Triggers/SubjectVisitFinalVisitTrigger.cs index ac1015e3a..278680ef2 100644 --- a/IRaCIS.Core.Application/Triggers/SubjectVisitFinalVisitTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/SubjectVisitFinalVisitTrigger.cs @@ -37,21 +37,21 @@ namespace IRaCIS.Core.Application.Triggers throw new BusinessValidationFailedException("该受试者此访视后有影像上传,该访视不允许设置为末次访视"); } - await _subjectRepository.BatchUpdateAsync(t => t.Id == subjectVisit.SubjectId, + await _subjectRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisit.SubjectId, u => new Subject() { Status = SubjectStatus.OutOfVisit }); //末次访视后的 访视设置为不可用 - await _subjectVisitRepository.BatchUpdateAsync(t => t.SubjectId == subjectVisit.SubjectId && t.VisitNum > subjectVisit.VisitNum, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Unavailable }); + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == subjectVisit.SubjectId && t.VisitNum > subjectVisit.VisitNum, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Unavailable }); } else { //回退 - await _subjectRepository.BatchUpdateAsync(t => t.Id == subjectVisit.SubjectId, + await _subjectRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisit.SubjectId, u => new Subject() { Status = SubjectStatus.OnVisit }); - await _subjectVisitRepository.BatchUpdateAsync(t => t.SubjectId == subjectVisit.SubjectId && t.VisitExecuted == VisitExecutedEnum.Unavailable, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.UnExecuted }); + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == subjectVisit.SubjectId && t.VisitExecuted == VisitExecutedEnum.Unavailable, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.UnExecuted }); } diff --git a/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs b/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs index fc6664766..f21400bcd 100644 --- a/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs @@ -25,7 +25,7 @@ namespace IRaCIS.Core.Application.Triggers { await UpdateSubjectVisitImageDateAsync(context.Entity.SubjectVisitId); - await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Executed }); @@ -46,7 +46,7 @@ namespace IRaCIS.Core.Application.Triggers if (context.ChangeType == ChangeType.Added ) { await UpdateSubjectVisitImageDateAsync(subjectVisitId); - await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Executed }); @@ -88,7 +88,7 @@ namespace IRaCIS.Core.Application.Triggers await _subjectVisitRepository.AddListInspectionRecordAsync(datas); - await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.ToSubmit, + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.ToSubmit, u => new SubjectVisit() { VisitExecuted = 0, SVENDTC = null, SVSTDTC = null, SubmitState = SubmitStateEnum.None }); } } @@ -108,7 +108,7 @@ namespace IRaCIS.Core.Application.Triggers var minArray = new DateTime?[] { svTime.DicomStudyMinStudyTime, svTime.NoneDicomStudyMinStudyTime }; var maxArray = new DateTime?[] { svTime.DicomStudyMaxStudyTime, svTime.NoneDicomStudyMaxStudyTime }; - await _subjectVisitRepository.BatchUpdateAsync(t=>t.Id ==subjectVisitId, u => new SubjectVisit() + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t=>t.Id ==subjectVisitId, u => new SubjectVisit() { EarliestScanDate = minArray.Min(), diff --git a/IRaCIS.Core.Application/Triggers/TrialVisitPlanConfirmTrigger.cs b/IRaCIS.Core.Application/Triggers/TrialVisitPlanConfirmTrigger.cs index d30616e57..6c241e305 100644 --- a/IRaCIS.Core.Application/Triggers/TrialVisitPlanConfirmTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/TrialVisitPlanConfirmTrigger.cs @@ -170,7 +170,7 @@ namespace IRaCIS.Core.Application.Triggers }); //变更某一访视计划Item 受试者访视相关字段 - await _subjectVisitRepository.BatchUpdateAsync(t => t.TrialId == trialId && t.VisitStageId == changedItem.Id, k => new SubjectVisit() + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.VisitStageId == changedItem.Id, k => new SubjectVisit() { IsBaseLine = changedItem.IsBaseLine, VisitName = changedItem.VisitName, diff --git a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs index 0f7e0f466..641441743 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs @@ -22,36 +22,38 @@ namespace IRaCIS.Core.Infra.EFCore /// EF跟踪方式 生成 部分字段立即更新,默认会去处理更新更新人 更新时间 - Task UpdatePartialFieldsNowAsync(Guid id, Expression> updateFactory, params EntityVerifyExp[] verify); + Task UpdateNowNoQueryAsync(Guid id, Expression> updateFactory, params EntityVerifyExp[] verify); /// EF跟踪方式 生成 部分字段更新, 通过主键id 和表达式树 更新部分字段,默认不提交事务,一般用于服务里面 和别的操作 一起提交事务 - Task UpdatePartialFieldsAsync(Guid id, Expression> updateFactory, bool autoSave = false, params EntityVerifyExp[] verify); + Task UpdateNoQueryAsync(Guid id, Expression> updateFactory, bool autoSave = false, params EntityVerifyExp[] verify); + + /// 批量删除,相当于原生sql, 没用EF跟踪方式(所有查询出来,再删除 浪费性能) - Task BatchDeleteAsync(Expression> deleteFilter); + Task BatchDeleteNoTrackingAsync(Expression> deleteFilter); /// 批量更新,相当于原生sql, 没用EF跟踪方式(所有查询出来,再更新 浪费性能) - Task BatchUpdateAsync(Expression> where, Expression> updateFactory); + Task BatchUpdateNoTrackingAsync(Expression> where, Expression> updateFactory); /// 批量删除,EF跟踪方式(所有查询出来,再删除 浪费性能,但是稽查 或者触发某些操作时,需要知道数据库实体信息 不可避免用这种) - Task> TrackingDeleteFromQueryAsync(Expression> deleteFilter, bool autoSave = false); + Task> DeleteFromQueryAsync(Expression> deleteFilter, bool autoSave = false,bool ignoreQueryFilter = false); - Task TrackingDeleteFromQueryAsync(Guid id, bool autoSave = false); + Task DeleteFromQueryAsync(Guid id, bool autoSave = false, bool ignoreQueryFilter = false); /// EF跟踪方式 已有查询好的,再更新部分字段 稽查的时候需要完整的实体信息 - Task TrackingUpdateAsync(TEntity entity, Expression> updateFactory, + Task UpdateAsync(TEntity entity, Expression> updateFactory, bool autoSave = false, CancellationToken cancellationToken = default); /// EF跟踪方式 先查询出来,再更新部分字段 稽查的时候需要完整的实体信息 - Task TrackingUpdateFromQueryAsync(Guid id, Expression> updateFactory, - bool autoSave = false, CancellationToken cancellationToken = default); + Task UpdateFromQueryAsync(Guid id, Expression> updateFactory, + bool autoSave = false, bool ignoreQueryFilter = false, CancellationToken cancellationToken = default); - Task TrackingUpdateFromQueryAsync(Expression> updateFilter, + Task UpdateFromQueryAsync(Expression> updateFilter, Expression> updateFactory, - bool autoSave = false, CancellationToken cancellationToken = default); + bool autoSave = false , bool ignoreQueryFilter = false,CancellationToken cancellationToken = default); diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index 45159a3f4..2cbf67235 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -140,7 +140,7 @@ namespace IRaCIS.Core.Infra.EFCore /// EF跟踪方式 生成 部分字段更新, 通过主键id 和表达式树 更新部分字段 /// 例如 Guid.Parse("8a90c96e-0776-4f7b-82a6-18933d339584"),u => new Dictionary() { ParentId = null, Code = "test" }默认会去处理更新更新人 更新时间 - public async Task UpdatePartialFieldsAsync(Guid id, Expression> updateFactory, bool autoSave = false, params EntityVerifyExp[] verify) + public async Task UpdateNoQueryAsync(Guid id, Expression> updateFactory, bool autoSave = false, params EntityVerifyExp[] verify) { await SetPartialFieldUpdateAsync(id, updateFactory, verify); @@ -150,7 +150,7 @@ namespace IRaCIS.Core.Infra.EFCore /// EF跟踪方式 生成 部分字段立即更新,默认会去处理更新更新人 更新时间 - public async Task UpdatePartialFieldsNowAsync(Guid id, Expression> updateFactory, + public async Task UpdateNowNoQueryAsync(Guid id, Expression> updateFactory, params EntityVerifyExp[] verify) { await SetPartialFieldUpdateAsync(id, updateFactory, verify); @@ -226,27 +226,10 @@ namespace IRaCIS.Core.Infra.EFCore - public async Task TrackingUpdateFromQueryAsync(Expression> updateFilter, - Expression> updateFactory, - bool autoSave = false, CancellationToken cancellationToken = default) - { - if (updateFilter == null) - { - throw new ArgumentException("更新过滤条件不允许为空", nameof(updateFilter)); - } - - var searchEntityList = await _dbSet.AsNoTracking().Where(updateFilter).ToListAsync(); - - foreach (var needUpdateEntity in searchEntityList) - { - await TrackingUpdateAsync(needUpdateEntity, updateFactory, autoSave); - } - - } /// EF跟踪方式 外层先有查询好的完成实体,再更新部分字段 稽查的时候需要完整的实体信息 - public async Task TrackingUpdateAsync(TEntity waitModifyEntity, Expression> updateFactory, bool autoSave = false, CancellationToken cancellationToken = default) + public async Task UpdateAsync(TEntity waitModifyEntity, Expression> updateFactory, bool autoSave = false, CancellationToken cancellationToken = default) { var entityEntry = _dbContext.Entry(waitModifyEntity); entityEntry.State = EntityState.Detached; @@ -259,14 +242,14 @@ namespace IRaCIS.Core.Infra.EFCore } - - /// EF跟踪方式 先查询出来,再更新部分字段 稽查的时候需要完整的实体信息 - public async Task TrackingUpdateFromQueryAsync(Guid id, Expression> updateFactory, - bool autoSave = false, CancellationToken cancellationToken = default) + public async Task UpdateFromQueryAsync(Guid id, Expression> updateFactory, + bool autoSave = false, bool ignoreQueryFilter = false, CancellationToken cancellationToken = default) { + + var query = ignoreQueryFilter ? _dbSet.AsNoTracking().IgnoreQueryFilters() : _dbSet.AsNoTracking(); //不跟踪 查询出来的实体就是Detached - var searchEntity = await _dbSet.AsNoTracking().IgnoreQueryFilters().FirstOrDefaultAsync(t => t.Id == id); + var searchEntity = await query.FirstOrDefaultAsync(t => t.Id == id); if (searchEntity == null) { @@ -283,7 +266,27 @@ namespace IRaCIS.Core.Infra.EFCore return searchEntity; } - /// 应用更新后拥有完整的实体信息,便于稽查 + public async Task UpdateFromQueryAsync(Expression> updateFilter, + Expression> updateFactory, + bool autoSave = false, bool ignoreQueryFilter = false, CancellationToken cancellationToken = default) + { + if (updateFilter == null) + { + throw new ArgumentException("更新过滤条件不允许为空", nameof(updateFilter)); + } + var query = ignoreQueryFilter ? _dbSet.AsNoTracking().IgnoreQueryFilters() : _dbSet.AsNoTracking(); + + var searchEntityList = await query.Where(updateFilter).ToListAsync(); + + foreach (var needUpdateEntity in searchEntityList) + { + await UpdateAsync(needUpdateEntity, updateFactory, autoSave); + } + + } + + + /// 更新后拥有完整的实体信息,便于稽查 private void ModifyPartialFiled(TEntity waitModifyEntity, Expression> updateFactory) { List list = ((MemberInitExpression)updateFactory.Body).Bindings.Select(mb => mb.Member.Name) @@ -318,9 +321,11 @@ namespace IRaCIS.Core.Infra.EFCore /// EF跟踪方式(查询出来,再删除 浪费性能,但是稽查 或者触发某些操作时,需要知道数据库实体信息 不可避免用这种) - public async Task TrackingDeleteFromQueryAsync(Guid id, bool autoSave = false) + public async Task DeleteFromQueryAsync(Guid id, bool autoSave = false, bool ignoreQueryFilter = false) { - var waitDelete = await _dbSet.IgnoreQueryFilters().Where(t=>t.Id== id).FirstOrDefaultAsync(); + var query = ignoreQueryFilter ? _dbSet.AsNoTracking().IgnoreQueryFilters() : _dbSet.AsNoTracking(); + + var waitDelete = await query.Where(t=>t.Id== id).FirstOrDefaultAsync(); if (waitDelete == null) { @@ -335,9 +340,10 @@ namespace IRaCIS.Core.Infra.EFCore /// 批量删除,EF跟踪方式(所有查询出来,再删除 浪费性能,但是稽查 或者触发某些操作时,需要知道数据库实体信息 不可避免用这种) - public async Task> TrackingDeleteFromQueryAsync(Expression> deleteFilter, bool autoSave = false) + public async Task> DeleteFromQueryAsync(Expression> deleteFilter, bool autoSave = false, bool ignoreQueryFilter = false) { - var waitDeleteList = await _dbSet.IgnoreQueryFilters().Where(deleteFilter).ToListAsync(); + var query = ignoreQueryFilter ? _dbSet.AsNoTracking().IgnoreQueryFilters() : _dbSet.AsNoTracking(); + var waitDeleteList = await query.Where(deleteFilter).ToListAsync(); foreach (var deleteItem in waitDeleteList) { @@ -357,14 +363,14 @@ namespace IRaCIS.Core.Infra.EFCore #region 不走EF 跟踪机制的删除 更新 以及批量操作 /// 批量删除,相当于原生sql, 没用EF跟踪方式(所有查询出来,再删除 浪费性能) - public async Task BatchDeleteAsync(Expression> deleteFilter) + public async Task BatchDeleteNoTrackingAsync(Expression> deleteFilter) { return await _dbSet.IgnoreQueryFilters().Where(deleteFilter).BatchDeleteAsync() > 0; } /// 批量更新,相当于原生sql, 没用EF跟踪方式(所有查询出来,再更新 浪费性能) - public async Task BatchUpdateAsync(Expression> where, + public async Task BatchUpdateNoTrackingAsync(Expression> where, Expression> updateFactory) {