本文整理汇总了C#中ClientAssociationParameters类的典型用法代码示例。如果您正苦于以下问题:C# ClientAssociationParameters类的具体用法?C# ClientAssociationParameters怎么用?C# ClientAssociationParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientAssociationParameters类属于命名空间,在下文中一共展示了ClientAssociationParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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)
//.........这里部分代码省略.........
示例2: 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();
}
示例3: 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;
}
}
示例4: 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;
}
}
示例5: 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());
}
示例6: 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();
}
示例7: 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);
}
示例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)
{
try
{
base.ResultStatus = message.Status.Status;
if (message.Status.Status == DicomState.Success)
{
if (message.CommandField == DicomCommandField.NCreateResponse && message.AffectedSopClassUid == SopClass.BasicFilmSessionSopClassUid)
{
_filmSessionUid = message.AffectedSopInstanceUid;
}
else if (message.CommandField == DicomCommandField.NCreateResponse && message.AffectedSopClassUid == SopClass.BasicFilmBoxSopClassUid)
{
_filmBoxUids.Add(message.AffectedSopInstanceUid);
_filmBoxResponseMessages.Add(message.AffectedSopInstanceUid, message.DataSet);
}
Platform.Log(LogLevel.Info, "Success status received in Printer Status Scu!");
_results = message.DataSet;
switch (_nextRequestType)
{
case RequestType.FilmBox:
SendCreateFilmBoxRequest(client, association, message);
break;
case RequestType.ImageBox:
SendSetImageBoxRequest(client, association);
break;
case RequestType.PrintAction:
SendActionPrintRequest(client, association);
break;
case RequestType.DeleteFilmBox:
SendDeleteFilmBoxRequest(client, association, message);
break;
case RequestType.DeleteFilmSession:
SendDeleteFilmSessionRequest(client, association);
break;
case RequestType.Close:
base.ReleaseConnection(client);
break;
case RequestType.None:
default:
// TODO: throw error....
break;
}
}
else
{
// TODO: Handle this... check for warnings - they are OK? throw exception on errors... ?
}
}
catch (Exception ex)
{
Platform.Log(LogLevel.Error, ex.ToString());
base.ReleaseConnection(client);
throw;
}
}
示例9: SendCStoreUntilSuccess
/// <summary>
/// Generic routine to continue attempting to send C-STORE-RQ messages in the <see cref="StorageInstanceList"/> until one is successful.
/// </summary>
/// <remarks>
/// <para>
/// This routine will continue attempting to send a C-STORE until one has successfully been sent or all
/// SOP instances in the <see cref="StorageInstanceList"/> have been sent. Possible failures are that
/// a SOP Class was not negotiated, or a failure happened reading the SOP Instance from disk.
/// </para>
/// </remarks>
/// <param name="client">DICOM Client class</param>
/// <param name="association">Association Parameters</param>
private void SendCStoreUntilSuccess(DicomClient client, ClientAssociationParameters association)
{
/// TODO (CR Jun 2012): Probably shouldn't use thread pool threads for potentially long-running operations.
/// Although unlikely, this could exhaust the .NET thread pool.
// Added the background thread as part of ticket #9568. Note that we probably should have some threading
// built into NetworkBase as opposed to here.
ThreadPool.QueueUserWorkItem(delegate
{
try
{
bool ok = SendCStore(client, association);
while (ok == false)
{
Platform.Log(LogLevel.Info, "Attempted to send {0} of {1} instances to {2}.", _fileListIndex + 1, _storageInstanceList.Count, client.AssociationParams.CalledAE);
_fileListIndex++;
if (_fileListIndex >= _storageInstanceList.Count)
{
Platform.Log(LogLevel.Info,
"Completed sending C-STORE-RQ messages, releasing association.");
client.SendReleaseRequest();
StopRunningOperation();
return;
}
/// TODO (CR Jun 2012): Do we need to check for a stop signal?
// TODO (Marmot): Check stop?
// TODO (CR Jun 2012): Stop is checked for in OnReceiveResponseMessage after each c-store-rsp received.
// There's a small chance that every image we're attempting to send wasn't negotiated over the association and it
// takes awhile to go through the list, but the chances of that are small, plus it should be quick.
ok = SendCStore(client, association);
}
}
catch
{
Platform.Log(LogLevel.Error, "Error when sending C-STORE-RQ messages, aborted on-going send operations");
try
{
client.SendAssociateAbort(DicomAbortSource.ServiceProvider, DicomAbortReason.NotSpecified);
StopRunningOperation();
}
catch
{
Platform.Log(LogLevel.Error, "Error attempting to abort association");
}
}
}, null);
}
示例10: 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);
}
}
示例11: 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);
}
示例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: OnReceiveAssociateAccept
/// <summary>
/// Called when received associate accept.
/// </summary>
/// <param name="client">The client.</param>
/// <param name="association">The association.</param>
public override void OnReceiveAssociateAccept(DicomClient client, ClientAssociationParameters association)
{
base.OnReceiveAssociateAccept(client, association);
SendMoveRequest(client, association);
}