在 C# WinForms 应用程序中处理大量设置?

发布于 2024-07-30 00:58:53 字数 303 浏览 3 评论 0原文

我将(希望)承担一个大型项目,将企业 Visual FoxPro 应用程序迁移到 .NET 3.5 上的 C# 3.0。 我知道该应用程序具有大量设置,这些设置会对从多用户/多站点配置到报告属性的所有内容产生影响。 当前至少有 150 种不同的全局设置。

这些设置当前仅以位形式存储在应用程序的数据库中,这可以防止在用户级别更改它们,因为所有实例共享相同的数据库。

我的问题是,您是否知道有什么方法可以处理这些设置的存储,从而允许每个用户更改它们,而不牺牲性能? 它还需要以允许在应用程序运行时更改值的方式存储。 任何想法,将不胜感激。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

因为看清所以看轻 2024-08-06 00:58:53

如果您想进入“企业”,您可以尝试将设置定义表与用户设置表配对。

设置定义将具有由域列(用于 UI 设置、连接设置、语言设置等...)和设置标识符定义的 PK。 第三列将定义默认/全局值。

用户设置将 PK 设置为设置定义的 PK + 用户 ID 和设置值列 varchar(x)。

如果应用程序支持语言,则应将语言 ID 列添加到两个表中。

将用户更改保存到用户设置表应该很简单。 当全局设置更改时收到通知有点复杂。

编辑:要记住的一件事是始终回退到某些默认值:全局设置/默认语言。

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.

清音悠歌 2024-08-06 00:58:53

我相信标准的 Settings.Settings 文件为您提供了此功能,包括应用程序或用户范围的变量。 尽管我不能 100% 确定是否会在不重新启动应用程序的情况下拾取更改。

请参阅此处了解更多信息:
MSDN:在 C# 中使用设置

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#

む无字情书 2024-08-06 00:58:53

将用户字段添加到应用程序数据库中存储设置的表中,然后将当前用户作为参数添加到对此表的所有读/写调用。

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.

╰沐子 2024-08-06 00:58:53

您可能必须逻辑地处理特定于数据/应用程序与特定于用户的项目。 在VFP(foxpro)中,无论用户是谁,表及其各自的主键显然都是相同的。 其他的东西,例如默认值可以根据个人用户、帐户、访问、添加/编辑/删除的能力等进行定制

。HTH

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文