当前位置: 首页>>代码示例>>C#>>正文


C# ServerAssociationParameters.GetPresentationContext方法代码示例

本文整理汇总了C#中ClearCanvas.Dicom.Network.ServerAssociationParameters.GetPresentationContext方法的典型用法代码示例。如果您正苦于以下问题:C# ServerAssociationParameters.GetPresentationContext方法的具体用法?C# ServerAssociationParameters.GetPresentationContext怎么用?C# ServerAssociationParameters.GetPresentationContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ClearCanvas.Dicom.Network.ServerAssociationParameters的用法示例。


在下文中一共展示了ServerAssociationParameters.GetPresentationContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnReceiveRequestMessage

		public void OnReceiveRequestMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, ClearCanvas.Dicom.DicomMessage message)
		{
			foreach (byte pcid in association.GetPresentationContextIDs())
			{
				DicomPresContext context = association.GetPresentationContext(pcid);
				if (context.Result == DicomPresContextResult.Accept)
				{
					if (context.AbstractSyntax == SopClass.StudyRootQueryRetrieveInformationModelFind)
					{
						DicomMessage response = new DicomMessage();
						response.DataSet[DicomTags.StudyInstanceUid].SetStringValue("1.2.3");
						response.DataSet[DicomTags.PatientId].SetStringValue("1");
						response.DataSet[DicomTags.PatientsName].SetStringValue("test");
						response.DataSet[DicomTags.StudyId].SetStringValue("1");
						response.DataSet[DicomTags.StudyDescription].SetStringValue("dummy");
						server.SendCFindResponse(presentationID, message.MessageId, response, DicomStatuses.Pending);

						DicomMessage finalResponse = new DicomMessage();
						server.SendCFindResponse(presentationID, message.MessageId, finalResponse, DicomStatuses.Success);
					}
					else if (context.AbstractSyntax == SopClass.VerificationSopClass)
					{
						server.SendCEchoResponse(presentationID, message.MessageId, DicomStatuses.Success);
					}
				}
			}
		}
开发者ID:nhannd,项目名称:Xian,代码行数:27,代码来源:Form1.cs

