Пример #1
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            this.ForumEditor.DataSource = this.Get<IModuleManager<ForumEditor>>().ActiveAsDataTable("Editors");

            // TODO: vzrus: UseFullTextSearch check box is data layer specific and can be hidden by YAF.Classes.Data.CommonDb.FullTextSupported  property.)
            this.DataBind();

            // load Board Setting collection information...
            var settingCollection = new YafBoardSettingCollection(this.Get<YafBoardSettings>());

            // handle checked fields...
            foreach (string name in settingCollection.SettingsBool.Keys)
            {
                Control control = this.HostSettingsTabs.FindControlRecursive(name);

                if (control != null && control is CheckBox && settingCollection.SettingsBool[name].CanRead)
                {
                    // get the value from the property...
                    ((CheckBox)control).Checked =
                        (bool)
                        Convert.ChangeType(
                            settingCollection.SettingsBool[name].GetValue(this.Get<YafBoardSettings>(), null),
                            typeof(bool));
                }
            }

            // handle string fields...
            foreach (string name in settingCollection.SettingsString.Keys)
            {
                Control control = this.HostSettingsTabs.FindControlRecursive(name);

                if (control != null && control is TextBox && settingCollection.SettingsString[name].CanRead)
                {
                    // get the value from the property...
                    ((TextBox)control).Text =
                        (string)
                        Convert.ChangeType(
                            settingCollection.SettingsString[name].GetValue(this.Get<YafBoardSettings>(), null),
                            typeof(string));
                }
                else if (control != null && control is DropDownList && settingCollection.SettingsString[name].CanRead)
                {
                    ListItem listItem =
                        ((DropDownList)control).Items.FindByValue(
                            settingCollection.SettingsString[name].GetValue(this.Get<YafBoardSettings>(), null).ToString());

                    if (listItem != null)
                    {
                        listItem.Selected = true;
                    }
                }
            }

            // handle int fields...
            foreach (string name in settingCollection.SettingsInt.Keys)
            {
                Control control = this.HostSettingsTabs.FindControlRecursive(name);

                if (control != null && control is TextBox && settingCollection.SettingsInt[name].CanRead)
                {
                    // get the value from the property...
                    ((TextBox)control).Text =
                        settingCollection.SettingsInt[name].GetValue(this.Get<YafBoardSettings>(), null).ToString();
                }
                else if (control != null && control is DropDownList && settingCollection.SettingsInt[name].CanRead)
                {
                    ListItem listItem =
                        ((DropDownList)control).Items.FindByValue(
                            settingCollection.SettingsInt[name].GetValue(this.Get<YafBoardSettings>(), null).ToString());

                    if (listItem != null)
                    {
                        listItem.Selected = true;
                    }
                }
            }

            // handle double fields...
            foreach (string name in settingCollection.SettingsDouble.Keys)
            {
                Control control = this.HostSettingsTabs.FindControlRecursive(name);

                if (control != null && control is TextBox && settingCollection.SettingsDouble[name].CanRead)
                {
                    // get the value from the property...
                    ((TextBox)control).Text =
                        settingCollection.SettingsDouble[name].GetValue(this.Get<YafBoardSettings>(), null).ToString();
                }
                else if (control != null && control is DropDownList && settingCollection.SettingsDouble[name].CanRead)
                {
                    ListItem listItem =
                        ((DropDownList)control).Items.FindByValue(
                            settingCollection.SettingsDouble[name].GetValue(this.Get<YafBoardSettings>(), null).ToString());

                    if (listItem != null)
                    {
                        listItem.Selected = true;
                    }
                }
            }

            // special field handling...
            this.AvatarSize.Text = (this.Get<YafBoardSettings>().AvatarSize != 0)
                                       ? this.Get<YafBoardSettings>().AvatarSize.ToString()
                                       : string.Empty;
            this.MaxFileSize.Text = (this.Get<YafBoardSettings>().MaxFileSize != 0)
                                        ? this.Get<YafBoardSettings>().MaxFileSize.ToString()
                                        : string.Empty;

            this.SQLVersion.Text = this.HtmlEncode(this.Get<YafBoardSettings>().SQLVersion);

            if (General.GetCurrentTrustLevel() <= AspNetHostingPermissionLevel.Medium)
            {
                return;
            }

            this.AppCores.Text = Platform.Processors;
            try
            {
                var cpuUsage =
                           new System.Diagnostics.PerformanceCounter
                               {
                                   CategoryName = "Processor",
                                   CounterName = "% Processor Time",
                                   InstanceName = "_Total"
                               };
                float f = cpuUsage.NextValue();
                this.AppCores.Text += " cores, used : " + f.ToType<string>() + "%";
            }
            catch (Exception)
            {
            }

            this.AppMemory.Text = "{0} MB of {1} MB".FormatWith(Platform.AllocatedMemory/ 1000000, 
                 Platform.MappedMemory/1000000);
            this.AppOSName.Text = Platform.VersionString; 
        
            this.AppRuntime.Text = "{0} {1}".FormatWith(Platform.RuntimeName, Platform.RuntimeString);
        }
