コード例 #1
0
        /// <summary> Gets the administrative setting values, which includes display information
        /// along with the current value and key </summary>
        /// <param name="Response"></param>
        /// <param name="UrlSegments"></param>
        /// <param name="QueryString"></param>
        /// <param name="Protocol"></param>
        /// <param name="IsDebug"></param>
        public void GetAdminSettings(HttpResponse Response, List<string> UrlSegments, NameValueCollection QueryString, Microservice_Endpoint_Protocol_Enum Protocol, bool IsDebug)
        {
            Custom_Tracer tracer = new Custom_Tracer();

            try
            {
                tracer.Add_Trace("AdministrativeServices.GetAdminSettings", "Pulling dataset from the database");

                // Get the complete aggregation
                DataSet adminSet = Engine_Database.Get_Settings_Complete(true, tracer);

                // If the returned value from the database was NULL, there was an error
                if ((adminSet == null) || (adminSet.Tables.Count == 0) || ( adminSet.Tables[0].Rows.Count == 0))
                {
                    Response.ContentType = "text/plain";
                    Response.Output.WriteLine("Error completing request");

                    if (IsDebug)
                    {
                        Response.Output.WriteLine("DataSet returned from the database was either NULL or empty");
                        if (Engine_Database.Last_Exception != null)
                        {
                            Response.Output.WriteLine();
                            Response.Output.WriteLine(Engine_Database.Last_Exception.Message);
                            Response.Output.WriteLine();
                            Response.Output.WriteLine(Engine_Database.Last_Exception.StackTrace);
                        }

                        Response.Output.WriteLine();
                        Response.Output.WriteLine(tracer.Text_Trace);
                    }

                    Response.StatusCode = 500;
                    return;
                }

                tracer.Add_Trace("AdministrativeServices.GetAdminSettings", "Build the list of return objects");
                Admin_Setting_Collection returnValue = new Admin_Setting_Collection();

                try
                {
                    DataColumn keyColumn = adminSet.Tables[0].Columns["Setting_Key"];
                    DataColumn valueColumn = adminSet.Tables[0].Columns["Setting_Value"];
                    DataColumn tabPageColumn = adminSet.Tables[0].Columns["TabPage"];
                    DataColumn headingColumn = adminSet.Tables[0].Columns["Heading"];
                    DataColumn hiddenColumn = adminSet.Tables[0].Columns["Hidden"];
                    DataColumn reservedColumn = adminSet.Tables[0].Columns["Reserved"];
                    DataColumn helpColumn = adminSet.Tables[0].Columns["Help"];
                    DataColumn optionsColumn = adminSet.Tables[0].Columns["Options"];
                    DataColumn idColumn = adminSet.Tables[0].Columns["SettingID"];
                    DataColumn dimensionsColumn = adminSet.Tables[0].Columns["Dimensions"];

                    //Setting_Key, Setting_Value, TabPage, Heading, Hidden, Reserved, Help, Options

                    // Build the return values
                    foreach (DataRow thisRow in adminSet.Tables[0].Rows)
                    {
                        // Build the value object
                        Admin_Setting_Value thisValue = new Admin_Setting_Value
                        {
                            Key = thisRow[keyColumn].ToString(),
                            Value = thisRow[valueColumn] == DBNull.Value ? null : thisRow[valueColumn].ToString(),
                            TabPage = thisRow[tabPageColumn] == DBNull.Value ? null : thisRow[tabPageColumn].ToString(),
                            Heading = thisRow[headingColumn] == DBNull.Value ? null : thisRow[headingColumn].ToString(),
                            Hidden = bool.Parse(thisRow[hiddenColumn].ToString()),
                            Reserved = short.Parse(thisRow[reservedColumn].ToString()),
                            Help = thisRow[helpColumn] == DBNull.Value ? null : thisRow[helpColumn].ToString(),
                            SettingID = short.Parse(thisRow[idColumn].ToString())
                        };

                        // Get dimensions, if some were provided
                        if (thisRow[dimensionsColumn] != DBNull.Value)
                        {
                            string dimensions = thisRow[dimensionsColumn].ToString();
                            if (!String.IsNullOrWhiteSpace(dimensions))
                            {
                                short testWidth;
                                short testHeight;

                                // Does this include width AND height?
                                if (dimensions.IndexOf("|") >= 0)
                                {
                                    string[] splitter = dimensions.Split("|".ToCharArray());
                                    if ((splitter[0].Length > 0) && ( short.TryParse(splitter[0], out testWidth )))
                                    {
                                        thisValue.Width = testWidth;
                                        if ((splitter[1].Length > 0) && (short.TryParse(splitter[1], out testHeight)))
                                        {
                                            thisValue.Height = testHeight;

                                        }
                                    }
                                }
                                else
                                {
                                    if (short.TryParse(dimensions, out testWidth))
                                    {
                                        thisValue.Width = testWidth;
                                    }
                                }
                            }
                        }

                        // Get the options
                        if (thisRow[optionsColumn] != DBNull.Value)
                        {
                            string[] options = thisRow[optionsColumn].ToString().Split("|".ToCharArray());
                            foreach( string thisOption in options )
                                thisValue.Add_Option(thisOption.Trim());
                        }

                        // Add to the return value
                        returnValue.Settings.Add(thisValue);
                    }

                }
                catch (Exception ex)
                {
                    Response.ContentType = "text/plain";
                    Response.Output.WriteLine("Error completing request");

                    if (IsDebug)
                    {
                        Response.Output.WriteLine("Error creating the Builder_Settings object from the database tables");
                        Response.Output.WriteLine();
                        Response.Output.WriteLine(ex.Message);
                        Response.Output.WriteLine();
                        Response.Output.WriteLine(ex.StackTrace);
                        Response.Output.WriteLine();
                        Response.Output.WriteLine(tracer.Text_Trace);
                    }

                    Response.StatusCode = 500;
                    return;
                }

                // If this was debug mode, then just write the tracer
                if (IsDebug)
                {
                    Response.ContentType = "text/plain";
                    Response.Output.WriteLine("DEBUG MODE DETECTED");
                    Response.Output.WriteLine();
                    Response.Output.WriteLine(tracer.Text_Trace);

                    return;
                }

                // Get the JSON-P callback function
                string json_callback = "parseAdminSettings";
                if ((Protocol == Microservice_Endpoint_Protocol_Enum.JSON_P) && (!String.IsNullOrEmpty(QueryString["callback"])))
                {
                    json_callback = QueryString["callback"];
                }

                // Use the base class to serialize the object according to request protocol
                Serialize(returnValue, Response, Protocol, json_callback);
            }
            catch (Exception ee)
            {
                if (IsDebug)
                {
                    Response.ContentType = "text/plain";
                    Response.Output.WriteLine("EXCEPTION CAUGHT!");
                    Response.Output.WriteLine();
                    Response.Output.WriteLine(ee.Message);
                    Response.Output.WriteLine();
                    Response.Output.WriteLine(ee.StackTrace);
                    Response.Output.WriteLine();
                    Response.Output.WriteLine(tracer.Text_Trace);
                    return;
                }

                Response.ContentType = "text/plain";
                Response.Output.WriteLine("Error completing request");
                Response.StatusCode = 500;
            }
        }
