/// <summary> /// Set a Config parameter /// </summary> /// <param name="value"></param> /// <param name="column"></param> public void SetConfig(ConfigValue value, ConfigColumn column) { try { if (ds != null) { if (ds.Tables["CONFIG"] != null) { switch (column) { case ConfigColumn.Prompt: ds.Tables["CONFIG"].Rows[0][dcConfigPrompt] = value.ToString(); break; case ConfigColumn.Synchronize: ds.Tables["CONFIG"].Rows[0][dcConfigSynchronize] = value.ToString(); break; } } } } catch { } }
public void Save() { string sql = @" IF EXISTS (SELECT * FROM GlobalConfig WHERE GlobalConfigGuid = @guid) BEGIN UPDATE GlobalConfig SET [Name] = @name, Description = @description, ConfigValue = @configValue, GroupName = @groupName, SuperOnly = @superOnly, EnumValues = @enumValues WHERE [GlobalConfigID] = @id END ELSE BEGIN INSERT INTO GlobalConfig (GlobalConfigGUID, [Name], [Description], [ConfigValue], [ValueType] ,[GroupName], [SuperOnly], [EnumValues]) VALUES (NewID(), @name, @description, @configValue, @valueType, @groupName, @superOnly, @enumValues) END" ; var parameters = new[] { new SqlParameter("@name", Name), new SqlParameter("@description", Description), new SqlParameter("@configValue", ConfigValue.ToString()), new SqlParameter("@valueType", ValueType), new SqlParameter("@enumValues", AllowableValues.ToDelimitedString()), new SqlParameter("@groupName", GroupName), new SqlParameter("@superOnly", SuperOnly ? 1 : 0), new SqlParameter("@guid", GUID), new SqlParameter("@id", ID) }; DB.ExecuteSQL(sql, parameters); DependencyResolver.Current.GetService <GlobalConfigCache>().ResetCache(); }