目的:利用DCMTK,向Orthanc服务器存储dcm文件
在DCMTK目录运行控制台,用storescu -h可以详细了解到storescu的所有指令
我们输入storescu 127.0.0.1 4242 "D:\Study\manifest-1722566998113\RIDER Pilot\1.3.6.1.4.1.9328.50.1.0117\05-20-2000-143-CT CHEST W CONT-61279\2.000000-PSEUDOSMART PREP-61284" +sd ( -ll info -aet 我的ae标题 -aec 对方ae标题) 扫描当前文件夹里的所有dcm文件
可以看到,dcm文件成功上传到服务器上了
补充在C#中的实现过程
/// <summary>
/// 上传选中的文件,重复上传不管
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void btnUpLoad_Click(object sender, RoutedEventArgs e)
{
var client = DicomClientFactory.Create("172.20.111.101", 4242, false, "SCU", "ANY-SCP");
client.ClientOptions.AssociationRequestTimeoutInMs = (int)TimeSpan.FromMinutes(5).TotalMilliseconds;
DicomCStoreResponse response = null;
DicomRequest.OnTimeoutEventArgs timeout = null;
try
{
string Path = (string)lbSelectDCM.Content;
if (Path == "null")
{
return;
}
//处理多个文件传入
string[] FilePaths = Path.Split('\n');
foreach (string filepath in FilePaths)
{
if (string.IsNullOrWhiteSpace(filepath)) return;
// 清理文件路径中的换行符等不可见字符,刚刚有个换行符卡住
string cleanedFilePath = filepath.Trim();
var request = new DicomCStoreRequest(TestData.Resolve(cleanedFilePath.Trim()))
{
OnResponseReceived = (req, res) => response = res,
OnTimeout = (sender, args) => timeout = args
};
await client.AddRequestAsync(request);
await client.SendAsync();
Assert.NotNull(response);
Assert.Equal(DicomStatus.Success, response.Status);
lbUploadResult.Content = response.Status;
Assert.Null(timeout);
}
}
catch (Exception)
{
lbUploadResult.Content = "fail";
}
}