示例2: StringBuilder

        //private static void WriteLog(string s)
        //{
        //    File.AppendAllText("C:\\_store.txt", string.Format("{0}\n",s));
        //}

        /// <summary>
        /// Hàm xử lý khi nhận xong dữ liệu Dicom
        /// </summary>
        /// <param name="server"></param>
        /// <param name="association"></param>
        /// <param name="presentationId"></param>
        /// <param name="message"></param>
        void IDicomServerHandler.OnReceiveRequestMessage(DicomServer server, ServerAssociationParameters association,
                                                         byte presentationId, DicomMessage message)
        {
            //wc.Stop();
            //WriteLog(wc.ElapsedMilliseconds.ToString());

            if (message.CommandField == DicomCommandField.CEchoRequest)
            {
                server.SendCEchoResponse(presentationId, message.MessageId, DicomStatuses.Success);
                return;
            }

            String studyInstanceUid = null;
            String seriesInstanceUid = null;
            DicomUid sopInstanceUid;
            //String patientName = null;
            String sex = null;
            sex = message.DataSet[DicomTags.PatientsSex].GetString(0, "O");

            bool ok = message.DataSet[DicomTags.SopInstanceUid].TryGetUid(0, out sopInstanceUid);
            if (ok) ok = message.DataSet[DicomTags.SeriesInstanceUid].TryGetString(0, out seriesInstanceUid);
            if (ok) ok = message.DataSet[DicomTags.StudyInstanceUid].TryGetString(0, out studyInstanceUid);
            //if (ok) ok = message.DataSet[DicomTags.PatientsName].TryGetString(0, out patientName);

            if (!ok)
            {
                VBLogger.LogError("Unable to retrieve UIDs from request message, sending failure status.");

                server.SendCStoreResponse(presentationId, message.MessageId, sopInstanceUid.UID,
                                          DicomStatuses.ProcessingFailure);
                return;
            }
            TransferSyntax syntax = association.GetPresentationContext(presentationId).AcceptedTransferSyntax;

            server.SendCStoreResponse(presentationId, message.MessageId,
                                      sopInstanceUid.UID,
                                      DicomStatuses.Success);
            string pathImage = "";
            var path = new StringBuilder();
            path.AppendFormat("{0}{1}{2}{3}{4}", StorageLocation, Path.DirectorySeparatorChar,
                              studyInstanceUid, Path.DirectorySeparatorChar, seriesInstanceUid);

            try
            {
                // Save File
                if (!Directory.Exists(StorageLocation))
                    Directory.CreateDirectory(StorageLocation);
                if (!Directory.Exists(path.ToString()))
                    Directory.CreateDirectory(path.ToString());
                path.AppendFormat("{0}{1}.dcm", Path.DirectorySeparatorChar, sopInstanceUid.UID);

                var dicomFile = new DicomFile(message, path.ToString())
                                    {
                                        TransferSyntaxUid = syntax.UidString,
                                        MediaStorageSopInstanceUid = sopInstanceUid.UID,
                                        ImplementationClassUid = DicomImplementation.ClassUID.UID,
                                        ImplementationVersionName = DicomImplementation.Version,
                                        SourceApplicationEntityTitle = association.CallingAE,
                                        MediaStorageSopClassUid = message.SopClass.Uid
                                    };
                dicomFile.Save(DicomWriteOptions.None);

                //WriteLog(string.Format("Save File OK!: {0}", wc.ElapsedMilliseconds));

                var pd = new DicomUncompressedPixelData(message.DataSet);
                pathImage = path.ToString();
                byte[] thePixels = pd.GetFrame(0);
                var pixData = new UInt16[thePixels.Length/2];
                int h = dicomFile.DataSet[DicomTags.Rows].GetUInt16(0, 0);
                int w = dicomFile.DataSet[DicomTags.Columns].GetUInt16(0, 0);
                UInt16 max = 0, min = UInt16.MaxValue;
                //min = pd.ge
                unsafe
                {
                    fixed (byte* pixPointer = thePixels)
                    {
                        var pP = (UInt16*) pixPointer;
                        for (int i = 0; i < w*h; ++i)
                        {
                            pixData[i] = *pP;
                            if (min > pixData[i]) min = pixData[i];
                            if (max < pixData[i]) max = pixData[i];
                            pP++;
                        }
                    }
                }
                int indexOf = pathImage.LastIndexOf(".dcm");
                pathImage = pathImage.Substring(0, indexOf);
//.........这里部分代码省略.........
开发者ID:khaha2210,项目名称:radio,代码行数:101,代码来源:StorageScp.cs

示例3: StringBuilder

        void IDicomServerHandler.OnReceiveRequestMessage(DicomServer server, ServerAssociationParameters association, byte presentationID, DicomMessage message)
        {

            if (message.CommandField == DicomCommandField.CEchoRequest)
            {
                server.SendCEchoResponse(presentationID, message.MessageId, DicomStatuses.Success);
                return;
            }

            String studyInstanceUid = null;
            String seriesInstanceUid = null;
            DicomUid sopInstanceUid;
            String patientName = null;

            bool ok = message.DataSet[DicomTags.SopInstanceUid].TryGetUid(0, out sopInstanceUid);
            if (ok) ok = message.DataSet[DicomTags.SeriesInstanceUid].TryGetString(0, out seriesInstanceUid);
            if (ok) ok = message.DataSet[DicomTags.StudyInstanceUid].TryGetString(0, out studyInstanceUid);
            if (ok) ok = message.DataSet[DicomTags.PatientsName].TryGetString(0, out patientName);
		
            if (!ok)
            {
                Platform.Log(LogLevel.Error, "Unable to retrieve UIDs from request message, sending failure status.");

                server.SendCStoreResponse(presentationID, message.MessageId, sopInstanceUid.UID,
                    DicomStatuses.ProcessingFailure);
                return;
            }
            TransferSyntax syntax = association.GetPresentationContext(presentationID).AcceptedTransferSyntax;

            if (List)
            {
                Platform.Log(LogLevel.Info, message.Dump());
            }

            if (Bitbucket)
            {
                Platform.Log(LogLevel.Info, "Received SOP Instance: {0} for patient {1} in syntax {2}", sopInstanceUid,
                             patientName, syntax.Name);

                server.SendCStoreResponse(presentationID, message.MessageId,
                    sopInstanceUid.UID,
                    DicomStatuses.Success);
                return;
            }

            if (!Directory.Exists(StorageLocation))
                Directory.CreateDirectory(StorageLocation);

            var path = new StringBuilder();
            path.AppendFormat("{0}{1}{2}{3}{4}", StorageLocation,  Path.DirectorySeparatorChar,
                studyInstanceUid, Path.DirectorySeparatorChar,seriesInstanceUid);

            Directory.CreateDirectory(path.ToString());

            path.AppendFormat("{0}{1}.dcm", Path.DirectorySeparatorChar, sopInstanceUid.UID);

            var dicomFile = new DicomFile(message, path.ToString())
                                {
                                    TransferSyntaxUid = syntax.UidString,
                                    MediaStorageSopInstanceUid = sopInstanceUid.UID,
                                    ImplementationClassUid = DicomImplementation.ClassUID.UID,
                                    ImplementationVersionName = DicomImplementation.Version,
                                    SourceApplicationEntityTitle = association.CallingAE,
                                    MediaStorageSopClassUid = message.SopClass.Uid
                                };


            dicomFile.Save(DicomWriteOptions.None);

            Platform.Log(LogLevel.Info, "Received SOP Instance: {0} for patient {1} in syntax {2}", sopInstanceUid,
                         patientName, syntax.Name);

            server.SendCStoreResponse(presentationID, message.MessageId,
                sopInstanceUid.UID, 
                DicomStatuses.Success);
        }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:76,代码来源:StorageScp.cs


注:本文中的ClearCanvas.Dicom.Network.ServerAssociationParameters.GetPresentationContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。