static void Main(string[] args) { DateTime?searchDate = null; bool downloadOnly = false; if (args.Length > 0) { if (args[0] == "-downloadonly") { downloadOnly = true; } if ((args[0]) == "-version") { System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo fileVersion = FileVersionInfo.GetVersionInfo(assembly.Location); Console.WriteLine(fileVersion.FileVersion); return; } } Console.Write(licenseStatement); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); List <int> statusCodeIdsNew = LocalDAO.GetNewApplicationStatusCodes(); List <int> statusCodeIdsDead = LocalDAO.GetDeadApplicationStatusCodes(); if (UserInputDAO.TryGetQueries(queriesFilename, out Dictionary <string, string> queries, out string errorMessage)) { Console.WriteLine("There are " + queries.Count.ToString() + " queries in " + queriesFilename); Settings settings = LocalDAO.GetSettings(); if (LocalDAO.CreateDatabaseIfNeeded()) { if (!LocalDAO.ValidateDatabase()) { Console.WriteLine("Local trademark application database is corrupted"); Console.WriteLine("Deleting and re-creating database"); LocalDAO.DeleteDatabase(); LocalDAO.CreateDatabaseIfNeeded(); settings.EarliestFilingDate = DateTime.MinValue; } DateTime latestDate = settings.LastDownloadDate; if (settings.EarliestFilingDate == DateTime.MinValue || settings.LastSuccessfulReportDate == DateTime.MinValue) { //first run searchDate = PromptPastDate("Search Start Date (ex: Jan 1 2019):"); settings.EarliestFilingDate = (DateTime)searchDate; settings.LastSuccessfulReportDate = settings.EarliestFilingDate; LocalDAO.SaveSettings(settings); latestDate = settings.EarliestFilingDate; } DateTime yesterday = DateTime.Now.AddDays(-1).Date; if ((latestDate).Date >= yesterday) { Console.WriteLine("Local trademark application database is up-to-date"); } else { foreach (DateTime day in EachDay(latestDate, yesterday)) { WriteTimeStampedLine("Getting USPTO applications from " + day.ToString("MMM dd, yyyy")); var trademarkApplications = UsptoDAO.GetDailyTrademarkApplications(day, LocalDAO.StatusCodes, settings.EarliestFilingDate, settings.DownloadAttempts); LocalDAO.SaveApplications(trademarkApplications.newApps, trademarkApplications.deadApps); settings.LastDownloadDate = day; LocalDAO.SaveSettings(settings); } } if (!downloadOnly) { Console.WriteLine(); //run report Console.WriteLine("Earliest Filings Downloaded: " + settings.EarliestFilingDate.ToString(dateFormat)); Console.WriteLine("Latest Filings Downloaded: " + settings.LastDownloadDate.ToString(dateFormat)); Console.WriteLine("Last Report Date: " + settings.LastSuccessfulReportDate.ToString(dateFormat)); Console.WriteLine(); if (searchDate == null) { searchDate = PromptPastDate("Search Start Date:", settings.EarliestFilingDate); } string reportName = RunReport(queries, settings, (DateTime)searchDate); OpenBrowser(settings.ReportsDirectory + Path.DirectorySeparatorChar + reportName); } } else { Console.WriteLine("One or more necessary files are missing or corrupted. Please re-install."); PressAnyKey(); } } else { Console.WriteLine("ERROR: " + queriesFilename + " " + errorMessage); PressAnyKey(); } }