/// <summary>
 /// Handles the ChannelStatusChange message from a producer.
 /// </summary>
 /// <param name="header">The message header.</param>
 /// <param name="channelStatusChange">The ChannelStatusChange message.</param>
 protected virtual void HandleChannelStatusChange(IMessageHeader header, ChannelStatusChange channelStatusChange)
 {
     Notify(OnChannelStatusChange, header, channelStatusChange);
 }
Example #2
0
        protected override void PersistMessageToStoreImpl(ExtractFileCollectionInfoMessage message, IMessageHeader header)
        {
            if (InCompletedJobCollection(message.ExtractionJobIdentifier))
            {
                throw new ApplicationException("Received an ExtractFileCollectionInfoMessage for a job that is already completed");
            }

            MongoExpectedFilesDoc expectedFilesForKey = MongoExpectedFilesDoc.FromMessage(message, header, _dateTimeProvider);

            _database
            .GetCollection <MongoExpectedFilesDoc>(ExpectedFilesCollectionName(message.ExtractionJobIdentifier))
            .InsertOne(expectedFilesForKey);
        }
Example #3
0
        /// <summary>
        /// Sends a WMLS_DeleteFromStoreResponse message to a customer.
        /// </summary>
        /// <param name="correlatedHeader">The message header that the message to send is correlated with.</param>
        /// <param name="result">The result code.</param>
        /// <param name="suppMsgOut">The supplementary message out.</param>
        /// <param name="extension">The message header extension.</param>
        /// <returns>The sent message on success; <c>null</c> otherwise.</returns>
        public virtual EtpMessage <WMLS_DeleteFromStoreResponse> WMLS_DeleteFromStoreResponse(IMessageHeader correlatedHeader, int result, string suppMsgOut, IMessageHeaderExtension extension = null)
        {
            var body = new WMLS_DeleteFromStoreResponse()
            {
                Result     = result,
                SuppMsgOut = suppMsgOut ?? string.Empty,
            };

            return(SendResponse(body, correlatedHeader, extension: extension));
        }
Example #4
0
        /// <summary>
        /// Handles the OpenChannelResponse message from a customer.
        /// </summary>
        /// <param name="header">The message header.</param>
        /// <param name="message">The OpenChannelResponse message.</param>
        protected virtual void HandleOpenChannelResponse(IMessageHeader header, OpenChannelResponse message)
        {
            var args = Notify(OnOpenChannelResponse, header, message);

            HandleOpenChannelResponse(args);
        }
Example #5
0
 public Message(IMessageHeader theHeader, IContract theBody)
 {
     this.header = theHeader;
     this.body   = theBody;
 }
 /// <summary>
 /// Sends a ChannelData message to a consumer.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="dataItems">The list of <see cref="IDataItem" /> objects.</param>
 /// <param name="messageFlag">The message flag.</param>
 /// <returns>The message identifier.</returns>
 long IStreamingProducer.ChannelData(IMessageHeader request, IList <IDataItem> dataItems, MessageFlags messageFlag)
 {
     return(ChannelData(request, dataItems.Cast <DataItem>().ToList(), messageFlag));
 }
 /// <summary>
 /// Handles the ChangeNotification message from a store.
 /// </summary>
 /// <param name="header">The message header.</param>
 /// <param name="notification">The ChangeNotification message.</param>
 protected virtual void HandleChangeNotification(IMessageHeader header, ChangeNotification notification)
 {
     Notify(OnChangeNotification, header, notification);
 }
 /// <summary>
 /// Handles the ProtocolException message.
 /// </summary>
 /// <param name="header">The message header.</param>
 /// <param name="protocolException">The ProtocolException message.</param>
 protected virtual void HandleProtocolException(IMessageHeader header, IProtocolException protocolException)
 {
     Notify(OnProtocolException, header, protocolException);
     Logger.DebugFormat("[{0}] Protocol exception: {1} - {2}", Session.SessionId, protocolException.ErrorCode, protocolException.ErrorMessage);
 }
        /// <summary>
        /// Notifies subscribers of the specified event handler.
        /// </summary>
        /// <typeparam name="T">The type of the message.</typeparam>
        /// <typeparam name="TContext">The type of the context.</typeparam>
        /// <param name="handler">The message handler.</param>
        /// <param name="header">The message header.</param>
        /// <param name="message">The message body.</param>
        /// <param name="context">The message context.</param>
        /// <returns>The protocol event args.</returns>
        protected ProtocolEventArgs <T, TContext> Notify <T, TContext>(ProtocolEventHandler <T, TContext> handler, IMessageHeader header, T message, TContext context) where T : ISpecificRecord
        {
            var args = new ProtocolEventArgs <T, TContext>(header, message, context);

            handler?.Invoke(this, args);
            return(args);
        }
