public List <ITransformTask> Create(string[] files, CancellationToken cancellationToken) { List <ITransformTask> taskList = new List <ITransformTask>(); foreach (var file in files) { var configFilePath = Path.Combine(_hostingEnvironment.WebRootPath, "configs", file); if (!File.Exists(configFilePath)) { throw new FileNotFoundException($"{configFilePath} not found."); } var configuration = new ConfigurationBuilder().AddJsonFile(configFilePath).Build(); var options = new TransformOptions(); configuration.Bind(nameof(TransformOptions), options); taskList.Add(CreateTask(options, cancellationToken)); } return(taskList); }
public static List <SqlTransformContext> CreateSqlTransformContexts(this TransformOptions options, CancellationToken cancellationToken) { List <SqlTransformContext> transformContexts = new List <SqlTransformContext>(); foreach (var map in options.Maps) { var context = new SqlTransformContext { SelectSql = map.CreateSqlScript(out string fieldsPattern), CountSql = map.CreateCountScript(), FieldPattern = fieldsPattern, IdentityColumnName = map.IdentityColumnName, TableName = map.TableName, CancellationToken = cancellationToken }; transformContexts.Add(context); } return(transformContexts); } }