Beispiel #1
0
        internal static WhiteListForecastWorker GetWhiteListForecastWorker()
        {
            IConfigurationSource   configurationSource    = GetConfigurationSource();
            WhiteListConfiguration whiteListConfiguration = configurationSource.GetWindowsAzureHostedServiceWhiteListConfiguration();

            if (whiteListConfiguration != null)
            {
                SubscriptionConfiguration[] subscriptionConfigurations = configurationSource.GetAllWindowsAzureSubscriptionConfigurations();
                ISubscription[]             subscriptions = new ISubscription[subscriptionConfigurations.Length];
                for (int i = 0; i < subscriptionConfigurations.Length; i++)
                {
                    subscriptions[i] = subscriptionConfigurations[i].Convert();
                }

                if (whiteListConfiguration.IncludeDeploymentCreateServices)
                {
                    foreach (DeploymentCreateConfiguration deploymentCreateConfiguration in configurationSource.GetWindowsAzureDeploymentCreateConfigurations())
                    {
                        bool alreadyIncluded = false;
                        foreach (WhiteListService configuredWhiteListService in whiteListConfiguration.Services)
                        {
                            if (configuredWhiteListService.Name == deploymentCreateConfiguration.ServiceName)
                            {
                                alreadyIncluded = true;
                            }
                        }

                        if (!alreadyIncluded)
                        {
                            WhiteListService whiteListService = new WhiteListService {
                                Name = deploymentCreateConfiguration.ServiceName
                            };
                            whiteListConfiguration.Services.Add(whiteListService);
                        }
                    }
                }

                if (whiteListConfiguration.IncludeDeploymentDeleteServices)
                {
                    foreach (DeploymentDeleteConfiguration deploymentDeleteConfiguration in configurationSource.GetWindowsAzureDeploymentDeleteConfigurations())
                    {
                        bool alreadyIncluded = false;
                        foreach (WhiteListService configuredWhiteListService in whiteListConfiguration.Services)
                        {
                            if (configuredWhiteListService.Name == deploymentDeleteConfiguration.ServiceName)
                            {
                                alreadyIncluded = true;
                            }
                        }

                        if (!alreadyIncluded)
                        {
                            WhiteListService whiteListService = new WhiteListService {
                                Name = deploymentDeleteConfiguration.ServiceName
                            };
                            whiteListConfiguration.Services.Add(whiteListService);
                        }
                    }
                }

                if (whiteListConfiguration.IncludeHorizontalScaleServices)
                {
                    foreach (ScheduledHorizontalScaleConfiguration windowsAzureScheduledHorizontalScaleConfiguration in configurationSource.GetWindowsAzureScheduledHorizontalScaleConfigurations())
                    {
                        bool alreadyIncluded = false;
                        foreach (WhiteListService configuredWhiteListService in whiteListConfiguration.Services)
                        {
                            if (configuredWhiteListService.Name == windowsAzureScheduledHorizontalScaleConfiguration.ServiceName)
                            {
                                alreadyIncluded = true;
                            }
                        }

                        if (!alreadyIncluded)
                        {
                            WhiteListService whiteListService = new WhiteListService {
                                Name = windowsAzureScheduledHorizontalScaleConfiguration.ServiceName
                            };
                            whiteListConfiguration.Services.Add(whiteListService);
                        }
                    }
                }

                WhiteListForecastWorker whiteListForecastWorker = new WhiteListForecastWorker(
                    subscriptions,
                    new Deployment(),
                    new Operation(),
                    whiteListConfiguration.Services.ToArray(),
                    whiteListConfiguration.PollingIntervalInMinutes);
                return(whiteListForecastWorker);
            }

            return(null);
        }