Пример #1
0
        private static void Run()
        {
            string path = @"D:\db\";

            // Cria uma stream que sera lido
            var inputStream = new TextInputSource();

            inputStream.Open(Path.Combine(path, "input.csv"));

            // Cria uma stream que sera gravado
            var outputStream = new TextOutputSource();

            outputStream.Open(Path.Combine(path, "output.csv"));

            // Cria a transformação
            var transformation = new Transformation(inputStream, outputStream);

            transformation.AddRowTransformer(new RowTransformerSkipLine(0));
            transformation.AddTransformer(new TransformerNullToEmpty());
            transformation.AddTransformer(new TransformerToLower());

            // Adiciona um evento, com ele podemos acessar os estatos da transformação
            transformation.Diagnose += Transformation_Diagnose;

            // Executa a transformação e finaliza a transformação
            transformation.Execute();
            transformation.Dispose();
        }
Пример #2
0
        private static void RunJoinSources()
        {
            string path = @"D:\db\join\";

            List <IInputSource> sources = new List <IInputSource>();

            // Cria uma stream que sera lido
            var inputStream1 = new TextInputSource();

            inputStream1.Open(Path.Combine(path, "input1.csv"));
            sources.Add(inputStream1);

            var inputStream2 = new TextInputSource();

            inputStream2.Open(Path.Combine(path, "input2.csv"));
            sources.Add(inputStream2);

            var inputStream3 = new TextInputSource();

            inputStream3.Open(Path.Combine(path, "input3.csv"));
            sources.Add(inputStream3);

            var inputStream4 = new TextInputSource();

            inputStream4.Open(Path.Combine(path, "input4.csv"));
            sources.Add(inputStream4);

            var inputStream5 = new TextInputSource();

            inputStream5.Open(Path.Combine(path, "input5.csv"));
            sources.Add(inputStream5);

            var inputStream6 = new TextInputSource();

            inputStream6.Open(Path.Combine(path, "input6.csv"));
            sources.Add(inputStream6);

            var join = new JoinInputSource(sources);

            // Cria uma stream que sera gravado
            var outputStream = new TextOutputSource();

            outputStream.Open(Path.Combine(path, "output.csv"));

            // Cria a transformação
            var transformation = new Transformation(join, outputStream);

            transformation.AddRowTransformer(new RowTransformerSkipLine(0));
            transformation.AddTransformer(new TransformerNullToEmpty());
            transformation.AddTransformer(new TransformerToLower());

            // Adiciona um evento, com ele podemos acessar os estatos da transformação
            transformation.Diagnose += Transformation_Diagnose;

            // Executa a transformação e finaliza a transformação
            transformation.Execute();
            transformation.Dispose();
        }
Пример #3
0
        public void TestExcecution()
        {
            var t = new Transformation(MockInput(), MockOutput());

            t.AddRowTransformer(MockRowTransformer());
            t.AddTransformer(MockTransformer());
            t.Execute();
            t.Dispose();

            Assert.Equal(1, t.Counter);
        }
Пример #4
0
        public Transformation Build()
        {
            var transformation = new Transformation(_input, _output);

            foreach (var t in _transformers)
            {
                transformation.AddTransformer(t);
            }

            foreach (var t in _rowTransformers)
            {
                transformation.AddRowTransformer(t);
            }

            return(transformation);
        }