Beispiel #1
0
        /// <summary>
        /// Performs the find request to the specified remote dicom server with the specified attributes.
        /// </summary>
        /// <param name="clientAETitle">The client AE title.</param>
        /// <param name="remoteAE">The remote AE.</param>
        /// <param name="remoteHost">The remote host.</param>
        /// <param name="remotePort">The remote port.</param>
        /// <param name="requestAttributeCollection">The request attribute collection.</param>
        /// <returns></returns>
        public IList <DicomAttributeCollection> Find(string clientAETitle, string remoteAE, string remoteHost, int remotePort, DicomAttributeCollection requestAttributeCollection)
        {
            if (requestAttributeCollection == null)
            {
                throw new ArgumentNullException("requestAttributeCollection");
            }

            _requestAttributeCollection = requestAttributeCollection;
            if (!ValidateQuery())
            {
                throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Invalid query for SCU type {0}", GetType().FullName.Substring(GetType().FullName.LastIndexOf(".") + 1)));
            }

            _results = new List <DicomAttributeCollection>();

            if (ReuseAssociation && Status == ScuOperationStatus.Running)
            {
                ProgressEvent.Reset();

                SendFindRequest(_dicomClient, _associationParameters);

                ProgressEvent.WaitOne();
            }
            else
            {
                ClientAETitle = clientAETitle;
                RemoteAE      = remoteAE;
                RemoteHost    = remoteHost;
                RemotePort    = remotePort;

                Connect();
            }

            return(_results);
        }
Beispiel #2
0
        /// <summary>
        ///     Connects to specified server with the specified information.
        /// </summary>
        /// <remarks>
        ///     Note this calls <see cref="SetPresentationContexts" /> to get the list of presentation
        ///     contexts for the association request, so this method should be overwritten in the subclass.
        /// </remarks>
        protected void Connect()
        {
            try
            {
                if (_dicomClient != null)
                {
                    // TODO: Dispose of properly...
                    CloseDicomClient();
                }

                if (string.IsNullOrEmpty(ClientAETitle) || string.IsNullOrEmpty(RemoteAE) ||
                    string.IsNullOrEmpty(RemoteHost) || RemotePort == 0)
                {
                    throw new InvalidOperationException("Client and/or Remote info not specified.");
                }

                AssociationParameters =
                    new ClientAssociationParameters(ClientAETitle, RemoteAE, RemoteHost, RemotePort);

                AssociationParameters.ReadTimeout  = ReadTimeout;
                AssociationParameters.WriteTimeout = WriteTimeout;

                SetPresentationContexts();

                Status       = ScuOperationStatus.Running;
                _dicomClient = DicomClient.Connect(AssociationParameters, this);
                _dicomClient.LogInformation = LogInformation;
                ProgressEvent.WaitOne();
            }
            catch (Exception ex)
            {
                Status             = ScuOperationStatus.ConnectFailed;
                FailureDescription = ex.Message;
                LogAdapter.Logger.Error("Exception attempting connection to RemoteHost {0} ({1}:{2})", RemoteAE,
                                        RemoteHost, RemotePort);
                throw;
            }
        }