public Batch Import(string scheme, string filePath)
        {
            IBatchBuilder batchBuilder = new BatchFactory().GetBatchBuilder(scheme);

            batchDirector.BuildBatch(batchBuilder, filePath);
            return(batchBuilder.GetBatch());
        }
예제 #2
0
        public override void Initialize()
        {
            base.Initialize();

            AddArtistToCache(Artist.Unknown);
            AddArtistToCache(Artist.Various);

            var batch = BatchFactory.Create();

            var commands = new List <ICommand>();

            foreach (var artist in Cache.GetAll())
            {
                var command = CommandFactory.Create();

                command.AddStatement(
                    Insert
                    .OrReplace
                    .Into(Schema.Name)
                    .Columns(Schema.Fields.Select(x => x.Getter))
                    .Values(artist, Schema.Fields.Select(x => x.Getter))
                    );

                commands.Add(command);
            }

            commands.Each(x => batch.AddCommand(x));

            Store.Execute(batch);
        }
예제 #3
0
 public BatchPostHandler(
     IRepository<Batch> batches,
     BatchFactory batchFactory,
     IFileStore fileStore)
 {
     _batches = batches;
     _batchFactory = batchFactory;
     _fileStore = fileStore;
 }
예제 #4
0
        public void BatchCreateProductByName()
        {
            const int batchSize = 5;
            var       factory   = new BatchFactory();

            IEnumerable <IProduct> products = factory.Create(batchSize);

            Assert.AreEqual(batchSize, products.Count());
            Assert.AreEqual(batchSize, products.Count(x => x is ProductA));

            products = factory.Create("a", batchSize);
            Assert.AreEqual(batchSize, products.Count());
            Assert.AreEqual(batchSize, products.Count(x => x is ProductA));

            products = factory.Create("b", batchSize);
            Assert.AreEqual(batchSize, products.Count());
            Assert.AreEqual(batchSize, products.Count(x => x is ProductB));
        }
예제 #5
0
        public void BatchCreateProductByName()
        {
            var batchSize = 5;
            var factory   = new BatchFactory();

            //create default product
            var products = factory.Create(batchSize);

            Assert.AreEqual <int>(batchSize, products.Count());
            Assert.AreEqual <int>(batchSize, products.Count(x => x is ProductA));

            //concrete product type by name
            products = factory.Create("a", batchSize);
            Assert.AreEqual <int>(batchSize, products.Count());
            Assert.AreEqual <int>(batchSize, products.Count(x => x is ProductA));

            products = factory.Create("b", batchSize);
            Assert.AreEqual <int>(batchSize, products.Count());
            Assert.AreEqual <int>(batchSize, products.Count(x => x is ProductB));
        }
예제 #6
0
        public Boolean run(App app)
        {
            Printer.info("Checking for CCL update");

            double currentVersion   = App.VERSION;
            double availableVersion = Convert.ToDouble(app.source.SelectSingleNode("/source/launcher/currentVersion").InnerText);

            String exeName     = app.source.SelectSingleNode("/source/launcher/exe").InnerText;
            String exeNameTemp = exeName + "_temp";

            // if there is no new version or allowUpdate in source file is set to false
            if (availableVersion == currentVersion || app.source.SelectSingleNode("/source/launcher/allowUpdate").InnerText.Equals("false"))
            {
                Printer.resultOk();
                return(true);
            }

            // new version available
            Printer.resultNotice("new version available");

            Printer.info("Downloading new version");
            using (WebClient client = new WebClient())
            {
                try {
                    client.DownloadFile(app.source.SelectSingleNode("/source/launcher/url").InnerText, exeNameTemp);
                }
                catch (WebException exception)
                {
                    app.logger.Error("New version of the CCL was not found. Dump: " + exception.ToString());
                    return(false);
                }
            }

            Printer.info("Creating update script");
            int pid = Process.GetCurrentProcess().Id;

            BatchFactory.moverBatch(pid.ToString(), exeNameTemp, exeName, SelfUpdateModule.BATCH_UPDATER);

            Console.ReadLine();
            return(false);
        }
예제 #7
0
        static void Main(string[] args)
        {
            stopwatch = new Stopwatch();
            stopwatch.Start();
            List <FileBatch> batches = new List <FileBatch>();

            // Get all files from directory
            FileReader reader = new FileReader(fileStorage);

            FileInfo[] files = reader.Read("*.csv", recursive: true);

            BatchFactory <FileBatch> factory = new BatchFactory <FileBatch>(maxThreads, new List <object>(files));

            factory.SubscribeCompleted(WriteStatus);
            factory.SubscribeCompleted(IncreaseLines);

            factory.OnDone += new BatchFactory <FileBatch> .OnDoneHandler(OnBatchDone);

            factory.Start();
            Console.ReadKey();
        }
