Ejemplo n.º 1
0
        private DicomNGetResponse GetPrintJob(DicomNGetRequest request)
        {
            if (_printJobList.ContainsKey(request.SOPInstanceUID.UID))
            {
                var printJob = _printJobList[request.SOPInstanceUID.UID];

                var sb = new System.Text.StringBuilder();

                var dataset = new DicomDataset();

                if (request.Attributes != null && request.Attributes.Length > 0)
                {
                    foreach (var item in request.Attributes)
                    {
                        sb.AppendFormat("GetPrintJob attribute {0} requested", item);
                        sb.AppendLine();
                        var value = printJob.Get(item, "");
                        dataset.Add(item, value);
                    }

                    Logger.Info(sb.ToString());
                }

                var response = new DicomNGetResponse(request, DicomStatus.Success);
                response.Dataset = dataset;
                return(response);
            }
            else
            {
                var response = new DicomNGetResponse(request, DicomStatus.NoSuchObjectInstance);
                return(response);
            }
        }
Ejemplo n.º 2
0
        public DicomNGetResponse OnNGetRequest(DicomNGetRequest request)
        {
            lock (_synchRoot)
            {
                this.Logger.Info(request.ToString(true));

                if (request.SOPClassUID == DicomUID.PrinterSOPClass &&
                    request.SOPInstanceUID == DicomUID.PrinterSOPInstance)
                {
                    return(GetPrinter(request));
                }
                else if (request.SOPClassUID == DicomUID.PrintJobSOPClass)
                {
                    return(GetPrintJob(request));
                }
                else if (request.SOPClassUID == DicomUID.PrinterConfigurationRetrievalSOPClass &&
                         request.SOPInstanceUID == DicomUID.PrinterConfigurationRetrievalSOPInstance)
                {
                    return(GetPrinterConfiguration(request));
                }
                else
                {
                    return(new DicomNGetResponse(request, DicomStatus.NoSuchSOPClass));
                }
            }
        }
        public async Task OnNGetRequestAsync_ShouldRespond()
        {
            var port = Ports.GetNext();

            using (DicomServerFactory.Create <AsyncDicomNServiceProvider>(port, logger: _logger.IncludePrefix("DicomServer")))
            {
                var client = DicomClientFactory.Create("127.0.0.1", port, false, "SCU", "ANY-SCP");
                client.Logger = _logger.IncludePrefix(typeof(DicomClient).Name);

                DicomNGetResponse response = null;
                DicomRequest.OnTimeoutEventArgs timeout = null;
                var request = new DicomNGetRequest(
                    DicomUID.BasicFilmSession,
                    new DicomUID("1.2.3", null, DicomUidType.SOPInstance))
                {
                    OnResponseReceived = (req, res) => response = res,
                    OnTimeout          = (sender, args) => timeout = args
                };

                await client.AddRequestAsync(request).ConfigureAwait(false);

                await client.SendAsync().ConfigureAwait(false);

                Assert.NotNull(response);
                Assert.Equal(DicomStatus.Success, response.Status);
                Assert.Null(timeout);
            }
        }
Ejemplo n.º 4
0
        public async Task <DicomNGetResponse> OnNGetRequestAsync(DicomNGetRequest request)
        {
            lock (_synchRoot)
            {
                Logger.Info(request.ToString(true));

                if (request.SOPClassUID == DicomUID.Printer &&
                    request.SOPInstanceUID == DicomUID.PrinterInstance)
                {
                    return(GetPrinter(request));
                }
                else if (request.SOPClassUID == DicomUID.PrintJob)
                {
                    return(GetPrintJob(request));
                }
                else if (request.SOPClassUID == DicomUID.PrinterConfigurationRetrieval &&
                         request.SOPInstanceUID == DicomUID.PrinterConfigurationRetrievalInstance)
                {
                    return(GetPrinterConfiguration(request));
                }
                else
                {
                    return(new DicomNGetResponse(request, DicomStatus.NoSuchSOPClass));
                }
            }
        }
Ejemplo n.º 5
0
        private DicomNGetResponse GetPrinterConfiguration(DicomNGetRequest request)
        {
            var dataset = new DicomDataset();
            var config  = new DicomDataset();

            var sequence = new DicomSequence(DicomTag.PrinterConfigurationSequence, config);

            dataset.Add(sequence);

            var response = new DicomNGetResponse(request, DicomStatus.Success);

            response.Command.Add(DicomTag.AffectedSOPInstanceUID, request.SOPInstanceUID);
            response.Dataset = dataset;
            return(response);
        }
