/// <summary>
        /// Summarize a <see cref="AttemptToSendNotificationEventBase"/> as a <see cref="AttemptToSendNotificationOutcome" />.
        /// </summary>
        /// <param name="attemptToSendNotificationResult">The event.</param>
        /// <returns>
        /// A <see cref="AttemptToSendNotificationEventBase"/> summarized in a <see cref="AttemptToSendNotificationOutcome"/>.
        /// </returns>
        public static AttemptToSendNotificationOutcome GetOutcome(
            this AttemptToSendNotificationResult attemptToSendNotificationResult)
        {
            new { attemptToSendNotificationResult }.AsArg().Must().NotBeNull();

            AttemptToSendNotificationOutcome result;

            var channelToOperationsOutcomeInfoMap = attemptToSendNotificationResult.ChannelToOperationsOutcomeInfoMap;

            var anyOperationsFailed = channelToOperationsOutcomeInfoMap
                                      .Values
                                      .SelectMany(_ => _)
                                      .Any(_ => _.Outcome == ChannelOperationOutcome.Failed);

            if (anyOperationsFailed)
            {
                var anyChannelsSucceeded = channelToOperationsOutcomeInfoMap
                                           .Values
                                           .Any(_ => _.All(c => c.Outcome == ChannelOperationOutcome.Succeeded));

                result = anyChannelsSucceeded
                    ? AttemptToSendNotificationOutcome.SentOnSomePreparedChannels
                    : AttemptToSendNotificationOutcome.CouldNotSendOnAnyPreparedChannel;
            }
            else
            {
                result = AttemptToSendNotificationOutcome.SentOnAllPreparedChannels;
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CouldNotSendOnAnyPreparedChannelEvent"/> class.
        /// </summary>
        /// <param name="id">The notification tracking code identifier.</param>
        /// <param name="timestampUtc">The timestamp in UTC.</param>
        /// <param name="attemptToSendNotificationResult">The result of attempting to send the notification.</param>
        public CouldNotSendOnAnyPreparedChannelEvent(
            long id,
            DateTime timestampUtc,
            AttemptToSendNotificationResult attemptToSendNotificationResult)
            : base(id, timestampUtc, attemptToSendNotificationResult)
        {
            var attemptToSendNotificationOutcome = attemptToSendNotificationResult.GetOutcome();

            new { attemptToSendNotificationOutcome }.AsArg().Must().BeEqualTo(AttemptToSendNotificationOutcome.CouldNotSendOnAnyPreparedChannel);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AttemptToSendNotificationEventBase"/> class.
        /// </summary>
        /// <param name="id">The notification tracking code identifier.</param>
        /// <param name="timestampUtc">The timestamp in UTC.</param>
        /// <param name="attemptToSendNotificationResult">The result of attempting to send the notification.</param>
        protected AttemptToSendNotificationEventBase(
            long id,
            DateTime timestampUtc,
            AttemptToSendNotificationResult attemptToSendNotificationResult)
            : base(id, timestampUtc)
        {
            new { attemptToSendNotificationResult }.AsArg().Must().NotBeNull();

            this.AttemptToSendNotificationResult = attemptToSendNotificationResult;
        }
Esempio n. 4
0
        public override AttemptToSendNotificationEventBase DeepCloneWithAttemptToSendNotificationResult(AttemptToSendNotificationResult attemptToSendNotificationResult)
        {
            var result = new SentOnSomePreparedChannelsEvent(
                this.Id.DeepClone(),
                this.TimestampUtc.DeepClone(),
                attemptToSendNotificationResult);

            return(result);
        }
 public virtual AttemptToSendNotificationEventBase DeepCloneWithAttemptToSendNotificationResult(AttemptToSendNotificationResult attemptToSendNotificationResult)
 {
     throw new NotImplementedException("This method should be abstract.  It was generated as virtual so that you aren't forced to override it when you create a new model that derives from this model.  It will be overridden in the generated designer file.");
 }