예제 #8
0
        public Boolean run(App app)
        {
            // This module has no printable output

            String exeNameActual  = AppDomain.CurrentDomain.FriendlyName;
            String exeNameDesired = app.getSourceValue("/source/launcher/exe");

            // if there is no new version or allowUpdate in source file is set to false
            if (exeNameActual.Equals(exeNameDesired))
            {
                return(true);
            }

            // new version available
            Printer.info("Launcher needs to be renamed");
            Printer.info("Creating rename script");
            int pid = Process.GetCurrentProcess().Id;

            BatchFactory.moverBatch(pid.ToString(), exeNameActual, exeNameDesired, SelfRenameModule.BATCH_RENAMER);

            Console.ReadLine();
            return(false);
        }
        /// <summary>
        ///		Allocates all the object specific to this Scene. For Manager use only!
        /// </summary>
        public void LoadScene()
        {
            this.isLoaded = true;
            this.isMarkedForSceneChange = false;

            // Load scene

            // Initialize the HUD
            this.hudDisplay.Initialize();

            // Make all collision pairs
            CollisionPairFactory collisonFactory = new CollisionPairFactory();

            collisonFactory.CreatePairs();

            // Make all the sprite batches
            BatchFactory spriteBatchFactory = new BatchFactory();

            spriteBatchFactory.CreateBatches();


            // Call event
            this.OnSceneLoad();
        }
예제 #10
0
        public void CreateTable()
        {
            var batchJob = new BatchJob();
            var builder  = new BatchBuilder(batchJob)
                           .Description("User")
                           .TargetTable("dbo.User")
                           .CanInsert()
                           .CanUpdate()
                           .Field(f => f
                                  .Name("EmailAddress")
                                  .DisplayName("Email Address")
                                  .DataType <string>()
                                  .IsKey()
                                  )
                           .Field(f => f
                                  .Name("FirstName")
                                  .DisplayName("First Name")
                                  .DataType <string>()
                                  )
                           .Field(f => f
                                  .Name("LastName")
                                  .DisplayName("Last Name")
                                  .DataType <string>()
                                  )
                           .Field(f => f
                                  .Name("IsValidated")
                                  .DisplayName("Validated")
                                  .DataType <bool>()
                                  )
                           .Field(f => f
                                  .Name("LockoutCount")
                                  .DisplayName("Lockout Count")
                                  .DataType <int?>()
                                  .CanBeNull()
                                  )
                           .Field(f => f
                                  .Name("Updated")
                                  .DisplayName("Updated")
                                  .DataType <DateTimeOffset>()
                                  .Default(FieldDefault.CurrentDate)
                                  );

            batchJob.Should().NotBeNull();
            batchJob.Fields.Count.Should().Be(6);

            batchJob.FileName = "Testing.csv";

            builder.Field("EmailAddress", f => f.Index(0));
            builder.Field("IsValidated", f => f.Index(1));
            builder.Field("LastName", f => f.Index(2));
            builder.Field("FirstName", f => f.Index(3));
            builder.Field("LockoutCount", f => f.Index(4));

            batchJob.Data = new[]
            {
                new[] { "email", "validated", "last", "first", "lockout" },
                new[] { "*****@*****.**", "true", "last1", "first1", "" },
                new[] { "*****@*****.**", "false", "", "first2", "" },
                new[] { "*****@*****.**", "", "last3", "first3", "2" },
            };

            var batchFactory   = new BatchFactory(new[] { new BatchValidator() }, null);
            var batchProcessor = new BatchProcessor(NullLogger <BatchProcessor> .Instance, batchFactory, null);

            batchProcessor.Should().NotBeNull();

            var dataTable = batchProcessor.CreateTable(batchJob);

            dataTable.Should().NotBeNull();

            dataTable.Columns.Count.Should().Be(6);

            dataTable.Columns[0].ColumnName.Should().Be("EmailAddress");
            dataTable.Columns[0].DataType.Should().Be <string>();

            dataTable.Columns[1].ColumnName.Should().Be("FirstName");
            dataTable.Columns[1].DataType.Should().Be <string>();

            dataTable.Columns[2].ColumnName.Should().Be("LastName");
            dataTable.Columns[2].DataType.Should().Be <string>();

            dataTable.Columns[3].ColumnName.Should().Be("IsValidated");
            dataTable.Columns[3].DataType.Should().Be <bool>();

            dataTable.Columns[4].ColumnName.Should().Be("LockoutCount");
            dataTable.Columns[4].DataType.Should().Be <int>();

            dataTable.Rows.Count.Should().Be(3);

            dataTable.Rows[0][0].Should().Be("*****@*****.**");
            dataTable.Rows[0][1].Should().Be("first1");
            dataTable.Rows[0][2].Should().Be("last1");
            dataTable.Rows[0][3].Should().Be(true);
            dataTable.Rows[0][4].Should().Be(DBNull.Value);

            dataTable.Rows[1][0].Should().Be("*****@*****.**");
            dataTable.Rows[1][1].Should().Be("first2");
            dataTable.Rows[1][2].Should().Be("");
            dataTable.Rows[1][3].Should().Be(false);
            dataTable.Rows[1][4].Should().Be(DBNull.Value);

            dataTable.Rows[2][0].Should().Be("*****@*****.**");
            dataTable.Rows[2][1].Should().Be("first3");
            dataTable.Rows[2][2].Should().Be("last3");
            dataTable.Rows[2][3].Should().Be(false);
            dataTable.Rows[2][4].Should().Be(2);
        }