public static void Execute(IGraphOptions _ops) { json_reader = new JSONGraphReader(); nlg = new LanguageGenerator(); ops = _ops; string dir = ops.DirectoryName; string csvFilename = ops.CsvFilename; string inputFilename = ops.InputFilename; string[] json_files = Directory.GetFiles(dir, "*.json"); nlg.output_path = ops.OutputDir; processFile(inputFilename, null, null); log.Info("Successfully released the Excel handle. This is awesome."); IGraphConsole.WriteLine("Done."); Environment.Exit(IGraphConstants.EXIT_SUCCESS); }
public static void Main(string[] args) { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US", false); WriteBanner(); IGraphOptions opts = new IGraphOptions(args); #region Logger /// Logging setup. We do not use a configuration file. ColoredConsoleAppender appender = new ColoredConsoleAppender(); appender.Layout = new PatternLayout("[%5level]\t%m\n"); AddColorMapping(appender, Level.Error, ColoredConsoleAppender.Colors.Red | ColoredConsoleAppender.Colors.HighIntensity); AddColorMapping(appender, Level.Warn, ColoredConsoleAppender.Colors.Yellow | ColoredConsoleAppender.Colors.HighIntensity); switch (opts.LogLevel) { case 0: appender.Threshold = Level.Off; break; case 1: appender.Threshold = Level.Fatal; break; case 2: appender.Threshold = Level.Error; break; case 3: appender.Threshold = Level.Warn; break; case 4: appender.Threshold = Level.Info; break; case 5: appender.Threshold = Level.Debug; break; case 6: appender.Threshold = Level.All; break; default: appender.Threshold = Level.Warn; break; } appender.ActivateOptions(); BasicConfigurator.Configure(appender); IGraphConsole.WriteLine("Log level set to: " + appender.Threshold + " (" + opts.LogLevel + ")"); #endregion if (opts.isHelp) { opts.Help(); } else if (!opts.Validate()) { IGraphConsole.WriteError("There are unrecognized options." + "\n\tTry igl -h or igl --help for more information."); opts.Help(); Environment.Exit(IGraphConstants.INVALID_OPTIONS); } else if (opts.isFile && !File.Exists(opts.InputFilename)) { IGraphConsole.WriteError("The specified file was not found." + "\n\tYou said: " + opts.InputFilename); Environment.Exit(IGraphConstants.EXCEL_NOT_FOUND); } else if (opts.isCsv && !File.Exists(opts.CsvFilename)) { IGraphConsole.WriteError("CSV file not found."); Environment.Exit(IGraphConstants.CSV_NOT_FOUND); } else if (!Directory.Exists(opts.DirectoryName)) { IGraphConsole.WriteError("Directory does not exist." + "\n\tYou said: " + opts.DirectoryName + "\n\tRemember to add quotes if directory contains spaces."); Environment.Exit(IGraphConstants.DIR_NOT_FOUND); } else { IGraphLite.Execute(opts); } }
public static void Execute(IGraphOptions _ops) { // Atributes :) xl_reader = new ExcelGraphReader(); nlg = new LanguageGenerator(); ops = _ops; string dir = ops.DirectoryName; string csvFilename = ops.CsvFilename; string inputFilename = ops.InputFilename; if (ops.isFile) { processFile(inputFilename, null, null); } else if (ops.isCsv) { CsvFile[] xl_csvfiles = CsvParse.parse(csvFilename); string path_csvfile = Path.GetDirectoryName(Path.GetFullPath(csvFilename)); if (xl_csvfiles.Length == 0) { IGraphConsole.WriteError("CSV file found, but no Excel files in it." + "\n\tYou said: " + csvFilename); Environment.Exit(IGraphConstants.NO_GRAPH_FILES_IN_CSV); } // All's well so far, process each graph in each file in the dir log.Info(xl_csvfiles.Length + " Excel file(s) in the csv file."); foreach (CsvFile csvfile in xl_csvfiles) { string file = csvfile.Filename; string f = Path.Combine(path_csvfile, file); // full path of "file" if (File.Exists(f)) { processFile(f, csvfile.Language, csvfile.Title); } else { log.Warn("Excel file not found." + "\n\tThe Excel file must be in: " + f); } } } else { // Do Excel files exist in the directory? string[] xl_files = Directory.GetFiles(dir, "*.xls"); if (xl_files.Length == 0) { IGraphConsole.WriteError("Directory found, but no Excel files in it." + "\n\tYou said: " + (dir == "." ? ". (current directory)" : dir)); Environment.Exit(IGraphConstants.NO_GRAPH_FILES_IN_DIR); } log.Info(xl_files.Length + " Excel file(s) in the directory."); // All's well so far, process each graph in each file in the dir foreach (string file in xl_files) { processFile(file, null, null); } } log.Info("Successfully released the Excel handle. This is awesome."); IGraphConsole.WriteLine("Done."); Environment.Exit(IGraphConstants.EXIT_SUCCESS); }