views:

259

answers:

4

I will (hopefully) be taking on a large project to migrate an enterprise Visual FoxPro application to C# 3.0 on .NET 3.5. I know that this application has a huge number of settings that have an impact on everything from multi-user/multi-site configurations to report properties. There's at least 150 different settings that are currently globally scoped.

The settings are currently just stored as bits in the application's database, which prevents them from being changed at the user level, since all instances share the same db.

My question is, do you know of any way to handle the storage of these settings that would allow them to be changed per user, without sacrificing performance/ It would also need to be stored in a way that allows the values to be changed while the application is running. Any ideas would be appreciated.

+4  A: 

The standard Settings.Settings file I believe offers you this functionality, including application or user scoped variables. Although I'm not 100% sure if changes are picked up without restarting the application.

See here for more info: MSDN:Using Settings in C#

MattH
That is a good system for a reasonable number of settings, and of cource user-scoped settings would solve some of my concerns. But, the number of settings I'm going to be dealing with here are monsterous, and I do not want to stuff it into the app.config or Settings.settings. An ideal solution would involve something along the lines of object serialization as a way to store the settings in a small space, but still enable modification through a separate )or same) app. Any thoughts in this area?
Dustin Hoffman
What is the objection to storing them in a settings file?Even with a large amount of settings this approach should work. The settings file is stored in XML so I grant you it wont be an efficient filesize, but I wouldn't expect a large impact on application load time.The settings file can also easily be updated at runtime, you'll just need to add an appropriate GUI around it.Alternatively as its XML based, you could manipulate the file directly, but I'd recommend using the standard API personally.
MattH
I think I'll utilize the basic Settings system for now, with the intent of creating a serialized version that can reside in isolated storage for each user of the application. Thanks for all the help!
Dustin Hoffman
A: 

Add a User field to the table in the application's database that stores settings, and then add the current user as a parameter to all the read/write calls to this table.

MusiGenesis
+1  A: 

If you want to go "enterprise", you can try having a setting definitions table, paired with a user settings table.

The setting definitions would have the PK defined by a domain column (for UI settings, connection settings, language settings and so on...), and a setting identifier. A third column would define the default/global value.

The user settings would have the PK set to setting definitions' PK + user id and a setting value column, varchar(x).

If the application is language aware, language id columns should be added to both tables.

Saving user changes to the user settings table should be trivial. Being notified when global settings change is a bit more complicated.

EDIT: one thing to keep in mind is to always fallback to some default: global setting / default language.

Sorin Comanescu
A: 

You might have to work through logically for items that are data/application specific vs user specific. In VFP (foxpro), the tables and their respective primary keys are obviously the same, regardless of the user. Other things, such as default values may be customizable per individual user, accounts, access, abilities to add/edit/delete, etc.

HTH

DRapp