Exemplo n.º 1
0
		/// <summary>
		/// Called when received response message.
		/// </summary>
		/// <param name="client">The client.</param>
		/// <param name="association">The association.</param>
		/// <param name="presentationID">The presentation ID.</param>
		/// <param name="message">The message.</param>
		public override void OnReceiveResponseMessage(DicomClient client, ClientAssociationParameters association, byte presentationID, DicomMessage message)
		{
			try
			{
				this.ResultStatus = message.Status.Status;
				switch (this.ResultStatus)
				{
					case DicomState.Cancel:
					case DicomState.Pending:
					case DicomState.Failure:
						Platform.Log(LogLevel.Error, string.Format("{0} status received in Print Scu response message", message.Status.Status));

						this.FailureDescription = SR.MessagePrinterError;
						this.ReleaseConnection(client);
						return;

					case DicomState.Warning:
						Platform.Log(LogLevel.Warn, string.Format("{0} status received in Print Scu response message", message.Status.Status));
						break;

					case DicomState.Success:
						break;
				}

				EventsHelper.Fire(this.ProgressUpdated, this, new ProgressUpdateEventArgs(_numberOfImageBoxesSent));

				if (Canceled)
				{
					Platform.Log(LogLevel.Info, "Cancel requested by user.  Closing association.");
					client.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.NotSpecified);
					return;
				}

				Platform.Log(LogLevel.Info, "Success status received in Print Scu");

				var affectedUid = new DicomUid(message.AffectedSopInstanceUid, "Instance UID", UidType.SOPInstance);

				switch (message.CommandField)
				{
					case DicomCommandField.NCreateResponse:
						switch (_eventObject)
						{
							case EventObject.FilmSession:
								_filmSession.OnCreated(affectedUid);
								break;
							case EventObject.FilmBox:
								{
									var responseFilmBoxModule = new BasicFilmBoxModuleIod(message.DataSet);
									_filmSession.OnFilmBoxCreated(affectedUid,
										CollectionUtils.Map<ReferencedInstanceSequenceIod, DicomUid>(
											responseFilmBoxModule.ReferencedImageBoxSequenceList,
											imageBoxModule => new DicomUid(imageBoxModule.ReferencedSopInstanceUid, "Instance UID", UidType.SOPInstance)
										));
								}
								break;
						}

						break;

					case DicomCommandField.NDeleteResponse:
						switch (_eventObject)
						{
							case EventObject.FilmSession:
								_filmSession.OnDeleted();
								this.ReleaseConnection(client);
								break;
							case EventObject.FilmBox:
								_filmSession.OnFilmBoxDeleted();
								break;
						}

						break;

					case DicomCommandField.NSetResponse:
						_numberOfImageBoxesSent++;
						_filmSession.OnImageBoxSet(affectedUid);
						break;

					case DicomCommandField.NActionResponse:
						_filmSession.OnFilmBoxPrinted(affectedUid);

						break;
					default:
						break;
				}
			}
			catch (Exception ex)
			{
				this.FailureDescription = ex.Message;
				Platform.Log(LogLevel.Error, ex.ToString());
				ReleaseConnection(client);
				throw;
			}
		}
Exemplo n.º 2
0
        /// <summary>
        /// Begins the print asynchronously.
        /// </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="basicFilmSessionModuleIod">The basic film session module iod.</param>
        /// <param name="basicFilmBoxModuleIod">The basic film box module iod.</param>
        /// <param name="imageBoxPixelModuleIods">The image box pixel module iods.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="asyncState">State of the async.</param>
        /// <returns></returns>
        public IAsyncResult BeginPrint(string clientAETitle, string remoteAE, string remoteHost, int remotePort, BasicFilmSessionModuleIod basicFilmSessionModuleIod, BasicFilmBoxModuleIod basicFilmBoxModuleIod, IList<ImageBoxPixelModuleIod> imageBoxPixelModuleIods, AsyncCallback callback, object asyncState)
        {
            PrintDelegate printDelegate = new PrintDelegate(this.Print);

            return printDelegate.BeginInvoke(clientAETitle, remoteAE, remoteHost, remotePort, basicFilmSessionModuleIod, basicFilmBoxModuleIod, imageBoxPixelModuleIods, callback, asyncState);
        }
