Commit 9ed82e73 authored by alan.f's avatar alan.f

change-inputs-to-model

parent 1c1fd957
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Models\InputsDto.cs" />
<Compile Include="SCU_Store.cs" /> <Compile Include="SCU_Store.cs" />
<Compile Include="Form1.cs"> <Compile Include="Form1.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
......
using System; using C_UI.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
...@@ -25,7 +26,10 @@ namespace C_UI ...@@ -25,7 +26,10 @@ namespace C_UI
string fileExt = System.IO.Path.GetExtension(ofdUploadFile.FileName); string fileExt = System.IO.Path.GetExtension(ofdUploadFile.FileName);
if (result == DialogResult.OK && fileExt==".dcm") if (result == DialogResult.OK && fileExt==".dcm")
{ {
SCU_Store.StoreFile(cbxIPs.Text, int.Parse(txtPort.Text), ofdUploadFile.FileNames, txtServerAET.Text, txtAet.Text); InputsDto inputsDto = new InputsDto() { ServerHost= cbxIPs.Text ,Port= int.Parse(txtPort.Text) ,
FileNames= ofdUploadFile.FileNames ,ServerAET= txtServerAET.Text,Aet = txtAet.Text
};
SCU_Store.StoreFile(inputsDto);
} }
} }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace C_UI.Models
{
public struct InputsDto
{
public string ServerHost { get; set; }
public int Port { get; set; }
public string[] FileNames { get; set; }
public string ServerAET { get; set; }
public string Aet { get; set; }
}
}
...@@ -12,6 +12,7 @@ using System.Windows.Forms; ...@@ -12,6 +12,7 @@ using System.Windows.Forms;
using DicomClient = Dicom.Network.Client.DicomClient; using DicomClient = Dicom.Network.Client.DicomClient;
using System.Reactive.Threading.Tasks; using System.Reactive.Threading.Tasks;
using System.CodeDom; using System.CodeDom;
using C_UI.Models;
namespace C_UI namespace C_UI
{ {
...@@ -20,13 +21,12 @@ namespace C_UI ...@@ -20,13 +21,12 @@ namespace C_UI
{ {
static Logger logger = LogManager.GetCurrentClassLogger(); static Logger logger = LogManager.GetCurrentClassLogger();
public static async Task StoreFile(string _storeServerHost, int _storeServerPort, string[] dicomFiles public static async Task StoreFile(InputsDto inputsDto)
, string _aet, string _storeServerAET)
{ {
var client = new DicomClient(_storeServerHost, _storeServerPort, false, _storeServerAET, _aet); var client = new DicomClient(inputsDto.ServerHost, inputsDto.Port, false, inputsDto.ServerAET, inputsDto.Aet);
client.NegotiateAsyncOps(); client.NegotiateAsyncOps();
dicomFiles.ToObservable() inputsDto.FileNames.ToObservable()
.Select(async fileName => .Select(async fileName =>
{ {
var request = new DicomCStoreRequest(fileName); var request = new DicomCStoreRequest(fileName);
...@@ -37,10 +37,15 @@ namespace C_UI ...@@ -37,10 +37,15 @@ namespace C_UI
}) })
.Select(t => .Select(t =>
{ {
t.Wait();
return t.Result; return t.Result;
}) }).Subscribe();
.Subscribe(filename => logger.Warn($"file sent:{filename}"), onError => logger.Error(onError.Message), () => { }); //.Subscribe(filename =>
//{
// logger.Warn($"file sent:{filename}");
//},
//onError =>
//{ logger.Error(onError.Message); },
//() => { });
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment