コード例 #1
0
 public bool Equals(EventStateEnum obj)
 {
     if ((object)obj == null)
     {
         return(false);
     }
     return(StringComparer.OrdinalIgnoreCase.Equals(this.Value, obj.Value));
 }
コード例 #2
0
 public DomainEventLogEntry(DomainEvent @event)
 {
     EventId       = @event.Id;
     CreationTime  = @event.CreationDate;
     EventTypeName = @event.GetType().FullName;
     Content       = SafeSerialize(@event);
     State         = EventStateEnum.Unread;
     TimeSent      = 0;
 }
コード例 #3
0
 public IntegrationEventLogEntry(IntegrationEvent @event)
 {
     EventId       = @event.Id;
     CreationTime  = @event.CreationDate;
     EventTypeName = @event.GetType().FullName;
     Content       = JsonConvert.SerializeObject(@event);
     State         = EventStateEnum.NotPublished;
     TimeSent      = 0;
 }
コード例 #4
0
        protected Task UpdateEventStatus(Guid eventId, EventStateEnum status)
        {
            var eventLogEntry = _context.EventLogEntries.SingleOrDefault(ie => ie.EventId == eventId);

            eventLogEntry.UpdateState(status);

            _context.EventLogEntries.Update(eventLogEntry);

            return(_context.SaveChangesAsync());
        }
コード例 #5
0
 public IntegrationEventLogServiceFixture AddNonScopedEventEntries(int total, EventStateEnum state)
 {
     for (int i = 0; i < total; i++)
     {
         var entry = GetLogEntry(string.Empty, state);
         OperationalDbContext.IntegrationEventLogs.Add(entry);
     }
     OperationalDbContext.SaveChanges();
     return(this);
 }
コード例 #6
0
        public IntegrationEventLogServiceFixture AddScopedEventEntries(int total, EventStateEnum state)
        {
            var scopeId = EventLogService.ScopeId;

            for (var i = 0; i < total; i++)
            {
                var entry = GetLogEntry(scopeId, state);
                OperationalDbContext.IntegrationEventLogs.Add(entry);
            }
            OperationalDbContext.SaveChanges();
            return(this);
        }
コード例 #7
0
        private Task UpdateEventStatus(Guid eventId, EventStateEnum status)
        {
            var eventLogEntry = _integrationEventLogContext.IntegrationEventLogs.Single(ie => ie.EventId == eventId);

            eventLogEntry.State = status;

            if (status == EventStateEnum.InProgress)
            {
                eventLogEntry.TimesSent++;
            }

            return(_integrationEventLogContext.SaveChangesAsync());
        }
コード例 #8
0
        private Task UpdateEventStatus(long eventId, EventStateEnum status)
        {
            var eventLogEntry = _context.EventLogs.Single(ie => ie.EventId == eventId);

            eventLogEntry.State = status;

            if (status == EventStateEnum.InProgress)
            {
                eventLogEntry.TimesSent++;
            }

            _context.EventLogs.Update(eventLogEntry);
            return(_context.SaveChangesAsync());
        }
コード例 #9
0
    private async Task UpdateEventStatus(string eventId, EventStateEnum status)
    {
        var eventLogEntry = await _dbContext.IntegrationEventLogs
                            .SingleAsync(ie => ie.EventId == eventId);

        eventLogEntry.State = status;

        if (status == EventStateEnum.InProgress)
        {
            eventLogEntry.TimesSent++;
        }

        await _dbContext.SaveChangesAsync();
    }
コード例 #10
0
        private async Task UpdateEventStatusAsync(Guid eventId, EventStateEnum status)
        {
            var eventLogEntry = _context.IntegrationEventLogs.Single(ie => ie.EventId == eventId);

            eventLogEntry.State = status;

            if (status == EventStateEnum.InProgress)
            {
                eventLogEntry.TimesSent++;
            }

            _context.IntegrationEventLogs.Update(eventLogEntry);

            await _context.SaveChangesAsync();
        }
