public static void StartAppEngine(RichTextBox richTextBox) { // assign the richTextBox global to point to the one on the main form mainformRichTextBox = richTextBox; try { // startup the OWIN webserver on the port specified in App.config // http://+ means that any host name is valid (ipaddress, localhost, MachineName etc) string url = "http://+:" + AppCommon.GetAppEnginePort().ToString(); WebApp.Start <Startup>(url); Log("Starting AdLineup App Engine", EventLogEntryType.Information); Log("App Engine API URL " + BuildUrl(GetAppEngineUrl(), "", GetAppEnginePort()) + " . ", EventLogEntryType.Information); Log("Remote server URL " + AppCommon.GetRemoteWebApiUrl() + " . ", EventLogEntryType.Information); Log("Saving files to " + GetFileSaveDirectory() + " . ", EventLogEntryType.Information); // purge old files older than the specified number of hours if purge enabled int countOfPurgedFiles = 0; if (AppCommon.IsPurgeOldFilesEnabled()) { countOfPurgedFiles = AppCommon.PurgeOldFiles(GetFileSaveDirectory(), AppCommon.GetPurgeAgeHours()); if (countOfPurgedFiles > 0) { AppCommon.Log("Purged " + countOfPurgedFiles.ToString() + " files from " + GetFileSaveDirectory() + " .", EventLogEntryType.Information); } } } catch (Exception e) { string message = AppendInnerExceptionMessages("Could not start the App Engine - " + e.Message, e); Log(message, EventLogEntryType.Error); Log("App Engine stopped.", EventLogEntryType.Error); } } // StartAppEngine()
public static void GenerateReport(Report report) { // generates the specified report in the specified format // gives the file the specified filename and stores it in the specified directory // check for valid input if (report.Name.Length == 0) { throw new Exception("GenerateReport: No report.Name specified."); } if (report.Filename.Length == 0) { throw new Exception("GenerateReport: No report.Filename specified."); } if (report.Url.Length == 0) { throw new Exception("GenerateReport: No report.Url specified."); } // generate the specified report AppCommon.Log("Generating report " + report.Name + ".", EventLogEntryType.Information); switch (report.Name.ToUpper()) { case "SAMPLEREPORT": Reports.SampleReport.Generate(report, fileSaveDirectory, app); break; // SAMPLEREPORT case "CUSTOMERSINDEXPRINTERFRIENDLY": Reports.CustomersIndexPrinterFriendlyReport.Generate(report, fileSaveDirectory, app); break; case "ADSINDEXPRINTERFRIENDLY": Reports.AdsIndexPrinterFriendlyReport.Generate(report, fileSaveDirectory, app); break; case "BILLBOARDSINDEXPRINTERFRIENDLY": Reports.BillboardsIndexPrinterFriendlyReport.Generate(report, fileSaveDirectory, app); break; } // purge old files older than the specified number of hours if purge enabled int countOfPurgedFiles = 0; if (AppCommon.IsPurgeOldFilesEnabled()) { countOfPurgedFiles = AppCommon.PurgeOldFiles(fileSaveDirectory, AppCommon.GetPurgeAgeHours()); if (countOfPurgedFiles > 0) { AppCommon.Log("Purged " + countOfPurgedFiles.ToString() + " files from " + fileSaveDirectory + " .", EventLogEntryType.Information); } } } // GenerateReport