public async Task <ExecuteOperationResponse> ExecuteOperationAsync(
            [FromRoute] Guid operationId,
            [FromBody] ExecuteOperationRequest request)
        {
            var response = new ExecuteOperationResponse();

            if (_operationService.IsOperationTypeSupported(request.Type))
            {
                try
                {
                    response.TxHash = await _operationService.ExecuteOperationAsync
                                      (
                        operationId,
                        request.Type,
                        request.MasterWalletAddress,
                        request.Nonce,
                        request.PayloadJson
                                      );
                }
                catch (WalletNotFoundException)
                {
                    response.Error = ExecuteOperationError.MasterWalletNotFound;
                }
            }
            else
            {
                response.Error = ExecuteOperationError.NotSupportedOperationType;
            }

            return(response);
        }
Beispiel #2
0
            private async Task RunOperationManualPollAsync(int icm)
            {
                try
                {
                    ExecuteOperationResponse operationRunning = await client.Operations.RunOperationAsync(operationRequest);

                    while (true)
                    {
                        OperationResult status = await client.Operations.GetOperationStatusAsync(operationRunning.Id);

                        if (status.Status.IsStateComplete())
                        {
                            // Operation reached a final state, get the result.
                            operationResult = await client.Operations.GetOperationResultsAsync(operationRunning.Id);

                            Log.Verbose("Operation has completed execution for {0}: {1}. Operation Result is:{2}{3}", extensionName, operationName, System.Environment.NewLine, operationResult.ResultMessage);
                            // We upload all results of all operations
                            SALsA.GetInstance(icm)?.TaskManager.AddTask(
                                BlobStorage.UploadText(icm, String.Format("action/{1}-{0}_{2}.txt", extensionName, operationName, Log.UID),
                                                       operationResult.ResultMessage));
                            return;
                        }
                        // Warning: Setting too short a delay could result in requests being throttled
                        Log.Verbose("Operation <{0}: {1}> is still in process, polling status again in 5 seconds", extensionName, operationName);
                        await Task.Delay(5000);
                    }
                }

                catch (Exception ex)
                {
                    Log.Error("Operation <{0}: {1}> execution failed.", extensionName, operationName);
                    Log.Exception(ex);
                }
            }