Example #10
0
        public IMessageContents GetMessage(IMessageHeader header)
        {
            try
            {
                Message msg = queue.ReceiveById(header.Id, new TimeSpan(0, 0, 5), currentTransaction.Transaction);
                if(msg == null)
                    throw new MessagingException("Unable to retreive message: "+header.MessageLabel);

                MessageContents contents = new MessageContents(msg);
                return contents;
            }
            catch(MessageQueueException mqe)
            {
                throw new MessagingException(mqe.Message);
            }
        }
Example #11
0
        public IMessageContents PreviewMessage(IMessageHeader header)
        {
            try
            {
                Message msg = queue.PeekById(header.Id, new TimeSpan(0, 0, 5));
                if(msg == null)
                    throw new MessagingException("MSG no longer exists in the queue.");

                MessageContents contents = new MessageContents(msg);
                return contents;
            }
            catch(MessageQueueException e)
            {
                throw new MessagingException(e.Message);
            }
        }
Example #12
0
 public Mandatory(IMessageHeader header)
 {
     _header = header;
 }
Example #13
0
 protected bool CheckSameOriginRule(IMessageHeader header) {
     if(this.localIp == null) localIp = Utils.GetIpAddress();
     return IgnoreSameOriginMessages && localIp.Equals(header.GetSenderAddress().Address);
 }
 public IMessageBuilder AddHeader(IMessageHeader header, bool mustUnderstand)
 {
     _outgoingMessage.AddHeader(header, mustUnderstand);
     return this;
 }
Example #15
0
        /// <summary>
        /// Sends a ChannelDataFrameSet message to a consumer.
        /// </summary>
        /// <param name="correlatedHeader">The message header that the message to send is correlated with.</param>
        /// <param name="frameSet">The channel data frame set.</param>
        /// <param name="isFinalPart">Whether or not this is the final part of a multi-part message.</param>
        /// <returns>The sent message on success; <c>null</c> otherwise.</returns>
        public virtual EtpMessage <ChannelDataFrameSet> ChannelDataFrameSet(IMessageHeader correlatedHeader, ChannelDataFrameSet frameSet, bool isFinalPart = true)
        {
            var body = frameSet;

            return(SendResponse(body, correlatedHeader, isMultiPart: true, isFinalPart: isFinalPart, isNoData: frameSet?.Data?.Count == 0));
        }
Example #16
0
        /// <summary>
        /// Sends a SubscribeNotificationsResponse message to a customer.
        /// </summary>
        /// <param name="correlatedHeader">The message header that the messages to send are correlated with.</param>
        /// <param name="success">The successes.</param>
        /// <param name="isFinalPart">Whether or not this is the final  of a multi- message.</param>
        /// <param name="extension">The message header extension.</param>
        /// <returns>The sent message on success; <c>null</c> otherwise.</returns>
        public virtual EtpMessage <SubscribeNotificationsResponse> SubscribeNotificationsResponse(IMessageHeader correlatedHeader, IDictionary <string, string> success, bool isFinalPart = true, IMessageHeaderExtension extension = null)
        {
            var body = new SubscribeNotificationsResponse
            {
                Success = success ?? new Dictionary <string, string>(),
            };

            return(SendResponse(body, correlatedHeader, extension: extension, isMultiPart: true, isFinalPart: isFinalPart));
        }
