ChangeTransferSyntax() public method

public ChangeTransferSyntax ( DicomTransferSyntax newTransferSyntax, DcmCodecParameters parameters ) : void
newTransferSyntax DicomTransferSyntax
parameters DcmCodecParameters
return void
示例#1
0
        private bool SendDimse(byte pcid, DcmCommand command, DcmDataset dataset)
        {
            try {
                _disableTimeout = true;

                DicomTransferSyntax ts = _assoc.GetAcceptedTransferSyntax(pcid);

                if (dataset != null && ts != dataset.InternalTransferSyntax) {
                    if (ts.IsEncapsulated || dataset.InternalTransferSyntax.IsEncapsulated)
                        throw new DicomNetworkException("Unable to transcode encapsulated transfer syntax!");
                    dataset.ChangeTransferSyntax(ts, null);
                }

                DcmDimseProgress progress = new DcmDimseProgress();

                progress.EstimatedCommandLength = (int)command.CalculateWriteLength(DicomTransferSyntax.ImplicitVRLittleEndian, DicomWriteOptions.Default | DicomWriteOptions.CalculateGroupLengths);

                if (dataset != null)
                    progress.EstimatedDatasetLength = (int)dataset.CalculateWriteLength(ts, DicomWriteOptions.Default);

                PDataTFStream pdustream = new PDataTFStream(_network, pcid, (int)_assoc.MaximumPduLength);
                pdustream.OnPduSent += delegate() {
                    progress.BytesTransfered = pdustream.BytesSent;
                    OnSendDimseProgress(pcid, command, dataset, progress);
                };

                lock (_socket) {
                    OnSendDimseBegin(pcid, command, dataset, progress);

                    DicomStreamWriter dsw = new DicomStreamWriter(pdustream);
                    dsw.Write(command, DicomWriteOptions.Default | DicomWriteOptions.CalculateGroupLengths);

                    if (dataset != null) {
                        pdustream.IsCommand = false;
                        dsw.Write(dataset, DicomWriteOptions.Default);
                    }

                    // flush last pdu
                    pdustream.Flush(true);

                    OnSendDimse(pcid, command, dataset, progress);
                }

                return true;
            }
            catch (Exception e) {
            #if DEBUG
                Log.Error("{0} -> Error sending DIMSE: {1}", LogID, e.ToString());
            #else
                Log.Error("{0} -> Error sending DIMSE: {1}", LogID, e.Message);
            #endif
                OnNetworkError(e);
                return false;
            }
            finally {
                _disableTimeout = false;
            }
        }
示例#2
0