Ejemplo n.º 1
0
 public JobInfo(JobParameterization job)
 {
     Current        = ExtractSource(job.Current);
     Target         = ExtractSource(job.Target);
     FilePath       = job.Action !.FilePath != null;
     FolderPath     = job.Action !.FolderPath != null;
     CsvPath        = job.Action !.CsvPath != null;
     UsePluralForms = job.Action !.UsePluralForms;
     PushToConsole  = job.Action !.PushToConsole;
 }
Ejemplo n.º 2
0
        private async Task <bool> ProcessJobAsync(
            MainParameterization parameters,
            IKustoManagementGatewayFactory kustoGatewayFactory,
            IFileGateway localFileGateway,
            string jobName,
            JobParameterization job)
        {
            _tracer.WriteLine(false, $"Job '{jobName}':");
            _tracer.WriteLine(false, "");
            try
            {
                _tracer.WriteLine(true, "Current DB Provider...  ");

                var currentDbProvider = CreateDatabaseProvider(job.Current, kustoGatewayFactory, localFileGateway);

                _tracer.WriteLine(true, "Target DB Provider...  ");

                var targetDbProvider = CreateDatabaseProvider(job.Target, kustoGatewayFactory, localFileGateway);

                var currentDbTask = RetrieveDatabaseAsync(currentDbProvider, "current");
                var targetDbTask  = RetrieveDatabaseAsync(targetDbProvider, "target");

                await Task.WhenAll(currentDbTask, targetDbTask);

                var currentDb = await currentDbTask;
                var targetDb  = await targetDbTask;

                _tracer.WriteLine(false, "Compute Delta...");

                var delta           = currentDb.ComputeDelta(targetDb);
                var actions         = new CommandCollection(job.Action !.UsePluralForms, delta);
                var jobSuccess      = ReportOnDeltaCommands(parameters, actions);
                var actionProviders = CreateActionProvider(
                    job.Action !,
                    kustoGatewayFactory,
                    localFileGateway,
                    job.Current?.Adx);

                _tracer.WriteLine(false, "Processing delta commands...");
                foreach (var actionProvider in actionProviders)
                {
                    await actionProvider.ProcessDeltaCommandsAsync(
                        parameters.FailIfDataLoss,
                        actions);
                }
                _tracer.WriteLine(false, "Delta processed / Job completed");
                _tracer.WriteLine(false, "");

                return(jobSuccess);
            }
            catch (DeltaException ex)
            {
                throw new DeltaException($"Issue in running job '{jobName}'", ex);
            }
        }