Example #17
0
 /// <summary>
 /// Converts the <see cref="IErrorInfo"/> instance into a <see cref="EtpException"/>.
 /// </summary>
 /// <param name="errorInfo">The <see cref="IErrorInfo"/> instance to convert.</param>
 /// <param name="protocol">The protocol number.</param>
 /// <param name="correlatedHeader">The message header that the exception to send is correlated with, if any.</param>
 /// <returns>The exception.</returns>
 public static EtpException ToException(this IErrorInfo errorInfo, int protocol, IMessageHeader correlatedHeader = null)
 {
     return(new EtpException(protocol, errorInfo, correlatedHeader));
 }
Example #18
0
 /// <summary>
 /// Sends a complete multi- set of SubscribeNotificationsResponse and ProtocolException messages to a customer.
 /// If there are no successes, an empty SubscribeNotificationsRecord message is sent.
 /// If there are no errors, no ProtocolException message is sent.
 /// </summary>
 /// <param name="correlatedHeader">The message header that the messages to send are correlated with.</param>
 /// <param name="success">The successes.</param>
 /// <param name="errors">The errors.</param>
 /// <param name="setFinalPart">Whether or not the final  flag should be set on the last message.</param>
 /// <param name="responseExtension">The message header extension for the SubscribeNotificationsResponse message.</param>
 /// <param name="exceptionExtension">The message header extension for the ProtocolException message.</param>
 /// <returns>The first message sent in the response on success; <c>null</c> otherwise.</returns>
 public virtual EtpMessage <SubscribeNotificationsResponse> SubscribeNotificationsResponse(IMessageHeader correlatedHeader, IDictionary <string, string> success, IDictionary <string, IErrorInfo> errors, bool setFinalPart = true, IMessageHeaderExtension responseExtension = null, IMessageHeaderExtension exceptionExtension = null)
 {
     return(SendMapResponse(SubscribeNotificationsResponse, correlatedHeader, success, errors, setFinalPart: setFinalPart, responseExtension: responseExtension, exceptionExtension: exceptionExtension));
 }
Example #19
0
 public EventArgsMessage(IMessageHeader header, IMessage message)
 {
     this.MessageHeader = header;
     this.Message = message;
 }
Example #20
0
 public bool IsDescendantOf(IMessageHeader other)
 {
     return(Parents != null && Parents.Contains(other.MessageGuid));
 }
 /// <summary>
 /// Handles the DeleteNotification message from a store.
 /// </summary>
 /// <param name="header">The message header.</param>
 /// <param name="notification">The DeleteNotification message.</param>
 protected virtual void HandleDeleteNotification(IMessageHeader header, DeleteNotification notification)
 {
     Notify(OnDeleteNotification, header, notification);
 }
Example #22
0
 /// <summary>
 /// Handles the ChannelDataFrameSet message from a producer.
 /// </summary>
 /// <param name="header">The message header.</param>
 /// <param name="channelDataFrameSet">The ChannelDataFrameSet message.</param>
 protected virtual void HandleChannelDataFrameSet(IMessageHeader header, ChannelDataFrameSet channelDataFrameSet)
 {
     Notify(OnChannelDataFrameSet, header, channelDataFrameSet);
 }
Example #23
0
 /// <summary>
 /// Initializes a new <see cref="EtpMessage"/> instance.
 /// </summary>
 /// <param name="header">The message header</param>
 /// <param name="body">The message body</param>
 /// <param name="extension">The message extension</param>
 public EtpMessage(IMessageHeader header, IEtpMessageBody body, IMessageHeaderExtension extension = null)
 {
     Header    = header;
     Extension = extension;
     Body      = body;
 }