コード例 #11
0
        private Task UpdateEventStatus(Guid eventId, EventStateEnum status)
        {
            var eventLogEntry = _outboxEventContext.Outbox.Single(ie => ie.EventId == eventId);

            eventLogEntry.State = status;

            if (status == InProgress)
            {
                eventLogEntry.TimesSent++;
            }

            _outboxEventContext.Outbox.Update(eventLogEntry);

            return(_outboxEventContext.SaveChangesAsync());
        }
コード例 #12
0
        private Task UpdateEventStatus(Guid eventId, EventStateEnum status)
        {
            var eventLogEntry = _integrationEventLogContext.Get <IntegrationEventLogEntry>(ie => ie.EventId == eventId);

            eventLogEntry.State = status;

            if (status == EventStateEnum.InProgress)
            {
                eventLogEntry.TimesSent++;
            }

            _integrationEventLogContext.Update(eventLogEntry);
            _integrationEventLogContext.Commit();

            return(Task.CompletedTask);
        }
コード例 #13
0
        /// <summary>
        /// Updates the given event with the given status and saves it to the database.
        /// </summary>
        /// <param name="eventId">The id of the event to change the status of.</param>
        /// <param name="status">The new status of the event.</param>
        private Task UpdateEventStatus(Guid eventId, EventStateEnum status)
        {
            var eventLogEntry = _integrationEventLogContext.IntegrationEventLogs.Single(ie => ie.EventId == eventId);

            eventLogEntry.State = status;

            // If the event fails to send due to a crash or disconnect or similar, it should be retried.
            // This keeps track of the number of tries.
            if (status == EventStateEnum.InProgress)
            {
                eventLogEntry.TimesSent++;
            }

            _integrationEventLogContext.IntegrationEventLogs.Update(eventLogEntry);

            return(_integrationEventLogContext.SaveChangesAsync());
        }
コード例 #14
0
        private Task UpdateEventStatus(Guid eventId, EventStateEnum status)
        {
            var eventLogEntry = _database.GetCollection <IntegrationEventLogEntry>("IntegrationEventLogs")
                                .Find(x => x.EventId == eventId)
                                .FirstOrDefault();

            eventLogEntry.State = status;

            if (status == EventStateEnum.InProgress)
            {
                eventLogEntry.TimesSent++;
            }

            return(_database.GetCollection <IntegrationEventLogEntry>("IntegrationEventLogs")
                   .ReplaceOneAsync(x => x.EventId == eventId, eventLogEntry, new UpdateOptions {
                IsUpsert = true
            }));
        }
コード例 #15
0
 public void UpdateState(EventStateEnum state)
 {
     State          = state.ToString();
     LastModifiedAt = DateTime.UtcNow;
 }
