internal void Apply(ApplicationPoolDefaults pool)
        {
            if (CLRVersion == CLRVersion.V40)
            {
                pool.ManagedRuntimeVersion = "v4.0";
            }
            else if (CLRVersion == CLRVersion.V20)
            {
                pool.ManagedRuntimeVersion = "v2.0";
            }
            else if (CLRVersion == CLRVersion.NoManagedCode)
            {
                pool.ManagedRuntimeVersion = string.Empty;
            }

            pool.Enable32BitAppOnWin64 = Enable32Bit;
            pool.ManagedPipelineMode   = Mode;
            pool.QueueLength           = QueueLength;
            pool.StartMode             = Start;

            pool.ProcessModel.MaxProcesses = MaxProcesses;
            pool.ProcessModel.UserName     = UserName;


            pool.Cpu.Limit                     = Limit;
            pool.Cpu.Action                    = Action;
            pool.Cpu.ResetInterval             = new TimeSpan(0, Interval, 0);
            pool.Cpu.SmpAffinitized            = Affinitized;
            pool.Cpu.SmpProcessorAffinityMask  = Mask;
            pool.Cpu.SmpProcessorAffinityMask2 = Mask2;

            MaxProcesses = pool.ProcessModel.MaxProcesses;
            UserName     = pool.ProcessModel.UserName;
        }
        public ApplicationPoolDefaultsSettings(ApplicationPoolDefaults pool)
        {
            if (pool.ManagedRuntimeVersion == "v4.0")
            {
                CLRVersion = CLRVersion.V40;
            }
            else if (pool.ManagedRuntimeVersion == "v2.0")
            {
                CLRVersion = CLRVersion.V20;
            }
            else
            {
                CLRVersion = CLRVersion.NoManagedCode;
            }

            Enable32Bit = pool.Enable32BitAppOnWin64;
            Mode        = pool.ManagedPipelineMode;
            QueueLength = pool.QueueLength;
            Start       = pool.StartMode;

            Limit       = pool.Cpu.Limit;
            Action      = pool.Cpu.Action;
            Interval    = pool.Cpu.ResetInterval.GetTotalMinutes();
            Affinitized = pool.Cpu.SmpAffinitized;
            Mask        = pool.Cpu.SmpProcessorAffinityMask;
            Mask2       = pool.Cpu.SmpProcessorAffinityMask2;

            MaxProcesses = pool.ProcessModel.MaxProcesses;
            UserName     = pool.ProcessModel.UserName;
        }
        public ApplicationPoolDefaultsSettingsDialog(IServiceProvider serviceProvider, ApplicationPoolDefaults defaults)
            : base(serviceProvider)
        {
            InitializeComponent();
            _defaults = defaults;
            var settings = new ApplicationPoolDefaultsSettings(defaults);

            propertyGrid1.SelectedObject = settings;
        }