Example #24
0
        /// <summary>
        /// Sends a complete multi-part set of response and ProtocolException messages to a customer.
        /// If there is no content for the positive response, an empty response message is sent.
        /// If there are no errors, no ProtocolException message is sent.
        /// </summary>
        /// <typeparam name="TBody">The response message body type.</typeparam>
        /// <typeparam name="TResponse">The response content type.</typeparam>
        /// <param name="responseMethod">The method to send the response message.</param>
        /// <param name="correlatedHeader">The message header that the messages to send are correlated with.</param>
        /// <param name="response">The response content.</param>
        /// <param name="errors">The errors.</param>
        /// <param name="setFinalPart">Whether or not the final part flag should be set on the last message.</param>
        /// <param name="responseExtension">The message header extension for the OpenChannelsResponse message.</param>
        /// <param name="exceptionExtension">The message header extension for the ProtocolException message.</param>
        /// <returns>The first message sent in the response on success; <c>null</c> otherwise.</returns>
        public virtual EtpMessage <TBody> SendMapResponse <TBody, TResponse>(Func <IMessageHeader, IDictionary <string, TResponse>, bool, IMessageHeaderExtension, EtpMessage <TBody> > responseMethod, IMessageHeader correlatedHeader, IDictionary <string, TResponse> response, IDictionary <string, IErrorInfo> errors, bool setFinalPart = true, IMessageHeaderExtension responseExtension = null, IMessageHeaderExtension exceptionExtension = null)
            where TBody : IEtpMessageBody
        {
            var message = responseMethod(correlatedHeader, response, /* isFinalPart: */ ((errors == null || errors.Count == 0) && setFinalPart), /* extension: */ responseExtension);

            if (message == null)
            {
                return(null);
            }

            if (errors?.Count > 0)
            {
                var ret = ProtocolException(errors, correlatedHeader: correlatedHeader, setFinalPart: setFinalPart, extension: exceptionExtension);
                if (ret == null)
                {
                    return(null);
                }
            }

            return(message);
        }
Example #25
0
        protected override void PersistMessageToStoreImpl(ExtractionRequestInfoMessage message, IMessageHeader header)
        {
            if (InCompletedJobCollection(message.ExtractionJobIdentifier))
            {
                throw new ApplicationException("Received an ExtractionRequestInfoMessage for a job that is already completed");
            }

            MongoExtractJobDoc newJobInfo = MongoExtractJobDoc.FromMessage(message, header, _dateTimeProvider);

            _inProgressJobCollection.InsertOne(newJobInfo);
        }
 /// <summary>
 /// Handles the PutDataArray message from a store.
 /// </summary>
 /// <param name="header">The message header.</param>
 /// <param name="message">The PutDataArray message.</param>
 protected virtual void HandlePutDataArray(IMessageHeader header, PutDataArray message)
 {
     Notify(OnPutDataArray, header, message);
 }
