Beispiel #1
0
        private void PrintJobProc(object state)
        {
            NPrintState print = (NPrintState)state;

            if (print.Job != null)
            {
                print.Job.ExecutionStatus     = "PRINTING";
                print.Job.ExecutionStatusInfo = "PRINTING";
                SendNEventReportRequest(print.PresentationID, NextMessageID(), DicomUID.PrintJobSOPClass, print.Job.SOPInstanceUID, 2, print.Job.Dataset);
            }

            try {
                print.Document.Print();

                if (print.Job != null)
                {
                    print.Job.ExecutionStatus     = "DONE";
                    print.Job.ExecutionStatusInfo = "SUCCESS";
                    SendNEventReportRequest(print.PresentationID, NextMessageID(), DicomUID.PrintJobSOPClass, print.Job.SOPInstanceUID, 3, print.Job.Dataset);
                }
            } catch (Exception e) {
                if (print.Job != null)
                {
                    print.Job.ExecutionStatus     = "FAILURE";
                    print.Job.ExecutionStatusInfo = e.Message;
                    SendNEventReportRequest(print.PresentationID, NextMessageID(), DicomUID.PrintJobSOPClass, print.Job.SOPInstanceUID, 4, print.Job.Dataset);
                }
            }
        }
Beispiel #2
0
        protected override void OnReceiveNActionRequest(byte presentationID, ushort messageID,
                                                        DicomUID requestedClass, DicomUID requestedInstance, ushort actionTypeID, DcmDataset dataset)
        {
            if (_session == null)
            {
                Log.Error("{0} -> A Basic Film Session does not exist for this association", LogID);
                SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
                return;
            }

            DcmPrintDocument document = new DcmPrintDocument(_config, _session.Clone());

            if (requestedClass == DicomUID.BasicFilmSessionSOPClass && actionTypeID == 0x0001)
            {
                foreach (DcmFilmBox box in _session.BasicFilmBoxes)
                {
                    document.AddFilmBox(box.Clone());
                }
            }

            else if (requestedClass == DicomUID.BasicFilmBoxSOPClass && actionTypeID == 0x0001)
            {
                DcmFilmBox box = _session.FindFilmBox(requestedInstance);
                if (box == null)
                {
                    Log.Error("{0} -> Received N-ACTION request for invalid film box", LogID);
                    SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
                    return;
                }

                document.AddFilmBox(box.Clone());
            }

            else
            {
                SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
            }

            DcmDataset result = null;

            NPrintState state = new NPrintState();

            state.PresentationID = presentationID;
            state.Document       = document;

            //DicomUID jobUid = DicomUID.Generate(_session.SOPInstanceUID, 9999);
            //jobUid = DicomUID.Generate(jobUid, _jobs.Count + 1);

            //DcmPrintJob job = new DcmPrintJob(jobUid);
            //job.ExecutionStatus = "PENDING";
            //job.ExecutionStatusInfo = "QUEUED";
            //job.CreationDateTime = DateTime.Now;
            //job.PrintPriority = _session.PrintPriority;
            //job.PrinterName = Config.Instance.PrinterSettings.PrinterName;
            //job.Originator = Associate.CallingAE;

            //result = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);
            //result.AddReferenceSequenceItem(DicomTags.ReferencedPrintJobSequenceRETIRED, DicomUID.PrintJob, job.SOPInstanceUID);

            //state.Job = job;
            //_jobs.Add(job);

            new Thread(PrintJobProc).Start(state);

            SendNActionResponse(presentationID, messageID, requestedClass, requestedInstance, actionTypeID, result, DcmStatus.Success);

            if (state.Job != null)
            {
                SendNEventReportRequest(presentationID, NextMessageID(), DicomUID.PrintJobSOPClass, state.Job.SOPInstanceUID, 1, state.Job.Dataset);
            }
        }
Beispiel #3
0
		protected override void OnReceiveNActionRequest(byte presentationID, ushort messageID, 
			DicomUID requestedClass, DicomUID requestedInstance, ushort actionTypeID, DcmDataset dataset) {

			if (_session == null) {
				Log.Error("{0} -> A Basic Film Session does not exist for this association", LogID);
				SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
				return;
			}

			DcmPrintDocument document = new DcmPrintDocument(_config, _session.Clone());

			if (requestedClass == DicomUID.BasicFilmSessionSOPClass && actionTypeID == 0x0001) {
				foreach (DcmFilmBox box in _session.BasicFilmBoxes)
					document.AddFilmBox(box.Clone());
			}
			
			else if (requestedClass == DicomUID.BasicFilmBoxSOPClass && actionTypeID == 0x0001) {
				DcmFilmBox box = _session.FindFilmBox(requestedInstance);
				if (box == null) {
					Log.Error("{0} -> Received N-ACTION request for invalid film box", LogID);
					SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
					return;
				}

				document.AddFilmBox(box.Clone());
			}

			else {
				SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
			}

			DcmDataset result = null;

			NPrintState state = new NPrintState();
			state.PresentationID = presentationID;
			state.Document = document;

			//DicomUID jobUid = DicomUID.Generate(_session.SOPInstanceUID, 9999);
			//jobUid = DicomUID.Generate(jobUid, _jobs.Count + 1);

			//DcmPrintJob job = new DcmPrintJob(jobUid);
			//job.ExecutionStatus = "PENDING";
			//job.ExecutionStatusInfo = "QUEUED";
			//job.CreationDateTime = DateTime.Now;
			//job.PrintPriority = _session.PrintPriority;
			//job.PrinterName = Config.Instance.PrinterSettings.PrinterName;
			//job.Originator = Associate.CallingAE;

			//result = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);
			//result.AddReferenceSequenceItem(DicomTags.ReferencedPrintJobSequenceRETIRED, DicomUID.PrintJob, job.SOPInstanceUID);

			//state.Job = job;
			//_jobs.Add(job);
			
			new Thread(PrintJobProc).Start(state);

			SendNActionResponse(presentationID, messageID, requestedClass, requestedInstance, actionTypeID, result, DcmStatus.Success);

			if (state.Job != null) {
				SendNEventReportRequest(presentationID, NextMessageID(), DicomUID.PrintJobSOPClass, state.Job.SOPInstanceUID, 1, state.Job.Dataset);
			}
		}