コード例 #16
0
        internal static void CheckResponseAndResult(EventRequest expected, EventResponse actual, EventStateEnum eventStateCode)
        {
            Assert.AreEqual(32, actual.EventToken.Length);
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.FriendlyUrlPath, actual.FriendlyUrlPath);
            Assert.AreEqual(expected.Description, actual.Description);
            Assert.AreEqual(eventStateCode, actual.State);
            Assert.AreEqual(expected.StartDatetime.ToString(), actual.StartDatetime.ToString());
            Assert.AreEqual(expected.EndDatetime.ToString(), actual.EndDatetime.ToString());
            if (String.IsNullOrWhiteSpace(expected.TermsAndConditionsContent))
            {
                Assert.AreEqual(@"By making this payment you expressly authorize the service provider, Peloton Technologies Inc., to charge your credit card for the noted dollar amount.
You can expect that your credit card information will be transmitted securely with the utmost protection by the service provider Peloton Technologies Inc.
If you require an adjustment to your transaction after processing has occurred, please contact one of our representatives prior to contacting the service provider, Peloton Technologies.
If you wish to dispute a charge please contact Peloton Technologies Inc. at {0} or {1}.".Replace("\n", "")
                                .Replace("\r", ""), actual.TermsAndConditionsContent.Replace("\n", "").Replace("\r", ""));
            }
            else
            {
                Assert.AreEqual(expected.TermsAndConditionsContent, actual.TermsAndConditionsContent);
            }

            if (String.IsNullOrWhiteSpace(expected.RefundPolicyContent))
            {
                Assert.AreEqual("For all refunds, please contact one of our representatives.", actual.RefundPolicyContent);
            }
            else
            {
                Assert.AreEqual(expected.RefundPolicyContent, actual.RefundPolicyContent);
            }

            // TODO: the api only saves/returns one Event Item. The rest are discarded.
            //Assert.AreEqual(expected.Items.Count, actual.Items.Count);
            // workaround:
            if (expected.Items.Count >= 2)
            {
                Assert.AreEqual(1, actual.Items.Count);
            }
            else
            {
                Assert.AreEqual(expected.Items.Count, actual.Items.Count);
            }

            for (var i = 0; i < actual.Items.Count; i++)
            {
                Debug.WriteLine($"item {i}");

                var expectedItem = expected.Items.ElementAt(i);
                var actualItem   = actual.Items.ElementAt(i);

                //var actualItem = actual.Items.Where(ai => ai.Name == expectedItem.Name).Single();

                // TODO: the name field is ignored on creation of Event POST
                //Assert.AreEqual(expectedItem.Name, actualItem.Name);
                // item name actually comes back as the event name
                // workaround:
                Assert.AreEqual(expected.Name, actualItem.Name);
                // TODO: the description field is ignored on creation of Event POST
                //Assert.AreEqual(expectedItem.Description, actualItem.Description);
                // item description comes back as the event description
                // workaround:
                Assert.AreEqual(expected.Description, actualItem.Description);
                Assert.AreEqual(expectedItem.QuantitySelector, actualItem.QuantitySelector);
                // TODO: the default_unit_quantity field is ignored on creation of Event POST
                //Assert.AreEqual(expectedItem.DefaultUnitQuantity, actualItem.DefaultUnitQuantity);
                // item default quantity will come back un-set
                // workaround:
                Assert.AreEqual(default(int), actualItem.DefaultUnitQuantity);
                Assert.AreEqual(expectedItem.UnitQuantityDescription, actualItem.UnitQuantityDescription);
                Assert.AreEqual(expectedItem.UnitAmount, actualItem.UnitAmount);
                Assert.AreEqual(expectedItem.Amount, actualItem.Amount);
                Assert.AreEqual(expectedItem.AmountAdjustable, actualItem.AmountAdjustable);

                Assert.AreEqual(expectedItem.CustomFields.Count, actualItem.CustomFields.Count);
                for (var j = 0; j < expectedItem.CustomFields.Count; j++)
                {
                    Debug.WriteLine($"item custom field {j}");
                    var expectedItemCustomField = expectedItem.CustomFields.ElementAt(j);
                    var actualItemCustomField   = actualItem.CustomFields.ElementAt(j);



                    Assert.AreEqual(expectedItemCustomField.Name, actualItemCustomField.Name);
                    Assert.AreEqual(expectedItemCustomField.DefaultValue, actualItemCustomField.DefaultValue);
                    Assert.AreEqual(expectedItemCustomField.Type, actualItemCustomField.Type);
                    Assert.AreEqual(expectedItemCustomField.DisplayOrder, actualItemCustomField.DisplayOrder);
                    Assert.AreEqual(expectedItemCustomField.Required, actualItemCustomField.Required);
                }
            }
        }
コード例 #17
0
 public EventState(EventStateEnum eventState)
 {
     Id   = (int)eventState;
     Name = eventState.ToString();
 }
コード例 #18
0
 private static IntegrationEventLogEntry GetLogEntry(string scopeId, EventStateEnum state = EventStateEnum.NotPublished)
 => new IntegrationEventLogEntry(new FakeIntegrationEvent(), scopeId)
 {
     State = state
 };