修改删除检查文件
parent
083595cdea
commit
d22c6f8702
|
@ -779,7 +779,6 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
|
||||
//}).ToListAsync();
|
||||
|
||||
var succeess2 = await _repository.BatchDeleteAsync<DicomInstance>(t => t.StudyId == id);
|
||||
var success3 = await _dicomSeriesrepository.BatchDeleteNoTrackingAsync(t => t.StudyId == id);
|
||||
|
||||
//var success3 = await _dicomSeriesrepository.DeleteFromQueryAsync(t => t.StudyId == id, true);
|
||||
|
@ -787,19 +786,52 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
|
||||
//删除 物理文件
|
||||
|
||||
var instancePathList = await _repository.Where<DicomInstance>(t => t.StudyId == id)
|
||||
.Select(t => t.Path).ToListAsync();
|
||||
//var instancePathList = await _repository.Where<DicomInstance>(t => t.StudyId == id)
|
||||
// .Select(t => t.Path).ToListAsync();
|
||||
|
||||
instancePathList.ForEach(path =>
|
||||
var instancePath= await _repository.Where<DicomInstance>(t => t.StudyId == id).Select(t => t.Path).FirstOrDefaultAsync();
|
||||
|
||||
|
||||
//instancePathList.ForEach(path =>
|
||||
//{
|
||||
|
||||
// var physicalPath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, path);
|
||||
|
||||
// Console.WriteLine(physicalPath);
|
||||
|
||||
|
||||
// if (System.IO.File.Exists(physicalPath))
|
||||
// {
|
||||
// Console.WriteLine("存在:" + physicalPath);
|
||||
// File.Delete(physicalPath);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine("不存在:" + physicalPath);
|
||||
// }
|
||||
//});
|
||||
|
||||
var parentDirectory = Directory.GetParent(FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, instancePath ?? string.Empty))?.FullName;
|
||||
|
||||
if (parentDirectory != null)
|
||||
{
|
||||
Console.WriteLine("删除目录: " + parentDirectory);
|
||||
|
||||
var physicalPath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, path);
|
||||
|
||||
if (System.IO.File.Exists(physicalPath))
|
||||
// 递归删除目录
|
||||
if (Directory.Exists(parentDirectory))
|
||||
{
|
||||
File.Delete(physicalPath);
|
||||
Directory.Delete(parentDirectory, recursive: true);
|
||||
Console.WriteLine("目录已删除。");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("无法找到父目录。");
|
||||
}
|
||||
|
||||
var succeess2 = await _repository.BatchDeleteAsync<DicomInstance>(t => t.StudyId == id);
|
||||
|
||||
|
||||
//var instanceIdList = await _repository.Where<DicomInstance>(t => t.StudyId == id)
|
||||
// .Select(t => new { InstanceId = t.Id, t.SeriesId, t.StudyId, t.SubjectId, t.SiteId }).ToListAsync();
|
||||
|
|
Loading…
Reference in New Issue