Пример #2
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            this.ForumEditor.DataSource = ForumEditorHelper.GetFilteredEditorList();

            // TODO: vzrus: UseFullTextSearch check box is data layer specific and can be hidden by YAF.Classes.Data.LegacyDb.FullTextSupported  property.)
            this.DataBind();

            // load Board Setting collection information...
            var settingCollection = new YafBoardSettingCollection(this.Get<YafBoardSettings>());

            // handle checked fields...
            foreach (var name in settingCollection.SettingsBool.Keys)
            {
                Control control = this.HostSettingsTabs.FindControlRecursive(name);

                if (control is CheckBox && settingCollection.SettingsBool[name].CanRead)
                {
                    // get the value from the property...
                    ((CheckBox)control).Checked =
                        (bool)
                        Convert.ChangeType(
                            settingCollection.SettingsBool[name].GetValue(this.Get<YafBoardSettings>(), null),
                            typeof(bool));
                }
            }

            // handle string fields...
            foreach (var name in settingCollection.SettingsString.Keys)
            {
                Control control = this.HostSettingsTabs.FindControlRecursive(name);

                if (control is TextBox && settingCollection.SettingsString[name].CanRead)
                {
                    // get the value from the property...
                    ((TextBox)control).Text =
                        (string)
                        Convert.ChangeType(
                            settingCollection.SettingsString[name].GetValue(this.Get<YafBoardSettings>(), null),
                            typeof(string));
                }
                else if (control is DropDownList && settingCollection.SettingsString[name].CanRead)
                {
                    ListItem listItem =
                        ((DropDownList)control).Items.FindByValue(
                            settingCollection.SettingsString[name].GetValue(this.Get<YafBoardSettings>(), null)
                                .ToString());

                    if (listItem != null)
                    {
                        listItem.Selected = true;
                    }
                }
            }

            // handle int fields...
            foreach (var name in settingCollection.SettingsInt.Keys)
            {
                Control control = this.HostSettingsTabs.FindControlRecursive(name);

                if (control is TextBox && settingCollection.SettingsInt[name].CanRead)
                {
                    ((TextBox)control).CssClass = name.Equals("ServerTimeCorrection")
                                                      ? "NumericServerTimeCorrection"
                                                      : "Numeric";

                    // get the value from the property...
                    ((TextBox)control).Text =
                        settingCollection.SettingsInt[name].GetValue(this.Get<YafBoardSettings>(), null).ToString();
                }
                else if (control is DropDownList && settingCollection.SettingsInt[name].CanRead)
                {
                    ListItem listItem =
                        ((DropDownList)control).Items.FindByValue(
                            settingCollection.SettingsInt[name].GetValue(this.Get<YafBoardSettings>(), null).ToString());

                    if (listItem != null)
                    {
                        listItem.Selected = true;
                    }
                }
            }

            // handle double fields...
            foreach (var name in settingCollection.SettingsDouble.Keys)
            {
                Control control = this.HostSettingsTabs.FindControlRecursive(name);

                if (control is TextBox && settingCollection.SettingsDouble[name].CanRead)
                {
                    ((TextBox)control).CssClass = "Numeric";

                    // get the value from the property...
                    ((TextBox)control).Text =
                        settingCollection.SettingsDouble[name].GetValue(this.Get<YafBoardSettings>(), null).ToString();
                }
                else if (control is DropDownList && settingCollection.SettingsDouble[name].CanRead)
                {
                    ListItem listItem =
                        ((DropDownList)control).Items.FindByValue(
                            settingCollection.SettingsDouble[name].GetValue(this.Get<YafBoardSettings>(), null)
                                .ToString());

                    if (listItem != null)
                    {
                        listItem.Selected = true;
                    }
                }
            }

            // special field handling...
            this.AvatarSize.Text = (this.Get<YafBoardSettings>().AvatarSize != 0)
                                       ? this.Get<YafBoardSettings>().AvatarSize.ToString()
                                       : string.Empty;
            this.MaxFileSize.Text = (this.Get<YafBoardSettings>().MaxFileSize != 0)
                                        ? this.Get<YafBoardSettings>().MaxFileSize.ToString()
                                        : string.Empty;

            this.SQLVersion.Text = this.HtmlEncode(this.Get<YafBoardSettings>().SQLVersion);

            if (General.GetCurrentTrustLevel() <= AspNetHostingPermissionLevel.Medium)
            {
                return;
            }

            this.AppCores.Text = Platform.Processors;
            this.AppMemory.Text = "{0} MB of {1} MB".FormatWith(
                Platform.AllocatedMemory.ToType<long>() / 1000000,
                Platform.MappedMemory.ToType<long>() / 1000000);
            this.AppOSName.Text = Platform.VersionString;
            this.AppRuntime.Text = "{0} {1}".FormatWith(Platform.RuntimeName, Platform.RuntimeString);
        }
