Example #1
0
        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()