diff --git a/DICOMStore.cs b/DICOMStore.cs
index c9fa115..5a72cbf 100644
--- a/DICOMStore.cs
+++ b/DICOMStore.cs
@@ -11,18 +11,20 @@ static class DICOMStore
{
///
/// The method will read all files in a directory/sub-directories and send a DICOMweb Store request (STOW-RS)
- /// Each 5 DICOM files will be grouped as a multi-part content and sent in a single request.
+ /// DICOM files will be grouped as defined in as a multi-part content and sent in a single request.
///
///
///
- public static void StoreDicomInDirectory(string directory, string storeUrl)
+ ///
+ ///
+ public static void StoreDicomInDirectory(string directory, string storeUrl, string pattern, int batch)
{
var mimeType = "application/dicom";
MultipartContent multiContent = GetMultipartContent(mimeType);
int count = 0;
- //Enumerate all files in a directory/sub-directories
- foreach (var path in Directory.EnumerateFiles(directory, "*.*", SearchOption.AllDirectories))
+ //Enumerate files in a directory/sub-directories
+ foreach (var path in Directory.EnumerateFiles(directory, pattern, SearchOption.AllDirectories))
{
count++;
@@ -32,7 +34,7 @@ public static void StoreDicomInDirectory(string directory, string storeUrl)
multiContent.Add(sContent);
- if (count % 5 == 0)
+ if (count % batch == 0)
{
count = 0;
@@ -42,7 +44,7 @@ public static void StoreDicomInDirectory(string directory, string storeUrl)
}
}
- //Flush any remaining images (should be less than 5)
+ //Flush any remaining images (should be less than BATCH)
if (multiContent.Count() > 0)
{
StoreToServer(multiContent, storeUrl);
@@ -83,7 +85,7 @@ private static void StoreToServer(MultipartContent multiContent, string storeUrl
HttpResponseMessage response = result.Result;
- Console.WriteLine(response.StatusCode);
+ Console.WriteLine($"[{(uint)response.StatusCode}]{response.StatusCode}: {response.ReasonPhrase}");
var result2 = response.Content.ReadAsStringAsync();
diff --git a/Program.cs b/Program.cs
index 0b3c6c2..3ba7b53 100644
--- a/Program.cs
+++ b/Program.cs
@@ -8,10 +8,11 @@ namespace DICOMcloudUploader
{
class Program
{
- static void Main(string dir = null, string url = null)
+ static void Main(int batch = 5, string dir = null, string url = null, string pattern = null)
{
string uploadFolder = "";
url ??= "http://localhost:44301/stowrs/";
+ pattern ??= "*.*";
if (string.IsNullOrWhiteSpace(dir))
{
@@ -32,6 +33,8 @@ static void Main(string dir = null, string url = null)
sb.AppendLine($"1. DICOM Directory: {uploadFolder}");
sb.AppendLine($"2. DICOMweb Store Endpoint: {url}");
+ sb.AppendLine($"3. DICOM Directory File Pattern: {pattern}");
+ sb.AppendLine($"4. DICOMweb Store Send Batch: {batch}");
sb.AppendLine($"Press \"Enter\" to accept, \"1\" to change DICOM directory, \"2\" to change store endpoint or any key to exit");
Console.WriteLine(sb);
@@ -47,6 +50,16 @@ static void Main(string dir = null, string url = null)
Console.WriteLine("Enter URL for DICOMweb Store endpoint:");
url = Console.ReadLine();
}
+ else if (input == "3")
+ {
+ Console.WriteLine("Enter File Pattern DICOM directory to upload:");
+ pattern = Console.ReadLine();
+ }
+ else if (input == "4")
+ {
+ Console.WriteLine("Enter integer for DICOMweb Store send batch:");
+ int.TryParse( Console.ReadLine(), out batch);
+ }
else if (input != "")
{
return;
@@ -62,7 +75,7 @@ static void Main(string dir = null, string url = null)
DateTime startTime = DateTime.Now;
Console.WriteLine($"Upload start time: {startTime}");
- DICOMStore.StoreDicomInDirectory(uploadFolder, url);
+ DICOMStore.StoreDicomInDirectory(uploadFolder, url, pattern, batch);
DateTime endTime = DateTime.Now;
Console.WriteLine($"Upload end time: {endTime}");
diff --git a/README.md b/README.md
index 6de2df6..268d11f 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,11 @@ If arguments not provided in the command line, you will get the chance to specif
|arg| Description |
|--|--|
| --dir | Optional - Path to DICOM directory |
-| -url | URL to a DICOMweb Store (aka STOW-RS) endpoint
+| --url | URL to a DICOMweb Store (aka STOW-RS) endpoint |
+| --pattern | File Pattern for DICOM directory to upload. Default is "\*.\*" |
+| --batch | Optional - Integer for DICOMweb Store send batch. Default is 5 |
## Examples:
-`DICOMcloudUploader.exe --dir "d:\dicomimages" --url "http://dicomcloud.azurewebsites.net/api/studies"`
+```DICOMcloudUploader.exe --dir "d:\dicomimages" --url "http://dicomcloud.azurewebsites.net/api/studies"```
+
+```DICOMcloudUploader.exe --dir "d:\dicomimages" --url "http://dicomcloud.azurewebsites.net/api/studies" --pattern "*.dcm" --batch 12```
\ No newline at end of file