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 !"); }