public void Apply(DcmAssociate associate) { foreach (DcmPresContext pc in associate.GetPresentationContexts()) { if (pc.Result == DcmPresContextResult.Proposed) { if (AbstractSyntaxes.Contains(pc.AbstractSyntax.UID)) { IList <DicomTransferSyntax> txs = pc.GetTransfers(); for (int i = 0; i < txs.Count; i++) { if (TransferSyntaxes.Contains(txs[i].UID.UID)) { if (!DicomUID.IsImageStorage(pc.AbstractSyntax) && DicomTransferSyntax.IsImageCompression(txs[i])) { continue; } pc.SetResult(DcmPresContextResult.Accept, txs[i]); break; } } if (pc.Result != DcmPresContextResult.Accept) { pc.SetResult(DcmPresContextResult.RejectTransferSyntaxesNotSupported); } } else { pc.SetResult(DcmPresContextResult.RejectAbstractSyntaxNotSupported); } } } }
protected override void OnConnected() { if (OnCStoreConnected != null) { try { OnCStoreConnected(this); } catch (Exception e) { Log.Error("Unhandled exception in user C-Store Connected Callback: {0}", e.Message); } } if (PendingCount > 0) { DcmAssociate associate = new DcmAssociate(); lock (_lock) { foreach (DicomUID uid in _presContextMap.Keys) { if (_preferredTransferSyntax != null) { if (!_presContextMap[uid].Contains(_preferredTransferSyntax)) { _presContextMap[uid].Remove(_preferredTransferSyntax); } _presContextMap[uid].Insert(0, _preferredTransferSyntax); } if (_offerExplicit && !_presContextMap[uid].Contains(DicomTransferSyntax.ExplicitVRLittleEndian)) { _presContextMap[uid].Add(DicomTransferSyntax.ExplicitVRLittleEndian); } if (!_presContextMap[uid].Contains(DicomTransferSyntax.ImplicitVRLittleEndian)) { _presContextMap[uid].Add(DicomTransferSyntax.ImplicitVRLittleEndian); } if (!DicomUID.IsImageStorage(uid)) { List <DicomTransferSyntax> remove = new List <DicomTransferSyntax>(); foreach (DicomTransferSyntax tx in _presContextMap[uid]) { if (DicomTransferSyntax.IsImageCompression(tx)) { remove.Add(tx); } } foreach (DicomTransferSyntax tx in remove) { _presContextMap[uid].Remove(tx); } } } if (SerializedPresentationContexts) { foreach (DicomUID uid in _presContextMap.Keys) { foreach (DicomTransferSyntax ts in _presContextMap[uid]) { byte pcid = associate.AddPresentationContext(uid); associate.AddTransferSyntax(pcid, ts); } } } else { foreach (DicomUID uid in _presContextMap.Keys) { byte pcid = associate.AddOrGetPresentationContext(uid); foreach (DicomTransferSyntax ts in _presContextMap[uid]) { associate.AddTransferSyntax(pcid, ts); } } } } associate.CalledAE = CalledAE; associate.CallingAE = CallingAE; associate.MaximumPduLength = MaxPduSize; SendAssociateRequest(associate); } else { Close(); } }