Пример #3
0
        /// <summary>
        /// Saves the Host Settings
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Save_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            // write all the settings back to the settings class

            // load Board Setting collection information...
            var settingCollection = new YafBoardSettingCollection(this.Get<YafBoardSettings>());

            // handle checked fields...
            foreach (string name in settingCollection.SettingsBool.Keys)
            {
                using (Control control = this.HostSettingsTabs.FindControlRecursive(name))
                {

                    if (control != null && control is CheckBox && settingCollection.SettingsBool[name].CanWrite)
                    {
                        settingCollection.SettingsBool[name].SetValue(
                            this.Get<YafBoardSettings>(), ((CheckBox)control).Checked, null);
                    }
                }
            }

            // handle string fields...
            foreach (string name in settingCollection.SettingsString.Keys)
            {
                using (Control control = this.HostSettingsTabs.FindControlRecursive(name))
                {

                    if (control is TextBox && settingCollection.SettingsString[name].CanWrite)
                    {
                        settingCollection.SettingsString[name].SetValue(
                            this.Get<YafBoardSettings>(), ((TextBox)control).Text.Trim(), null);
                    }
                    else if (control is DropDownList
                             && settingCollection.SettingsString[name].CanWrite)
                    {
                        settingCollection.SettingsString[name].SetValue(
                            this.Get<YafBoardSettings>(),
                            Convert.ToString(((DropDownList)control).SelectedItem.Value),
                            null);
                    }
                }
            }

            // handle int fields...
            foreach (string name in settingCollection.SettingsInt.Keys)
            {
                using (Control control = this.HostSettingsTabs.FindControlRecursive(name))
                {
                    if (control is TextBox && settingCollection.SettingsInt[name].CanWrite)
                    {
                        string value = ((TextBox)control).Text.Trim();
                        int i;

                        if (value.IsNotSet())
                        {
                            i = 0;
                        }
                        else
                        {
                            int.TryParse(value, out i);
                        }

                        settingCollection.SettingsInt[name].SetValue(this.Get<YafBoardSettings>(), i, null);
                    }
                    else if (control is DropDownList && settingCollection.SettingsInt[name].CanWrite)
                    {
                        settingCollection.SettingsInt[name].SetValue(
                            this.Get<YafBoardSettings>(), ((DropDownList)control).SelectedItem.Value.ToType<int>(), null);
                    }
                }
            }

            // handle double fields...
            foreach (string name in settingCollection.SettingsDouble.Keys)
            {
                using (Control control = this.HostSettingsTabs.FindControlRecursive(name))
                {
                    if (control is TextBox && settingCollection.SettingsDouble[name].CanWrite)
                    {
                        string value = ((TextBox)control).Text.Trim();
                        double i;

                        if (value.IsNotSet())
                        {
                            i = 0;
                        }
                        else
                        {
                            double.TryParse(value, out i);
                        }

                        settingCollection.SettingsDouble[name].SetValue(this.Get<YafBoardSettings>(), i, null);
                    }
                    else if (control != null && control is DropDownList
                             && settingCollection.SettingsDouble[name].CanWrite)
                    {
                        settingCollection.SettingsDouble[name].SetValue(
                            this.Get<YafBoardSettings>(),
                            Convert.ToDouble(((DropDownList)control).SelectedItem.Value),
                            null);
                    }
                }
            }

            // save the settings to the database
            ((YafLoadBoardSettings)this.Get<YafBoardSettings>()).SaveRegistry();

            // reload all settings from the DB
            this.PageContext.BoardSettings = null;

            YafBuildLink.Redirect(ForumPages.admin_admin);
        }
        /// <summary>
        /// The bind data.
        /// </summary>
        private void BindData()
        {
            this.ForumEditor.DataSource = this.Get<IModuleManager<ForumEditor>>().ActiveAsDataTable("Editors");

              // TODO: vzrus: UseFullTextSearch check box is data layer specific and can be hidden by YAF.Classes.Data.LegacyDb.FullTextSupported  property.)
              this.DataBind();

              // load Board Setting collection information...
              var settingCollection = new YafBoardSettingCollection(this.PageContext.BoardSettings);

              // handle checked fields...
              foreach (string name in settingCollection.SettingsBool.Keys)
              {
            Control control = this.HostSettingsTabs.FindControlRecursive(name);

            if (control != null && control is CheckBox && settingCollection.SettingsBool[name].CanRead)
            {
              // get the value from the property...
              ((CheckBox)control).Checked =
            (bool)
            Convert.ChangeType(
              settingCollection.SettingsBool[name].GetValue(this.PageContext.BoardSettings, null), typeof(bool));
            }
              }

              // handle string fields...
              foreach (string name in settingCollection.SettingsString.Keys)
              {
            Control control = this.HostSettingsTabs.FindControlRecursive(name);

            if (control != null && control is TextBox && settingCollection.SettingsString[name].CanRead)
            {
              // get the value from the property...
              ((TextBox)control).Text =
            (string)
            Convert.ChangeType(
              settingCollection.SettingsString[name].GetValue(this.PageContext.BoardSettings, null), typeof(string));
            }
            else if (control != null && control is DropDownList && settingCollection.SettingsString[name].CanRead)
            {
              ListItem listItem =
            ((DropDownList)control).Items.FindByValue(
              settingCollection.SettingsString[name].GetValue(this.PageContext.BoardSettings, null).ToString());

              if (listItem != null)
              {
            listItem.Selected = true;
              }
            }
              }

              // handle int fields...
              foreach (string name in settingCollection.SettingsInt.Keys)
              {
            Control control = this.HostSettingsTabs.FindControlRecursive(name);

            if (control != null && control is TextBox && settingCollection.SettingsInt[name].CanRead)
            {
              // get the value from the property...
              ((TextBox)control).Text =
            settingCollection.SettingsInt[name].GetValue(this.PageContext.BoardSettings, null).ToString();
            }
            else if (control != null && control is DropDownList && settingCollection.SettingsInt[name].CanRead)
            {
              ListItem listItem =
            ((DropDownList)control).Items.FindByValue(
              settingCollection.SettingsInt[name].GetValue(this.PageContext.BoardSettings, null).ToString());

              if (listItem != null)
              {
            listItem.Selected = true;
              }
            }
              }

              // handle double fields...
              foreach (string name in settingCollection.SettingsDouble.Keys)
              {
            Control control = this.HostSettingsTabs.FindControlRecursive(name);

            if (control != null && control is TextBox && settingCollection.SettingsDouble[name].CanRead)
            {
              // get the value from the property...
              ((TextBox)control).Text =
            settingCollection.SettingsDouble[name].GetValue(this.PageContext.BoardSettings, null).ToString();
            }
            else if (control != null && control is DropDownList && settingCollection.SettingsDouble[name].CanRead)
            {
              ListItem listItem =
            ((DropDownList)control).Items.FindByValue(
              settingCollection.SettingsDouble[name].GetValue(this.PageContext.BoardSettings, null).ToString());

              if (listItem != null)
              {
            listItem.Selected = true;
              }
            }
              }

              // special field handling...
              this.AvatarSize.Text = (this.PageContext.BoardSettings.AvatarSize != 0)
                               ? this.PageContext.BoardSettings.AvatarSize.ToString()
                               : string.Empty;
              this.MaxFileSize.Text = (this.PageContext.BoardSettings.MaxFileSize != 0)
                                ? this.PageContext.BoardSettings.MaxFileSize.ToString()
                                : string.Empty;

              this.SQLVersion.Text = this.HtmlEncode(this.PageContext.BoardSettings.SQLVersion);
        }