public void Send(string host, int port, bool useTls, string callingAe, string calledAe, int millisecondsTimeout = DefaultAssociationTimeout) { if (!CanSend) { return; } var noDelay = Options?.TcpNoDelay ?? DicomServiceOptions.Default.TcpNoDelay; var ignoreSslPolicyErrors = Options?.IgnoreSslPolicyErrors ?? DicomServiceOptions.Default.IgnoreSslPolicyErrors; _networkStream = NetworkManager.CreateNetworkStream(host, port, useTls, noDelay, ignoreSslPolicyErrors); var assoc = new DicomAssociation(callingAe, calledAe) { MaxAsyncOpsInvoked = _asyncInvoked, MaxAsyncOpsPerformed = _asyncPerformed, RemoteHost = host, RemotePort = port }; try { DoSendAsync(_networkStream, assoc, millisecondsTimeout, true).Wait(); } catch (AggregateException e) { // ReSharper disable once PossibleNullReferenceException throw e.Flatten().InnerException; } }
/// <summary> /// Synchonously send existing requests to DICOM service. /// </summary> /// <param name="host">DICOM host.</param> /// <param name="port">Port.</param> /// <param name="useTls">True if TLS security should be enabled, false otherwise.</param> /// <param name="callingAe">Calling Application Entity Title.</param> /// <param name="calledAe">Called Application Entity Title.</param> public void Send(string host, int port, bool useTls, string callingAe, string calledAe) { if (!CanSend) { return; } var noDelay = Options?.TcpNoDelay ?? DicomServiceOptions.Default.TcpNoDelay; var ignoreSslPolicyErrors = Options?.IgnoreSslPolicyErrors ?? DicomServiceOptions.Default.IgnoreSslPolicyErrors; this.networkStream = NetworkManager.CreateNetworkStream(host, port, useTls, noDelay, ignoreSslPolicyErrors); var assoc = new DicomAssociation(callingAe, calledAe) { MaxAsyncOpsInvoked = this.asyncInvoked, MaxAsyncOpsPerformed = this.asyncPerformed, RemoteHost = host, RemotePort = port }; try { DoSendAsync(this.networkStream, assoc).Wait(); } catch (AggregateException e) { throw e.Flatten().InnerException; } }
/// <summary> /// Synchonously send existing requests to DICOM service. /// </summary> /// <param name="host">DICOM host.</param> /// <param name="port">Port.</param> /// <param name="useTls">Treu if TLS security should be enabled, false otherwise.</param> /// <param name="callingAe">Calling Application Entity Title.</param> /// <param name="calledAe">Called Application Entity Title.</param> public void Send(string host, int port, bool useTls, string callingAe, string calledAe) { if (!this.CanSend) { return; } var noDelay = this.Options != null ? this.Options.TcpNoDelay : DicomServiceOptions.Default.TcpNoDelay; var ignoreSslPolicyErrors = (this.Options ?? DicomServiceOptions.Default).IgnoreSslPolicyErrors; this.networkStream = NetworkManager.CreateNetworkStream(host, port, useTls, noDelay, ignoreSslPolicyErrors); this.InitializeSend(this.networkStream.AsStream(), callingAe, calledAe); this.completeNotifier.Task.Wait(); this.FinalizeSend(); }
/// <summary> /// Asynchonously send existing requests to DICOM service. /// </summary> /// <param name="host">DICOM host.</param> /// <param name="port">Port.</param> /// <param name="useTls">True if TLS security should be enabled, false otherwise.</param> /// <param name="callingAe">Calling Application Entity Title.</param> /// <param name="calledAe">Called Application Entity Title.</param> /// <returns>Awaitable task.</returns> public Task SendAsync(string host, int port, bool useTls, string callingAe, string calledAe) { if (!CanSend) { Task.FromResult(false); // TODO Replace with Task.CompletedTask when moving to .NET 4.6 } var noDelay = Options?.TcpNoDelay ?? DicomServiceOptions.Default.TcpNoDelay; var ignoreSslPolicyErrors = Options?.IgnoreSslPolicyErrors ?? DicomServiceOptions.Default.IgnoreSslPolicyErrors; this.networkStream = NetworkManager.CreateNetworkStream(host, port, useTls, noDelay, ignoreSslPolicyErrors); var assoc = new DicomAssociation(callingAe, calledAe) { MaxAsyncOpsInvoked = this.asyncInvoked, MaxAsyncOpsPerformed = this.asyncPerformed, RemoteHost = host, RemotePort = port }; return(DoSendAsync(this.networkStream, assoc)); }