diff --git a/IRaCIS.Core.API/appsettings.Uat_IRC.json b/IRaCIS.Core.API/appsettings.Uat_IRC.json index 18d24b8ce..1493f5f84 100644 --- a/IRaCIS.Core.API/appsettings.Uat_IRC.json +++ b/IRaCIS.Core.API/appsettings.Uat_IRC.json @@ -15,15 +15,16 @@ "ObjectStoreUse": "AliyunOSS", "AliyunOSS": { - "regionId": "cn-shanghai", - "internalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com", - "endpoint": "https://oss-cn-shanghai.aliyuncs.com", - "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ", - "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio", - "bucketName": "zy-irc-uat-store", - "roleArn": "acs:ram::1899121822495495:role/oss-upload", - "viewEndpoint": "https://zy-irc-uat-store.oss-cn-shanghai.aliyuncs.com", - "region": "oss-cn-shanghai" + "RegionId": "cn-shanghai", + "InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com", + "EndPoint": "https://oss-cn-shanghai.aliyuncs.com", + "AccessKeyId": "LTAI5tJV76pYX5yPg1N9QVE8", + "AccessKeySecret": "roRNLa9YG1of4pYruJGCNKBXEWTAWa", + "BucketName": "zy-irc-uat-store", + "RoleArn": "acs:ram::1899121822495495:role/webdirect", + "ViewEndpoint": "https://zy-irc-uat-store.oss-cn-shanghai.aliyuncs.com", + "Region": "oss-cn-shanghai", + "DurationSeconds": 7200 }, "MinIO": { @@ -38,6 +39,17 @@ "secretKey": "DzMaU2L4OXl90uytwOmDXF2encN0Jf4Nxu2XkYqQ", "bucketName": "irc-uat" + }, + "AWS": { + "Region": "us-east-1", + "EndPoint": "s3.us-east-1.amazonaws.com", + "UseSSL": true, + "RoleArn": "arn:aws:iam::471112624751:role/sts_s3_upload", + "AccessKeyId": "AKIAW3MEAFJXWRCGSX5Z", + "SecretAccessKey": "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", + "BucketName": "ei-med-s3-lili-uat-store", + "ViewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com/", + "DurationSeconds": 7200 } }, diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 46c1ecdf5..3e79fff0b 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -1002,11 +1002,12 @@ - + 在调用预归档前验证 这些检查是否可以全新上传还是已存在补充 目前前端允许 IsAllowUpload==true 全新、IsAllowReUpload==true 补充的study ,全部丢到后端,后端判断存在,就删除之前的检查,全新插入 + @@ -6871,6 +6872,11 @@ 答案分组 + + + 单位 + + 答案组合 diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs index 088c77ef3..7d82d7ec2 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs @@ -527,6 +527,8 @@ namespace IRaCIS.Core.Application.Contracts [NotDefault] public string SubjectCode { get; set; } + + public Guid? VisitTaskId { get; set; } } @@ -554,6 +556,6 @@ namespace IRaCIS.Core.Application.Contracts { public Guid SubjectVisitId { get; set; } - public Guid VisitTaskId { get; set; } + public Guid TaskId { get; set; } } } diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs index b59a3e043..e9ad732f9 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs @@ -256,18 +256,28 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc /// 在调用预归档前验证 这些检查是否可以全新上传还是已存在补充 目前前端允许 IsAllowUpload==true 全新、IsAllowReUpload==true 补充的study ,全部丢到后端,后端判断存在,就删除之前的检查,全新插入 /// /// + /// /// - public async Task> VerifyIRStudyAllowUpload(TaskStudyAchivePreConfirmCommand inCommand) + public async Task> VerifyIRStudyAllowUpload(TaskStudyAchivePreConfirmCommand inCommand, [FromServices] IRepository _dicomStudyRepository) { - var notAllowedUidList = _taskStudyRepository.Where(t => t.TrialId == inCommand.TrialId && inCommand.StudyInstanceUidList.Contains(t.StudyInstanceUid)).Select(t => new + var notAllowedUidList1 = _taskStudyRepository.Where(t => t.TrialId == inCommand.TrialId && inCommand.StudyInstanceUidList.Contains(t.StudyInstanceUid)).Select(t => new { t.StudyInstanceUid, t.SubjectId, SubejectCode = t.VisitTask.IsAnalysisCreate ? t.VisitTask.BlindSubjectCode : t.Subject.Code }).ToList(); + var notAllowedUidList2 = _dicomStudyRepository.Where(t => t.TrialId == inCommand.TrialId && inCommand.StudyInstanceUidList.Contains(t.StudyInstanceUid)).Select(t => new + { + t.StudyInstanceUid, + t.SubjectId, + SubejectCode = t.Subject.Code + }).ToList(); + + var notAllowedUidList = notAllowedUidList1.Union(notAllowedUidList2); + var result = new List(); foreach (var studyUid in inCommand.StudyInstanceUidList) @@ -275,6 +285,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc var findStudy = notAllowedUidList.Where(t => t.StudyInstanceUid == studyUid).FirstOrDefault(); if (findStudy != null) { + //同一个subject 同一份影响 if (findStudy.SubejectCode == inCommand.SubjectCode && findStudy.SubjectId == inCommand.SubjectId) { @@ -574,7 +585,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc } else { - await _noneDicomStudyFileReposiotry.BatchDeleteNoTrackingAsync(t => t.VisitTaskId == visitTaskId && t.NoneDicomStudyId == noneDicomStudyId); + await _noneDicomStudyFileReposiotry.BatchDeleteNoTrackingAsync(t => t.VisitTaskId == visitTaskId && t.OriginNoneDicomStudyId == noneDicomStudyId); } return ResponseOutput.Ok(); @@ -590,9 +601,13 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc [HttpPost] public async Task> GetIRUploadTaskNoneDicomStudyList(IRUploadStudyQuery inQuery) { + var info = await _readingQuestionCriterionTrialRepository.Where(t => t.Id == inQuery.TrialReadingCriterionId) + .Select(t => new { t.IsImageFilter, t.CriterionModalitys }).FirstNotNullAsync(); + var query = from u in _visitTaskRepository.Where(t => t.SubjectId == inQuery.SubjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SourceSubjectVisitId != null && t.DoctorUserId == _userInfo.Id && t.TaskState == TaskState.Effect) - join ns in _noneDicomStudyReposiotry.Where(t => t.SubjectId == inQuery.SubjectId) on u.SourceSubjectVisitId equals ns.SubjectVisitId + join ns in _noneDicomStudyReposiotry.Where(t => t.SubjectId == inQuery.SubjectId).WhereIf(info.IsImageFilter,t=> ("|" + info.CriterionModalitys + "|").Contains("|" + t.Modality + "|")) + on u.SourceSubjectVisitId equals ns.SubjectVisitId select new TaskNoneDicomStudyDTO() { @@ -723,9 +738,16 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc [HttpPost] public async Task> GetSubjectImageDownloadSelectList(IRReadingDownloadQuery inQuery) { + var doctorUserId = _userInfo.Id; + + //医学审核查看下载按钮,这个时候需要知道医生 + if (inQuery.VisitTaskId != null && inQuery.VisitTaskId!=Guid.Empty) + { + doctorUserId = await _visitTaskRepository.Where(t => t.Id == inQuery.VisitTaskId).Select(t => (Guid)t.DoctorUserId).FirstNotNullAsync(); + } var query = _visitTaskRepository.Where(t => t.SubjectId == inQuery.SubjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId - && t.SourceSubjectVisitId != null && t.DoctorUserId == _userInfo.Id && t.TaskState == TaskState.Effect) + && t.SourceSubjectVisitId != null && t.DoctorUserId == doctorUserId && t.TaskState == TaskState.Effect) .ProjectTo(_mapper.ConfigurationProvider); @@ -801,10 +823,16 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc var isQueryDicom = inQuery.DicomStudyIdList.Count > 0; var isQueryNoneDicom = inQuery.NoneDicomStudyIdList.Count > 0; + var taskIdList = inQuery.SubjectVisitTaskList.Select(t => t.TaskId).ToList(); + var subjectVisitIdList = inQuery.SubjectVisitTaskList.Select(t => t.SubjectVisitId).ToList(); + //var a = _visitTaskRepository.Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.DoctorUserId == _userInfo.Id); + var query = from sv in _subjectRepository.Where(t => t.Id == inQuery.SubjectId).SelectMany(t => t.SubjectVisitList.Where(t => subjectVisitIdList.Contains(t.Id))) - join visitTask in _visitTaskRepository.Where(t => t.TaskState == TaskState.Effect && t.DoctorUserId == _userInfo.Id && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId) + //一致性分析,导致查询出来两条数据 + join visitTask in _visitTaskRepository.Where(t=> taskIdList.Contains(t.Id)) /*.Where(t => t.TaskState == TaskState.Effect && t.DoctorUserId == _userInfo.Id && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)*/ + on sv.Id equals visitTask.SourceSubjectVisitId select new { diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs index 0e7c0e217..45d2f4a3a 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs @@ -32,11 +32,11 @@ namespace IRaCIS.Core.Application.Contracts [FromQuery, NotDefault] Guid subjectVisitId, [FromQuery] Guid? nonedicomStudyId, [FromQuery] bool isFilterZip, - [FromQuery] Guid? visiTaskId) + [FromQuery] Guid? visitTaskId) { IQueryable noneDicomStudyQueryable = default; - if (visiTaskId == null) + if (visitTaskId == null) { noneDicomStudyQueryable = _noneDicomStudyRepository.Where(t => t.SubjectVisitId == subjectVisitId).WhereIf(nonedicomStudyId != null, t => t.Id == nonedicomStudyId) @@ -44,9 +44,9 @@ namespace IRaCIS.Core.Application.Contracts } else { - noneDicomStudyQueryable = _noneDicomStudyRepository.Where(t => t.TaskNoneDicomFileList.Any(t => t.VisitTaskId == visiTaskId)) + noneDicomStudyQueryable = _noneDicomStudyRepository.Where(t => t.TaskNoneDicomFileList.Any(t => t.VisitTaskId == visitTaskId)) .WhereIf(nonedicomStudyId != null, t => t.Id == nonedicomStudyId) - .ProjectTo(_mapper.ConfigurationProvider, new { isFilterZip = isFilterZip, visiTaskId = visiTaskId }); + .ProjectTo(_mapper.ConfigurationProvider, new { isFilterZip = isFilterZip, visiTaskId = visitTaskId }); } diff --git a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs index d9ec78199..afc1653ac 100644 --- a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs @@ -136,7 +136,8 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.FeedBackUserName, c => c.MapFrom(t => t.CreateUser.UserName)) .ForMember(d => d.FeedBackFullName, c => c.MapFrom(t => t.CreateUser.FullName)) .ForMember(d => d.UserTypeEnum, c => c.MapFrom(t => t.CreateUser.UserTypeEnum)); - CreateMap().ReverseMap(); + + CreateMap().ReverseMap(); } } diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs index e929e8702..0806e360d 100644 --- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs @@ -599,8 +599,9 @@ namespace IRaCIS.Core.Application.Service Guid? visiTaskId = null; CreateMap() - .ForMember(d => d.NoneDicomStudyFileList, u => u.MapFrom(s => isFilterZip ? s.TaskNoneDicomFileList.WhereIf(visiTaskId!=null,t=>t.VisitTaskId==visiTaskId) - .Where(t => !t.FileType.Contains(StaticData.FileType.Zip)) : s.TaskNoneDicomFileList.WhereIf(visiTaskId != null, t => t.VisitTaskId == visiTaskId))) + .ForMember(d => d.NoneDicomStudyFileList, u => u.MapFrom(s => isFilterZip ? + s.TaskNoneDicomFileList.Where(t=> visiTaskId != null?t.VisitTaskId==visiTaskId:true).Where(t => !t.FileType.Contains(StaticData.FileType.Zip)) + : s.TaskNoneDicomFileList.Where(t => visiTaskId != null ? t.VisitTaskId == visiTaskId : true))) .ForMember(d => d.CodeView, u => u.MapFrom(s => s.StudyCode)); } diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs index bba7f9d64..13ff07419 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs @@ -1911,6 +1911,12 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// public List AnswerGroup { get; set; } + + /// + /// 单位 + /// + public ValueUnit? Unit { get; set; } + /// /// 答案组合 /// diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingCriterionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingCriterionService.cs index 2dd1fa9cc..3e10d2952 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingCriterionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingCriterionService.cs @@ -678,6 +678,7 @@ namespace IRaCIS.Core.Application.Service.RC case CriterionType.OCT: criterion.IsImageFilter = true; criterion.IsReadingPeriod = false; + criterion.IsGlobalReading = false; criterion.IsReadingTaskViewInOrder = ReadingOrder.SubjectRandom; criterion.ImageDownloadEnum = ReadingImageDownload.Subejct; criterion.ImageUploadEnum = ReadingImageUpload.IRReadingSubejctEnable; diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingJudgeTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingJudgeTaskService.cs index cb5c0597f..742ff0a80 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingJudgeTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingJudgeTaskService.cs @@ -47,6 +47,7 @@ namespace IRaCIS.Application.Services DictionaryCode=x.DictionaryCode, JudgeType = x.JudgeType, Type=x.Type, + Unit= x.Unit, ReadingQuestionTrialId = x.Id, JudgeDifferenceValue= x.JudgeDifferenceValue, JudgeDifferenceType=x.JudgeDifferenceType, diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingNoDicomTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingNoDicomTaskService.cs index 4f3a7c39d..0276b80f9 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingNoDicomTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingNoDicomTaskService.cs @@ -6,6 +6,7 @@ using Panda.DynamicWebApi.Attributes; using IRaCIS.Core.Application.Contracts; using MassTransit; using IRaCIS.Core.Application.Filter; +using IRaCIS.Core.Domain.Models; namespace IRaCIS.Application.Services { @@ -66,7 +67,7 @@ namespace IRaCIS.Application.Services /// /// [HttpPost] - public async Task> > GetReadingImageFile(GetReadingImgInDto inDto) + public async Task>> GetReadingImageFile(GetReadingImgInDto inDto) { var task = await GetNextTask(new GetNextTaskInDto() { @@ -84,10 +85,26 @@ namespace IRaCIS.Application.Services // 阅片期取前面所有的图像 visitIds.AddRange(await _subjectVisitRepository.Where(x => x.VisitNum <= task.VisitNum && x.SubjectId == task.SubjectId).Select(x => x.Id).ToListAsync()); } - List result = await _noneDicomStudyRepository.Where(t => visitIds.Contains(t.SubjectVisitId) && t.NoneDicomFileList.Any(t=>!t.FileType.Contains(StaticData.FileType.Zip))) - .ProjectTo(_mapper.ConfigurationProvider, new { isFilterZip = true }).ToListAsync(); - var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisistTaskId).FirstNotNullAsync(); + var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisistTaskId).Select(t => new { t.BlindSubjectCode, t.TrialReadingCriterionId, t.TrialReadingCriterion.IsImageFilter, t.TrialReadingCriterion.CriterionModalitys }).FirstNotNullAsync(); + + + IQueryable noneDicomStudyQueryable = default; + if (inDto.VisistTaskId == null) + { + noneDicomStudyQueryable = _noneDicomStudyRepository + .Where(t => visitIds.Contains(t.SubjectVisitId) && t.NoneDicomFileList.Any(t => !t.FileType.Contains(StaticData.FileType.Zip))) + .WhereIf(taskinfo.IsImageFilter == true, t => taskinfo.CriterionModalitys.Contains(t.Modality)) + .ProjectTo(_mapper.ConfigurationProvider, new { isFilterZip = true }); + } + else + { + noneDicomStudyQueryable = _noneDicomStudyRepository.Where(t => t.TaskNoneDicomFileList.Any(t => t.VisitTaskId == inDto.VisistTaskId)) + .Where(t => visitIds.Contains(t.SubjectVisitId)) + .ProjectTo(_mapper.ConfigurationProvider, new { isFilterZip = true, visiTaskId = inDto.VisistTaskId }); + } + List result = await noneDicomStudyQueryable.ToListAsync(); + var trialInfo = await _trialRepository.Where(x => x.Id == inDto.TrialId).Select(x => new { @@ -121,7 +138,7 @@ namespace IRaCIS.Application.Services var taskInfo = await _visitTaskRepository.Where(x => x.Id == task.VisitTaskId).FirstNotNullAsync(); - return ResponseOutput.Ok (result, new + return ResponseOutput.Ok(result, new { VisitTaskId = task.VisitTaskId, SubjectId = task.SubjectId, diff --git a/IRaCIS.Core.Application/Service/Visit/DTO/VisitPointViewModel.cs b/IRaCIS.Core.Application/Service/Visit/DTO/VisitPointViewModel.cs index 31e34b7b0..af0413301 100644 --- a/IRaCIS.Core.Application/Service/Visit/DTO/VisitPointViewModel.cs +++ b/IRaCIS.Core.Application/Service/Visit/DTO/VisitPointViewModel.cs @@ -186,8 +186,11 @@ namespace IRaCIS.Core.Application.Contracts public class GetReadingVisitStudyListIndto { + [NotDefault] public Guid TrialId { get; set; } + [NotDefault] public Guid SujectVisitId { get; set; } + [NotDefault] public Guid VisitTaskId { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index 1a0b415f2..ee4383ff0 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -37,7 +37,7 @@ namespace IRaCIS.Core.Application.Services IRepository _trialReadingCriterionRepository ) : BaseService, ISubjectVisitService { - + [HttpPost] [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] @@ -541,7 +541,7 @@ namespace IRaCIS.Core.Application.Services SeriesId = x.SeriesId, StudyId = x.StudyId, InstanceId = x.InstanceId, - NumberOfFrames=x.NumberOfFrames, + NumberOfFrames = x.NumberOfFrames, }).ToListAsync(); @@ -594,20 +594,20 @@ namespace IRaCIS.Core.Application.Services HtmlPath = k.HtmlPath, Path = k.Path, InstanceNumber = k.InstanceNumber, - StudyId= k.StudyId, - SeriesId= k.SeriesId, + StudyId = k.StudyId, + SeriesId = k.SeriesId, }).ToListAsync(); item.InstanceInfoList.ForEach(x => { - var keyFramesList = rowInfoList.Where(y => y.InstanceId == x.Id&&y.NumberOfFrames!=0).Select(y => y.NumberOfFrames).Distinct().ToList(); + var keyFramesList = rowInfoList.Where(y => y.InstanceId == x.Id && y.NumberOfFrames != 0).Select(y => y.NumberOfFrames).Distinct().ToList(); if (keyFramesList.Count() > 0) { x.KeyFramesList = keyFramesList; } - + var item = rowInfoList.FirstOrDefault(y => y.InstanceId == x.Id); if (item != null) { @@ -632,7 +632,7 @@ namespace IRaCIS.Core.Application.Services - studyList.Insert(0,thisVisitTaskStudy); + studyList.Insert(0, thisVisitTaskStudy); } @@ -658,7 +658,7 @@ namespace IRaCIS.Core.Application.Services #region 非Dicom 检查查询 var noDicomList = await _noneDicomStudyRepository.Where(x => x.TrialId == indto.TrialId && x.SubjectVisitId == indto.SujectVisitId && x.NoneDicomFileList.Any(t => !t.FileType.Contains(StaticData.FileType.Zip))) - .WhereIf(taskInfo.IsImageFilter == true, t => taskInfo.CriterionModalitys.Contains(t.Modality) ).ToListAsync(); + .WhereIf(taskInfo.IsImageFilter == true, t => taskInfo.CriterionModalitys.Contains(t.Modality)).ToListAsync(); List noDicomStudyList = noDicomList.Select(x => new VisitStudyDTO() @@ -672,11 +672,14 @@ namespace IRaCIS.Core.Application.Services }).ToList(); + var isExistTaskNoneDicomFile = _noneDicomStudyFileRepository.Any(t => t.VisitTaskId == indto.VisitTaskId); + foreach (var item in noDicomStudyList) { var nodicom = noDicomList.Where(x => x.Id == item.StudyId).First(); - var instanceCount = await _noneDicomStudyFileRepository.Where(x => x.NoneDicomStudyId == item.StudyId).CountAsync(); + var instanceCount = await _noneDicomStudyFileRepository.WhereIf(isExistTaskNoneDicomFile,x=>x.OriginNoneDicomStudyId== item.StudyId) + .WhereIf(isExistTaskNoneDicomFile==false, x=>x.NoneDicomStudyId == item.StudyId).CountAsync(); if (instanceCount == 0) { @@ -697,7 +700,9 @@ namespace IRaCIS.Core.Application.Services SubjectVisitId=nodicom.SubjectVisitId, SubjectId=nodicom.SubjectId, SeriesNumber=1, - NoneDicomFileFirstFile=await _noneDicomStudyFileRepository.Where(x=>x.NoneDicomStudyId==item.StudyId && !x.FileType.Contains(StaticData.FileType.Zip)).Select(x=>x.Path).FirstOrDefaultAsync(), + NoneDicomFileFirstFile=await _noneDicomStudyFileRepository.WhereIf(isExistTaskNoneDicomFile,x=>x.OriginNoneDicomStudyId== item.StudyId) + .WhereIf(isExistTaskNoneDicomFile==false, x=>x.NoneDicomStudyId == item.StudyId) + .Where(x=> !x.FileType.Contains(StaticData.FileType.Zip)).Select(x=>x.Path).FirstOrDefaultAsync(), } }; diff --git a/IRaCIS.Core.Domain/Management/UserFeedBack.cs b/IRaCIS.Core.Domain/Management/UserFeedBack.cs index f83a4e91b..d02c8c12e 100644 --- a/IRaCIS.Core.Domain/Management/UserFeedBack.cs +++ b/IRaCIS.Core.Domain/Management/UserFeedBack.cs @@ -33,7 +33,7 @@ namespace IRaCIS.Core.Domain.Models public VisitTask VisitTask { get; set; } [NotMapped] - public List ScreenshotList => JsonConvert.DeserializeObject>(ScreenshotListStr); + public List FeedBackScreenshotList => JsonConvert.DeserializeObject>(ScreenshotListStr); #endregion diff --git a/IRaCIS.Core.Domain/Visit/SubjectVisit.cs b/IRaCIS.Core.Domain/Visit/SubjectVisit.cs index 44e477ee1..2e7a566fa 100644 --- a/IRaCIS.Core.Domain/Visit/SubjectVisit.cs +++ b/IRaCIS.Core.Domain/Visit/SubjectVisit.cs @@ -16,8 +16,6 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public TrialSite TrialSite { get; set; } - [JsonIgnore] - public VisitStage VisitStage { get; set; } [JsonIgnore] [ForeignKey("OutPlanPreviousVisitId")] public SubjectVisit OutPlanPreviousVisit { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs index 1326060fc..9d77cb761 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs @@ -16,8 +16,8 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration public void Configure(EntityTypeBuilder builder) { - - builder.HasMany(t => t.ChildList).WithOne(t => t.Parent); + //自身同时存在一对多 和一对一的关系,配置一对多的就可以,一对一 不用配置,有点奇怪 + builder.HasMany(t => t.ChildList).WithOne(t => t.Parent).HasForeignKey(d => d.ParentId); } } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs deleted file mode 100644 index a9011126a..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs +++ /dev/null @@ -1,33 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -using System.Reflection.Emit; - - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - public class DoctorConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - builder - .HasOne(dd => dd.Doctor) - .WithMany(p => p.DoctorDicRelationList) - .HasForeignKey(dd => dd.DoctorId); - - builder - .HasOne(dd => dd.Dictionary) - .WithMany(d => d.DoctorDicRelationList) - .HasForeignKey(dd => dd.DictionaryId); - } - - - } - - - - -} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadModuleConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadModuleConfigration.cs index 5d7c8d501..6159328a5 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadModuleConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadModuleConfigration.cs @@ -12,7 +12,7 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration public void Configure(EntityTypeBuilder builder) { - builder.HasOne(t => t.SubjectVisit).WithMany(t => t.ReadModuleList); + builder.HasOne(t => t.SubjectVisit).WithMany(t => t.ReadModuleList).HasForeignKey(t=>t.SubjectVisitId); } } } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs index 239c349da..87893ad17 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs @@ -13,9 +13,9 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration { //不能同时配置一对多 和一对一 但是有时表要存储多的最新的 比如受试者 最新的访视 在这里要显示配置 - builder.HasOne(s => s.LatestSubjectVisit); - builder.HasOne(s => s.FinalSubjectVisit); - builder.HasMany(s => s.SubjectVisitList).WithOne(sv => sv.Subject); + builder.HasOne(s => s.LatestSubjectVisit).WithMany().HasForeignKey(t => t.LatestSubjectVisitId); + builder.HasOne(s => s.FinalSubjectVisit).WithMany().HasForeignKey(t => t.FinalSubjectVisitId); + builder.HasMany(s => s.SubjectVisitList).WithOne(sv => sv.Subject).HasForeignKey(t => t.SubjectId); } } } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectVisitConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectVisitConfigration.cs deleted file mode 100644 index 2025d4ce4..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectVisitConfigration.cs +++ /dev/null @@ -1,20 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - public class SubjectVisitConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - - - - builder.HasOne(s => s.Subject).WithMany(sv => sv.SubjectVisitList); - } - } -} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialDocumentConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialDocumentConfigration.cs deleted file mode 100644 index ff8d813cf..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialDocumentConfigration.cs +++ /dev/null @@ -1,38 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - public class TrialDocUserTypeConfirmConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - ////项目文档 需要确认的用户类型 找到项目下对应用户类型的用户 用UserTypeId 关联 - //builder - // .HasMany(dd => dd.TrialUserList) - // .WithOne(d => d.TrialDocNeedConfirmedUserType) - // .HasForeignKey(s => new {/* s.TrialId,*/ s.User.UserTypeId }) - // .HasPrincipalKey(c => new { /*c.TrialDocument.TrialId,*/ c.NeedConfirmUserTypeId }); - } - } - - public class TrialDocConfirmUserConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - - - //builder - // .HasOne(dd => dd.TrialUser) - // .WithMany(d => d.TrialDocUserConfirmedList) - // .HasForeignKey(s => new { s.TrialDocument.TrialId, s.ConfirmUserId }) - // .HasPrincipalKey(c => new { c.TrialId, c.UserId }); - } - } -} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteConfigration.cs index c3a433a58..a9173db0a 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteConfigration.cs @@ -5,16 +5,6 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace IRaCIS.Core.Infra.EFCore.EntityConfigration { - public class TrialSiteConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - - - } - } public class SubjectCriteriaEvaluationConfigration : IEntityTypeConfiguration { diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteSurveyConfigration .cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteSurveyConfigration .cs deleted file mode 100644 index 2637b26c4..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteSurveyConfigration .cs +++ /dev/null @@ -1,18 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - public class TrialSiteSurveyConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - - - } - } -} diff --git a/IRaCIS.Core.Test/CodeFirstTest/CodeFirst使用说明 b/IRaCIS.Core.Test/CodeFirstTest/CodeFirst使用说明 new file mode 100644 index 000000000..5a329af9d --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/CodeFirst使用说明 @@ -0,0 +1,15 @@ + +#οѧϰĵ +https://www.cnblogs.com/cqpanda/p/16815263.html + + + # dotnet ef migrations add ǩ -p Ŀ -c -o ǨļĿ¼ + + 1Ǩļ + dotnet ef migrations add Initial -p IRaCIS.Core.Test -c IRCContext -o CodeFirstTest/MSSQL/Migrations + + 2ղɵǨļ + dotnet ef migrations remove -p IRaCIS.Core.Test -c IRCContext + + 3Ǩļµݿ + dotnet ef database update -p IRaCIS.Core.Test -c IRCContext \ No newline at end of file diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/DictionaryConfigration.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/DictionaryConfigration.cs new file mode 100644 index 000000000..07ea337df --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/DictionaryConfigration.cs @@ -0,0 +1,24 @@ +using IRaCIS.Core.Domain.Models; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL +{ + public class DictionaryConfigration : IEntityTypeConfiguration + { + + + public void Configure(EntityTypeBuilder builder) + { + + + builder.HasMany(t => t.ChildList).WithOne(t => t.Parent).HasForeignKey(d => d.ParentId); + + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/SubjectConfigration.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/SubjectConfigration.cs new file mode 100644 index 000000000..888935f60 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/SubjectConfigration.cs @@ -0,0 +1,33 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL +{ + public class SubjectConfigration : IEntityTypeConfiguration + { + + + public void Configure(EntityTypeBuilder builder) + { + + //不能同时配置一对多 和一对一 但是有时表要存储多的最新的 比如受试者 最新的访视 在这里要显示配置 + builder.HasOne(s => s.LatestSubjectVisit); + builder.HasOne(s => s.FinalSubjectVisit); + builder.HasMany(s => s.SubejectVisitList).WithOne(sv => sv.Subject); + } + } + + public class TestOneConfigration : IEntityTypeConfiguration + { + + + public void Configure(EntityTypeBuilder builder) + { + + builder.HasOne(s => s.LatestTestMany).WithMany().HasForeignKey(t=>t.LatestTestManyId); + builder.HasOne(s => s.FinalTestMany).WithMany().HasForeignKey(t => t.FinalTestManyId); + builder.HasMany(s => s.TestManyList).WithOne(sv => sv.TestOne).HasForeignKey(t => t.TestOneId); + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs new file mode 100644 index 000000000..01eb69f95 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using IRaCIS.Core.Test.CodeFirstTest.MSSQL; +using Microsoft.EntityFrameworkCore; + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL; + +public partial class IRCContext : DbContext +{ + public IRCContext() + { + } + + public IRCContext(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet TrialImageDownload { get; set; } + + public virtual DbSet TestNew { get; set; } + + public virtual DbSet Subject { get; set; } + + public virtual DbSet SubejectVisit { get; set; } + + public virtual DbSet Dictionary { get; set; } + public virtual DbSet TestOne { get; set; } + public virtual DbSet TestMany { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + => optionsBuilder.UseSqlServer("Server=106.14.89.110,1433;Database=IRC_Code;User ID=sa;Password=mssql_KnTs2a;TrustServerCertificate=true"); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + //遍历实体模型手动配置 + var typesToRegister = Assembly.GetExecutingAssembly().GetTypes().Where(q => q.GetInterface(typeof(IEntityTypeConfiguration<>).FullName) != null); + foreach (var type in typesToRegister) + { + dynamic configurationInstance = Activator.CreateInstance(type); + modelBuilder.ApplyConfiguration(configurationInstance); + } + + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910053652_testAdd.Designer.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910053652_testAdd.Designer.cs new file mode 100644 index 000000000..b4dbb3787 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910053652_testAdd.Designer.cs @@ -0,0 +1,100 @@ +// +using System; +using IRaCIS.Core.Test.CodeFirstTest.MSSQL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + [DbContext(typeof(IRCContext))] + [Migration("20240910053652_testAdd")] + partial class testAdd + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TestNew"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DownloadEndTime") + .HasColumnType("datetime2"); + + b.Property("DownloadStartTime") + .HasColumnType("datetime2"); + + b.Property("ImageCount") + .HasColumnType("int"); + + b.Property("ImageSize") + .HasColumnType("bigint"); + + b.Property("ImageType") + .HasColumnType("int"); + + b.Property("IsSuccess") + .HasColumnType("bit"); + + b.Property("SubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TrialImageDownload"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910053652_testAdd.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910053652_testAdd.cs new file mode 100644 index 000000000..e42fa119c --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910053652_testAdd.cs @@ -0,0 +1,38 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + /// + public partial class testAdd : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "TestNew", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TestName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreateTime = table.Column(type: "datetime2", nullable: false), + UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), + UpdateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TestNew", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "TestNew"); + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910055957_navigateTest.Designer.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910055957_navigateTest.Designer.cs new file mode 100644 index 000000000..760de65c8 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910055957_navigateTest.Designer.cs @@ -0,0 +1,119 @@ +// +using System; +using IRaCIS.Core.Test.CodeFirstTest.MSSQL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + [DbContext(typeof(IRCContext))] + [Migration("20240910055957_navigateTest")] + partial class navigateTest + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TrialImageDownloadId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TrialImageDownloadId"); + + b.ToTable("TestNew"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DownloadEndTime") + .HasColumnType("datetime2"); + + b.Property("DownloadStartTime") + .HasColumnType("datetime2"); + + b.Property("ImageCount") + .HasColumnType("int"); + + b.Property("ImageSize") + .HasColumnType("bigint"); + + b.Property("ImageType") + .HasColumnType("int"); + + b.Property("IsSuccess") + .HasColumnType("bit"); + + b.Property("SubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TrialImageDownload"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", null) + .WithMany("TestNewList") + .HasForeignKey("TrialImageDownloadId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Navigation("TestNewList"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910055957_navigateTest.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910055957_navigateTest.cs new file mode 100644 index 000000000..0f56141b3 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910055957_navigateTest.cs @@ -0,0 +1,51 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + /// + public partial class navigateTest : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TrialImageDownloadId", + table: "TestNew", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.CreateIndex( + name: "IX_TestNew_TrialImageDownloadId", + table: "TestNew", + column: "TrialImageDownloadId"); + + migrationBuilder.AddForeignKey( + name: "FK_TestNew_TrialImageDownload_TrialImageDownloadId", + table: "TestNew", + column: "TrialImageDownloadId", + principalTable: "TrialImageDownload", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_TestNew_TrialImageDownload_TrialImageDownloadId", + table: "TestNew"); + + migrationBuilder.DropIndex( + name: "IX_TestNew_TrialImageDownloadId", + table: "TestNew"); + + migrationBuilder.DropColumn( + name: "TrialImageDownloadId", + table: "TestNew"); + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.Designer.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.Designer.cs new file mode 100644 index 000000000..20cdc133f --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.Designer.cs @@ -0,0 +1,213 @@ +// +using System; +using IRaCIS.Core.Test.CodeFirstTest.MSSQL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + [DbContext(typeof(IRCContext))] + [Migration("20240910073024_oneToManyAndOneToOne")] + partial class oneToManyAndOneToOne + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("SubjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SubjectId"); + + b.ToTable("SubejectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("FinalSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("LatestSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("FinalSubjectVisitId"); + + b.HasIndex("LatestSubjectVisitId"); + + b.ToTable("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TrialImageDownloadId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TrialImageDownloadId"); + + b.ToTable("TestNew"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DownloadEndTime") + .HasColumnType("datetime2"); + + b.Property("DownloadStartTime") + .HasColumnType("datetime2"); + + b.Property("ImageCount") + .HasColumnType("int"); + + b.Property("ImageSize") + .HasColumnType("bigint"); + + b.Property("ImageType") + .HasColumnType("int"); + + b.Property("IsSuccess") + .HasColumnType("bit"); + + b.Property("SubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TrialImageDownload"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject") + .WithMany("SubejectVisitList") + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "FinalSubjectVisit") + .WithMany() + .HasForeignKey("FinalSubjectVisitId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "LatestSubjectVisit") + .WithMany() + .HasForeignKey("LatestSubjectVisitId"); + + b.Navigation("FinalSubjectVisit"); + + b.Navigation("LatestSubjectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", null) + .WithMany("TestNewList") + .HasForeignKey("TrialImageDownloadId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Navigation("SubejectVisitList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Navigation("TestNewList"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.cs new file mode 100644 index 000000000..3627f081b --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.cs @@ -0,0 +1,96 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + /// + public partial class oneToManyAndOneToOne : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "SubejectVisit", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + SubjectId = table.Column(type: "uniqueidentifier", nullable: false), + CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreateTime = table.Column(type: "datetime2", nullable: false), + UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), + UpdateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SubejectVisit", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Subject", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + LatestSubjectVisitId = table.Column(type: "uniqueidentifier", nullable: true), + FinalSubjectVisitId = table.Column(type: "uniqueidentifier", nullable: true), + CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreateTime = table.Column(type: "datetime2", nullable: false), + UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), + UpdateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Subject", x => x.Id); + table.ForeignKey( + name: "FK_Subject_SubejectVisit_FinalSubjectVisitId", + column: x => x.FinalSubjectVisitId, + principalTable: "SubejectVisit", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Subject_SubejectVisit_LatestSubjectVisitId", + column: x => x.LatestSubjectVisitId, + principalTable: "SubejectVisit", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_SubejectVisit_SubjectId", + table: "SubejectVisit", + column: "SubjectId"); + + migrationBuilder.CreateIndex( + name: "IX_Subject_FinalSubjectVisitId", + table: "Subject", + column: "FinalSubjectVisitId"); + + migrationBuilder.CreateIndex( + name: "IX_Subject_LatestSubjectVisitId", + table: "Subject", + column: "LatestSubjectVisitId"); + + migrationBuilder.AddForeignKey( + name: "FK_SubejectVisit_Subject_SubjectId", + table: "SubejectVisit", + column: "SubjectId", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_SubejectVisit_Subject_SubjectId", + table: "SubejectVisit"); + + migrationBuilder.DropTable( + name: "Subject"); + + migrationBuilder.DropTable( + name: "SubejectVisit"); + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.Designer.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.Designer.cs new file mode 100644 index 000000000..69d7b8786 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.Designer.cs @@ -0,0 +1,269 @@ +// +using System; +using IRaCIS.Core.Test.CodeFirstTest.MSSQL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + [DbContext(typeof(IRCContext))] + [Migration("20240910075136_seftOneToManyAndOneToOne")] + partial class seftOneToManyAndOneToOne + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ConfigTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ConfigTypeId"); + + b.HasIndex("ParentId"); + + b.ToTable("Dictionary"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("SubjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SubjectId"); + + b.ToTable("SubejectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("FinalSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("LatestSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("FinalSubjectVisitId"); + + b.HasIndex("LatestSubjectVisitId"); + + b.ToTable("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TrialImageDownloadId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TrialImageDownloadId"); + + b.ToTable("TestNew"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DownloadEndTime") + .HasColumnType("datetime2"); + + b.Property("DownloadStartTime") + .HasColumnType("datetime2"); + + b.Property("ImageCount") + .HasColumnType("int"); + + b.Property("ImageSize") + .HasColumnType("bigint"); + + b.Property("ImageType") + .HasColumnType("int"); + + b.Property("IsSuccess") + .HasColumnType("bit"); + + b.Property("SubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TrialImageDownload"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "ConfigType") + .WithMany() + .HasForeignKey("ConfigTypeId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "Parent") + .WithMany("ChildList") + .HasForeignKey("ParentId"); + + b.Navigation("ConfigType"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject") + .WithMany("SubejectVisitList") + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "FinalSubjectVisit") + .WithMany() + .HasForeignKey("FinalSubjectVisitId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "LatestSubjectVisit") + .WithMany() + .HasForeignKey("LatestSubjectVisitId"); + + b.Navigation("FinalSubjectVisit"); + + b.Navigation("LatestSubjectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", null) + .WithMany("TestNewList") + .HasForeignKey("TrialImageDownloadId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Navigation("ChildList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Navigation("SubejectVisitList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Navigation("TestNewList"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.cs new file mode 100644 index 000000000..32920762b --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.cs @@ -0,0 +1,60 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + /// + public partial class seftOneToManyAndOneToOne : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Dictionary", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + ConfigTypeId = table.Column(type: "uniqueidentifier", nullable: true), + Code = table.Column(type: "nvarchar(max)", nullable: false), + CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreateTime = table.Column(type: "datetime2", nullable: false), + UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), + UpdateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Dictionary", x => x.Id); + table.ForeignKey( + name: "FK_Dictionary_Dictionary_ConfigTypeId", + column: x => x.ConfigTypeId, + principalTable: "Dictionary", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Dictionary_Dictionary_ParentId", + column: x => x.ParentId, + principalTable: "Dictionary", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Dictionary_ConfigTypeId", + table: "Dictionary", + column: "ConfigTypeId"); + + migrationBuilder.CreateIndex( + name: "IX_Dictionary_ParentId", + table: "Dictionary", + column: "ParentId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Dictionary"); + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/IRCContextModelSnapshot.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/IRCContextModelSnapshot.cs new file mode 100644 index 000000000..ffb12bafa --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/IRCContextModelSnapshot.cs @@ -0,0 +1,266 @@ +// +using System; +using IRaCIS.Core.Test.CodeFirstTest.MSSQL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + [DbContext(typeof(IRCContext))] + partial class IRCContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ConfigTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ConfigTypeId"); + + b.HasIndex("ParentId"); + + b.ToTable("Dictionary", (string)null); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("SubjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SubjectId"); + + b.ToTable("SubejectVisit", (string)null); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("FinalSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("LatestSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("FinalSubjectVisitId"); + + b.HasIndex("LatestSubjectVisitId"); + + b.ToTable("Subject", (string)null); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TrialImageDownloadId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TrialImageDownloadId"); + + b.ToTable("TestNew", (string)null); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DownloadEndTime") + .HasColumnType("datetime2"); + + b.Property("DownloadStartTime") + .HasColumnType("datetime2"); + + b.Property("ImageCount") + .HasColumnType("int"); + + b.Property("ImageSize") + .HasColumnType("bigint"); + + b.Property("ImageType") + .HasColumnType("int"); + + b.Property("IsSuccess") + .HasColumnType("bit"); + + b.Property("SubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TrialImageDownload", (string)null); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "ConfigType") + .WithMany() + .HasForeignKey("ConfigTypeId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "Parent") + .WithMany("ChildList") + .HasForeignKey("ParentId"); + + b.Navigation("ConfigType"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject") + .WithMany("SubejectVisitList") + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "FinalSubjectVisit") + .WithMany() + .HasForeignKey("FinalSubjectVisitId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "LatestSubjectVisit") + .WithMany() + .HasForeignKey("LatestSubjectVisitId"); + + b.Navigation("FinalSubjectVisit"); + + b.Navigation("LatestSubjectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", null) + .WithMany("TestNewList") + .HasForeignKey("TrialImageDownloadId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Navigation("ChildList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Navigation("SubejectVisitList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Navigation("TestNewList"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs new file mode 100644 index 000000000..56a90d864 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs @@ -0,0 +1,134 @@ +using IRaCIS.Core.Domain.Models; +using IRaCIS.Core.Domain.Share; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL +{ + + [Table("TrialImageDownload")] + public class TrialImageDownload : BaseFullAuditEntity + { + public Guid SubjectVisitId { get; set; } + + public bool IsSuccess { get; set; } + + public DateTime DownloadStartTime { get; set; } + public DateTime? DownloadEndTime { get; set; } + + public ImageType ImageType { get; set; } + + public int ImageCount { get; set; } + + public long ImageSize { get; set; } + + #region 测试导航属性 + + public List TestNewList { get; set; } + + #endregion + } + + public enum ImageType + { + Dicom = 1, + NoneDIcom = 2 + }; + + public class TestNew : BaseFullAuditEntity + { + public Guid TrialImageDownloadId { get; set; } + + [StringLength(100)] + public string TestName { get; set; } + } + + + public class Subject : BaseFullAuditEntity + { + public string Name { get; set; } + + + public Guid? LatestSubjectVisitId { get; set; } + + public Guid? FinalSubjectVisitId { get; set; } + + #region 同时配置一对多,一对一 导航属性 + + [ForeignKey("FinalSubjectVisitId")] + public SubejectVisit FinalSubjectVisit { get; set; } + + [ForeignKey("LatestSubjectVisitId")] + public SubejectVisit LatestSubjectVisit { get; set; } + + public List SubejectVisitList { get; set; } + #endregion + + } + + public class SubejectVisit : BaseFullAuditEntity + { + public Subject Subject { get; set; } + + public Guid SubjectId { get; set; } + + } + + + public class Dictionary : BaseFullAuditEntity + { + #region 导航属性 + [ForeignKey("ConfigTypeId")] + public Dictionary ConfigType { get; set; } + + [ForeignKey("ParentId")] + public Dictionary Parent { get; set; } + + public List ChildList { get; set; } = new List(); + + #endregion + + + public Guid? ParentId { get; set; } + + + public Guid? ConfigTypeId { get; set; } + + public string Code { get; set; } + } + + + public class TestOne : BaseFullAuditEntity + { + public string Code { get; set; } + + [ForeignKey(nameof(TestOne.FinalTestMany))] + public Guid? LatestTestManyId { get; set; } + + [ForeignKey(nameof(TestOne.LatestTestMany))] + public Guid? FinalTestManyId { get; set; } + + #region 同时配置一对多,一对一 导航属性 + + + public TestMany FinalTestMany { get; set; } + + public TestMany LatestTestMany { get; set; } + + public List TestManyList { get; set; } + + #endregion + } + + public class TestMany : BaseFullAuditEntity + { + public TestOne TestOne { get; set; } + + public Guid TestOneId { get; set; } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/PGContext.cs b/IRaCIS.Core.Test/CodeFirstTest/PGSQL/PGContext.cs similarity index 100% rename from IRaCIS.Core.Test/CodeFirstTest/PGContext.cs rename to IRaCIS.Core.Test/CodeFirstTest/PGSQL/PGContext.cs diff --git a/IRaCIS.Core.Test/CodeFirstTest/Subject.cs b/IRaCIS.Core.Test/CodeFirstTest/PGSQL/Subject.cs similarity index 100% rename from IRaCIS.Core.Test/CodeFirstTest/Subject.cs rename to IRaCIS.Core.Test/CodeFirstTest/PGSQL/Subject.cs diff --git a/IRaCIS.Core.Test/Program.cs b/IRaCIS.Core.Test/Program.cs index 90e84d66e..b2b5d4a75 100644 --- a/IRaCIS.Core.Test/Program.cs +++ b/IRaCIS.Core.Test/Program.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using static System.Net.Mime.MediaTypeNames; partial class Program { @@ -55,7 +56,15 @@ partial class Program // 要生成的表名数组 - var tableNames = new List(args); + var tableNames = new List(args); + + var argsStr = args.ToString()??string.Empty; + + if (argsStr.Contains(".") || argsStr.Contains("-")|| argsStr.Contains("application")|| argsStr.Contains("IR")) + { + tableNames = new List(); + } + try {