Beispiel #4
0
        private static void SetToDefaults(ApplicationPool pool, ApplicationPoolDefaults defaults)
        {
            pool.ManagedPipelineMode   = defaults.ManagedPipelineMode;
            pool.ManagedRuntimeVersion = defaults.ManagedRuntimeVersion;
            pool.Enable32BitAppOnWin64 = defaults.Enable32BitAppOnWin64;
            pool.QueueLength           = defaults.QueueLength;
            pool.AutoStart             = defaults.AutoStart;

            pool.Cpu.Limit                     = defaults.Cpu.Limit;
            pool.Cpu.ResetInterval             = defaults.Cpu.ResetInterval;
            pool.Cpu.Action                    = defaults.Cpu.Action;
            pool.Cpu.SmpAffinitized            = defaults.Cpu.SmpAffinitized;
            pool.Cpu.SmpProcessorAffinityMask  = defaults.Cpu.SmpProcessorAffinityMask;
            pool.Cpu.SmpProcessorAffinityMask2 = defaults.Cpu.SmpProcessorAffinityMask2;

            if (pool.ProcessModel.Schema.HasAttribute(IdleTimeoutActionAttribute))
            {
                pool.ProcessModel.IdleTimeoutAction = defaults.ProcessModel.IdleTimeoutAction;
            }

            pool.ProcessModel.MaxProcesses      = defaults.ProcessModel.MaxProcesses;
            pool.ProcessModel.PingingEnabled    = defaults.ProcessModel.PingingEnabled;
            pool.ProcessModel.IdleTimeout       = defaults.ProcessModel.IdleTimeout;
            pool.ProcessModel.PingInterval      = defaults.ProcessModel.PingInterval;
            pool.ProcessModel.PingResponseTime  = defaults.ProcessModel.PingResponseTime;
            pool.ProcessModel.ShutdownTimeLimit = defaults.ProcessModel.ShutdownTimeLimit;
            pool.ProcessModel.StartupTimeLimit  = defaults.ProcessModel.StartupTimeLimit;

            pool.Recycling.LogEventOnRecycle              = defaults.Recycling.LogEventOnRecycle;
            pool.Recycling.DisallowOverlappingRotation    = defaults.Recycling.DisallowOverlappingRotation;
            pool.Recycling.DisallowRotationOnConfigChange = defaults.Recycling.DisallowRotationOnConfigChange;
            pool.Recycling.PeriodicRestart.PrivateMemory  = defaults.Recycling.PeriodicRestart.PrivateMemory;
            pool.Recycling.PeriodicRestart.Memory         = defaults.Recycling.PeriodicRestart.Memory;
            pool.Recycling.PeriodicRestart.Requests       = defaults.Recycling.PeriodicRestart.Requests;
            pool.Recycling.PeriodicRestart.Time           = defaults.Recycling.PeriodicRestart.Time;
        }
        public ApplicationPoolBasicSettingsDialog(IServiceProvider serviceProvider, ApplicationPool pool, ApplicationPoolDefaults defaults, ApplicationPoolCollection collection)
            : base(serviceProvider)
        {
            InitializeComponent();
            Pool = pool;
            var add = pool == null;

            if (pool == null)
            {
                Text                 = "Add Application Pool";
                cbStart.Checked      = defaults.AutoStart;
                cbMode.SelectedIndex = (int)defaults.ManagedPipelineMode;
                SetRuntimeVersion(defaults.ManagedRuntimeVersion);
            }
            else
            {
                Text                 = "Edit Application Pool";
                txtName.Text         = pool.Name;
                txtName.Enabled      = false;
                cbStart.Checked      = pool.AutoStart;
                cbMode.SelectedIndex = (int)pool.ManagedPipelineMode;
                SetRuntimeVersion(Pool.ManagedRuntimeVersion);
            }

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                if (Pool == null)
                {
                    if (collection.Any(item => item.Name == txtName.Text))
                    {
                        ShowMessage("An application pool with this name already exists.", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                        txtName.Focus();
                        return;
                    }

                    Pool = collection.Add(txtName.Text);
                }
                else
                {
                    Pool.Name = txtName.Text;
                }

                if (cbVersion.SelectedIndex == 0)
                {
                    Pool.ManagedRuntimeVersion = "v4.0";
                }
                else if (cbVersion.SelectedIndex == 1)
                {
                    Pool.ManagedRuntimeVersion = "v2.0";
                }
                else
                {
                    Pool.ManagedRuntimeVersion = string.Empty;
                }

                if (add && collection.Parent.Mode == WorkingMode.IisExpress)
                {
                    Pool["CLRConfigFile"] = @"%IIS_USER_HOME%\config\aspnet.config";
                }

                Pool.AutoStart           = cbStart.Checked;
                Pool.ManagedPipelineMode = (ManagedPipelineMode)cbMode.SelectedIndex;
                DialogResult             = DialogResult.OK;
            }));
        }
Beispiel #6
0
        public ApplicationPoolBasicSettingsDialog(IServiceProvider serviceProvider, ApplicationPool pool, ApplicationPoolDefaults defaults, ApplicationPoolCollection collection)
            : base(serviceProvider)
        {
            InitializeComponent();
            Pool        = pool;
            _collection = collection;
            _add        = pool == null;
            if (pool == null)
            {
                Text                 = "Add Application Pool";
                cbStart.Checked      = defaults.AutoStart;
                cbMode.SelectedIndex = (int)defaults.ManagedPipelineMode;
                SetRuntimeVersion(defaults.ManagedRuntimeVersion);
                return;
            }

            Text                 = "Edit Application Pool";
            txtName.Text         = pool.Name;
            txtName.Enabled      = false;
            cbStart.Checked      = pool.AutoStart;
            cbMode.SelectedIndex = (int)pool.ManagedPipelineMode;
            SetRuntimeVersion(Pool.ManagedRuntimeVersion);
        }
        public ApplicationPoolDefaultsSettingsDialog(IServiceProvider serviceProvider, ApplicationPoolDefaults defaults)
            : base(serviceProvider)
        {
            InitializeComponent();
            var settings = new ApplicationPoolDefaultsSettings(defaults);

            propertyGrid1.SelectedObject = settings;

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                ((ApplicationPoolDefaultsSettings)propertyGrid1.SelectedObject).Apply(defaults);
                DialogResult = DialogResult.OK;
            }));
        }