private static DirectoryInfo ParseLogFileFolder()
        {
            const string appSettingKeyName = "LogFileFolder";
            var          logFileFolder     = SitkaConfiguration.GetRequiredAppSetting(appSettingKeyName);

            Check.RequireDirectoryExists(logFileFolder, "App setting {0} must be a folder that exists, folder does not exist.");
            return(new DirectoryInfo(logFileFolder));
        }
        private void InitializeTempFolders()
        {
            var tempPath          = new DirectoryInfo(SitkaConfiguration.GetRequiredAppSetting("TempFolder"));
            var baseTempDirectory = new DirectoryInfo($"{tempPath.FullName}\\{TemplateTempDirectoryName}\\");

            baseTempDirectory.Create();
            FullTemplateTempDirectory      = baseTempDirectory.FullName;
            FullTemplateTempImageDirectory = baseTempDirectory.CreateSubdirectory(TemplateTempImageDirectoryName).FullName;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="httpPostedFileBase"></param>
        /// <returns>Full path to preserved file</returns>
        public static string PreserveFailedLocationImportFile(HttpPostedFileBase httpPostedFileBase)
        {
            var baseTempPath    = new DirectoryInfo(SitkaConfiguration.GetRequiredAppSetting("TempFolder"));
            var ogr2OgrTempPath = new DirectoryInfo(Path.Combine(baseTempPath.ToString(), FailedGeospatialImportFolderName));

            if (!ogr2OgrTempPath.Exists)
            {
                baseTempPath.CreateSubdirectory(FailedGeospatialImportFolderName);
            }

            var preservedFilename = Path.Combine(ogr2OgrTempPath.ToString(), $"{DateTime.Now.ToString("yyyyMMddhhmmss")}-{httpPostedFileBase.FileName}");

            httpPostedFileBase.SaveAs(preservedFilename);

            return(preservedFilename);
        }
Example #4
0
        /// <summary>
        /// We may want to do a version check on Google Chrome as well
        /// </summary>
        /// <returns></returns>
        //public const string ExpectedWhtmlToPdfVersionString = "0.12.5";

        public static HealthCheckResult Run()
        {
            var result = new HealthCheckResult("HeadlessGoogleChromeIsAvailable");

            // Assume success until we get failure
            result.HealthCheckStatus = HealthCheckStatus.OK;

            // Make sure we have HTTP context
            var currentHttpContext = HttpContext.Current;

            if (currentHttpContext == null)
            {
                result.HealthCheckStatus = HealthCheckStatus.Critical;
                result.AddResultMessage("Could not run check because missing HTTP context");
                return(result);
            }

            // Make sure Google Chrome .EXE exists where we expect it for this environment
            FileInfo googleChromeExecutablePathFileInfo = new FileInfo(SitkaConfiguration.GetRequiredAppSetting("HeadlessGoogleChromeExecutable"));

            if (!File.Exists(googleChromeExecutablePathFileInfo.FullName))
            {
                result.HealthCheckStatus = HealthCheckStatus.Critical;
                result.AddResultMessage($"Could not find Google Chrome .EXE at \"{googleChromeExecutablePathFileInfo.FullName}\"");
                return(result);
            }

            // We may want to do something like this for Google Chrome eventually; here for reference.

            //// If .EXE does exist, make sure it has the right version number
            //var versionString = WkhtmlToPdfCommandLineRunner.RunWkhtmlToPdfAndGetVersionNumber();

            //if (versionString != ExpectedWhtmlToPdfVersionString)
            //{
            //    result.HealthCheckStatus = HealthCheckStatus.Critical;
            //    string wkhtmlPdfExecutablePath = SitkaConfiguration.GetRequiredAppSetting("WkhtmltopdfExecutable");
            //    result.AddResultMessage($"Wkhtmltopdf found at {wkhtmlPdfExecutablePath} is version {versionString}; expected {ExpectedWhtmlToPdfVersionString}");

            //    return result;
            //}

            //result.AddResultMessage($"Wkhtmltopdf is expected version ({versionString})");

            result.AddResultMessage($"Google Chrome appears to be installed where expected at {googleChromeExecutablePathFileInfo.FullName}");
            return(result);
        }
Example #5
0
        public static string GenerateForgotPasswordUrlWithReturnUrl(string returnUrl)
        {
            var forgotPasswordUrl = SitkaConfiguration.GetRequiredAppSetting("KeystoneForgotPasswordUrl");

            return($"{forgotPasswordUrl}?RedirectUrl={HttpUtility.UrlEncode(returnUrl)}");
        }
Example #6
0
        public static string GenerateCreateAccountWithReturnUrl(string returnUrl)
        {
            var createAccountUrl = SitkaConfiguration.GetRequiredAppSetting("KeystoneRegisterUrl");

            return($"{createAccountUrl}?RedirectUrl={HttpUtility.UrlEncode(returnUrl)}");
        }
Example #7
0
            public override IEnumerable <string> GetCanonicalHostNamesForEnvironment()
            {
                var canonicalHostNames = SitkaConfiguration.GetRequiredAppSettingList("CanonicalHostName");

                return(canonicalHostNames);
            }