using bsmd.database; using CommandLine; using log4net; using System; namespace bsmd.Tool { public static class Program { private static readonly ILog log = LogManager.GetLogger("Tool"); public static int Main(string[] args) { int result = 0; log4net.Config.XmlConfigurator.Configure(); Options options = new Options(); try { Parser.Default.ParseArguments(args).WithParsed(o => { if (o.CheckRules) { if (Guid.TryParse(options.MessageCoreId, out Guid coreId)) { CheckRules.Check(coreId); } else { Console.WriteLine("cannot parse message core id"); log.FatalFormat("CheckRules: cannot parse message core id"); } } if (!string.IsNullOrEmpty(o.CleanupFolderRoot)) { CleanupFiles.Cleanup(options.CleanupFolderRoot, options.StaleDays, options.CleanupRecursive); } if(o.ImportLocodes) { if(!string.IsNullOrEmpty(o.LocodeCSV) && !string.IsNullOrEmpty(o.LocodeDB)) { LocodeSQliteImport.Import(o.LocodeDB, o.LocodeCSV); } } if(o.Echolot) { string outputFolder = Properties.Settings.Default.EcholotOutputFolder; if (!o.OutputFolder.IsNullOrEmpty()) outputFolder = o.OutputFolder; int maxThreads = 2; if (o.MaxThreads.HasValue) maxThreads = o.MaxThreads.Value; Echolot.Evaluate(outputFolder, maxThreads); } }); } catch (Exception ex) { log.Fatal(ex.ToString()); Console.WriteLine(ex.Message); result = 1; } return result; } } }