Ejemplo n.º 6
0
        private DicomNGetResponse GetPrinter(DicomNGetRequest request)
        {
            var ds = new DicomDataset();

            var sb = new StringBuilder();

            if (request.Attributes != null && request.Attributes.Length > 0)
            {
                foreach (var item in request.Attributes)
                {
                    sb.AppendFormat("GetPrinter attribute {0} requested", item);
                    sb.AppendLine();
                    var value = Printer.GetSingleValueOrDefault(item, "");
                    ds.Add(item, value);
                }

                Logger.Info(sb.ToString());
            }
            if (!ds.Any())
            {
                ds.Add(DicomTag.PrinterStatus, Printer.PrinterStatus);
                ds.Add(DicomTag.PrinterStatusInfo, "");
                ds.Add(DicomTag.PrinterName, Printer.PrinterName);
                ds.Add(DicomTag.Manufacturer, Printer.Manufacturer);
                ds.Add(DicomTag.DateOfLastCalibration, Printer.DateTimeOfLastCalibration.Date);
                ds.Add(DicomTag.TimeOfLastCalibration, Printer.DateTimeOfLastCalibration);
                ds.Add(DicomTag.ManufacturerModelName, Printer.ManufacturerModelName);
                ds.Add(DicomTag.DeviceSerialNumber, Printer.DeviceSerialNumber);
                ds.Add(DicomTag.SoftwareVersions, Printer.SoftwareVersions);
            }

            var response = new DicomNGetResponse(request, DicomStatus.Success)
            {
                Dataset = ds
            };

            Logger.Info(response.ToString(true));
            return(response);
        }
Ejemplo n.º 7
0
        private DicomNGetResponse GetPrinter(DicomNGetRequest request)
        {
            var ds = new DicomDataset();

            var sb = new System.Text.StringBuilder();

            if (request.Attributes != null && request.Attributes.Length > 0)
            {
                foreach (var item in request.Attributes)
                {
                    sb.AppendFormat("GetPrinter attribute {0} requested", item);
                    sb.AppendLine();
                    var value = "undefine";
                    ds.Add(item, value);
                }

                Logger.Info(sb.ToString());
            }
            if (ds.Count() == 0)
            {
                ds.Add(DicomTag.PrinterStatus, "");
                ds.Add(DicomTag.PrinterStatusInfo, "");
                ds.Add(DicomTag.PrinterName, "");
                ds.Add(DicomTag.Manufacturer, "");
                ds.Add(DicomTag.DateOfLastCalibration, "");
                ds.Add(DicomTag.TimeOfLastCalibration, "");
                ds.Add(DicomTag.ManufacturerModelName, "");
                ds.Add(DicomTag.DeviceSerialNumber, "");
                ds.Add(DicomTag.SoftwareVersions, "");
            }

            var response = new DicomNGetResponse(request, DicomStatus.Success);

            response.Dataset = ds;

            LogManager.Instance.Info(response.ToString(true));
            return(response);
        }
Ejemplo n.º 8
0
 public async Task <DicomNGetResponse> OnNGetRequestAsync(DicomNGetRequest request)
 {
     Logger.Log(LogLevel.Info, "receiving N-Get, not supported");
     return(new DicomNGetResponse(request, DicomStatus.UnrecognizedOperation));
 }
Ejemplo n.º 9
0
 public DicomNGetResponse(DicomNGetRequest request, DicomStatus status)
     : base(request, status)
 {
     SOPInstanceUID = request.SOPInstanceUID;
 }
Ejemplo n.º 10
0
 public DicomNGetResponse(DicomNGetRequest request, DicomStatus status)
     : base(request, status)
 {
     SOPInstanceUID = request.SOPInstanceUID;
 }
Ejemplo n.º 11
0
 public DicomNGetResponse OnNGetRequest(DicomNGetRequest request)
 {
     throw new NotImplementedException();
 }
 public Task <DicomNGetResponse> OnNGetRequestAsync(DicomNGetRequest request)
 => Task.FromResult(new DicomNGetResponse(request, DicomStatus.Success)
 {
     Dataset = request.Dataset
 });
Ejemplo n.º 13
0
 public Task <DicomNGetResponse> OnNGetRequestAsync(DicomNGetRequest request) => throw new NotImplementedException();
Ejemplo n.º 14
0
 public DicomNGetResponse OnNGetRequest(DicomNGetRequest request)
 {
     return(null);
 }
Ejemplo n.º 15
0
 public DicomNGetResponse OnNGetRequest(DicomNGetRequest request)
 {
     Logger.Log(LogLevel.Info, "receiving N-Get, not supported");
     Log.Loger("receiving N-Get, not supported");
     return(new DicomNGetResponse(request, DicomStatus.UnrecognizedOperation));
 }