public static List<PDataTF> GetPDataTFs(AbstractDIMSEBase dimse, PresentationContext pContext, int maxPDULength = 16384) { var list = new List<PDataTF>(); var commandEls = dimse.Elements; list.Add(new PDataTF(new DICOMObject(dimse.Elements), true, true, pContext)); var dataDIMSE = dimse as AbstractDIMSE; if (dataDIMSE != null && dataDIMSE.Data != null) { List<byte[]> chunks = GetChunks(dataDIMSE.Data, maxPDULength, pContext); chunks .Select((c, i) => new PDataTF(c, i == chunks.Count - 1, false, pContext)) .ToList() .ForEach(list.Add); } return list; }
public static List<PDataTF> GetPDataTFs(AbstractDIMSEBase dimse, Association asc, PresentationContext pContext = null) { pContext = pContext ?? asc.PresentationContexts.First(a => a.AbstractSyntax == dimse.AffectedSOPClassUID); var list = new List<PDataTF>(); var commandEls = dimse.Elements; list.Add(new PDataTF(new DICOMObject(dimse.Elements), true, true, pContext)); var dataDIMSE = dimse as AbstractDIMSE; if (dataDIMSE != null && dataDIMSE.Data != null) { List<byte[]> chunks = GetChunks(dataDIMSE.Data, asc.UserInfo.MaxPDULength, asc); chunks .Select( (c, i) => new PDataTF(c, i == chunks.Count - 1, false, asc.PresentationContexts.First(a => a.AbstractSyntax == dimse.AffectedSOPClassUID))) .ToList() .ForEach(list.Add); } return list; }
public static void Send(AbstractDIMSEBase dimse, Association asc, PresentationContext pContext = null) { if (asc.State != NetworkState.TRANSPORT_CONNECTION_OPEN) { asc.OutboundMessages.Enqueue(dimse); AssociationMessenger.SendRequest(asc, dimse.AffectedSOPClassUID); } else { asc.Logger.Log("--> DIMSE" + dimse.GetLogString()); dimse.LogData(asc); var stream = asc.Stream; List<PDataTF> pds = GetPDataTFs(dimse, asc, pContext); if (pds.Count > 0 && stream.CanWrite) { foreach (PDataTF pd in pds) { byte[] message = pd.Write(); stream.Write(message, 0, message.Length); } } } }