コード例 #2
0
 private static bool Is_Value_ReadOnly(Admin_Setting_Value Value, bool ReadOnlyMode, bool LimitedRightsMode )
 {
     return ((ReadOnlyMode) || (Value.Reserved > 2) || ((LimitedRightsMode) && (Value.Reserved != 0)));
 }
コード例 #3
0
        private void Add_Setting_Table_Setting(TextWriter Output, Admin_Setting_Value Value, bool OddRow)
        {
            // Determine how to show this
            bool constant = Is_Value_ReadOnly(Value, readonlyMode, limitedRightsMode);

            Output.WriteLine(OddRow
                     ? "          <tr class=\"sbkSeav_TableEvenRow\">"
                     : "          <tr class=\"sbkSeav_TableOddRow\">");

            if (constant)
                Output.WriteLine("            <td class=\"sbkSeav_TableKeyCell\">" + Value.Key + ":</td>");
            else
                Output.WriteLine("            <td class=\"sbkSeav_TableKeyCell\"><label for=\"setting" + Value.SettingID + "\">" + Value.Key + "</label>:</td>");

            Output.WriteLine("            <td>");

            if (constant)
                Output.WriteLine("              <table class=\"sbkSeav_InnerTableConstant\">");
            else
                Output.WriteLine("              <table class=\"sbkSeav_InnerTable\">");
            Output.WriteLine("                <tr style=\"vertical-align:middle;border:0;\">");
            Output.WriteLine("                  <td style=\"max-width: 650px;\">");

            // Determine how to show this
            if (constant)
            {
                // Readonly for this value
                if (String.IsNullOrWhiteSpace(Value.Value))
                {
                    Output.WriteLine("                    <em>( no value )</em>");
                }
                else
                {
                    Output.WriteLine("                    " + HttpUtility.HtmlEncode(Value.Value).Replace(",", ", "));
                }
            }
            else
            {
                // Get the value, for easy of additional checks
                string setting_value = String.IsNullOrEmpty(Value.Value) ? String.Empty : Value.Value;

                if ((Value.Options != null) && (Value.Options.Count > 0))
                {

                    Output.WriteLine("                    <select id=\"setting" + Value.SettingID + "\" name=\"setting" + Value.SettingID + "\" class=\"sbkSeav_select\" >");

                    // Some special options here
                    bool option_found = false;
                    if (Value.Options[0] == "{ACE_THEMES}")
                    {
                        string indent = "                      ";
                        string setting_value_no_space = setting_value.Replace(" ", "").Replace("_", "");

                        Output.WriteLine(indent + "<optgroup label=\"Bright\">");
                        Output.WriteLine(String.Compare(setting_value_no_space, "chrome", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"chrome\" selected=\"selected\">Chrome</option>" : indent + "  <option value=\"chrome\">Chrome</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "clouds", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"clouds\" selected=\"selected\">Clouds</option>" : indent + "  <option value=\"clouds\">Clouds</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "crimsoneditor", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"crimson_editor\" selected=\"selected\">Crimson Editor</option>" : indent + "  <option value=\"crimson_editor\">Crimson Editor</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "dawn", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"dawn\" selected=\"selected\">Dawn</option>" : indent + "  <option value=\"dawn\">Dawn</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "dreamweaver", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"dreamweaver\" selected=\"selected\">Dreamweaver</option>" : indent + "  <option value=\"dreamweaver\">Dreamweaver</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "eclipse", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"eclipse\" selected=\"selected\">Eclipse</option>" : indent + "  <option value=\"eclipse\">Eclipse</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "github", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"github\" selected=\"selected\">GitHub</option>" : indent + "  <option value=\"github\">GitHub</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "iplastic", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"iplastic\" selected=\"selected\">IPlastic</option>" : indent + "  <option value=\"iplastic\">IPlastic</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "solarizedlight", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"solarized_light\" selected=\"selected\">Solarized Light</option>" : indent + "  <option value=\"solarized_light\">Solarized Light</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "textmate", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"textmate\" selected=\"selected\">TextMate</option>" : indent + "  <option value=\"textmate\">TextMate</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "tomorrow", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"tomorrow\" selected=\"selected\">Tomorrow</option>" : indent + "  <option value=\"tomorrow\">Tomorrow</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "xcode", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"xcode\" selected=\"selected\">XCode</option>" : indent + "  <option value=\"xcode\">XCode</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "kuroir", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"kuroir\" selected=\"selected\">Kuroir</option>" : indent + "  <option value=\"kuroir\">Kuroir</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "katzenmilch", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"katzenmilch\" selected=\"selected\">KatzenMilch</option>" : indent + "  <option value=\"katzenmilch\">KatzenMilch</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "sqlserver", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"sqlserver\" selected=\"selected\">SQL Server</option>" : indent + "  <option value=\"sqlserver\">SQL Server</option>");
                        Output.WriteLine(indent + "</optgroup>");

                        Output.WriteLine(indent + "<optgroup label=\"Dark\">");
                        Output.WriteLine(String.Compare(setting_value_no_space, "ambiance", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"ambiance\" selected=\"selected\">Ambiance</option>" : indent + "  <option value=\"ambiance\">Ambiance</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "chaos", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"chaos\" selected=\"selected\">Chaos</option>" : indent + "  <option value=\"chaos\">Chaos</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "cloudsmidnight", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"clouds_midnight\" selected=\"selected\">Clouds Midnight</option>" : indent + "  <option value=\"clouds_midnight\">Clouds Midnight</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "cobalt", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"cobalt\" selected=\"selected\">Cobalt</option>" : indent + "  <option value=\"cobalt\">Cobalt</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "gruvbox", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"gruvbox\" selected=\"selected\">Gruvbox</option>" : indent + "  <option value=\"gruvbox\">Gruvbox</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "idlefingers", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"idle_fingers\" selected=\"selected\">Idle Fingers</option>" : indent + "  <option value=\"idle_fingers\">Idle Fingers</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "krtheme", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"kr_theme\" selected=\"selected\">krTheme</option>" : indent + "  <option value=\"kr_theme\">krTheme</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "merbivore", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"merbivore\" selected=\"selected\">Merbivore</option>" : indent + "  <option value=\"merbivore\">Merbivore</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "merbivoresoft", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"merbivore_soft\" selected=\"selected\">Merbivore Soft</option>" : indent + "  <option value=\"merbivore_soft\">Merbivore Soft</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "monoindustrial", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"mono_industrial\" selected=\"selected\">Mono Industrial</option>" : indent + "  <option value=\"mono_industrial\">Mono Industrial</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "monokai", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"monokai\" selected=\"selected\">Monokai</option>" : indent + "  <option value=\"monokai\">Monokai</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "pastelondark", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"pastel_on_dark\" selected=\"selected\">Pastel on dark</option>" : indent + "  <option value=\"pastel_on_dark\">Pastel on dark</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "solarizeddark", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"solarized_dark\" selected=\"selected\">Solarized Dark</option>" : indent + "  <option value=\"solarized_dark\">Solarized Dark</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "terminal", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"terminal\" selected=\"selected\">Terminal</option>" : indent + "  <option value=\"terminal\">Terminal</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "tomorrownight", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"tomorrow_night\" selected=\"selected\">Tomorrow Night</option>" : indent + "  <option value=\"tomorrow_night\">Tomorrow Night</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "tomorrownightblue", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"tomorrow_night_blue\" selected=\"selected\">Tomorrow Night Blue</option>" : indent + "  <option value=\"tomorrow_night_blue\">Tomorrow Night Blue</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "tomorrownightbright", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"tomorrow_night_bright\" selected=\"selected\">Tomorrow Night Bright</option>" : indent + "  <option value=\"tomorrow_night_bright\">Tomorrow Night Bright</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "tomorrownighteighties", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"tomorrow_night_eighties\" selected=\"selected\">Tomorrow Night 80s</option>" : indent + "  <option value=\"tomorrow_night_eighties\">Tomorrow Night 80s</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "twilight", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"twilight\" selected=\"selected\">Twilight</option>" : indent + "  <option value=\"twilight\">Twilight</option>");
                        Output.WriteLine(String.Compare(setting_value_no_space, "vibrantink", StringComparison.InvariantCultureIgnoreCase) == 0 ? indent + "  <option value=\"vibrant_ink\" selected=\"selected\">Vibrant Ink</option>" : indent + "  <option value=\"vibrant_ink\">Vibrant Ink</option>");
                        Output.WriteLine(indent + "</optgroup>");

                    }
                    else
                    {
                        foreach (string thisValue in Value.Options)
                        {
                            if (String.Compare(thisValue, setting_value, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                option_found = true;
                                Output.WriteLine("                      <option selected=\"selected\">" + setting_value + "</option>");
                            }
                            else
                            {
                                Output.WriteLine("                      <option>" + thisValue + "</option>");
                            }
                        }

                        if (!option_found)
                        {
                            Output.WriteLine("                      <option selected=\"selected\">" + setting_value + "</option>");
                        }
                    }

                    Output.WriteLine("                    </select>");
                }
                else
                {
                    if ((Value.Width.HasValue) && (Value.Width.Value > 0))
                        Output.WriteLine("                    <input id=\"setting" + Value.SettingID + "\" name=\"setting" + Value.SettingID + "\" class=\"sbkSeav_input sbkAdmin_Focusable\" type=\"text\"  style=\"width: " + Value.Width + "px;\" value=\"" + HttpUtility.HtmlEncode(setting_value) + "\" />");
                    else
                        Output.WriteLine("                    <input id=\"setting" + Value.SettingID + "\" name=\"setting" + Value.SettingID + "\" class=\"sbkSeav_input sbkAdmin_Focusable\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(setting_value) + "\" />");
                }
            }

            Output.WriteLine("                  </td>");
            Output.WriteLine("                  <td>");
            if (!String.IsNullOrEmpty(Value.Help))
                Output.WriteLine("                    <img  class=\"sbkSeav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + Value.Help.Replace("'", "").Replace("\"", "").Replace("\n", "\\n") + "');\"  title=\"" + Value.Help.Replace("'", "").Replace("\"", "").Replace("\n", "\\n") + "\" />");
            Output.WriteLine("                  </td>");
            Output.WriteLine("                </tr>");
            Output.WriteLine("              </table>");
            Output.WriteLine("            </td>");
            Output.WriteLine("          </tr>");
        }
コード例 #4
0
        private void build_setting_objects_for_display()
        {
            // First step, get all the tab headings (excluding Deprecated and Builder)
            // and also categorize the values by tab page to start with
            tabPageNames = new SortedList<string, string>();
            settingsByPage = new Dictionary<string, List<Admin_Setting_Value>>();
            builderSettings = new List<Admin_Setting_Value>();
            foreach (Admin_Setting_Value thisValue in currSettings.Settings)
            {
                // If this is hidden, just do nothing
                if (thisValue.Hidden) continue;

                // Check on if this is reserved and shouldn't be displayed
                if ((limitedRightsMode) && (thisValue.Reserved == 2))
                    continue;

                // Get the tab page name, and handle nulls or empty values gracefully
                string tabPage = String.IsNullOrWhiteSpace(thisValue.TabPage) ? "General Settings" : thisValue.TabPage;

                // If deprecated skip here
                if (String.Compare(tabPage, "Deprecated", StringComparison.OrdinalIgnoreCase) == 0) continue;

                // Handle builder settings separately
                if (String.Compare(tabPage, "Builder", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    builderSettings.Add(thisValue);
                    continue;
                }

                // Was this tab page already added?
                if ((!settingsByPage.ContainsKey(tabPage)))
                {
                    // We are going to move 'General.." up to the front, others are in alphabetical order
                    if (tabPage.IndexOf("General", StringComparison.OrdinalIgnoreCase) == 0)
                        tabPageNames.Add("00", tabPage);
                    else
                        tabPageNames.Add(tabPage, tabPage);
                    settingsByPage[tabPage] = new List<Admin_Setting_Value> { thisValue };
                }
                else
                {
                    settingsByPage[tabPage].Add(thisValue);
                }
            }

            // Add some readonly configuration information from the config file
            // First, look for a server tab name
            if (!limitedRightsMode)
            {
                string tabNameForConfig = tabPageNames.Values.FirstOrDefault(ThisTabName => ThisTabName.IndexOf("Server", StringComparison.OrdinalIgnoreCase) >= 0);
                if (String.IsNullOrEmpty(tabNameForConfig))
                {
                    foreach (string thisTabName in tabPageNames.Values.Where(ThisTabName => ThisTabName.IndexOf("System", StringComparison.OrdinalIgnoreCase) >= 0))
                    {
                        tabNameForConfig = thisTabName;
                        break;
                    }
                }
                if (String.IsNullOrEmpty(tabNameForConfig))
                {
                    tabNameForConfig = tabPageNames.Values[0];
                }

                // Build the values to add
                Admin_Setting_Value dbString = new Admin_Setting_Value
                {
                    Heading = "Configuration Settings",
                    Help = "Connection string used to connect to the SobekCM database\n\nThis value resides in the configuration file on the web server.  See your database and web server administrator to change this value.",
                    Hidden = false,
                    Key = "Database Connection String",
                    Reserved = 3,
                    SettingID = 9990,
                    Value = UI_ApplicationCache_Gateway.Settings.Database_Connection.Connection_String
                };

                Admin_Setting_Value dbType = new Admin_Setting_Value
                {
                    Heading = "Configuration Settings",
                    Help = "Type of database used to drive the SobekCM system.\n\nCurrently, only Microsoft SQL Server is allowed with plans to add PostgreSQL and MySQL to the supported database system.\n\nThis value resides in the configuration on the web server.  See your database and web server administrator to change this value.",
                    Hidden = false,
                    Key = "Database Type",
                    Reserved = 3,
                    SettingID = 9991,
                    Value = UI_ApplicationCache_Gateway.Settings.Database_Connection.Database_Type_String
                };

                Admin_Setting_Value isHosted = new Admin_Setting_Value
                {
                    Heading = "Configuration Settings",
                    Help = "Flag indicates if this instance is set as 'hosted', in which case a new Host Administrator role is added and some rights are reserved to that role which are normally assigned to system administrators.\n\nThis value resides in the configuration on the web server.  See your database and web server administrator to change this value.",
                    Hidden = false,
                    Key = "Hosted Intance",
                    Reserved = 3,
                    SettingID = 9994,
                    Value = UI_ApplicationCache_Gateway.Settings.Servers.isHosted.ToString().ToLower()
                };

                Admin_Setting_Value errorEmails = new Admin_Setting_Value
                {
                    Heading = "Configuration Settings",
                    Help = "Email address for the web application to mail for any errors encountered while executing requests.\n\nThis account will be notified of inabilities to connect to servers, potential attacks, missing files, etc..\n\nIf the system is able to connect to the database, the 'System Error Email' address listed there, if there is one, will be used instead.\n\nUse a semi-colon betwen email addresses if multiple addresses are included.\n\nExample: '[email protected];[email protected]'.\n\nThis value resides in the web.config file on the web server.  See your web server administrator to change this value.",
                    Hidden = false,
                    Key = "Error Emails",
                    Reserved = 3,
                    SettingID = 9992,
                    Value = UI_ApplicationCache_Gateway.Settings.Email.System_Error_Email
                };

                Admin_Setting_Value errorWebPage = new Admin_Setting_Value
                {
                    Heading = "Configuration Settings",
                    Help = "Static page the user should be redirected towards if an unexpected exception occurs which cannot be handled by the web application.\n\nExample: 'http://ufdc.ufl.edu/error.html'.\n\nThis value resides in the web.config file on the web server.  See your web server administrator to change this value.",
                    Hidden = false,
                    Key = "Error Web Page",
                    Reserved = 3,
                    SettingID = 9993,
                    Value = UI_ApplicationCache_Gateway.Settings.Servers.System_Error_URL
                };

                // Add them all to the tab page
                List<Admin_Setting_Value> settings = settingsByPage[tabNameForConfig];
                settings.Add(dbType);
                settings.Add(dbString);
                settings.Add(isHosted);
                settings.Add(errorEmails);
                settings.Add(errorWebPage);
            }
        }
コード例 #5
0
        private void Add_Setting_Table_Setting(TextWriter Output, Admin_Setting_Value Value, bool OddRow )
        {
            // Determine how to show this
            bool constant = Is_Value_ReadOnly(Value, readonlyMode, limitedRightsMode);

            Output.WriteLine(OddRow
                     ? "          <tr class=\"sbkSeav_TableEvenRow\">"
                     : "          <tr class=\"sbkSeav_TableOddRow\">");

            if ( constant )
                Output.WriteLine("            <td class=\"sbkSeav_TableKeyCell\">" + Value.Key + ":</td>");
            else
                Output.WriteLine("            <td class=\"sbkSeav_TableKeyCell\"><label for=\"setting" + Value.SettingID + "\">" + Value.Key + "</label>:</td>");

            Output.WriteLine("            <td>");

            if ( constant )
                Output.WriteLine("              <table class=\"sbkSeav_InnerTableConstant\">");
            else
                Output.WriteLine("              <table class=\"sbkSeav_InnerTable\">");
            Output.WriteLine("                <tr style=\"vertical-align:middle;border:0;\">");
            Output.WriteLine("                  <td style=\"max-width: 650px;\">");

            // Determine how to show this
            if (constant)
            {
                // Readonly for this value
                if (String.IsNullOrWhiteSpace(Value.Value))
                {
                    Output.WriteLine("                    <em>( no value )</em>");
                }
                else
                {
                    Output.WriteLine("                    " + HttpUtility.HtmlEncode(Value.Value).Replace(",", ", "));
                }
            }
            else
            {
                // Get the value, for easy of additional checks
                string setting_value = String.IsNullOrEmpty(Value.Value) ? String.Empty : Value.Value;

                if (( Value.Options != null ) && ( Value.Options.Count > 0 ))
                {

                    Output.WriteLine("                    <select id=\"setting" + Value.SettingID + "\" name=\"setting" + Value.SettingID + "\" class=\"sbkSeav_select\" >");

                    bool option_found = false;
                    foreach (string thisValue in Value.Options)
                    {
                        if (String.Compare(thisValue, setting_value, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            option_found = true;
                            Output.WriteLine("                      <option selected=\"selected\">" + setting_value + "</option>");
                        }
                        else
                        {
                            Output.WriteLine("                      <option>" + thisValue + "</option>");
                        }
                    }

                    if (!option_found)
                    {
                        Output.WriteLine("                      <option selected=\"selected\">" + setting_value + "</option>");
                    }
                    Output.WriteLine("                    </select>");
                }
                else
                {
                    if ((Value.Width.HasValue ) && ( Value.Width.Value > 0 ))
                        Output.WriteLine("                    <input id=\"setting" + Value.SettingID + "\" name=\"setting" + Value.SettingID +  "\" class=\"sbkSeav_input sbkAdmin_Focusable\" type=\"text\"  style=\"width: " + Value.Width + "px;\" value=\"" + HttpUtility.HtmlEncode(setting_value) + "\" />");
                    else
                    Output.WriteLine("                    <input id=\"setting" + Value.SettingID + "\" name=\"setting" + Value.SettingID + "\" class=\"sbkSeav_input sbkAdmin_Focusable\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(setting_value) + "\" />");
                }
            }

            Output.WriteLine("                  </td>");
            Output.WriteLine("                  <td>");
            if ( !String.IsNullOrEmpty(Value.Help))
                Output.WriteLine("                    <img  class=\"sbkSeav_HelpButton\" src=\"" + Static_Resources.Help_Button_Jpg + "\" onclick=\"alert('" + Value.Help.Replace("'", "").Replace("\"", "").Replace("\n", "\\n") + "');\"  title=\"" + Value.Help.Replace("'", "").Replace("\"", "").Replace("\n", "\\n") + "\" />");
            Output.WriteLine("                  </td>");
            Output.WriteLine("                </tr>");
            Output.WriteLine("              </table>");
            Output.WriteLine("            </td>");
            Output.WriteLine("          </tr>");
        }