예제 #1
0
        public async Task RunBatch(dynamic parameters)
        {
            string outputFolder = parameters.outputFolder;

            EnvironmentHelper.UserName = () => "PK-Sim Master";

            _logger.AddInSeparator($"Starting training material generation: {DateTime.Now.ToIsoFormat()}");
            var outputDirectory = new DirectoryInfo(outputFolder);

            if (outputDirectory.Exists)
            {
                outputDirectory.Delete(recursive: true);
                _logger.AddInfo($"Deleting folder '{outputFolder}'");
            }

            outputDirectory.Create();

            var begin = DateTime.UtcNow;

            await generateTrainingMaterial(outputFolder);

            var end       = DateTime.UtcNow;
            var timeSpent = end - begin;

            _logger.AddInSeparator($"Finished training material generation in {timeSpent.ToDisplay()}'");
        }
예제 #2
0
        public async Task RunBatch(dynamic parameters)
        {
            string           inputFolder      = parameters.inputFolder;
            string           outputFolder     = parameters.outputFolder;
            string           logFileFullPath  = parameters.logFileFullPath;
            BatchExportMode  exportMode       = parameters.exportMode;
            NotificationType notificationType = parameters.notificationType;

            clear();

            using (new BatchLoggerDisposer(_logger, logFileFullPath, notificationType))
            {
                _logger.AddInSeparator($"Starting batch run: {DateTime.Now.ToIsoFormat()}", NotificationType.Info);

                var inputDirectory = new DirectoryInfo(inputFolder);
                if (!inputDirectory.Exists)
                {
                    throw new ArgumentException($"Input folder '{inputFolder}' does not exist");
                }

                var allSimulationFiles = inputDirectory.GetFiles(CoreConstants.Filter.JSON_FILTER);
                if (allSimulationFiles.Length == 0)
                {
                    throw new ArgumentException($"No simulation json file found in '{inputFolder}'");
                }

                var outputDirectory = new DirectoryInfo(outputFolder);
                if (!outputDirectory.Exists)
                {
                    _logger.AddDebug($"Creating folder '{outputFolder}'");
                    outputDirectory.Create();
                }

                var allExistingFiles = outputDirectory.GetFiles("*.csv");
                allExistingFiles.Each(outputFile =>
                {
                    FileHelper.DeleteFile(outputFile.FullName);
                    _logger.AddDebug($"Deleting file '{outputFile.FullName}'");
                });

                var begin = DateTime.UtcNow;
                _logger.AddInfo($"Found {allSimulationFiles.Length} files in '{inputFolder}'");

                foreach (var simulationFile in allSimulationFiles)
                {
                    await exportSimulationTo(simulationFile, outputFolder, exportMode);
                }

                var end       = DateTime.UtcNow;
                var timeSpent = end - begin;
                _logger.AddInSeparator($"{_allSimulationNames.Count} simulations calculated and exported in '{timeSpent.ToDisplay()}'", NotificationType.Info);

                createSummaryFilesIn(outputDirectory);

                _logger.AddInSeparator($"Batch run finished: {DateTime.Now.ToIsoFormat()}", NotificationType.Info);
            }
        }
예제 #3
0
        public async Task RunBatch(dynamic parameters)
        {
            string inputFolder  = parameters.inputFolder;
            string outputFolder = parameters.outputFolder;

            clear();

            _logger.AddInSeparator($"Starting project comparison run: {DateTime.Now.ToIsoFormat()}");

            var inputDirectory = new DirectoryInfo(inputFolder);

            if (!inputDirectory.Exists)
            {
                throw new ArgumentException($"Input folder '{inputFolder}' does not exist");
            }

            var allProjectFiles = inputDirectory.GetFiles(CoreConstants.Filter.PROJECT_FILTER);

            if (allProjectFiles.Length == 0)
            {
                throw new ArgumentException($"No project file found in '{inputFolder}'");
            }

            var outputDirectory = new DirectoryInfo(outputFolder);

            if (outputDirectory.Exists)
            {
                outputDirectory.Delete(recursive: true);
                _logger.AddInfo($"Deleting folder '{outputFolder}'");
            }

            outputDirectory.Create();
            var afterConversionDirectory = outputDirectory.CreateSubdirectory("after_conversion_results");
            var originalDirectory        = outputDirectory.CreateSubdirectory("original_results");
            var newDirectory             = outputDirectory.CreateSubdirectory("new_simulation_based_on_old_building_blocks_results");
            var pkmlOldDirectory         = outputDirectory.CreateSubdirectory("pkml_from_converted_simulations");
            var pkmlNewDirecotry         = outputDirectory.CreateSubdirectory("pkml_from_new_simulations");

            var begin = DateTime.UtcNow;

            //this tasks cannot be run in // because of global stuff going on in deserialization.
            foreach (var projectFile in allProjectFiles)
            {
                await exportProjectResults(projectFile, originalDirectory, afterConversionDirectory, newDirectory, pkmlOldDirectory, pkmlNewDirecotry);
            }

            var end       = DateTime.UtcNow;
            var timeSpent = end - begin;

            _logger.AddInSeparator($"Finished project comparison run in {timeSpent.ToDisplay()}'");
        }