修改锁
parent
1958dca2be
commit
884e03fab5
|
@ -13,6 +13,8 @@ using IRaCIS.Core.Application.Filter;
|
|||
using IRaCIS.Core.Application.MediatR.Handlers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Newtonsoft.Json;
|
||||
using System.Threading;
|
||||
using Nito.AsyncEx;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
{
|
||||
|
@ -20,6 +22,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
public class StudyService : BaseService, IStudyService
|
||||
{
|
||||
private static object lockCodeGenerate = new object();
|
||||
private readonly AsyncLock _mutex = new AsyncLock();
|
||||
|
||||
private readonly IEasyCachingProvider _provider;
|
||||
|
||||
|
@ -128,12 +131,13 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
studyMonitor.UploadFinishedTime = DateTime.Now;
|
||||
studyMonitor.ArchiveFinishedTime = DateTime.Now;
|
||||
studyMonitor.IsDicomReUpload = !incommand.IsAdd;
|
||||
studyMonitor.IsSuccess = true;
|
||||
|
||||
if (incommand.IsAdd)
|
||||
{
|
||||
var study = _mapper.Map<DicomStudy>(incommand.Study);
|
||||
|
||||
lock (lockCodeGenerate)
|
||||
using (await _mutex.LockAsync())
|
||||
{
|
||||
|
||||
//查询数据库获取最大的Code 没有记录则为0
|
||||
|
@ -277,9 +281,12 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
|
||||
}
|
||||
|
||||
|
||||
using (await _mutex.LockAsync())
|
||||
{
|
||||
await _dicomstudyRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue