Ejemplo n.º 1
0
        /// <summary>
        /// Gets the storage configuration.
        /// </summary>
        /// <param name="serviceSection">The service section.</param>
        /// <returns>
        /// Storage Configuration
        /// </returns>
        protected override ICmsStorageConfiguration GetStorageConfiguration(CmsTestConfigurationSection serviceSection)
        {
            var accessKey = serviceSection.AmazonStorage.GetValue(AmazonAccessKey);
            var secretKey = serviceSection.AmazonStorage.GetValue(AmazonSecretKey);

            if (!string.IsNullOrWhiteSpace(accessKey) && !string.IsNullOrWhiteSpace(secretKey))
            {
                return serviceSection.AmazonStorage;
            }

            accessKey = Environment.GetEnvironmentVariable("BETTERCMS_AMAZON_STORAGE_ACCESS_KEY", EnvironmentVariableTarget.Machine);
            secretKey = Environment.GetEnvironmentVariable("BETTERCMS_AMAZON_STORAGE_SECRET_KEY", EnvironmentVariableTarget.Machine);
            if (!string.IsNullOrWhiteSpace(accessKey) || !string.IsNullOrWhiteSpace(secretKey))
            {
                var bucketName = Environment.GetEnvironmentVariable("BETTERCMS_AMAZON_STORAGE_BUCKET_NAME", EnvironmentVariableTarget.Machine);

                var configuration = new CmsStorageConfigurationElement
                    {
                        ContentRoot = Environment.GetEnvironmentVariable("BETTERCMS_AMAZON_STORAGE_CONTENT_ROOT", EnvironmentVariableTarget.Machine),
                        PublicContentUrlRoot = Environment.GetEnvironmentVariable("BETTERCMS_AMAZON_STORAGE_PUBLIC_CONTENT_ROOT", EnvironmentVariableTarget.Machine),
                        ServiceType = StorageServiceType.Auto
                    };

                configuration.Add(new KeyValueElement {Key = AmazonAccessKey, Value = accessKey});
                configuration.Add(new KeyValueElement {Key = AmazonSecretKey, Value = secretKey});
                configuration.Add(new KeyValueElement {Key = AmazonBucketName, Value = bucketName});

                return configuration;
            }

            return null;
        }
        /// <summary>
        /// Gets the storage configuration.
        /// </summary>
        /// <param name="serviceSection">The service section.</param>
        /// <returns>
        /// Storage Configuration
        /// </returns>
        protected override ICmsStorageConfiguration GetStorageConfiguration(Configuration.CmsTestConfigurationSection serviceSection)
        {
            var userName = serviceSection.FtpStorage.GetValue(FtpUserName);
            var password = serviceSection.FtpStorage.GetValue(FtpPassword);

            if (!string.IsNullOrWhiteSpace(userName) && !string.IsNullOrWhiteSpace(password))
            {
                return serviceSection.FtpStorage;
            }

            userName = Environment.GetEnvironmentVariable("BETTERCMS_FTP_STORAGE_USER_NAME", EnvironmentVariableTarget.Machine);
            password = Environment.GetEnvironmentVariable("BETTERCMS_FTP_STORAGE_PASSWORD", EnvironmentVariableTarget.Machine);
            if (!string.IsNullOrWhiteSpace(userName) || !string.IsNullOrWhiteSpace(password))
            {
                var usePassiveMode = Environment.GetEnvironmentVariable("BETTERCMS_FTP_STORAGE_USE_PASSIVE_MODE", EnvironmentVariableTarget.Machine);
                var ftpRoot = Environment.GetEnvironmentVariable("BETTERCMS_FTP_STORAGE_FTP_ROOT", EnvironmentVariableTarget.Machine);

                var configuration = new CmsStorageConfigurationElement
                {
                    ContentRoot = Environment.GetEnvironmentVariable("BETTERCMS_FTP_STORAGE_CONTENT_ROOT", EnvironmentVariableTarget.Machine),
                    PublicContentUrlRoot = Environment.GetEnvironmentVariable("BETTERCMS_FTP_STORAGE_CONTENT_ROOT_URL", EnvironmentVariableTarget.Machine),
                    ServiceType = StorageServiceType.Ftp
                };

                configuration.Add(new KeyValueElement { Key = FtpUserName, Value = userName });
                configuration.Add(new KeyValueElement { Key = FtpPassword, Value = password });
                configuration.Add(new KeyValueElement { Key = FtpUsePassiveMode, Value = usePassiveMode });
                configuration.Add(new KeyValueElement { Key = FtpRootUrl, Value = ftpRoot });

                return configuration;
            }

            return null;
        }
        protected override ICmsStorageConfiguration GetStorageConfiguration(Configuration.CmsTestConfigurationSection serviceSection)
        {
            var accountName = serviceSection.AzureStorage.GetValue(AzureAccountName);
            var secretKey = serviceSection.AzureStorage.GetValue(AzureSecondaryKey);

            if (!string.IsNullOrWhiteSpace(accountName) && !string.IsNullOrWhiteSpace(secretKey))
            {
                return serviceSection.AzureStorage;
            }

            accountName = Environment.GetEnvironmentVariable("BETTERCMS_AZURE_STORAGE_ACCOUNT_KEY", EnvironmentVariableTarget.Machine);
            secretKey = Environment.GetEnvironmentVariable("BETTERCMS_AZURE_STORAGE_SECONDARY_KEY", EnvironmentVariableTarget.Machine);
            if (!string.IsNullOrWhiteSpace(accountName) || !string.IsNullOrWhiteSpace(secretKey))
            {
                var containerName = Environment.GetEnvironmentVariable("BETTERCMS_AZURE_STORAGE_CONTAINER_NAME", EnvironmentVariableTarget.Machine);
                var useHttps = Environment.GetEnvironmentVariable("BETTERCMS_AZURE_STORAGE_USE_HTTPS", EnvironmentVariableTarget.Machine);

                var configuration = new CmsStorageConfigurationElement
                {
                    ContentRoot = Environment.GetEnvironmentVariable("BETTERCMS_AZURE_STORAGE_CONTENT_ROOT", EnvironmentVariableTarget.Machine),
                    ServiceType = StorageServiceType.Auto
                };

                configuration.Add(new KeyValueElement { Key = AzureAccountName, Value = accountName });
                configuration.Add(new KeyValueElement { Key = AzureSecondaryKey, Value = secretKey });
                configuration.Add(new KeyValueElement { Key = AzureContainerName, Value = containerName });
                if (!string.IsNullOrWhiteSpace(useHttps))
                {
                    configuration.Add(new KeyValueElement { Key = AzureUseHttps, Value = useHttps });
                }

                return configuration;
            }

            return null;
        }