public async Task <IJob> LoadJobAsync(string path) { JobDataObject jobDataObject = await GetJobAsync(path); jobDataObject.Path = path; return(ToJob(jobDataObject, this)); }
private IJob ToJob(JobDataObject j, IJobLoader loader) => new Job { Name = j.Name, Active = j.Active, Description = j.Description, Parent = j.Parent, Priority = j.Priority, ConnectionName = j.ConnectionName, Warehouse = j.Warehouse, Units = ToUnitCollection(j.Units, loader, j.Path), Variables = ToVariableCollection(j.Variables), Properties = j.Properties } as IJob;
private JobDataObject SetJobVariables(JobDataObject job, ICriteria criteria) { try { var adhocVariables = criteria.JobVariables[job.Name]; if (adhocVariables != null && adhocVariables.Count > 0) { var jobVariables = job.Variables; job.Variables = jobVariables.Select(v => { (bool useAdhocValue, string adhocValue) = GetAdhocValue(adhocVariables, v.Name); return(new VariableDataObject { Active = v.Active, Name = v.Name, Value = useAdhocValue ? adhocValue : v.Value }); // inner function returns tuple with adhoc value if it is present (bool, string)GetAdhocValue(IDictionary <string, string> adhocVars, string name) { try { return(true, adhocVars[name]); } catch (KeyNotFoundException e) { logger.LogWarning($"Ignored - Key Not found - {e.Message}"); // Do not use adhoc value if not found return(false, null); } catch (Exception e) { logger.LogError("Error in getting job variable from criteria : " + e.Message); return(false, null); } } }); } } catch (Exception) { logger.LogDebug("No adhoc variables found for job : " + job.Name); } return(job); }
private async Task <ICollection <JobDataObject> > GetAllJobsAsync(string folder = default) { var jobDataObjects = new List <JobDataObject>(); var keys = await textFileProvider.ListFileKeysAsync(bucketName, filePattern); foreach (var key in keys) { if (folder == default || key.StartsWith(folder)) { JobDataObject job = await GetJobAsync(key); job.Path = key; jobDataObjects.Add(job); } } return(jobDataObjects); }