///// <summary> ///// Sends a request for DIMSE association to a DICOM service ///// </summary> ///// <param name="asc">the underlying association</param> ///// <param name="abstractSyntax">the proposed abstract syntaxes (what should the service be able to do)</param> public static void SendRequest(Association asc, params string[] abstractSyntaxes) { var request = new Request {CalledEntityTitle = asc.AeTitle, CallingEntityTitle = asc.ServiceClass.ApplicationEntity.AeTitle}; abstractSyntaxes.Select((a, i) => new {a, i}) .ToList() .ForEach(a => { var pres = new PresentationContext { AbstractSyntax = a.a, Id = a.i*2 + 1, //Convention of odd numbers Reason = PresentationContextReason.ACCEPTANCE, TransferSyntaxes = asc.ServiceClass.SupportedTransferSyntaxes }; request.PresentationContexts.Add(pres); }); asc.PresentationContexts.AddRange(request.PresentationContexts); request.UserInfo = new UserInfo(); asc.Logger.Log("--> " + request); asc.SendMessage(request); }
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 RaiseAssociationRequestReceived(Request req, Association asc) { if (AssociationRequestReceived != null) { AssociationRequestReceived(req, asc); } }
public static Message<Request> ReadAssociationRequest(NetworkBinaryReader dr) { var rq = new Request(); rq.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)) { rq.ProtocolVersion = LengthReader.ReadBigEndian(sub, 2); sub.Skip(2); //Reserved Null Bytes rq.CalledEntityTitle = sub.ReadString(16).Trim(); rq.CallingEntityTitle = sub.ReadString(16).Trim(); sub.Skip(32); //Reserved Null Bytes rq.ApplicationContext = ItemReader.ReadApplicationContext(sub); while (sub.Peek(1)[0] == (byte)ItemType.PRESENTATION_CONTEXT_REQUEST) { PresentationContext context = ItemReader.ReadPresentationCtxRequest(sub); rq.PresentationContexts.Add(context); } rq.UserInfo = ItemReader.ReadUserInfo(sub); } return new Message<Request> { Payload = rq, Type = MessageType.PDU }; }