コード例 #1
0
        private void TranslationSubscriptionHandler(MessageContext <Translation> messageContext)
        {
            try
            {
                if (subscriptions.TryGetValue(messageContext.Message.Id, out var state))
                {
                    var translation = messageContext.Message;

                    state.Booking.BookedData   = translation.BookedData.HasValue && translation.BookedData.Value;
                    state.Booking.BookedMarket = translation.BookedMarket.HasValue && translation.BookedMarket.Value;

                    if (state.Booking.BookedData)
                    {
                        feedManager.SendDataSubscribeRequestAsync(
                            messageContext.Next(new TranslationSubscriptionRequest <TranslationState>()
                        {
                            Id = translation.Id, State = state.PersistableState
                        }),
                            CancellationToken.None
                            );
                    }

                    if (state.Booking.BookedMarket)
                    {
                        feedManager.SendMarketSubscribeRequestAsync(
                            messageContext.Next(new TranslationSubscriptionRequest <TranslationState>()
                        {
                            Id = translation.Id, State = state.PersistableState
                        }),
                            options,
                            CancellationToken.None
                            );
                    }
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Translation subscription error. ContextId: {messageContext.IncomingId}, TranslationId: {messageContext.Message.Id}");
            }
        }