Exemplo n.º 1
0
        private void ExpireOrder(Order order)
        {
            order.RemainingQuantity = 0;
            order.Status            = OrderStatus.Expired;

            OrderExpired?.Invoke(this, new OrderExpiredEventArgs(order));
        }
Exemplo n.º 2
0
        public void Handle(OrderExpired @event)
        {
            var order = this.orderRepository.GetBy(x => x.Id == @event.SourceId).FirstOrDefault();

            if (order != null)
            {
                context.RegisterDeleted(order);
                context.Commit();
            }
        }
Exemplo n.º 3
0
        private void OnMessage(OrderExpired @event)
        {
            this.EventCount++;
            this.Logger.LogInformation(LogId.Trading, $"{Received}{Event} {@event}.");

            this.ProcessOrderEvent(@event);
            this.ClearModifyBuffer(@event.OrderId);
            this.CancelExpiryBackup(@event.OrderId);
            this.SendToEventPublisher(@event);
        }
Exemplo n.º 4
0
 public void Handle(OrderExpired @event)
 {
     using (var context = contextFactory.Invoke()) {
         var order = context.Orders.FirstOrDefault(x => x.Id == @event.SourceId);
         if (order != null)
         {
             context.Orders.Remove(order);
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 5
0
        public async Task Timeout(OrderExpiredTimeout state, IMessageHandlerContext context)
        {
            log.Info($"Timeout expired, OrderId = {Data.OrderId}.");

            var message = new OrderExpired
            {
                OrderId = Data.OrderId
            };
            await context.Publish(message);

            MarkAsComplete();
        }
        public void when_order_totals_calculated_then_updates_order_total()
        {
            var e = new OrderExpired {
                SourceId = placed.SourceId
            };

            sut.Handle(e);

            var order = FindOrder(e.SourceId);

            Assert.Null(order);
        }
 public void Handle(OrderExpired @event)
 {
     // No need to keep this priced order alive if it is expired.
     using (var context = this.contextFactory.Invoke())
     {
         var dto = context.Find <PricedOrder>(@event.SourceId);
         if (dto != null)
         {
             context.Set <PricedOrder>().Remove(dto);
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 8
0
        public void When_order_totals_calculated_then_updates_order_total()
        {
            var e = new OrderExpired()
            {
                SourceId = _placed.SourceId
            };

            this._eventHandler.Handle(e);

            var order = FindOrder(e.SourceId);

            Assert.Null(order);
        }
Exemplo n.º 9
0
 public void Handle(OrderExpired @event)
 {
     using (var context = this.contextFactory.Create())
     {
         var order = orderRepository.Find(@event.SourceId);
         if (order != null)
         {
             //DbContext.Orders.Remove(order);
             orderRepository.Remove(order);
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 10
0
 public Task <AsyncTaskResult> HandleAsync(OrderExpired evnt)
 {
     return(TryUpdateRecordAsync(connection =>
     {
         return connection.UpdateAsync(new
         {
             Status = (int)OrderStatus.Expired,
             Version = evnt.Version
         }, new
         {
             OrderId = evnt.AggregateRootId,
             Version = evnt.Version - 1
         }, ConfigSettings.OrderTable);
     }));
 }
Exemplo n.º 11
0
        internal void CanSerializeAndDeserialize_OrderExpiredEvents()
        {
            // Arrange
            var order   = new StubOrderBuilder().BuildStopMarketOrder();
            var expired = new OrderExpired(
                AccountId.FromString("FXCM-02851908-DEMO"),
                order.Id,
                StubZonedDateTime.UnixEpoch(),
                Guid.NewGuid(),
                StubZonedDateTime.UnixEpoch());

            // Act
            var packed   = this.serializer.Serialize(expired);
            var unpacked = (OrderExpired)this.serializer.Deserialize(packed);

            // Assert
            Assert.Equal(expired, unpacked);
            this.Output.WriteLine(Convert.ToBase64String(packed));
        }
 public void Handle(OrderExpired @event)
 {
     // No need to keep this priced order alive if it is expired.
     using (var context = contextFactory.Invoke()) {
         var pricedOrder = new PricedOrder {
             OrderId = @event.SourceId
         };
         var set = context.Set <PricedOrder>();
         set.Attach(pricedOrder);
         set.Remove(pricedOrder);
         try {
             context.SaveChanges();
         } catch (DbUpdateConcurrencyException) {
             Trace.TraceWarning(
                 "Ignoring priced order expiration message with version {1} for order id {0}. This could be caused because the message was already handled and the entity was already deleted.",
                 pricedOrder.OrderId,
                 @event.Version);
         }
     }
 }
 public void Handle(OrderExpired @event)
 {
     // No need to keep this priced order alive if it is expired.
     pricedOrderRepository.Delete(p => p.OrderId == @event.SourceId);
 }
Exemplo n.º 14
0
 public async Task Timeout(OrderExpired timeout, IMessageHandlerContext context)
 {
     log.Info($"Customer {Data.CustomerId} order of {timeout.Amount} timed out.");
     Data.RunningTotal -= timeout.Amount;
     await CheckForPreferredStatus(context);
 }
 public Task <AsyncTaskResult> HandleAsync(OrderExpired evnt)
 {
     return(_commandService.SendAsync(new CancelSeatReservation(evnt.ConferenceId, evnt.AggregateRootId)));
 }
Exemplo n.º 16
0
        public void when_order_totals_calculated_then_updates_order_total()
        {
            var e = new OrderExpired { SourceId = placed.SourceId };

            this.sut.Handle(e);

            var order = FindOrder(e.SourceId);
            Assert.Null(order);
        }
Exemplo n.º 17
0
 private void OnOrderExpired(OrderExpired e)
 {
 }
Exemplo n.º 18
0
 private void OnOrderExpired(OrderExpired e)
 {
 }
Exemplo n.º 19
0
 private void OnMessage(OrderExpired @event)
 {
     this.SendToBus(@event);
 }
Exemplo n.º 20
0
 private void OnMessage(OrderExpired @event)
 {
     this.ReceivedObjects.Add(@event);
 }
Exemplo n.º 21
0
 private void When(OrderExpired @event)
 {
     this.SetIsCompleteTrue();
 }
Exemplo n.º 22
0
 internal void ExpireOrder()
 {
     OrderExpired?.Invoke(this);
 }