private UserMessage CreateUserMessageFromMinderProperties(UserMessage userMessage, SignalMessage signalMessage)
        {
            var receiver =
                new Model.Core.Party(
                    role: $"{MinderUriPrefix}/testdriver",
                    partyId: new Model.Core.PartyId(id: "minder"));

            var collaboration = new CollaborationInfo(
                Maybe <AgreementReference> .Nothing,
                new Service(MinderUriPrefix),
                "Notify",
                CollaborationInfo.DefaultConversationId);

            IEnumerable <MessageProperty> props =
                signalMessage != null
                    ? new[]
            {
                new MessageProperty("RefToMessageId", signalMessage.RefToMessageId),
                new MessageProperty("SignalType", signalMessage.GetType().Name)
            }
                    : Enumerable.Empty <MessageProperty>();

            return(new UserMessage(
                       messageId: userMessage.MessageId,
                       refToMessageId: signalMessage != null ? signalMessage.RefToMessageId : userMessage.RefToMessageId,
                       mpc: userMessage.Mpc,
                       timestamp: DateTimeOffset.Now,
                       collaboration: collaboration,
                       sender: userMessage.Sender,
                       receiver: receiver,
                       partInfos: userMessage.PayloadInfo,
                       messageProperties: userMessage.MessageProperties.Concat(props)));
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="submit"></param>
        /// <param name="sendingPMode"></param>
        /// <returns></returns>
        internal static UserMessage CreateUserMessage(SubmitMessage submit, SendingProcessingMode sendingPMode)
        {
            if (submit == null)
            {
                throw new ArgumentNullException(nameof(submit));
            }

            if (sendingPMode == null)
            {
                throw new ArgumentNullException(nameof(sendingPMode));
            }

            var collaboration = new CollaborationInfo(
                ResolveAgreement(submit, sendingPMode),
                ResolveService(submit, sendingPMode),
                ResolveAction(submit, sendingPMode),
                ResolveConversationId(submit));

            return(new UserMessage(
                       messageId: submit.MessageInfo?.MessageId ?? IdentifierFactory.Instance.Create(),
                       refToMessageId: submit.MessageInfo?.RefToMessageId,
                       timestamp: DateTimeOffset.Now,
                       mpc: ResolveMpc(submit, sendingPMode),
                       collaboration: collaboration,
                       sender: ResolveSenderParty(submit, sendingPMode),
                       receiver: ResolveReceiverParty(submit, sendingPMode),
                       partInfos: ResolvePartInfos(submit, sendingPMode).ToArray(),
                       messageProperties: ResolveMessageProperties(submit, sendingPMode).ToArray()));
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UserMessage"/> class.
        /// </summary>
        /// <param name="messageId">The ebMS message identifier of this message unit.</param>
        /// <param name="refToMessageId">The reference to another ebMS message unit.</param>
        /// <param name="timestamp">The timestamp when this message is created.</param>
        /// <param name="mpc">The message partition channel of this message unit.</param>
        /// <param name="collaboration">The information which describes the business context through a service and action parameter.</param>
        /// <param name="sender">The agreed sender of this user message.</param>
        /// <param name="receiver">The agreed receiver of this user message.</param>
        /// <param name="partInfos">The information which describes the reference to the payloads in the SOAP Body or attachments.</param>
        /// <param name="messageProperties">The properties which offer an extension point to add additional business information.</param>
        internal UserMessage(
            string messageId,
            string refToMessageId,
            DateTimeOffset timestamp,
            string mpc,
            CollaborationInfo collaboration,
            Party sender,
            Party receiver,
            IEnumerable <PartInfo> partInfos,
            IEnumerable <MessageProperty> messageProperties) : base(messageId, refToMessageId, timestamp)
        {
            if (collaboration == null)
            {
                throw new ArgumentNullException(nameof(collaboration));
            }

            if (sender == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }

            if (receiver == null)
            {
                throw new ArgumentNullException(nameof(receiver));
            }

            if (partInfos == null)
            {
                throw new ArgumentNullException(nameof(partInfos));
            }

            if (partInfos.Any(p => p is null))
            {
                throw new ArgumentException(@"One or more PartInfo elements is a 'null' reference", nameof(partInfos));
            }

            if (messageProperties == null)
            {
                throw new ArgumentNullException(nameof(messageProperties));
            }

            if (messageProperties.Any(p => p is null))
            {
                throw new ArgumentException(@"One ore more MessageProperty elements is a 'null' reference", nameof(messageProperties));
            }

            Mpc = mpc ?? Constants.Namespaces.EbmsDefaultMpc;
            CollaborationInfo = collaboration;
            Sender            = sender;
            Receiver          = receiver;

            IsTest = collaboration.Service.Value.Equals(Constants.Namespaces.TestService) &&
                     collaboration.Action.Equals(Constants.Namespaces.TestAction);

            PayloadInfo       = partInfos.AsEnumerable();
            MessageProperties = messageProperties.AsEnumerable();
        }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserMessage"/> class.
 /// </summary>
 /// <param name="messageId">The ebMS message identifier of this message unit.</param>
 /// <param name="collaboration">The information which describes the business context through a service and action parameter.</param>
 /// <param name="sender">The agreed sender of this user message.</param>
 /// <param name="receiver">The agreed receiver of this user message.</param>
 /// <param name="partInfos">The information which describes the reference to the payloads in the SOAP Body or attachments.</param>
 /// <param name="messageProperties">The properties which offer an extension point to add additional business information.</param>
 public UserMessage(
     string messageId,
     CollaborationInfo collaboration,
     Party sender,
     Party receiver,
     IEnumerable <PartInfo> partInfos,
     IEnumerable <MessageProperty> messageProperties)
     : this(messageId, Constants.Namespaces.EbmsDefaultMpc, collaboration, sender, receiver, partInfos, messageProperties)
 {
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserMessage"/> class.
 /// </summary>
 /// <param name="messageId">The ebMS message identifier of this message unit.</param>
 /// <param name="mpc">The message partition channel of this message unit.</param>
 /// <param name="collaboration">The information which describes the business context through a service and action parameter.</param>
 /// <param name="sender">The agreed sender of this user message.</param>
 /// <param name="receiver">The agreed receiver of this user message.</param>
 /// <param name="partInfos">The information which describes the reference to the payloads in the SOAP Body or attachments.</param>
 /// <param name="messageProperties">The properties which offer an extension point to add additional business information.</param>
 public UserMessage(
     string messageId,
     string mpc,
     CollaborationInfo collaboration,
     Party sender,
     Party receiver,
     IEnumerable <PartInfo> partInfos,
     IEnumerable <MessageProperty> messageProperties)
     : this(messageId, null, DateTimeOffset.Now, mpc, collaboration, sender, receiver, partInfos, messageProperties)
 {
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserMessage"/> class.
 /// </summary>
 /// <param name="messageId">The ebMS message identifier of this message unit.</param>
 /// <param name="collaboration">The information which describes the business context through a service and action parameter.</param>
 internal UserMessage(string messageId, CollaborationInfo collaboration)
     : this(messageId, collaboration, Party.DefaultFrom, Party.DefaultTo, new PartInfo[0], new MessageProperty[0])
 {
 }