private ExecutionRequest ToExecutionRequestAsync(IExecutionRequestContext erContext) => new ExecutionRequest { CreatedDateTimeUtc = erContext.Execution.CreatedDateTimeUtc, ExecutionId = erContext.Execution.ExecutionId, ExecutionParameters = erContext.Execution.RequestData, ExecutionProfileName = erContext.Execution.ExecutionProfileName, ExecutionTimeoutDuration = erContext.ExtensionVersion.ExecutionExpirationPeriod, Executor = erContext.Execution.Executor, ExtensionId = erContext.Execution.ExtensionId, ExtensionSettings = erContext.ExecutionProfile.ExtensionSettings, ExtensionVersionId = erContext.Execution.ExtensionVersionId, InputObjects = erContext.ExtensionVersion.InputObjects.ToDictionary(io => io.Name), LastUpdatedDateTimeUtc = erContext.Execution.LastUpdatedDateTimeUtc, ObjectProviderName = erContext.Execution.ObjectProviderName, IsValidationSupported = erContext.ExtensionVersion.SupportsValidation, OutputObjects = erContext.ExtensionVersion.OutputObjects.ToDictionary(oo => oo.Name), Priority = erContext.Execution.Priority, StatusUpdateKey = erContext.Execution.StatusUpdateKey, SupportedServices = erContext.ExtensionVersion.SupportedServices, ValidateOnly = erContext.Execution.ValidateOnly, GetExecutionStatusUrl = GetExecutionStatusUrl(erContext.Execution.ExecutionId), UpdateExecutionStatusUrl = PutExecutionStatusUrl(erContext.Execution.ExecutionId), ExecutionModelName = erContext.ExecutionProfile.ExecutionModelName, ProvidedInputObjects = erContext.Execution.ProvidedInputObjects, SignatureRsaKeyXml = erContext.Execution.SignatureRsaKeyXml, ExecutorProperties = erContext.Execution.ExecutorProperties };
private async Task <Core.Models.Execution> ExecuteAsync(IExecutionRequestContext erContext) { // Dispatch the execution request to the execution pipeline... // For more information on the execution pipeline, see /doc/architecture/execution-pipeline.md. var execRequest = ToExecutionRequestAsync(erContext); var execContext = await execRequestRouter.RouteRequestAsync(execRequest, CancellationToken.None); // The result of all this processing is an execution context (/src/draco/core/Core.Models/ExecutionContext.cs). // An execution context contains all the information that the execution request does + an execution status update that includes // status, description, percentage complete, validation errors, etc. This execution context is then applied to the core execution model. erContext.Execution = ApplyExecutionContext(execContext, erContext.Execution); // Save the updated execution... await UpdateExecutionAsync(erContext.Execution); return(erContext.Execution); }
private async Task <ToContinueExecutionApiModel> CreateToContinueApiModelAsync(IExecutionRequestContext erContext, string message = null) => new ToContinueExecutionApiModel { ExecutionId = erContext.Execution.ExecutionId, ExecutionStatus = erContext.Execution.Status.ToString(), Message = message, PutContinueExecutionUrl = GetContinueExecutionUrl(erContext.Execution.ExecutionId), GetExecutionStatusUrl = GetExecutionStatusUrl(erContext.Execution.ExecutionId), ExecutorProperties = erContext.Execution.ExecutorProperties, InputObjects = await extensionObjectApiModelService.CreateInputObjectDictionaryAsync( erContext.Execution.InputObjects, erContext.Execution) };
private async Task <DirectExecutionRequestApiModel> CreateDirectExecutionRequestAsync(IExecutionRequestContext erContext) { // Convert the API request context to a core execution request... var execRequest = ToExecutionRequestAsync(erContext); // Then, convert the core execution request into a direct execution token... var directExecRequest = new DirectExecutionRequestApiModel { ExecutionId = execRequest.ExecutionId, ExecutionModelName = execRequest.ExecutionModelName, ExecutionProfileName = execRequest.ExecutionProfileName, ExecutionSettings = execRequest.ExtensionSettings, ExtensionId = execRequest.ExtensionId, ExtensionVersionId = execRequest.ExtensionVersionId, GetExecutionStatusUrl = execRequest.GetExecutionStatusUrl, ObjectProviderName = execRequest.ObjectProviderName, ExecutorProperties = execRequest.ExecutorProperties, Services = await execServiceProvider.GetServiceConfigurationAsync(execRequest) }; // Based on the selected execution profile, set the expiration date/time (how long the client can use the extension directly for) // and digitally sign the execution request using the hub's private key. In this model, we assume that the target execution has the hub's // public key and can us it to verify the authenticity of the token and all the information contained therein. // For more information, see /doc/architecture/direct-execution.md. directExecRequest.ExpirationDateTimeUtc = DateTime.UtcNow.Add(erContext.ExecutionProfile.DirectExecutionTokenDuration.Value); directExecRequest.Signature = await directExecRequestSigner.GenerateSignatureAsync(execRequest.SignatureRsaKeyXml, directExecRequest); // Update the execution to indicate that a direct access token is being provided... erContext.Execution.ExecutionTimeoutDateTimeUtc = directExecRequest.ExpirationDateTimeUtc; erContext.Execution.Status = ExecutionStatus.DirectExecutionTokenProvided; erContext.Execution.LastUpdatedDateTimeUtc = DateTime.UtcNow; // Persist the execution and return the direct execution token... await UpdateExecutionAsync(erContext.Execution); return(directExecRequest); }