public static void SendAccept(Accept accept, Association asc) { var stream = asc.Stream; byte[] message = accept.Write(); asc.Logger.Log("-->" + accept); stream.Write(message, 0, message.Length); }
public static void SetFinalContexts(this Association asc, Accept accept) { List<PresentationContext> final = new List<PresentationContext>(); foreach (var ctx in asc.PresentationContexts) { var accepted = accept.PresentationContexts.FirstOrDefault(p => p.Id == ctx.Id); if (accepted != null && accepted.Reason == Enums.PresentationContextReason.ACCEPTANCE) { ctx.TransferSyntaxes.Clear(); ctx.TransferSyntaxes.Add(accepted.TransferSyntaxes.First()); final.Add(ctx); } } asc.PresentationContexts = final; }
public static Accept Generate(Request request, List <PresentationContext> contexts) { var accept = new Accept { ApplicationContext = request.ApplicationContext, CalledEntityTitle = request.CalledEntityTitle, CallingEntityTitle = request.CallingEntityTitle, PresentationContexts = contexts, ProtocolVersion = request.ProtocolVersion, UserInfo = new UserInfo { AsynchronousOperations = null, ImplementationUID = Constants.EVIL_DICOM_IMP_UID, ImplementationVersion = Constants.EVIL_DICOM_IMP_VERSION, MaxPDULength = request.UserInfo.MaxPDULength } }; return(accept); }
public static Accept Generate(Request request, List<PresentationContext> contexts) { var accept = new Accept { ApplicationContext = request.ApplicationContext, CalledEntityTitle = request.CalledEntityTitle, CallingEntityTitle = request.CallingEntityTitle, PresentationContexts = contexts, ProtocolVersion = request.ProtocolVersion, UserInfo = new UserInfo { AsynchronousOperations = null, ImplementationUID = Constants.EVIL_DICOM_IMP_UID, ImplementationVersion = Constants.EVIL_DICOM_IMP_VERSION, MaxPDULength = request.UserInfo.MaxPDULength } }; return accept; }
public void RaiseAssociationAcceptanceReceived(Accept acc, Association asc) { if (AssociationAcceptanceReceived != null) { AssociationAcceptanceReceived(acc, asc); } }
public static Message<Accept> ReadAssociationAccept(NetworkBinaryReader dr) { var acc = new Accept(); acc.PresentationContexts = new List<PresentationContext>(); dr.Skip(1); //PDU ID and Reserved Null Byte int length = LengthReader.ReadBigEndian(dr.Take(4)); using (DICOMBinaryReader sub = dr.GetSubStream(length)) { acc.ProtocolVersion = LengthReader.ReadBigEndian(sub, 2); sub.Skip(2); //Reserved Null Bytes acc.CalledEntityTitle = sub.ReadString(16).Trim(); acc.CallingEntityTitle = sub.ReadString(16).Trim(); sub.Skip(32); //Reserved Null Bytes acc.ApplicationContext = ItemReader.ReadApplicationContext(sub); while (sub.Peek(1).First() == (byte)ItemType.PRESENTATION_CONTEXT_ACCEPT) { PresentationContext context = ItemReader.ReadPresentationCtxAccept(sub); if (context != null) { acc.PresentationContexts.Add(context); } } acc.UserInfo = ItemReader.ReadUserInfo(sub); } return new Message<Accept> { Payload = acc, Type = MessageType.PDU }; }