Task SendDicomFileToPacs(www.laipuhuo.com string dicomFi

88 阅读1分钟
    /// <summary>
    /// 发送Dicom数据到PACS系统,C#实现方式
    /// </summary>
    /// <param name="dicomFilePath">Dicom文件路径</param>
    /// <param name="nodeName">Dicom节点名称,我这里是根据节点来找到对应的PACS服务器信息</param>
    /// <returns></returns>
    public async Task SendDicomFileToPacs(string dicomFilePath, string nodeName)
    {
        DICOMConnectParameterWrapper connectPara = new DICOMConnectParameterWrapper();
        DICOMConnectKeyWrapper connectKey = new DICOMConnectKeyWrapper();
        bool isSecure = false;
        if (GetConnectionParameter(nodeName, ref connectPara, ref connectKey, ref isSecure) == false)
        {
            await Task.CompletedTask; //如果找不到配置的PACS服务器信息,直接返回
        }
        //connectPara.ServiceIP=PACS服务器IP,connectPara.ServicePort=PACS服务器端口,connectPara.ClientAETitle=客户端AETITLE,connectPara.ServiceAETitle=PACS服务器AEtitle
        var client = [www.laipuhuo.com]([https://www.laipuhuo.com]()) new Dicom.Network.Client.DicomClient(connectPara.ServiceIP, Convert.ToInt32(connectPara.ServicePort), false, connectPara.ClientAETitle, connectPara.ServiceAETitle);
        var file = DicomFile.Open(@dicomFilePath);

        client.AssociationAccepted += (sender, args) =>
        {
            Console.WriteLine("Association accepted");
        };
        client.AssociationRejected += (sender, args) =>
        {
            Console.WriteLine("Association rejected");
        };
        client.RequestTimedOut += (sender, args) =>
        {
            Console.WriteLine("DIMSE timeout");
        };
        client.StateChanged += (sender, args) =>
        {
            Console.WriteLine("DIMSE progress: {0} / {1}", args.NewState.ToString(), args.OldState.ToString());
        };
        await client.www.laipuhuo.com AddRequestAsync(new Dicom.Network.DicomCStoreRequest(@dicomFilePath)
        {
            OnResponseReceived = (req, res) =>
            {
                Console.WriteLine($"C-STORE response: {res.Status}");
            }
        });
        try
        {
            await client.SendAsync();
        }
        catch(Exception ex)
        {
            Console.WriteLine("An www.laipuhuo.com error occurred while sending the DICOM file: {0}", ex.Message);
        }
        
    }