Esempio n. 1
0
        public override async Task <int> RunAsync(string[] args)
        {
            string authorization = GetAuthorization();

            _blipAIClient = new BlipHttpClientAsync(authorization);

            LogVerboseLine("NLP Export");

            var intentions = await _blipAIClient.GetAllIntents(verbose : Verbose.IsSet);

            var entities = await _blipAIClient.GetAllEntities(verbose : Verbose.IsSet);

            Directory.CreateDirectory(OutputFilePath.Value);

            if (Excel.IsSet)
            {
                if (Excel.Value == string.Empty || Excel.Value == null)
                {
                    throw new ArgumentNullException("You must provide a file name to save the file.");
                }

                List <NLPExcelExportModel> excelExportModels = new List <NLPExcelExportModel>();

                excelExportModels.Add(WriteIntentionExcel(intentions));

                excelExportModels.Add(WriteQuestionsExcel(intentions));

                excelExportModels.Add(WriteAnswersExcel(intentions));

                excelExportModels.Add(WriteEntitiesExcel(entities));

                ExcelGeneratorService.WriteContentOnExcel(excelExportModels, OutputFilePath.Value, Excel.Value);
            }
            else
            {
                WriteIntentionCSV(intentions);

                WriteAnswersCSV(intentions);

                WriteEntitiesCSV(entities);
            }

            LogVerboseLine("DONE");

            return(0);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var chrono = new Stopwatch();

            chrono.Start();
            var generateExcel = args[0];

            // Arguments must be true or false, for excel generation
            if (generateExcel == null)
            {
                throw new ArgumentNullException();
            }

            ConfigureLogger();
            _logger.Information("Starting MediaChecker ...");

            // Initialization
            var configuration = GetConfiguration();
            var connectData   = GetConnectionData(configuration);

            _dbService = new DataBaseService(connectData);

            _logger.Information("Retrieving files ...");
            var mediaFiles = FileHelper.GetContentFolder(configuration.GetSection("InputFolder").Value);

            // TODO
            // FileHelpers.GetMetaDataFromList(mediaFiles);


            if (generateExcel.Equals("true"))
            {
                // Generate Excel file for with the result list
                _logger.Information("Generating Excel File ...");
                ExcelGeneratorService.GenerateExcelFile(mediaFiles, configuration.GetSection("ExcelOuputFolder").Value);
            }

            try
            {
                _logger.Information("Saving documents to db ...");

                // Avoid duplication
                var objCollection = _dbService.Collection;

                foreach (var file in mediaFiles
                         .ToList()
                         .Where(file => objCollection
                                .FindSync(x => x.Name == file.Name)
                                .Any()))
                {
                    mediaFiles.Remove(file);
                }

                if (mediaFiles.Count > 0)
                {
                    _dbService.Add(mediaFiles);
                }
                chrono.Stop();
                TimeSpan ts          = chrono.Elapsed;
                string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                     ts.Hours, ts.Minutes, ts.Seconds,
                                                     ts.Milliseconds / 10);
                _logger.Information($"Stop Watch = {elapsedTime}");
            }
            catch (MongoException e)
            {
                _logger.Error(e.Message);
            }

            _logger.Information("Done !");
        }