Example #27
0
        protected override void PersistMessageToStoreImpl(ExtractedFileVerificationMessage message, IMessageHeader header)
        {
            if (InCompletedJobCollection(message.ExtractionJobIdentifier))
            {
                throw new ApplicationException("Received an ExtractedFileVerificationMessage for a job that is already completed");
            }

            var newStatus = new MongoFileStatusDoc(
                MongoExtractionMessageHeaderDoc.FromMessageHeader(message.ExtractionJobIdentifier, header, _dateTimeProvider),
                message.DicomFilePath,
                message.OutputFilePath,
                wasAnonymised: true,
                isIdentifiable: message.IsIdentifiable,
                ExtractedFileStatus.Anonymised,
                statusMessage: message.Report);

            _database
            .GetCollection <MongoFileStatusDoc>(StatusCollectionName(message.ExtractionJobIdentifier))
            .InsertOne(newStatus);
        }
 /// <summary>
 /// Handles the GetDataArraySlice message from a store.
 /// </summary>
 /// <param name="header">The message header.</param>
 /// <param name="message">The GetDataArraySlice message.</param>
 protected virtual void HandleGetDataArraySlice(IMessageHeader header, GetDataArraySlice message)
 {
     Notify(OnGetDataArraySlice, header, message);
 }
 /// <summary>
 /// Handles the ChannelData message from a producer.
 /// </summary>
 /// <param name="header">The message header.</param>
 /// <param name="channelData">The ChannelData message.</param>
 protected virtual void HandleChannelData(IMessageHeader header, ChannelData channelData)
 {
     Notify(OnChannelData, header, channelData);
 }
 /// <summary>
 /// Sends a ProtocolException message for a unset type.
 /// </summary>
 /// <param name="handler">The handler.</param>
 /// <param name="header">The message header.</param>
 /// <returns>The message identifier.</returns>
 public static long Unset(this IProtocolHandler handler, IMessageHeader header)
 {
     return(handler.ProtocolException((int)EtpErrorCodes.Unset, "Unset: " + header.MessageType, header.MessageId));
 }
 /// <summary>
 /// Handles the ChannelRemove message from a producer.
 /// </summary>
 /// <param name="header">The message header.</param>
 /// <param name="channelRemove">The ChannelRemove message.</param>
 protected virtual void HandleChannelRemove(IMessageHeader header, ChannelRemove channelRemove)
 {
     Notify(OnChannelRemove, header, channelRemove);
 }
 /// <summary>
 /// Sends a ProtocolException message for a no role type.
 /// </summary>
 /// <param name="handler">The handler.</param>
 /// <param name="header">The message header.</param>
 /// <returns>The message identifier.</returns>
 public static long NoRole(this IProtocolHandler handler, IMessageHeader header)
 {
     return(handler.ProtocolException((int)EtpErrorCodes.NoRole, "No Role: " + header.MessageType, header.MessageId));
 }
Example #33
0
 /// <summary>
 /// Handles the ObjectFragment message from a store.
 /// </summary>
 /// <param name="header">The message header.</param>
 /// <param name="message">The ObjectFragment message.</param>
 protected virtual void HandleObjectFragment(IMessageHeader header, ObjectFragment message)
 {
     Notify(OnObjectFragment, header, message);
 }
 /// <summary>
 /// Sends a ProtocolException message for a no supported protocols type.
 /// </summary>
 /// <param name="handler">The handler.</param>
 /// <param name="header">The message header.</param>
 /// <returns>The message identifier.</returns>
 public static long NoSupportedProtocols(this IProtocolHandler handler, IMessageHeader header)
 {
     return(handler.ProtocolException((int)EtpErrorCodes.NoSupportedProtocols, "No supported protocols: " + header.MessageType, header.MessageId));
 }
 /// <summary>
 /// Sends a ChannelMetadata message to a consumer.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="channelMetadataRecords">The list of <see cref="IChannelMetadataRecord" /> objects.</param>
 /// <param name="messageFlag">The message flag.</param>
 /// <returns>The message identifier.</returns>
 long IStreamingProducer.ChannelMetadata(IMessageHeader request, IList <IChannelMetadataRecord> channelMetadataRecords, MessageFlags messageFlag)
 {
     return(ChannelMetadata(request, channelMetadataRecords.Cast <ChannelMetadataRecord>().ToList(), messageFlag));
 }
 /// <summary>
 /// Sends a ProtocolException message for an invalid message type.
 /// </summary>
 /// <param name="handler">The handler.</param>
 /// <param name="header">The message header.</param>
 /// <returns>The message identifier.</returns>
 public static long InvalidMessage(this IProtocolHandler handler, IMessageHeader header)
 {
     return(handler.ProtocolException((int)EtpErrorCodes.InvalidMessageType, "Invalid message type: " + header.MessageType, header.MessageId));
 }
 public void OriginalMessageHeader(IMessageHeader header)
 {
     messageLabel.Text = "[FWD] "+header.MessageLabel;
 }
 public void AddHeader(IMessageHeader header, bool mustUnderstand)
 {
     _outgoingMessage.AddHeader(header, mustUnderstand);
 }