public override void LoadEntity(ContainerBuilder builder, Process process, Entity entity) {
            builder.Register<IRead>(ctx => {
                var context = new PipelineContext(ctx.Resolve<IPipelineLogger>(), process, entity);
                var input = new InputContext(context, new Incrementer(context));
                switch (input.Connection.Provider) {
                    case "internal":
                        context.Debug("Registering {0} provider", input.Connection.Provider);
                        return new DataSetEntityReader(input);
                    case "sqlserver":
                        if (input.Entity.ReadSize == 0) {
                            context.Debug("Registering {0} reader", input.Connection.Provider);
                            return new SqlInputReader(input, input.InputFields);
                        }
                        context.Debug("Registering {0} batch reader", input.Connection.Provider);
                        return new SqlInputBatchReader(
                            input,
                            new SqlInputReader(input, input.Entity.GetPrimaryKey())
                            );
                    default:
                        context.Warn("Registering null reader", input.Connection.Provider);
                        return new NullEntityReader();
                }
            }).Named<IRead>(entity.Key);

        }
        public override void LoadEntity(ContainerBuilder builder, Process process, Entity entity) {
            if (entity.Delete) {
                builder.Register<IEntityDeleteHandler>(ctx => {
                    var context = new PipelineContext(ctx.Resolve<IPipelineLogger>(), process, entity);

                    var inputConnection = process.Connections.First(c => c.Name == entity.Connection);

                    IRead input = new NullReader(context);
                    switch (inputConnection.Provider) {
                        case "sqlserver":
                            input = new SqlReader(context, entity.GetPrimaryKey(), ReadFrom.Input);
                            break;
                    }

                    IRead output = new NullReader(context);
                    IDelete deleter = new NullDeleter(context);
                    var outputConnection = process.Connections.First(c => c.Name == "output");
                    switch (outputConnection.Provider) {
                        case "sqlserver":
                            output = new SqlReader(context, entity.GetPrimaryKey(), ReadFrom.Output);
                            deleter = new SqlDeleter(new OutputContext(context, new Incrementer(context)));
                            break;
                    }

                    return new ParallelDeleteHandler(new DefaultDeleteHandler(entity, input, output, deleter));
                }).Named<IEntityDeleteHandler>(entity.Key);
            }

        }
 public DefaultDeleteHandler(
     Entity entity,
     IRead inputReader,
     IRead outputReader,
     IDelete outputDeleter
     ) {
     _entity = entity;
     _inputReader = inputReader;
     _outputReader = outputReader;
     _outputDeleter = outputDeleter;
 }
Exemple #4
0
        private static TestReader GetTestReader(Entity entity) {
            var row1 = new Row(2, false) {
                [entity.Fields[0]] = 1,
                [entity.Fields[1]] = "One"
            };
            var row2 = new Row(2, false) {
                [entity.Fields[0]] = 2,
                [entity.Fields[1]] = "Two"
            };

            var data = new List<Row> { row1, row2 };
            return new TestReader(data);
        }
 public static IEnumerable<ITransform> GetTransforms(IComponentContext ctx, Process process, Entity entity, IEnumerable<Field> fields) {
     var transforms = new List<ITransform>();
     foreach (var f in fields.Where(f => f.Transforms.Any())) {
         var field = f;
         if (field.RequiresCompositeValidator()) {
             transforms.Add(new CompositeValidator(
                 new PipelineContext(ctx.Resolve<IPipelineLogger>(), process, entity, field),
                 field.Transforms.Select(t => SwitchTransform(ctx, new PipelineContext(ctx.Resolve<IPipelineLogger>(), process, entity, field, t) { Activity = PipelineActivity.Transform }))
                 ));
         } else {
             transforms.AddRange(field.Transforms.Select(t => SwitchTransform(ctx, new PipelineContext(ctx.Resolve<IPipelineLogger>(), process, entity, field, t) { Activity = PipelineActivity.Transform })));
         }
     }
     return transforms;
 }
 public override void LoadEntity(ContainerBuilder builder, Process process, Entity entity) {
     //master updater
     builder.Register<IUpdate>((ctx) => {
         var context = new PipelineContext(ctx.Resolve<IPipelineLogger>(), process, entity);
         var incrementer = new Incrementer(context);
         var output = new OutputContext(context, incrementer);
         switch (output.Connection.Provider) {
             case "sqlserver":
                 context.Debug("Registering {0} master updater", output.Connection.Provider);
                 return new SqlMasterUpdater(output);
             default:
                 context.Warn("Registering null updater");
                 return new NullMasterUpdater();
         }
     }).Named<IUpdate>(entity.Key);
 }
        public override void LoadEntity(ContainerBuilder builder, Process process, Entity entity) {
            builder.Register<IEntityController>(ctx => {
                var context = new PipelineContext(ctx.Resolve<IPipelineLogger>(), process, entity);
                var output = new OutputContext(context, new Incrementer(context));

                switch (output.Connection.Provider) {
                    case "sqlserver":
                        context.Debug("Registering sql server controller");
                        var initializer = process.Mode == "init" ? (IAction)new SqlEntityInitializer(output) : new NullInitializer();
                        return new SqlEntityController(output, initializer);
                    default:
                        context.Debug("Registering null controller");
                        return new NullEntityController();
                }

            }).Named<IEntityController>(entity.Key);
        }
Exemple #8
0
 public TestDeleter(Entity entity, List<Row> data) {
     _entity = entity;
     Data = data;
 }
Exemple #9
0
 public abstract void LoadEntity(ContainerBuilder builder, Process process, Entity entity);
 public SqlMasterUpdater(OutputContext output) {
     _output = output;
     _master = _output.Process.Entities.First(e => e.IsMaster);
 }