本文整理汇总了C#中ClearCanvas.Dicom.DicomMessage类的典型用法代码示例。如果您正苦于以下问题:C# DicomMessage类的具体用法?C# DicomMessage怎么用?C# DicomMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DicomMessage类属于ClearCanvas.Dicom命名空间,在下文中一共展示了DicomMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReceiveMessageAsFileStream
public override bool ReceiveMessageAsFileStream(Dicom.Network.DicomServer server, ServerAssociationParameters association, byte presentationId,
DicomMessage message)
{
var sopClassUid = message.AffectedSopClassUid;
if (sopClassUid.Equals(SopClass.BreastTomosynthesisImageStorageUid)
|| sopClassUid.Equals(SopClass.EnhancedCtImageStorageUid)
|| sopClassUid.Equals(SopClass.EnhancedMrColorImageStorageUid)
|| sopClassUid.Equals(SopClass.EnhancedMrImageStorageUid)
|| sopClassUid.Equals(SopClass.EnhancedPetImageStorageUid)
|| sopClassUid.Equals(SopClass.EnhancedUsVolumeStorageUid)
|| sopClassUid.Equals(SopClass.EnhancedXaImageStorageUid)
|| sopClassUid.Equals(SopClass.EnhancedXrfImageStorageUid)
|| sopClassUid.Equals(SopClass.UltrasoundMultiFrameImageStorageUid)
|| sopClassUid.Equals(SopClass.MultiFrameGrayscaleByteSecondaryCaptureImageStorageUid)
|| sopClassUid.Equals(SopClass.MultiFrameGrayscaleWordSecondaryCaptureImageStorageUid)
|| sopClassUid.Equals(SopClass.MultiFrameSingleBitSecondaryCaptureImageStorageUid)
|| sopClassUid.Equals(SopClass.MultiFrameTrueColorSecondaryCaptureImageStorageUid))
{
server.DimseDatasetStopTag = DicomTagDictionary.GetDicomTag(DicomTags.ReconstructionIndex); // Random tag at the end of group 20
server.StreamMessage = true;
return true;
}
return false;
}
示例2: SaveStreamData
public bool SaveStreamData(DicomMessage message, byte[] data, int offset, int count)
{
var importer = new SopInstanceImporter(_importContext);
var sopInstanceUid = message.DataSet[DicomTags.SopInstanceUid].GetString(0, string.Empty);
if (_fileStream == null)
{
if (!importer.GetStreamedFileStorageFolder(message, out _sourceFolder, out _filesystemStreamingFolder))
{
Platform.Log(LogLevel.Warn, "Unable to create a folder to save SOP Instance, rejecting: {0}", sopInstanceUid);
return false;
}
_sourceFilename = Path.Combine(_sourceFolder, Guid.NewGuid().ToString() + ServerPlatform.DicomFileExtension);
try
{
_fileStream = FileStreamOpener.OpenForSoleUpdate(_sourceFilename, FileMode.Create);
}
catch (Exception x)
{
Platform.Log(LogLevel.Warn, x, "Unable to open file for saving filestream: {0}", _sourceFilename);
return false;
}
}
_fileStream.Write(data, offset, count);
return true;
}
示例3: SaveStreamData
public bool SaveStreamData(DicomMessage message, byte[] data, int offset, int length)
{
if (_rejectFile) return true;
if (_fileStream == null)
{
_sourceFolder = _context.StorageConfiguration.FileStoreIncomingFolder;
_sourceFilename = Path.Combine(_sourceFolder, Guid.NewGuid().ToString() + ".cc");
try
{
_fileStream = FileStreamOpener.OpenForSoleUpdate(_sourceFilename, FileMode.Create);
}
catch (Exception x)
{
Platform.Log(LogLevel.Warn, x, "Unable to open file for saving filestream: {0}", _sourceFilename);
return false;
}
}
_fileStream.Write(data, offset, length);
return true;
}
示例4: 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);
}
}
}
}
示例5: PopulateInstance
/// <summary>
/// Populate at the IMAGE level a response message.
/// </summary>
/// <param name="request"></param>
/// <param name="response"></param>
/// <param name="tagList"></param>
/// <param name="theInstanceStream"></param>
private void PopulateInstance(DicomAttributeCollection request, DicomMessage response, List<uint> tagList,
InstanceXml theInstanceStream)
{
DicomAttributeCollection dataSet = response.DataSet;
dataSet[DicomTags.RetrieveAeTitle].SetStringValue(Partition.AeTitle);
dataSet[DicomTags.InstanceAvailability].SetStringValue("ONLINE");
DicomAttributeCollection sourceDataSet = theInstanceStream.Collection;
if (false == sourceDataSet.Contains(DicomTags.SpecificCharacterSet))
{
dataSet[DicomTags.SpecificCharacterSet].SetStringValue(sourceDataSet[DicomTags.SpecificCharacterSet].ToString());
dataSet.SpecificCharacterSet = sourceDataSet[DicomTags.SpecificCharacterSet].ToString(); // this will ensure the data is encoded using the specified character set
}
foreach (uint tag in tagList)
{
try
{
switch (tag)
{
case DicomTags.PatientId:
dataSet[DicomTags.PatientId].SetStringValue(request[DicomTags.PatientId].ToString());
break;
case DicomTags.StudyInstanceUid:
dataSet[DicomTags.StudyInstanceUid].SetStringValue(
request[DicomTags.StudyInstanceUid].ToString());
break;
case DicomTags.SeriesInstanceUid:
dataSet[DicomTags.SeriesInstanceUid].SetStringValue(
request[DicomTags.SeriesInstanceUid].ToString());
break;
case DicomTags.QueryRetrieveLevel:
dataSet[DicomTags.QueryRetrieveLevel].SetStringValue("IMAGE");
break;
default:
if (sourceDataSet.Contains(tag))
dataSet[tag] = sourceDataSet[tag].Copy();
else
dataSet[tag].SetNullValue();
break;
// Meta tags that should have not been in the RQ, but we've already set
case DicomTags.RetrieveAeTitle:
case DicomTags.InstanceAvailability:
case DicomTags.SpecificCharacterSet:
break;
}
}
catch (Exception e)
{
Platform.Log(LogLevel.Warn, e, "Unexpected error setting tag {0} in C-FIND-RSP",
dataSet[tag].Tag.ToString());
dataSet[tag].SetNullValue();
}
}
}
示例6: ConvertToDicomFile
/// <summary>
/// Converts a <see cref="DicomMessage"/> instance into a <see cref="DicomFile"/>.
/// </summary>
/// <remarks>This routine sets the Source AE title, </remarks>
/// <param name="message"></param>
/// <param name="filename"></param>
/// <param name="assocParms"></param>
/// <returns></returns>
protected static DicomFile ConvertToDicomFile(DicomMessage message, string filename, AssociationParameters assocParms)
{
// This routine sets some of the group 0x0002 elements.
DicomFile file = new DicomFile(message, filename);
file.SourceApplicationEntityTitle = assocParms.CallingAE;
file.TransferSyntax = message.TransferSyntax;
return file;
}
示例7: OnStartFilestream
public override IDicomFilestreamHandler OnStartFilestream(Dicom.Network.DicomServer server, ServerAssociationParameters association,
byte presentationId, DicomMessage message)
{
if (_importContext == null)
{
LoadImportContext(association);
}
return new StorageFilestreamHandler(Context, _importContext);
}
示例8: SendCFind
private void SendCFind()
{
DicomMessage msg = new DicomMessage();
DicomAttributeCollection cFindDataset = msg.DataSet;
// set the Query Retrieve Level
cFindDataset[DicomTags.QueryRetrieveLevel].SetStringValue("STUDY");
// set the other tags we want to retrieve
cFindDataset[DicomTags.StudyInstanceUid].SetStringValue("");
cFindDataset[DicomTags.PatientsName].SetStringValue("");
cFindDataset[DicomTags.PatientId].SetStringValue("");
cFindDataset[DicomTags.ModalitiesInStudy].SetStringValue("");
cFindDataset[DicomTags.StudyDescription].SetStringValue("");
byte pcid = _dicomClient.AssociationParams.FindAbstractSyntax(SopClass.StudyRootQueryRetrieveInformationModelFind);
_dicomClient.SendCFindRequest(pcid, _dicomClient.NextMessageID(), msg);
}
示例9: DicomFile
/// <summary>
/// Creates a new DicomFile instance from an existing <see cref="DicomMessage"/> instance.
/// </summary>
/// <remarks>
/// <para>
/// This routine assigns the existing <see cref="DicomMessage.DataSet"/> into the new
/// DicomFile instance.
/// </para>
/// <para>
/// A new <see cref="DicomAttributeCollection"/> is created for the MetaInfo. The
/// Media Storage SOP Instance UID, Media Storage SOP Class UID, Implementation Version Name,
/// and Implementation Class UID tags are automatically set in the meta information.
/// </para>
/// </remarks>
/// <param name="msg"></param>
/// <param name="filename"></param>
public DicomFile(DicomMessage msg, String filename)
{
MetaInfo = new DicomAttributeCollection(0x00020000, 0x0002FFFF);
DataSet = msg.DataSet;
MediaStorageSopInstanceUid = msg.AffectedSopInstanceUid;
MediaStorageSopClassUid = msg.AffectedSopClassUid;
ImplementationVersionName = DicomImplementation.Version;
ImplementationClassUid = DicomImplementation.ClassUID.UID;
if (msg.TransferSyntax.Encapsulated)
MetaInfo[DicomTags.TransferSyntaxUid].SetStringValue(msg.TransferSyntax.UidString);
else
MetaInfo[DicomTags.TransferSyntaxUid].SetStringValue(TransferSyntax.ExplicitVrLittleEndian.UidString);
MetaInfo[DicomTags.FileMetaInformationVersion].Values = new byte[] { 0x00, 0x01 };
_filename = filename;
}
示例10: SendCStore
/// <summary>
/// Generic routine to send the next C-STORE-RQ message in the _fileList.
/// </summary>
/// <param name="client">DICOM Client class</param>
/// <param name="association">Association Parameters</param>
public bool SendCStore(DicomClient client, ClientAssociationParameters association)
{
FileToSend fileToSend = _fileList[_fileListIndex];
DicomFile dicomFile = new DicomFile(fileToSend.filename);
try
{
dicomFile.Load(DicomReadOptions.Default);
}
catch (DicomException e)
{
Logger.LogErrorException(e, "Unexpected exception when loading DICOM file {0}",fileToSend.filename);
return false;
}
DicomMessage msg = new DicomMessage(dicomFile);
byte pcid = association.FindAbstractSyntaxWithTransferSyntax(fileToSend.sopClass, dicomFile.TransferSyntax);
if (pcid == 0)
{
if (dicomFile.TransferSyntax.Equals(TransferSyntax.ImplicitVrLittleEndian))
pcid = association.FindAbstractSyntaxWithTransferSyntax(fileToSend.sopClass, TransferSyntax.ExplicitVrLittleEndian);
if (pcid == 0)
{
Logger.LogError(
"Unable to find matching negotiated presentation context for sop {0} and syntax {1}",
dicomFile.SopClass.Name, dicomFile.TransferSyntax.Name);
return false;
}
}
client.SendCStoreRequest(pcid, client.NextMessageID(), DicomPriority.Medium, msg);
return true;
}
示例11: CompleteStream
public bool CompleteStream(Dicom.Network.DicomServer server, ServerAssociationParameters assoc, byte presentationId, DicomMessage message)
{
DicomProcessingResult result;
var importer = new ImportFilesUtility(_importContext);
if (_rejectFile)
{
result = new DicomProcessingResult();
result.SetError(DicomStatuses.StorageStorageOutOfResources, string.Format("Import failed, disk space usage exceeded"));
string studyInstanceUid = message.DataSet[DicomTags.StudyInstanceUid].GetString(0, string.Empty);
WorkItem workItem;
lock (_importContext.StudyWorkItemsSyncLock)
_importContext.StudyWorkItems.TryGetValue(studyInstanceUid, out workItem);
importer.InsertFailedWorkItemUid(workItem, message, result);
_importContext.FatalError = true;
importer.AuditFailure(result);
Platform.Log(LogLevel.Warn, "Failure receiving sop, out of disk space: {0}", message.AffectedSopInstanceUid);
server.SendCStoreResponse(presentationId, message.MessageId, message.AffectedSopInstanceUid, result.DicomStatus);
return true;
}
try
{
if (_fileStream != null)
{
_fileStream.Flush(true);
_fileStream.Close();
_fileStream.Dispose();
_fileStream = null;
}
// Convert to file to pass in the source filename
var theFile = new DicomFile(message,_sourceFilename);
result = importer.Import(theFile, BadFileBehaviourEnum.Delete, FileImportBehaviourEnum.Move);
if (result.Successful)
{
if (!String.IsNullOrEmpty(result.AccessionNumber))
Platform.Log(LogLevel.Info, "Received SOP Instance {0} from {1} to {2} (A#:{3} StudyUid:{4})",
result.SopInstanceUid, assoc.CallingAE, assoc.CalledAE, result.AccessionNumber,
result.StudyInstanceUid);
else
Platform.Log(LogLevel.Info, "Received SOP Instance {0} from {1} to {2} (StudyUid:{3})",
result.SopInstanceUid, assoc.CallingAE, assoc.CalledAE,
result.StudyInstanceUid);
}
}
catch (Exception e)
{
result = new DicomProcessingResult { DicomStatus = DicomStatuses.ProcessingFailure, ErrorMessage = e.Message };
}
if (!result.Successful)
{
Platform.Log(LogLevel.Warn, "Failure importing sop: {0}", result.ErrorMessage);
}
CleanupFile();
server.SendCStoreResponse(presentationId, message.MessageId, message.AffectedSopInstanceUid, result.DicomStatus);
return true;
}
示例12: AuditLog
/// <summary>
/// Helper method for logging audit information.
/// </summary>
/// <param name="parms"></param>
/// <param name="outcome"></param>
/// <param name="msg">The query message to be audited</param>
private static void AuditLog(AssociationParameters parms, EventIdentificationContentsEventOutcomeIndicator outcome, DicomMessage msg)
{
try
{
var helper = new QueryAuditHelper(ServerPlatform.AuditSource,
outcome, parms, msg.AffectedSopClassUid, msg.DataSet);
ServerPlatform.LogAuditMessage(helper);
}
catch (Exception e)
{
Platform.Log(LogLevel.Warn, "Unexpected exception logging DICOM Query audit message: {0}", e.Message);
}
}
示例13: OnReceiveRequest
public override bool OnReceiveRequest(Dicom.Network.DicomServer server,
ServerAssociationParameters association, byte presentationID, DicomMessage message)
{
string studyInstanceUid;
string seriesInstanceUid;
DicomUid sopInstanceUid;
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)
{
Platform.Log(LogLevel.Error, "Unable to retrieve UIDs from request message, sending failure status.");
server.SendCStoreResponse(presentationID, message.MessageId, sopInstanceUid.UID,
DicomStatuses.ProcessingFailure);
return true;
}
if (_importContext == null)
{
LoadImportContext(association);
}
var importer = new ImportFilesUtility(_importContext);
var result = importer.Import(message, BadFileBehaviourEnum.Ignore, FileImportBehaviourEnum.Save);
if (result.Successful)
{
if (!String.IsNullOrEmpty(result.AccessionNumber))
Platform.Log(LogLevel.Info, "Received SOP Instance {0} from {1} to {2} (A#:{3} StudyUid:{4})",
result.SopInstanceUid, association.CallingAE, association.CalledAE, result.AccessionNumber,
result.StudyInstanceUid);
else
Platform.Log(LogLevel.Info, "Received SOP Instance {0} from {1} to {2} (StudyUid:{3})",
result.SopInstanceUid, association.CallingAE, association.CalledAE,
result.StudyInstanceUid);
server.SendCStoreResponse(presentationID, message.MessageId, message.AffectedSopInstanceUid, result.DicomStatus);
}
else
{
if (result.DicomStatus == DicomStatuses.ProcessingFailure)
Platform.Log(LogLevel.Error, "Failure importing sop: {0}", result.ErrorMessage);
//OnReceiveError(message, result.ErrorMessage, association.CallingAE);
server.SendCStoreResponse(presentationID, message.MessageId, message.AffectedSopInstanceUid,
result.DicomStatus, result.ErrorMessage);
}
return true;
}
示例14: OnReceiveMoveSeriesRequest
private void OnReceiveMoveSeriesRequest(ClearCanvas.Dicom.Network.DicomServer server, byte presentationID, DicomMessage message, IDicomServiceNode remoteAEInfo)
{
string studyInstanceUid = message.DataSet[DicomTags.StudyInstanceUid].GetString(0, "");
var seriesUids = (string[])message.DataSet[DicomTags.SeriesInstanceUid].Values;
lock (_syncLock)
{
int subOperations = 0;
using (var context = new DataAccessContext())
{
var results = context.GetStudyStoreQuery().SeriesQuery(new SeriesIdentifier
{
StudyInstanceUid =
studyInstanceUid,
});
foreach (SeriesIdentifier series in results)
{
foreach (string seriesUid in seriesUids)
if (series.SeriesInstanceUid.Equals(seriesUid) &&
series.NumberOfSeriesRelatedInstances.HasValue)
{
subOperations += series.NumberOfSeriesRelatedInstances.Value;
break;
}
}
var s =
context.GetStudyStoreQuery().StudyQuery(new StudyRootStudyIdentifier
{StudyInstanceUid = studyInstanceUid});
var identifier = CollectionUtils.FirstElement(s);
var client = new DicomSendBridge();
client.SendSeries(remoteAEInfo, identifier, seriesUids, WorkItemPriorityEnum.High);
_sendOperations.Add(new SendOperationInfo(client.WorkItem, message.MessageId, presentationID,
server)
{
SubOperations = subOperations
});
}
}
}
示例15: OnReceiveCancelRequest
private void OnReceiveCancelRequest(DicomMessage message)
{
lock (_syncLock)
{
foreach (SendOperationInfo info in _sendOperations)
{
if (info.MessageId == message.MessageIdBeingRespondedTo)
{
RemoveSendOperationInfo(info);
WorkItemService.WorkItemService.Instance.Update(new WorkItemUpdateRequest
{
Cancel = true,
Identifier = info.WorkItemData.Identifier
});
}
}
}
}