예제 #1
0
        public int SaveModulesSettings(ConfigModules mod, int op)
        {
            String sql = "";

            switch (op)
            {
            case 0:
                sql = "DELETE FROM ConfigModules WHERE Module LIKE '" + mod.Module + "'";
                break;

            case 1:
                sql = "UPDATE ConfigModules SET IfModule = '" + mod.IfModule + "', IfModuleActive = " + mod.IfModuleActive + " WHERE Module LIKE '" + mod.Module + "'";
                break;

            case 2:
                sql = "INSERT INTO ConfigModules ('IfModule', 'IfModuleActive', 'Module', 'ServerType') VALUES ('" + mod.IfModule + "', " + mod.IfModuleActive + ", '" + mod.Module + "', '" + Globals.Servers.WebServer.Type.ToString() + "')";
                break;
            }

            try
            {
                return(Globals.dbConn.ExecuteNonQuery(sql));
            }
            catch (Exception)
            {
                return(0);
            }
        }
예제 #2
0
        /* WebServer Modules Extra Settings */
        public void LoadModulesSettings()
        {
            DataTable DBSettings = Globals.dbConn.GetDataTable("SELECT * FROM ConfigModules WHERE ServerType LIKE '" + Globals.Servers.WebServer.Type.ToString() + "'");

            if (DBSettings.Rows.Count > 0)
            {
                foreach (DataRow row in DBSettings.Rows)
                {
                    ConfigModules ModCnf = new ConfigModules();
                    foreach (DataColumn col in DBSettings.Columns)
                    {
                        try
                        {
                            PropertyInfo pi = ModCnf.GetType().GetProperty(col.ToString());
                            pi.SetValue(ModCnf, Convert.ChangeType(row[col], pi.PropertyType), null);
                        }
                        catch (Exception)
                        {
                        }
                    }

                    Globals.Servers.WebServer.ModulesConfig.Add(ModCnf);
                }
            }
        }
        private void SaveModuleConf()
        {
            String Module = this.checkedListModules.Items[this.SelModule].ToString();
            int    exists = -1;

            for (int i = 0; i < Globals.Servers.WebServer.ModulesConfig.Count; i++)
            {
                if (Globals.Servers.WebServer.ModulesConfig[i].Module == Module)
                {
                    exists = i;
                }
            }

            String lines = string.Join("\r\n", this.ExtraConfig.Lines);

            ConfigModules thisMod = new ConfigModules();

            thisMod.IfModule = lines;
            thisMod.Module   = Module;
            if (this.ModuleConfDisabled.Checked == true)
            {
                thisMod.IfModuleActive = 0;
            }
            else if (this.ModuleConfIfActive.Checked == true)
            {
                thisMod.IfModuleActive = 1;
            }
            else if (this.ModuleConfIfNotActive.Checked == true)
            {
                thisMod.IfModuleActive = 2;
            }
            else
            {
                thisMod.IfModuleActive = 0;
            }

            if (exists >= 0)
            {
                if (lines.Trim() == "")
                {
                    // DELETE
                    Globals.Servers.WebServer.ModulesConfig.RemoveAt(exists);
                    this.Database.SaveModulesSettings(thisMod, 0);
                }
                else
                {
                    // UPDATE
                    Globals.Servers.WebServer.ModulesConfig[exists] = thisMod;
                    this.Database.SaveModulesSettings(thisMod, 1);
                }
            }
            else if (lines.Trim() != "")
            {
                // INSERT
                Globals.Servers.WebServer.ModulesConfig.Add(thisMod);
                this.Database.SaveModulesSettings(thisMod, 2);
            }
        }