1

我正在使用 FoDicom 示例解决方案中的 QueryRetrieve SCU 项目...

FoDicom 样本

代码永远不会命中 SaveImage 方法。我正在查询www.dicomserver.co.uk以获取示例图像...我对此很陌生,不知所措。我错过了什么?

            var client = DicomClientFactory.Create(_qrServerHost, _qrServerPort, false, _aet, _qrServerAET);
        client.NegotiateAsyncOps();

        // Find a list of Studies

        var request = CreateStudyRequestByPatientName("Cooper");

        var studyUids = new List<string>();
        request.OnResponseReceived += (req, response) =>
        {
            studyUids.Add(response.Dataset?.GetSingleValue<string>(DicomTag.StudyInstanceUID));
        };
        await client.AddRequestAsync(request);
        await client.SendAsync();

        // find all series from a study that previous was returned
        var studyUID = studyUids[0];
        request = CreateSeriesRequestByStudyUID(studyUID);

        var serieUids = new List<string>();
        request.OnResponseReceived += (req, response) =>
        {
            serieUids.Add(response.Dataset?.GetSingleValue<string>(DicomTag.SeriesInstanceUID));
        };
        await client.AddRequestAsync(request);
        await client.SendAsync();

        // now get all the images of a serie with cGet in the same association

        client = DicomClientFactory.Create(_qrServerHost, _qrServerPort, false, _aet, _qrServerAET);

        var cGetRequest = CreateCGetBySeriesUID(studyUID, serieUids.First());
        client.OnCStoreRequest += (DicomCStoreRequest req) =>
        {
            Console.WriteLine(DateTime.Now.ToString() + " recived");
            SaveImage(req.Dataset);
            return Task.FromResult(new DicomCStoreResponse(req, DicomStatus.Success));
        };

        // the client has to accept storage of the images. We know that the requested images are of SOP class Secondary capture, 
        // so we add the Secondary capture to the additional presentation context
        // a more general approach would be to mace a cfind-request on image level and to read a list of distinct SOP classes of all
        // the images. these SOP classes shall be added here.
        var pcs = DicomPresentationContext.GetScpRolePresentationContextsFromStorageUids(
            DicomStorageCategory.Image,
            DicomTransferSyntax.ExplicitVRLittleEndian,
            DicomTransferSyntax.ImplicitVRLittleEndian,
            DicomTransferSyntax.ImplicitVRBigEndian);
        client.AdditionalPresentationContexts.AddRange(pcs);
        await client.AddRequestAsync(cGetRequest);
        await client.SendAsync();
4

1 回答 1

2

我禁用了我需要的部分代码。我添加了一段我需要它启动的代码...//客户端必须接受图像的存储...。

于 2021-10-14T18:48:44.530 回答