Example #1
0
        public static ManagerSettings CreateSettingsFromParamsOrDefault(NameValueCollection requestParams = null)
        {
            if (requestParams == null)
            {
                requestParams = new NameValueCollection();
            }
            var dBConnectionString          = ConfigurationManager.ConnectionStrings[SnapRepoConnectionStringName]?.ConnectionString;
            var blobStorageConnectionString = BlobStorageService.BlobStorageConnectionString;
            var databaseName = requestParams["databaseName"]
                               ?? ConfigurationManager.AppSettings["SnapRepo.DatabaseName"]
                               ?? new SqlConnectionStringBuilder(dBConnectionString).InitialCatalog;

            return(new ManagerSettings()
            {
                LocalRepositoryPath = StaticLocalRepositoryPath,
                AppDataFolder = requestParams["appDataFolder"]
                                ?? ConfigurationManager.AppSettings["SnapRepo.AppDataFolder"]
                                ?? TryGetEpiserverAppDataPath()
                                ?? "C:\\Path\\To\\AppData\\Folder",
                ContainerName = requestParams["containerName"]
                                ?? ConfigurationManager.AppSettings["SnapRepo.ContainerName"]
                                ?? "backup-repository",
                DatabaseOwner = requestParams["databaseOwner"]
                                ?? ConfigurationManager.AppSettings["SnapRepo.DatabaseOwner"]
                                ?? GetDbOwner(databaseName, dBConnectionString)
                                ?? "DbOwner",
                DatabaseServerName = requestParams["databaseServerName"]
                                     ?? ConfigurationManager.AppSettings["SnapRepo.DatabaseServerName"]
                                     ?? new SqlConnectionStringBuilder(dBConnectionString).DataSource,
                IisSiteName = requestParams["iisSiteName"]
                              ?? ConfigurationManager.AppSettings["SnapRepo.IisSiteName"],
                DbSharedBackupFolder = requestParams["dbSharedBackupFolder"]
                                       ?? ConfigurationManager.AppSettings["SnapRepo.DbSharedBackupFolder"],
                DatabaseName = databaseName,
                DbConnectionString = dBConnectionString,
                BlobStorageConnectionString = blobStorageConnectionString,
                AzureRepositoryUrl = BlobStorageService.GetBlobStorageUri(blobStorageConnectionString),
            });
        }