本文整理汇总了C#中DicomAttributeCollection.CalculateWriteLength方法的典型用法代码示例。如果您正苦于以下问题:C# DicomAttributeCollection.CalculateWriteLength方法的具体用法?C# DicomAttributeCollection.CalculateWriteLength怎么用?C# DicomAttributeCollection.CalculateWriteLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DicomAttributeCollection
的用法示例。
在下文中一共展示了DicomAttributeCollection.CalculateWriteLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendDimse
/// <summary>
/// Method for sending a DIMSE mesage.
/// </summary>
/// <param name="pcid"></param>
/// <param name="command"></param>
/// <param name="dataset"></param>
private void SendDimse(byte pcid, DicomAttributeCollection command, DicomAttributeCollection dataset)
{
try
{
TransferSyntax ts = _assoc.GetAcceptedTransferSyntax(pcid);
uint total =
command.CalculateWriteLength(TransferSyntax.ImplicitVrLittleEndian,
DicomWriteOptions.Default | DicomWriteOptions.CalculateGroupLengths);
if (dataset != null && !dataset.IsEmpty())
total += dataset.CalculateWriteLength(ts, DicomWriteOptions.Default);
PDataTFStream pdustream;
if (_assoc.RemoteMaximumPduLength == 0 || _assoc.RemoteMaximumPduLength > _assoc.LocalMaximumPduLength)
pdustream = new PDataTFStream(this, pcid, _assoc.LocalMaximumPduLength, total, NetworkSettings.Default.CombineCommandDataPdu);
else
pdustream = new PDataTFStream(this, pcid, _assoc.RemoteMaximumPduLength, total, NetworkSettings.Default.CombineCommandDataPdu);
pdustream.OnTick += delegate
{
OnSendDimseProgress(pcid, command, dataset);
if (DimseMessageSending != null)
DimseMessageSending(_assoc, pcid, command, dataset);
};
// Introduced lock as risk mitigation for ticket #10147. Note that a more thorough locking
// mechanism should be developed to work across PDU types, and also should take into account
// if we do end up using _multiThreaded = true
lock (_writeSyncLock)
{
LogSendReceive(false, command, dataset);
OnSendDimseBegin(pcid, command, dataset);
var dsw = new DicomStreamWriter(pdustream);
dsw.Write(TransferSyntax.ImplicitVrLittleEndian,
command, DicomWriteOptions.Default | DicomWriteOptions.CalculateGroupLengths);
if ((dataset != null) && !dataset.IsEmpty())
{
pdustream.IsCommand = false;
dsw.Write(ts, dataset, DicomWriteOptions.Default);
}
// flush last pdu
pdustream.Flush(true);
}
_assoc.TotalBytesSent += total;
OnDimseSent(pcid, command, dataset);
}
catch (Exception e)
{
OnNetworkError(e, true);
// TODO
// Should we throw another exception here? Should the user know there's an error? They'll get
// the error reported to them through the OnNetworkError routine, and throwing an exception here
// might cause us to call OnNetworkError a second time, because the exception may be caught at a higher
// level
// Note, when fixing defect #8184, realized that throwing an exception here would cause
// failures in the ImageServer, because there are places where we wouldn't catch the
// exception. Should be careful if this is ever introduced back in.
//throw new DicomException("Unexpected exception when sending a DIMSE message",e);
}
}
示例2: SendDimse
/// <summary>
/// Method for sending a DIMSE mesage.
/// </summary>
/// <param name="pcid"></param>
/// <param name="command"></param>
/// <param name="dataset"></param>
private void SendDimse(byte pcid, DicomAttributeCollection command, DicomAttributeCollection dataset)
{
try
{
TransferSyntax ts = _assoc.GetAcceptedTransferSyntax(pcid);
uint total =
command.CalculateWriteLength(TransferSyntax.ImplicitVrLittleEndian,
DicomWriteOptions.Default | DicomWriteOptions.CalculateGroupLengths);
if (dataset != null && !dataset.IsEmpty())
total += dataset.CalculateWriteLength(ts, DicomWriteOptions.Default);
PDataTFStream pdustream;
if (_assoc.RemoteMaximumPduLength == 0 || _assoc.RemoteMaximumPduLength > _assoc.LocalMaximumPduLength)
pdustream = new PDataTFStream(this, pcid, _assoc.LocalMaximumPduLength, total, NetworkSettings.Default.CombineCommandDataPdu);
else
pdustream = new PDataTFStream(this, pcid, _assoc.RemoteMaximumPduLength, total, NetworkSettings.Default.CombineCommandDataPdu);
pdustream.OnTick += delegate
{
OnSendDimseProgress(pcid, command, dataset);
if (DimseMessageSending != null)
DimseMessageSending(_assoc, pcid, command, dataset);
};
LogSendReceive(false, command, dataset);
OnSendDimseBegin(pcid, command, dataset);
DicomStreamWriter dsw = new DicomStreamWriter(pdustream);
dsw.Write(TransferSyntax.ImplicitVrLittleEndian,
command, DicomWriteOptions.Default | DicomWriteOptions.CalculateGroupLengths);
if ((dataset != null) && !dataset.IsEmpty())
{
pdustream.IsCommand = false;
dsw.Write(ts, dataset, DicomWriteOptions.Default);
}
// flush last pdu
pdustream.Flush(true);
_assoc.TotalBytesSent += total;
OnDimseSent(pcid, command, dataset);
}
catch (Exception e)
{
OnNetworkError(e, true);
// TODO
// Should we throw another exception here? Should the user know there's an error? They'll get
// the error reported to them through the OnNetworkError routine, and throwing an exception here
// might cause us to call OnNetworkError a second time, because the exception may be caught at a higher
// level
//throw new DicomException("Unexpected exception when sending a DIMSE message",e);
}
}