添加项目文件。
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.IO;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
|
||||
namespace IRaCIS.Core.Application
|
||||
{
|
||||
public class DicomFileStoreHelper
|
||||
{
|
||||
private readonly IWebHostEnvironment _hostEnvironment;
|
||||
private static string _fileStorePath = string.Empty;
|
||||
|
||||
private readonly ILogger<DicomFileStoreHelper> _logger;
|
||||
|
||||
public DicomFileStoreHelper(IWebHostEnvironment hostEnvironment, ILogger<DicomFileStoreHelper> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_hostEnvironment = hostEnvironment;
|
||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
|
||||
|
||||
//上传根路径
|
||||
_fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder);
|
||||
|
||||
}
|
||||
|
||||
public string GetInstanceFilePath(DicomStudy dicomStudy, Guid seriesId, string instanceId)
|
||||
{
|
||||
return Path.Combine(_fileStorePath, dicomStudy.TrialId.ToString(),
|
||||
dicomStudy.SiteId.ToString(), dicomStudy.SubjectId.ToString(), dicomStudy.SubjectVisitId.ToString(), StaticData.DicomFolder, dicomStudy.Id.ToString(), instanceId.ToString() + ".dcm");
|
||||
}
|
||||
|
||||
|
||||
public string CreateInstanceFilePath(DicomStudy dicomStudy, Guid seriesId, Guid instanceId)
|
||||
{
|
||||
|
||||
//加入访视层级 和Data
|
||||
var path = Path.Combine(_fileStorePath, dicomStudy.TrialId.ToString(),
|
||||
dicomStudy.SiteId.ToString(), dicomStudy.SubjectId.ToString(), dicomStudy.SubjectVisitId.ToString(), StaticData.DicomFolder, dicomStudy.Id.ToString());
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
return Path.Combine(path, instanceId.ToString() + ".dcm");
|
||||
}
|
||||
|
||||
|
||||
public string GetSubjectVisitPath(Guid trialId,Guid siteId,Guid subjectId, Guid subjectVisitId)
|
||||
{
|
||||
return Path.Combine(_fileStorePath, trialId.ToString(),
|
||||
siteId.ToString(), subjectId.ToString(), subjectVisitId.ToString(), StaticData.DicomFolder);
|
||||
}
|
||||
|
||||
//public static string CreateInstanceFilePath(DicomStudy dicomStudy, Guid seriesId, Guid instanceId)
|
||||
//{
|
||||
// string path = Path.Combine(_fileStorePath, "Dicom", dicomStudy.CreateTime.Year.ToString(), dicomStudy.TrialId.ToString(),
|
||||
// dicomStudy.SiteId.ToString(), dicomStudy.SubjectId.ToString(), dicomStudy.Id.ToString());
|
||||
// if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
||||
|
||||
// return Path.Combine(path, instanceId.ToString() + ".dcm");
|
||||
//}
|
||||
|
||||
//public static string GetInstanceFilePath(DicomStudy dicomStudy, Guid seriesId, Guid instanceId)
|
||||
//{
|
||||
// return Path.Combine(_fileStorePath, "Dicom", dicomStudy.CreateTime.Year.ToString(), dicomStudy.TrialId.ToString(),
|
||||
// dicomStudy.SiteId.ToString(), dicomStudy.SubjectId.ToString(), dicomStudy.Id.ToString(), instanceId.ToString() + ".dcm");
|
||||
//}
|
||||
|
||||
|
||||
//public static void RemoveStudyDirectory(DicomStudy dicomStudy)
|
||||
//{
|
||||
// string path = Path.Combine(_fileStorePath, "Dicom", dicomStudy.CreateTime.Year.ToString(), dicomStudy.TrialId.ToString(),
|
||||
// dicomStudy.SiteId.ToString(), dicomStudy.SubjectId.ToString(), dicomStudy.Id.ToString());
|
||||
// if (Directory.Exists(path)) Directory.Delete(path, true);
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using FellowOakDicom.Imaging;
|
||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||
|
||||
namespace IRaCIS.Core.Application.Dicom
|
||||
{
|
||||
public static class DicomRenderingHelper
|
||||
{
|
||||
public static Stream RenderPreviewJpeg(string filePath)
|
||||
{
|
||||
string jpegPath = filePath + ".preview.jpg";
|
||||
|
||||
if (!File.Exists(jpegPath))
|
||||
{
|
||||
using (Stream stream = new FileStream(jpegPath, FileMode.Create))
|
||||
{
|
||||
DicomImage image = new DicomImage(filePath);
|
||||
//image.ShowOverlays = false;
|
||||
//image.Scale = Math.Min(Math.Min(128.0 / image.Width, 128.0 / image.Height), 1.0);
|
||||
//image.RenderImage().AsClonedBitmap().Save(stream, ImageFormat.Jpeg);
|
||||
|
||||
var sharpimage = image.RenderImage().AsSharpImage();
|
||||
|
||||
sharpimage.Save(stream, new JpegEncoder());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return new FileStream(jpegPath, FileMode.Open);
|
||||
}
|
||||
|
||||
public static void RemovePreviewJpeg(string filePath)
|
||||
{
|
||||
string jpegPath = filePath + ".preview.jpg";
|
||||
if (File.Exists(jpegPath)) File.Delete(jpegPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace IRaCIS.Core.Application.Services
|
||||
{
|
||||
static class IdentifierHelper
|
||||
{
|
||||
//private static MD5 md5 = new MD5CryptoServiceProvider
|
||||
//
|
||||
private static MD5 md5 = MD5.Create();
|
||||
|
||||
private static object lockObj =new object();
|
||||
|
||||
public static Guid CreateGuid(params string[] parts)
|
||||
{
|
||||
lock (lockObj)
|
||||
{
|
||||
return new Guid(md5.ComputeHash(Encoding.UTF8.GetBytes(string.Concat(parts))));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user