protected override void OnReceiveNEventReportResponse(byte presentationID, ushort messageIdRespondedTo,
                                                              DicomUID affectedClass, DicomUID affectedInstance, ushort eventTypeID, DcmDataset dataset, DcmStatus status)
        {
            if (affectedClass == DicomUID.PrintJobSOPClass)
            {
                DcmPrintJob job = null;

                foreach (DcmPrintJob pj in _jobs)
                {
                    if (pj.SOPInstanceUID == affectedInstance)
                    {
                        job = pj;
                        break;
                    }
                }

                if (job != null && (job.ExecutionStatus == "DONE" || job.ExecutionStatus == "FAILURE"))
                {
                    _jobs.Remove(job);
                }

                return;
            }
        }
Example #2
0
        protected override void OnReceiveNGetRequest(byte presentationID, ushort messageID,
            DicomUID requestedClass, DicomUID requestedInstance, DicomTag[] attributes)
        {
            if (requestedClass == DicomUID.PrinterSOPClass && requestedInstance == DicomUID.PrinterSOPInstance) {
                DcmDataset ds = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);
                ds.AddElementWithValue(DicomTags.PrinterStatus, "NORMAL");
                ds.AddElementWithValue(DicomTags.PrinterStatus, "NORMAL");
                ds.AddElementWithValue(DicomTags.PrinterName, _config.PrinterName);
                ds.AddElementWithValue(DicomTags.Manufacturer, "N/A");
                ds.AddElementWithValue(DicomTags.ManufacturersModelName, "N/A");
                ds.AddElementWithValue(DicomTags.DeviceSerialNumber, "N/A");
                ds.AddElementWithValue(DicomTags.SoftwareVersions, "N/A");
                ds.SetDateTime(DicomTags.DateOfLastCalibration, DicomTags.TimeOfLastCalibration, DateTime.Now);

                SendNGetResponse(presentationID, messageID, requestedClass, requestedInstance, ds, DcmStatus.Success);
                return;
            }

            if (requestedClass == DicomUID.PrintJobSOPClass) {
                DcmPrintJob job = null;

                foreach (DcmPrintJob pj in _jobs) {
                    if (pj.SOPInstanceUID == requestedInstance) {
                        job = pj;
                        break;
                    }
                }

                if (job == null) {
                    job = new DcmPrintJob(requestedInstance);
                    job.ExecutionStatus = "DONE";
                    job.CreationDateTime = DateTime.Today;
                    job.PrintPriority = _session.PrintPriority;
                    job.PrinterName = _config.PrinterName;
                    job.Originator = Associate.CallingAE;
                }

                SendNGetResponse(presentationID, messageID, requestedClass, requestedInstance, job.Dataset, DcmStatus.Success);
                return;
            }

            if (requestedClass == DicomUID.PrinterConfigurationRetrievalSOPClass && requestedInstance == DicomUID.PrinterConfigurationRetrievalSOPInstance) {
                DcmDataset ds = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);
                DcmDataset config = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);

                DcmItemSequence sq = new DcmItemSequence(DicomTags.PrinterConfigurationSequence);
                sq.AddSequenceItem(config);
                ds.AddItem(sq);

                SendNGetResponse(presentationID, messageID, requestedClass, requestedInstance, ds, DcmStatus.Success);
                return;
            }

            SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
        }
        protected override void OnReceiveNGetRequest(byte presentationID, ushort messageID,
                                                     DicomUID requestedClass, DicomUID requestedInstance, DicomTag[] attributes)
        {
            if (requestedClass == DicomUID.PrinterSOPClass && requestedInstance == DicomUID.PrinterSOPInstance)
            {
                DcmDataset ds = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);
                ds.AddElementWithValue(DicomTags.PrinterStatus, "NORMAL");
                ds.AddElementWithValue(DicomTags.PrinterStatus, "NORMAL");
                ds.AddElementWithValue(DicomTags.PrinterName, _config.PrinterName);
                ds.AddElementWithValue(DicomTags.Manufacturer, "N/A");
                ds.AddElementWithValue(DicomTags.ManufacturersModelName, "N/A");
                ds.AddElementWithValue(DicomTags.DeviceSerialNumber, "N/A");
                ds.AddElementWithValue(DicomTags.SoftwareVersions, "N/A");
                ds.SetDateTime(DicomTags.DateOfLastCalibration, DicomTags.TimeOfLastCalibration, DateTime.Now);

                SendNGetResponse(presentationID, messageID, requestedClass, requestedInstance, ds, DcmStatus.Success);
                return;
            }

            if (requestedClass == DicomUID.PrintJobSOPClass)
            {
                DcmPrintJob job = null;

                foreach (DcmPrintJob pj in _jobs)
                {
                    if (pj.SOPInstanceUID == requestedInstance)
                    {
                        job = pj;
                        break;
                    }
                }

                if (job == null)
                {
                    job = new DcmPrintJob(requestedInstance);
                    job.ExecutionStatus  = "DONE";
                    job.CreationDateTime = DateTime.Today;
                    job.PrintPriority    = _session.PrintPriority;
                    job.PrinterName      = _config.PrinterName;
                    job.Originator       = Associate.CallingAE;
                }

                SendNGetResponse(presentationID, messageID, requestedClass, requestedInstance, job.Dataset, DcmStatus.Success);
                return;
            }

            if (requestedClass == DicomUID.PrinterConfigurationRetrievalSOPClass && requestedInstance == DicomUID.PrinterConfigurationRetrievalSOPInstance)
            {
                DcmDataset ds     = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);
                DcmDataset config = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);


                DcmItemSequence sq = new DcmItemSequence(DicomTags.PrinterConfigurationSequence);
                sq.AddSequenceItem(config);
                ds.AddItem(sq);

                SendNGetResponse(presentationID, messageID, requestedClass, requestedInstance, ds, DcmStatus.Success);
                return;
            }

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