Beispiel #1
0
        public void WhenCreateNewReportProcess_Then_StatusPending()
        {
            //arrange
            var globalConfig = new GlobalConfiguration {
                PathToExportExcelFiles = Environment.CurrentDirectory, TimerIntervalInMiliSeconds = 10000
            };
            var fileHandler             = new FileHandler();
            var excelExportService      = new DataTableExportToCsvService(fileHandler);
            var repositoryForSql        = new SqlServerRepository(connectionString);
            var repositoryReportProcess = new ReportProcessRepository(repositoryForSql);
            var reportProcessService    = new ReportProcessService(repositoryReportProcess, repositoryForSql, excelExportService, globalConfig);

            //act
            var listToProcess = repositoryReportProcess.GetListPendingToStart();

            var threadManager = new ThreadManager <ReportProcessModel>();

            threadManager.ProcessInParallel(10, listToProcess, reportProcessService.ExecuteProcess, TimeSpan.FromMinutes(2));

            var listToProcessSecondCycle = repositoryReportProcess.GetListPendingToStart();

            //assert
            Assert.IsTrue(listToProcess.Count() > 0);
            Assert.AreEqual(0, listToProcessSecondCycle.Count());
        }
Beispiel #2
0
        private static void Execute()
        {
            var globalConfig = new GlobalConfiguration
            {
                PathToExportExcelFiles     = Path.Combine(Environment.CurrentDirectory, "ExportedFiles"),
                TimerIntervalInMiliSeconds = 10000,
                ConnectionString           = @"",
                ThreadTimeOutInMiliseconds = 2000
            };
            var fileHandler             = new FileHandler();
            var excelExportService      = new DataTableExportToCsvService(fileHandler);
            var repositoryForSql        = new SqlServerRepository(globalConfig.ConnectionString);
            var repositoryReportProcess = new ReportProcessRepository(repositoryForSql);
            var reportProcessService    = new ReportProcessService(repositoryReportProcess, repositoryForSql, excelExportService, globalConfig);

            //act
            var listToProcess = repositoryReportProcess.GetListPendingToStart();

            var threadManager = new ThreadManager <ReportProcessModel>();

            threadManager.ProcessInParallel(10, listToProcess, reportProcessService.ExecuteProcess, TimeSpan.FromMinutes(globalConfig.ThreadTimeOutInMiliseconds));
        }