Exemplo n.º 3
0
        private void SendSetImageBoxRequest(DicomClient client, ClientAssociationParameters association)
        {
            if (_currentImageBoxIndex >= _imageBoxPixelModuleIods.Count)
            {
                // done sending images box - send print request
                _nextRequestType = RequestType.PrintAction;
                SendActionPrintRequest(client, association);
            }
            else
            {
                // want to get first film box response - although not sure if CC is using .net 3.5.. prolly not so do it old way
                IEnumerator<DicomAttributeCollection> filmBoxResponseEnumerator = _filmBoxResponseMessages.Values.GetEnumerator();
                filmBoxResponseEnumerator.Reset();
                filmBoxResponseEnumerator.MoveNext();

                BasicFilmBoxModuleIod basicFilmBoxModuleIod = new BasicFilmBoxModuleIod(filmBoxResponseEnumerator.Current);

                if (_currentImageBoxIndex > basicFilmBoxModuleIod.ReferencedImageBoxSequenceList.Count)
                {
                    throw new DicomException("Current Image Box Index is greater than number of Referenced ImageBox Sequences - set image box data");
                }

                ImageBoxPixelModuleIod imageBoxPixelModuleIod = _imageBoxPixelModuleIods[_currentImageBoxIndex];

                DicomMessage newRequestMessage = new DicomMessage(null, (DicomAttributeCollection)imageBoxPixelModuleIod.DicomAttributeProvider);
                newRequestMessage.RequestedSopClassUid = SopClass.BasicGrayscaleImageBoxSopClassUid;
                newRequestMessage.RequestedSopInstanceUid = basicFilmBoxModuleIod.ReferencedImageBoxSequenceList[_currentImageBoxIndex].ReferencedSopInstanceUid;

                byte pcid = association.FindAbstractSyntax(SopClass.BasicGrayscalePrintManagementMetaSopClass);

                _currentImageBoxIndex++;
                client.SendNSetRequest(pcid, client.NextMessageID(), newRequestMessage);
            }

        }
Exemplo n.º 4
0
 /// <summary>
 /// Prints with the specified parameters.
 /// </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="basicFilmSessionModuleIod">The basic film session module iod.</param>
 /// <param name="basicFilmBoxModuleIod">The basic film box module iod.</param>
 /// <param name="imageBoxPixelModuleIods">The image box pixel module iods.</param>
 public DicomState Print(string clientAETitle, string remoteAE, string remoteHost, int remotePort, BasicFilmSessionModuleIod basicFilmSessionModuleIod, BasicFilmBoxModuleIod basicFilmBoxModuleIod, IList<ImageBoxPixelModuleIod> imageBoxPixelModuleIods)
 {
     _results = null;
     _filmSessionUid = null;
     _basicFilmSessionModuleIod = basicFilmSessionModuleIod;
     _basicFilmBoxModuleIod = basicFilmBoxModuleIod;
     _imageBoxPixelModuleIods = imageBoxPixelModuleIods;
     _filmBoxResponseMessages.Clear();
     _currentImageBoxIndex = 0;
     _filmBoxUids.Clear();
     Connect(clientAETitle, remoteAE, remoteHost, remotePort);
     if (Status == ScuOperationStatus.AssociationRejected || Status == ScuOperationStatus.Failed || Status == ScuOperationStatus.ConnectFailed ||
         Status == ScuOperationStatus.NetworkError || Status == ScuOperationStatus.TimeoutExpired)
         return DicomState.Failure;
     return ResultStatus;
 }