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 TruckTrackWeb 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 IHttpActionResult PalletsIndexPrinterFriendly() { try { // create report object, Url is the public location where it can be viewed with a browser Report report = new Report(); report.Name = "PalletsIndexPrinterFriendly"; report.Filename = "PalletsIndexPrinterFriendly"; report.SaveFormat = WdSaveFormat.wdFormatPDF; report.Extension = AppCommon.GetExtensionFromWdSaveFormat(report.SaveFormat); report.Url = AppCommon.BuildUrl(AppCommon.GetAppEngineUrl(), report.Filename + "." + AppCommon.GetExtensionFromWdSaveFormat(report.SaveFormat), AppCommon.GetAppEnginePort()); // generate the report ReportManager.GenerateReport(report); // return the report properties return(Ok(report)); } catch (Exception e) { string message = AppCommon.AppendInnerExceptionMessages("ReportsController.PalletsIndexPrinterFriendly = " + e.Message, e); AppCommon.Log(message, EventLogEntryType.Error); throw new Exception(message); } } // PalletsIndexPrinterFriendly()
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 "VEHICLETYPESINDEXPRINTERFRIENDLY": Reports.VehicleTypesIndexPrinterFriendlyReport.Generate(report, fileSaveDirectory, app); break; case "PALLETSINDEXPRINTERFRIENDLY": Reports.PalletsIndexPrinterFriendlyReport.Generate(report, fileSaveDirectory, app); break; case "LOADSINDEXPRINTERFRIENDLY": Reports.LoadsIndexPrinterFriendlyReport.Generate(report, fileSaveDirectory, app); break; case "DRIVERSINDEXPRINTERFRIENDLY": Reports.DriversIndexPrinterFriendlyReport.Generate(report, fileSaveDirectory, app); break; case "STOPEVENTSINDEXPRINTERFRIENDLY": Reports.StopEventsIndexPrinterFriendlyReport.Generate(report, fileSaveDirectory, app); break; case "TRUCKSINDEXPRINTERFRIENDLY": Reports.TrucksIndexPrinterFriendlyReport.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