/// <summary> /// Report status back to api /// </summary> /// <param name="command">The command</param> /// <param name="cancellationToken">The cancellation token</param> /// <returns>The response</returns> public async Task <DownloadIntegrationExportCommandResult> Handle( DownloadIntegrationExportCommand command, CancellationToken cancellationToken) { Argument.NotNull(command, nameof(command)); var stopwatch = Stopwatch.StartNew(); var commandResult = await _handler .Handle(command, cancellationToken) .ConfigureAwait(Await.Default); stopwatch.Stop(); int duration = Convert(stopwatch.ElapsedMilliseconds); string exception = null; if (commandResult.Exception != null) { exception = commandResult.Exception.ToString(); if (exception.Length > ExceptionLength) { exception = exception.Substring(0, ExceptionLength); } } var request = new ReportIntegrationExportV1Request { IntegrationExportId = command.IntegrationExportId, IntegrationExportLogId = command.IntegrationExportLogId, Result = commandResult.Success == true ? DownloadIntegrationExportV1Result.Success : DownloadIntegrationExportV1Result.Failed, Duration = duration, Message = commandResult.Message, Exception = exception, }; _ = await _client .Execute(request, cancellationToken) .ConfigureAwait(Await.Default); return(commandResult); }
/// <summary> /// Execute example /// </summary> /// <param name="cancellationToken">The cancellation token</param> /// <returns>The task</returns> public async Task Execute(CancellationToken cancellationToken) { var integrationExportId = Guid.Parse("64064995-E24B-4C38-8DCA-DD32C29793AB"); var integrationExportLogId = Guid.Parse("A870F76B-CBD6-4A2A-80F4-E09D01718364"); var duration = 500; var request = new ReportIntegrationExportV1Request { IntegrationExportId = integrationExportId, IntegrationExportLogId = integrationExportLogId, Result = DownloadIntegrationExportV1Result.Success, Duration = duration, Message = "Success", Exception = "" }; var response = await _client .Execute(request, cancellationToken) .ThrowIfFailed() .ConfigureAwait(Await.Default); Require.NotNull(response, nameof(response)); }