Commit 294a59a8 authored by alan.f's avatar alan.f

remove-try-catch

parent afd464c0
......@@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
......@@ -22,11 +23,10 @@ namespace C_UI
{
DialogResult result = ofdUploadFile.ShowDialog();
string fileExt = System.IO.Path.GetExtension(ofdUploadFile.FileName);
if (result == DialogResult.OK && fileExt==".dcm") // Test result.
if (result == DialogResult.OK && fileExt==".dcm")
{
SCU_Store.StoreFile(cbxIPs.Text, int.Parse(txtPort.Text), ofdUploadFile.FileNames, txtServerAET.Text, txtAet.Text);
//Do whatever you want
//openFileDialog1.FileName .....
SCU_Store.StoreFile(cbxIPs.Text, int.Parse(txtPort.Text), ofdUploadFile.FileNames.ToObservable(), txtServerAET.Text, txtAet.Text);
}
}
......
......@@ -22,7 +22,7 @@
<rules>
<logger name="*" minlevel="Debug" writeTo="f1" />
<logger name="*" minlevel="Info" writeTo="f1" />
<!-- add your logging rules here -->
<!--
......
......@@ -10,6 +10,8 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DicomClient = Dicom.Network.Client.DicomClient;
using System.Reactive.Threading.Tasks;
using System.CodeDom;
namespace C_UI
{
......@@ -18,26 +20,25 @@ namespace C_UI
{
static Logger logger = LogManager.GetCurrentClassLogger();
public static async Task StoreFile(string _storeServerHost, int _storeServerPort, string[] dicomFiles, string _aet, string _storeServerAET)
public static async Task StoreFile(string _storeServerHost, int _storeServerPort, IObservable<string> dicomFiles
, string _aet, string _storeServerAET)
{
var client = new DicomClient(_storeServerHost, _storeServerPort, false, _storeServerAET, _aet);
client.NegotiateAsyncOps();
dicomFiles.ToObservable().Subscribe(async currentFile =>
dicomFiles.Select(x=>x).Subscribe(
async onNext =>
{
var request = new DicomCStoreRequest(onNext);
request.OnResponseReceived += (req, response) => logger.Info($"{response.Status}-{onNext}" );
await client.AddRequestAsync(request);
await client.SendAsync();
},
onError =>
{
try
{
var request = new DicomCStoreRequest(currentFile.ToString());
request.OnResponseReceived += (req, response) => logger.Info(response.Status);
await client.AddRequestAsync(request);
await client.SendAsync();
}
catch (Exception exception)
{
logger.Error(exception.Message);
}
});
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