/// <summary> /// Run the background command. /// </summary> /// <param name="context">Command task execution context.</param> public override async Task ExecuteCommandAsync(CommandTaskContext context) { foreach (var model in models) { CommandInfo command = new("psql"); new PostgreSQLSink(connectionString).ParseCommandString(command); command.ArgumentList.Add("-c"); command.ArgumentList.Add($"refresh materialized view {model} with data"); await RunCommandAsync(command); } }
/// <summary> /// Setup command workspace. /// </summary> /// <param name="context">Command task execution context.</param> public virtual async Task SetupAsync(CommandTaskContext context) { if (context is null) { throw new ArgumentNullException(nameof(context)); } Logger.LogTrace("Setup workspace for job"); context.Workspace = Path.Combine(Directory.GetCurrentDirectory(), $"workspace/job-{Context.Id}"); Directory.CreateDirectory(context.Workspace); await File.WriteAllTextAsync($"{context.Workspace}/{TaskIdName}", Context.Id.ToString()); Logger.LogTrace($"Workspace: {context.Workspace}"); }
/// <summary> /// Cleanup workspace. /// </summary> /// <param name="context">Command task execution context.</param> public virtual Task TeardownAsync(CommandTaskContext context) { if (context is null) { throw new ArgumentNullException(nameof(context)); } Logger.LogTrace("Teardown workspace for job"); if (!context.KeepWorkspace) { Logger.LogTrace("Workspace directory is not kept"); Directory.Delete(context.Workspace, recursive: true); } return(Task.CompletedTask); }
/// <summary> /// Run the background command. /// </summary> /// <remarks> /// Select the export layers in random order. /// </remarks> /// <param name="context">Command task execution context.</param> public override async Task ExecuteCommandAsync(CommandTaskContext context) { var rng = new Random(); foreach (var layer in exportLayers.OrderBy(i => rng.Next())) { // NOTE: We *must* delete the old dataset first. await _mapService.DeleteDatasetAsync(layer); if (await ExportDatasetAsync(layer)) { if (await _mapService.PublishAsync(layer)) { Logger.LogInformation($"Layer {layer} published with success"); } else { Logger.LogError($"Layer {layer} was not published"); } } } }
/// <summary> /// Run the background command. /// </summary> /// <param name="context">Command task execution context.</param> public abstract Task ExecuteCommandAsync(CommandTaskContext context);