Пример #1
0
        public async Task TestVariableMax()
        {
            return;

            #region arrange
            var dir = Path.Combine(AppContext.BaseDirectory, "TestVariableMax");
            if (Directory.Exists(dir))
            {
                Directory.Delete(dir, true);
            }
            Directory.CreateDirectory(dir);

            var sb = new StringBuilder();
            sb.AppendLine("nr,model,Track_number");
            sb.AppendLine("1,Ford,B325ROS");
            sb.AppendLine("2,Audi,PL654CSM");
            sb.AppendLine("3,BMW,B325DFH");
            sb.AppendLine("4,Ford,B325IYS");
            var file = Path.Combine(dir, "cars.csv");
            File.WriteAllText(file, sb.ToString());
            SimpleJob sj = new SimpleJob();
            sj
            .AddReceiver(new ReceiverCSVFileInt(file, Encoding.UTF8))
            .AddTransformer(new TransformIntoVariable("MaxCars", GroupingFunctions.Max, "nr"))

            ;
            sj.RuntimeParameters    = new RuntimeParameter[1];
            sj.RuntimeParameters[0] = new RuntimeParameter();
            sj.RuntimeParameters[0].VariableName = "MaxCars";
            //sj.RuntimeParameters[0].NameObjectsToApplyTo = new string[] { "MyReceiver" };

            #endregion
            #region act

            await sj.Execute();


            #endregion
            #region assert
            #endregion
        }
Пример #2
0
        static async Task MainAsync(string[] args)
        {
            var sj = new SimpleJob();

            IReceive folder = new ReceiverFolderHierarchical(@"D:\test", "*.txt");
            //await folder.LoadData();
            var t = new TransformerFileToLines();

            t.TrimEmptyLines = false;
            //t.valuesRead = folder.valuesRead;
            //await t.Run();

            var addBak = new TransformerFieldAddString("FullName", "FullName", ".bak");

            addBak.valuesRead = t.valuesTransformed;
            //await addBak.Run();


            //var regex = new TransformRowRegex(@"^(?x<ip>123).*?$","text");
            var regex = new TransformRowRegexReplaceGuid(@"^.*x(?<ip>\w+)123.*?$", "text");

            regex.ReplaceAllNextOccurences = true;
            //regex.valuesRead = addBak.valuesTransformed;
            //await regex.Run();
            var file = new SenderByRowToFile("FullName", "lineNr", "text", ".txt");

            file.FileMode = System.IO.FileMode.Append;
            //file.valuesToBeSent = regex.valuesTransformed;
            //await file.Send();

            sj
            .AddReceiver(folder)
            .AddTransformer(t)
            //.AddTransformer(addBak)
            .AddTransformer(regex)
            .AddSender(file);

            File.WriteAllText("def.txt", sj.SerializeMe());
            await sj.Execute();
        }