Пример #1
0
        public async Task Consume(ConsumeContext <GetStatusHistoryForOrderItemRequest> context)
        {
            using (LogContext.PushProperty(nameof(context.ConversationId), context.ConversationId))
            {
                Log.Information("Received {CommandName} command with conversationId {ConversationId} from the bus",
                                context.Message.GetType().Name, context.ConversationId);

                var historyEntries = await publicOrder.GetStatusHistoryForOrderItem(context.Message.OrderItemId);

                var response = new GetStatusHistoryForOrderItemResponse {
                    StatusHistory = historyEntries
                };

                await context.RespondAsync(response);
            }
        }
        private async Task <OrderingFlatDetailItem> GetOrderingDetailItemInternal(int id, bool nichtSichtbarEinsehen = false)
        {
            var ctx      = new ViaducContext(WebHelper.Settings["sqlConnectionString"]);
            var flatItem = ctx.OrderingFlatItem.FirstOrDefault(i => i.ItemId == id);

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

            var item = new OrderingFlatDetailItem();

            item.FromFlatItem(flatItem);

            if (flatItem.VeId.HasValue)
            {
                var elasticItem = await GetElasticArchiveRecord(flatItem.VeId.Value.ToString());

                if (elasticItem != null)
                {
                    var ancestors = GetAncestors(elasticItem);
                    item.ArchivplanKontext = ancestors;

                    if (nichtSichtbarEinsehen)
                    {
                        var snapshot = OrderHelper.GetOrderingIndexSnapshot(elasticItem);
                        OrderHelper.ApplySnapshotToDetailItem(snapshot, item.Item);
                    }
                }
                else
                {
                    Log.Warning("elasticRecord nicht gefunden ");
                }

                var orderHistory = (await orderManagerClient.GetOrderingHistoryForVe(flatItem.VeId.Value)).ToList();
                item.OrderingHistory        = orderHistory.Take(3);
                item.HasMoreOrderingHistory = orderHistory.Count > 3;
            }

            var statusHistory = await orderManagerClient.GetStatusHistoryForOrderItem(flatItem.ItemId);

            item.StatusHistory = statusHistory;
            return(item);
        }