本文整理汇总了C#中DicomClient类的典型用法代码示例。如果您正苦于以下问题:C# DicomClient类的具体用法?C# DicomClient怎么用?C# DicomClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DicomClient类属于命名空间,在下文中一共展示了DicomClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddFindRequest_NullDicomRequest_ThrowsException
public void AddFindRequest_NullDicomRequest_ThrowsException()
{
// Arrange
var mockProvider = new MockProvider();
var dicomClient = new DicomClient<TestInfo>(mockProvider.GetSettingsProviderFake(), mockProvider.GetRequestAdapterFake());
// Act + Assert
Assert.That(() => dicomClient.AddFindRequest(null), Throws.InstanceOf<ArgumentNullException>());
}
示例2: AddMoveRequest_RequestAdapterIsCalled
public void AddMoveRequest_RequestAdapterIsCalled()
{
// Arrange
var mockProvider = new MockProvider();
var requestAdapter = mockProvider.GetRequestAdapterFake();
var dicomClient = new DicomClient<TestInfo>(mockProvider.GetSettingsProviderFake(), requestAdapter);
var dicomMoveRequest = Substitute.For<IDicomMoveRequest>();
// Act
dicomClient.AddMoveRequest(dicomMoveRequest);
// Assert
Assert.That(() => requestAdapter.Received(1).CreateMoveDicomRequest(dicomMoveRequest), Throws.Nothing);
}
示例3: AddFindRequest_RequestAdapterIsCalled
public void AddFindRequest_RequestAdapterIsCalled()
{
// Arrange
var mockProvider = new MockProvider();
var fellowOakMockProvider = new FellowOakMockProvider();
var requestAdapter = mockProvider.GetRequestAdapterFake();
var dicomClient = new DicomClient<TestInfo>(mockProvider.GetSettingsProviderFake(), requestAdapter);
var dicomFindRequest = new FellowOakDicomFindRequest<TestInfo>(mockProvider.GetDicomMappingFake(),fellowOakMockProvider.GetDicomTagAdapterFake(), mockProvider.GetDicomInfoBuilderFake(), mockProvider.GetGeneralizedInfoProviderFake(), fellowOakMockProvider.GetDicomSopClassUidProviderFake(), c=> {},mockProvider.GetDicomWhereCollectionFake());
// Act
dicomClient.AddFindRequest(dicomFindRequest);
// Assert
Assert.That(() => requestAdapter.Received(1).CreateFindDicomRequest(dicomFindRequest), Throws.Nothing);
}
示例4: OnReceiveRequestMessage
public override void OnReceiveRequestMessage(DicomClient client, ClientAssociationParameters association, byte presentationID, DicomMessage message)
{
try
{
// We only handle NEventReport request messages
if (message.CommandField != DicomCommandField.NEventReportRequest ||
message.AffectedSopClassUid != SopClass.PrinterSopClassUid)
{
base.OnReceiveRequestMessage(client, association, presentationID, message);
return;
}
var printerStatus = IodBase.ParseEnum(message.EventTypeId.ToString(), PrinterStatus.None);
var printerModule = new PrinterModuleIod(message.DataSet);
var logMessage = string.Format("Received NEventReportRequest, Printer Status: {0}, Status Info = {1}", printerStatus,
printerModule.PrinterStatusInfo);
//Always respond.
Client.SendNEventReportResponse(GetPresentationContextId(this.AssociationParameters),
message, new DicomMessage(), DicomStatuses.Success);
switch (printerStatus)
{
case PrinterStatus.Failure:
Platform.Log(LogLevel.Error, logMessage);
this.FailureDescription = SR.MessagePrinterError;
this.ReleaseConnection(client);
return;
case PrinterStatus.Warning:
Platform.Log(LogLevel.Warn, logMessage);
break;
case PrinterStatus.None:
case PrinterStatus.Normal:
default:
Platform.Log(LogLevel.Debug, logMessage);
break;
}
}
catch (Exception ex)
{
this.FailureDescription = ex.Message;
Platform.Log(LogLevel.Error, ex.ToString());
ReleaseConnection(client);
throw;
}
}
示例5: OnReceiveResponseMessage
/// <summary>
/// Called when received response message. Sets the <see cref="Result"/> property as appropriate.
/// </summary>
/// <param name="client">The client.</param>
/// <param name="association">The association.</param>
/// <param name="presentationID">The presentation ID.</param>
/// <param name="message">The message.</param>
public override void OnReceiveResponseMessage(DicomClient client, ClientAssociationParameters association, byte presentationID, DicomMessage message)
{
if (message.Status.Status != DicomState.Success)
{
Platform.Log(LogLevel.Error, "Failure status received in sending verification: {0}", message.Status.Description);
_verificationResult = VerificationResult.Failed;
}
else if (_verificationResult == VerificationResult.Canceled)
{
Platform.Log(LogLevel.Info, "Verification was canceled");
}
else
{
Platform.Log(LogLevel.Info, "Success status received in sending verification!");
_verificationResult = VerificationResult.Success;
}
client.SendReleaseRequest();
StopRunningOperation();
}
示例6: SendVerificationRequest
/// <summary>
/// Generic routine to send the next C-ECHO-RQ message.
/// </summary>
/// <param name="client">DICOM Client class</param>
/// <param name="association">Association Parameters</param>
private void SendVerificationRequest(DicomClient client, ClientAssociationParameters association)
{
byte pcid = association.FindAbstractSyntax(SopClass.VerificationSopClass);
client.SendCEchoRequest(pcid, client.NextMessageID());
}
示例7: OnReceiveResponseMessage
/// <summary>
/// Called when received response message. If there are more files to send, will send them here.
/// </summary>
/// <param name="client">The client.</param>
/// <param name="association">The association.</param>
/// <param name="presentationID">The presentation ID.</param>
/// <param name="message">The message.</param>
public override void OnReceiveResponseMessage(DicomClient client, ClientAssociationParameters association, byte presentationID, DicomMessage message)
{
if (Status == ScuOperationStatus.Canceled)
{
Platform.Log(LogLevel.Info, "Cancel request received, releasing association from {0} to {1}", association.CallingAE, association.CalledAE);
client.SendReleaseRequest();
StopRunningOperation();
return;
}
}
示例8: OnReceiveResponseMessage
/// <summary>
/// Called when received response message.
/// </summary>
/// <param name="client">The client.</param>
/// <param name="association">The association.</param>
/// <param name="presentationID">The presentation ID.</param>
/// <param name="message">The message.</param>
public override void OnReceiveResponseMessage(DicomClient client, ClientAssociationParameters association, byte presentationID, DicomMessage message)
{
base.ResultStatus = message.Status.Status;
if (message.Status.Status == DicomState.Success)
{
this._results = message.DataSet;
}
base.ReleaseConnection(client);
}
示例9: OnDimseTimeout
/// <summary>
/// Called when a timeout occurs waiting for the next message, as specified by <see cref="AssociationParameters.ReadTimeout"/>.
/// </summary>
/// <param name="client">The client.</param>
/// <param name="association">The association.</param>
public override void OnDimseTimeout(DicomClient client, ClientAssociationParameters association)
{
Status = ScuOperationStatus.TimeoutExpired;
FailureDescription =
String.Format("Timeout Expired ({0} seconds) for remote host {1} when processing C-MOVE-RQ, aborting connection", association.ReadTimeout/1000,
RemoteAE);
Platform.Log(LogLevel.Error, FailureDescription);
try
{
client.SendAssociateAbort(DicomAbortSource.ServiceUser, DicomAbortReason.NotSpecified);
}
catch (Exception ex)
{
Platform.Log(LogLevel.Error, ex, "Error aborting association");
}
Platform.Log(LogLevel.Warn, "Completed aborting connection (after DIMSE timeout) from {0} to {1}",
association.CallingAE, association.CalledAE);
ProgressEvent.Set();
}
示例10: SendDeleteFilmSessionRequest
private void SendDeleteFilmSessionRequest(DicomClient client, ClientAssociationParameters association)
{
DicomMessage newRequestMessage = new DicomMessage(null, null);
newRequestMessage.RequestedSopInstanceUid = _filmSessionUid;
newRequestMessage.RequestedSopClassUid = SopClass.BasicFilmSessionSopClassUid;
_nextRequestType = RequestType.Close;
byte pcid = association.FindAbstractSyntaxOrThrowException(SopClass.BasicGrayscalePrintManagementMetaSopClass);
client.SendNDeleteRequest(pcid, client.NextMessageID(), newRequestMessage);
}
示例11: SendDeleteFilmBoxRequest
private void SendDeleteFilmBoxRequest(DicomClient client, ClientAssociationParameters association, DicomMessage responseMessage)
{
if (_filmBoxUids.Count == 0)
{
// no more film boxes left to delete - so send delete film session
SendDeleteFilmSessionRequest(client, association);
}
else
{
string currentFilmBoxUid = _filmBoxUids[0];
_filmBoxUids.Remove(currentFilmBoxUid);
DicomMessage newRequestMessage = new DicomMessage(null, null);
newRequestMessage.RequestedSopInstanceUid = currentFilmBoxUid;
newRequestMessage.RequestedSopClassUid = SopClass.BasicFilmBoxSopClassUid;
newRequestMessage.Priority = DicomPriority.Medium;
_nextRequestType = RequestType.DeleteFilmBox;
byte pcid = association.FindAbstractSyntaxOrThrowException(SopClass.BasicGrayscalePrintManagementMetaSopClass);
client.SendNDeleteRequest(pcid, client.NextMessageID(), newRequestMessage);
}
}
示例12: SendSetImageBoxRequest
private void SendSetImageBoxRequest(DicomClient client, ClientAssociationParameters association)
{
if (_currentImageBoxIndex >= _imageBoxPixelModuleIods.Count)
{
// done sending images box - send print request
_nextRequestType = RequestType.PrintAction;
SendActionPrintRequest(client, association);
}
else
{
// want to get first film box response - although not sure if CC is using .net 3.5.. prolly not so do it old way
IEnumerator<DicomAttributeCollection> filmBoxResponseEnumerator = _filmBoxResponseMessages.Values.GetEnumerator();
filmBoxResponseEnumerator.Reset();
filmBoxResponseEnumerator.MoveNext();
BasicFilmBoxModuleIod basicFilmBoxModuleIod = new BasicFilmBoxModuleIod(filmBoxResponseEnumerator.Current);
if (_currentImageBoxIndex > basicFilmBoxModuleIod.ReferencedImageBoxSequenceList.Count)
{
throw new DicomException("Current Image Box Index is greater than number of Referenced ImageBox Sequences - set image box data");
}
ImageBoxPixelModuleIod imageBoxPixelModuleIod = _imageBoxPixelModuleIods[_currentImageBoxIndex];
DicomMessage newRequestMessage = new DicomMessage(null, (DicomAttributeCollection)imageBoxPixelModuleIod.DicomAttributeProvider);
newRequestMessage.RequestedSopClassUid = SopClass.BasicGrayscaleImageBoxSopClassUid;
newRequestMessage.RequestedSopInstanceUid = basicFilmBoxModuleIod.ReferencedImageBoxSequenceList[_currentImageBoxIndex].ReferencedSopInstanceUid;
byte pcid = association.FindAbstractSyntax(SopClass.BasicGrayscalePrintManagementMetaSopClass);
_currentImageBoxIndex++;
client.SendNSetRequest(pcid, client.NextMessageID(), newRequestMessage);
}
}
示例13: SendCreateFilmBoxRequest
private void SendCreateFilmBoxRequest(DicomClient client, ClientAssociationParameters association, DicomMessage responseMessage)
{
ReferencedInstanceSequenceIod referencedFilmSessionSequence = new ReferencedInstanceSequenceIod();
referencedFilmSessionSequence.ReferencedSopClassUid = SopClass.BasicFilmSessionSopClassUid;
referencedFilmSessionSequence.ReferencedSopInstanceUid = responseMessage.AffectedSopInstanceUid;
_basicFilmBoxModuleIod.ReferencedFilmSessionSequenceList.Add(referencedFilmSessionSequence);
DicomMessage newRequestMessage = new DicomMessage(null, (DicomAttributeCollection)_basicFilmBoxModuleIod.DicomAttributeProvider);
byte pcid = association.FindAbstractSyntaxOrThrowException(SopClass.BasicGrayscalePrintManagementMetaSopClass);
_nextRequestType = RequestType.ImageBox;
client.SendNCreateRequest(DicomUid.GenerateUid(), pcid, client.NextMessageID(), newRequestMessage, DicomUids.BasicFilmBoxSOP);
}
示例14: SendCreateFilmSessionRequest
private void SendCreateFilmSessionRequest(DicomClient client, ClientAssociationParameters association)
{
DicomMessage newRequestMessage = new DicomMessage(null, (DicomAttributeCollection)_basicFilmSessionModuleIod.DicomAttributeProvider);
byte pcid = association.FindAbstractSyntaxOrThrowException(SopClass.BasicGrayscalePrintManagementMetaSopClass);
_nextRequestType = RequestType.FilmBox;
client.SendNCreateRequest(DicomUid.GenerateUid(), pcid, client.NextMessageID(), newRequestMessage, DicomUids.BasicFilmSession);
}
示例15: SendCStore
/// <summary>
/// Generic routine to send the next C-STORE-RQ message in the <see cref="StorageInstanceList"/>.
/// </summary>
/// <param name="client">DICOM Client class</param>
/// <param name="association">Association Parameters</param>
private bool SendCStore(DicomClient client, ClientAssociationParameters association)
{
StorageInstance fileToSend = _storageInstanceList[_fileListIndex];
OnImageStoreStarted(fileToSend);
DicomFile dicomFile;
try
{
// Check to see if image does not exist or is corrupted
if (fileToSend.SendStatus == DicomStatuses.ProcessingFailure)
{
_failureSubOperations++;
_remainingSubOperations--;
OnImageStoreCompleted(fileToSend);
return false;
}
dicomFile = fileToSend.LoadFile();
}
catch (DicomException e)
{
Platform.Log(LogLevel.Error, e, "Unexpected exception when loading DICOM file {0}", fileToSend.Filename);
fileToSend.ExtendedFailureDescription = e.GetType().Name + " " + e.Message;
_failureSubOperations++;
_remainingSubOperations--;
OnImageStoreCompleted(fileToSend);
return false;
}
DicomMessage msg = new DicomMessage(dicomFile);
byte pcid = 0;
if (fileToSend.TransferSyntax.Encapsulated)
{
pcid = association.FindAbstractSyntaxWithTransferSyntax(fileToSend.SopClass, fileToSend.TransferSyntax);
if (DicomCodecRegistry.GetCodec(fileToSend.TransferSyntax) != null)
{
if (pcid == 0)
pcid = association.FindAbstractSyntaxWithTransferSyntax(fileToSend.SopClass,
TransferSyntax.ExplicitVrLittleEndian);
if (pcid == 0)
pcid = association.FindAbstractSyntaxWithTransferSyntax(fileToSend.SopClass,
TransferSyntax.ImplicitVrLittleEndian);
}
}
else
{
if (pcid == 0)
pcid = association.FindAbstractSyntaxWithTransferSyntax(fileToSend.SopClass,
TransferSyntax.ExplicitVrLittleEndian);
if (pcid == 0)
pcid = association.FindAbstractSyntaxWithTransferSyntax(fileToSend.SopClass,
TransferSyntax.ImplicitVrLittleEndian);
}
if (pcid == 0)
{
fileToSend.SendStatus = DicomStatuses.SOPClassNotSupported;
fileToSend.ExtendedFailureDescription = "No valid presentation contexts for file.";
OnImageStoreCompleted(fileToSend);
_failureSubOperations++;
_remainingSubOperations--;
return false;
}
try
{
if (_moveOriginatorAe == null)
client.SendCStoreRequest(pcid, client.NextMessageID(), DicomPriority.Medium, msg);
else
client.SendCStoreRequest(pcid, client.NextMessageID(), DicomPriority.Medium, _moveOriginatorAe,
_moveOriginatorMessageId, msg);
}
catch(DicomNetworkException)
{
throw; //This is a DicomException-derived class that we want to throw.
}
catch(DicomCodecException e)
{
Platform.Log(LogLevel.Error, e, "Unexpected exception when compressing or decompressing file before send {0}", fileToSend.Filename);
fileToSend.SendStatus = DicomStatuses.ProcessingFailure;
fileToSend.ExtendedFailureDescription = "Error decompressing or compressing file before send.";
OnImageStoreCompleted(fileToSend);
_failureSubOperations++;
_remainingSubOperations--;
return false;
}
catch(DicomException e)
//.........这里部分代码省略.........