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


C# DicomAttributeCollection.CalculateWriteLength方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:75,代码来源:NetworkBase.cs

示例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);
            }
        }
开发者ID:scottshea,项目名称:monodicom,代码行数:66,代码来源:NetworkBase.cs


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