Beispiel #1
0
        public async Task <Activity> SaveActivity <TMessage>(TMessage message, ActivityType activityType) where TMessage : class
        {
            var messageContext = _messageContextProvider.GetContextForMessageBody(message);

            if (!Guid.TryParse(messageContext.MessageId, out Guid messageId))
            {
                throw new Exception($"The attempt to save activity from message type {typeof(TMessage).FullName} failed because the message id supplied by {nameof(IMessageContextProvider)}.{nameof(IMessageContextProvider.GetContextForMessageBody)} is not a GUID (the value provided was {messageContext.MessageId}");
            }

            var activity = _activityMapper.Map(message, activityType, messageId: messageId);

            await RunWithTry(() => _cosmosActivityRepository.UpsertActivityAsync(activity), "Saving activity to CosmosDB");
            await RunWithTry(() => _elasticActivityRepository.UpsertActivityAsync(activity), "Saving activity to Elastic");

            return(activity);
        }
 public Task FixAsync(ActivityDiscrepancy discrepancy, CancellationToken cancellationToken)
 {
     return(_cosmosRepo.UpsertActivityAsync(discrepancy.Activity));
 }