参数服务组件 Example 程序
2008-10-22 13:58
246 查看
组件的最大的优点在于不断改进完善,重复利用。我们开发项目时,经常会遇到,系统默认每页显示50条记录,但是用户
A用的显示器分辨率比较小,他希望默认是显示30条记录,显示效果正常。用户B用的是最新的,最大的显示器,他希望默
认能看到每页200条记录。还有可能他们关注的重点不同,希望系统默认登录系统的主页显示都不一样。
菜鸟可能会想到,这是需求互相冲突嘛,无法实现嘛,其实类似的需求会很多,这时候,我希望能有一个配置参数的服务
方法,默认采用系统的配置参数,若用户设置了自己的个性化需求,就按客户的设置显示数据。
当然我希望这个参数服务类,有非常简单的2个方法,一个是SetParameter只要调用就可以,会将参数写入到数据库,
若已经存在这个设置,他会进行覆盖,是比较智能化的,还有一个就是读取的方法GetParameter,很方便能读取设置。
当然我们的参数服务,可以将设置保存到本地文件中,也可以保存到运程的数据库服务器上,可以通过WebService、
Remoting或者WCF等方式运行是比较理想的。
有一些方便灵活的软件组件,开发软件会轻松一些,不用每个人都摸索、开发、测试,分工明确,责任明确会大大提
高软件的产量、质量,对于组件来说,功能定位明确也至关重要,可以不断完善提高这个组件的重复利用,提高服用率、
提高生产率。
以下是参考页面,及样例代码。
设置参数
![](http://images.cnblogs.com/cnblogs_com/jirigala/FrmExampleParameter01.JPG)
读取参数效果,当然也可以保存其他类型的数据,例如URL等。
![](http://images.cnblogs.com/cnblogs_com/jirigala/FrmExampleParameter02.JPG)
代码效果:(主要目的是非常方便调用,最好只是一行代码就可以了,代码太多了,就没有组建的意义了,不是简化调用了)
BaseSystemInfo.UserInfo 为当前操作员的信息,谁破坏了系统,是谁干的,总需要有个依据吧,最起码能有个IP地址吧。
若是谁搞破坏了,警察叔叔来抓,还好有个依据。
1
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
private void btnSet_Click(object sender, EventArgs e)
2
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
3
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// 本地模式
4
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
ParameterService.Instance.SetParameter(BaseSystemInfo.UserInfo, "Application", "ApplicationPeerPage", "PeerPage", this.txtSetApplication.Text);
5
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
ParameterService.Instance.SetParameter(BaseSystemInfo.UserInfo, "User", "UserAPeerPage", "PeerPage", this.txtSetA.Text);
6
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
ParameterService.Instance.SetParameter(BaseSystemInfo.UserInfo, "User", "UserBPeerPage", "PeerPage", this.txtSetB.Text);
7
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
8
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// 远程模式,采用接口、反射、工厂模式实现
9
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
ServiceManager.Instance.ParameterService.SetParameter(BaseSystemInfo.UserInfo, "Application", "ApplicationPeerPage", "PeerPage", this.txtSetApplication.Text);
10
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
}
11
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
private void btnGet_Click(object sender, EventArgs e)
13
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
14
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.txtGetApplication.Text = ParameterService.Instance.GetParameter(BaseSystemInfo.UserInfo, "Application", "ApplicationPeerPage", "PeerPage");
15
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.txtGetA.Text = ParameterService.Instance.GetParameter(BaseSystemInfo.UserInfo, "User", "UserAPeerPage", "PeerPage");
16
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.txtGetB.Text = ParameterService.Instance.GetParameter(BaseSystemInfo.UserInfo, "User", "UserBPeerPage", "PeerPage");
17
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
}
当然以上代码,不管是B/S,C/S运行模式下,都是可以调用的。
将权限管理、工作流管理做到我能力的极致,一个人只能做好那么很少的几件事情。
A用的显示器分辨率比较小,他希望默认是显示30条记录,显示效果正常。用户B用的是最新的,最大的显示器,他希望默
认能看到每页200条记录。还有可能他们关注的重点不同,希望系统默认登录系统的主页显示都不一样。
菜鸟可能会想到,这是需求互相冲突嘛,无法实现嘛,其实类似的需求会很多,这时候,我希望能有一个配置参数的服务
方法,默认采用系统的配置参数,若用户设置了自己的个性化需求,就按客户的设置显示数据。
当然我希望这个参数服务类,有非常简单的2个方法,一个是SetParameter只要调用就可以,会将参数写入到数据库,
若已经存在这个设置,他会进行覆盖,是比较智能化的,还有一个就是读取的方法GetParameter,很方便能读取设置。
当然我们的参数服务,可以将设置保存到本地文件中,也可以保存到运程的数据库服务器上,可以通过WebService、
Remoting或者WCF等方式运行是比较理想的。
有一些方便灵活的软件组件,开发软件会轻松一些,不用每个人都摸索、开发、测试,分工明确,责任明确会大大提
高软件的产量、质量,对于组件来说,功能定位明确也至关重要,可以不断完善提高这个组件的重复利用,提高服用率、
提高生产率。
以下是参考页面,及样例代码。
设置参数
读取参数效果,当然也可以保存其他类型的数据,例如URL等。
代码效果:(主要目的是非常方便调用,最好只是一行代码就可以了,代码太多了,就没有组建的意义了,不是简化调用了)
BaseSystemInfo.UserInfo 为当前操作员的信息,谁破坏了系统,是谁干的,总需要有个依据吧,最起码能有个IP地址吧。
若是谁搞破坏了,警察叔叔来抓,还好有个依据。
1
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
private void btnSet_Click(object sender, EventArgs e)
2
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
3
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// 本地模式
4
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
ParameterService.Instance.SetParameter(BaseSystemInfo.UserInfo, "Application", "ApplicationPeerPage", "PeerPage", this.txtSetApplication.Text);
5
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
ParameterService.Instance.SetParameter(BaseSystemInfo.UserInfo, "User", "UserAPeerPage", "PeerPage", this.txtSetA.Text);
6
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
ParameterService.Instance.SetParameter(BaseSystemInfo.UserInfo, "User", "UserBPeerPage", "PeerPage", this.txtSetB.Text);
7
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
8
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// 远程模式,采用接口、反射、工厂模式实现
9
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
ServiceManager.Instance.ParameterService.SetParameter(BaseSystemInfo.UserInfo, "Application", "ApplicationPeerPage", "PeerPage", this.txtSetApplication.Text);
10
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
}
11
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
private void btnGet_Click(object sender, EventArgs e)
13
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
14
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.txtGetApplication.Text = ParameterService.Instance.GetParameter(BaseSystemInfo.UserInfo, "Application", "ApplicationPeerPage", "PeerPage");
15
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.txtGetA.Text = ParameterService.Instance.GetParameter(BaseSystemInfo.UserInfo, "User", "UserAPeerPage", "PeerPage");
16
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.txtGetB.Text = ParameterService.Instance.GetParameter(BaseSystemInfo.UserInfo, "User", "UserBPeerPage", "PeerPage");
17
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
}
当然以上代码,不管是B/S,C/S运行模式下,都是可以调用的。
将权限管理、工作流管理做到我能力的极致,一个人只能做好那么很少的几件事情。
相关文章推荐
- 参数服务组件 Example 程序
- 参数服务组件 Example 程序
- 参数服务组件 Example 程序
- 参数服务组件 Example 程序
- 基础编码管理组件 Example 程序
- 在VC程序中调用服务组件
- 应用程序异常管理组件 Example 程序
- 由于另一个程序或正在运行的服务可能正在使用网络地址转换组件(Ipnat.sys),windows防火墙无法运行
- 为服务的可执行程序加上参数
- 应用程序异常管理组件 Example 程序
- 序列发生器组件 Example 程序
- 序列发生器管理组件 Example 程序
- inno setup执行带参数服务程序并启动服务
- 选择用户组件 Example 程序
- 基础编码管理组件 Example 程序
- 操作权限组件 Example 程序
- 快速掌握小程序组件事件自定义参数的方法
- 序列发生器组件 Example 程序
- 操作权限组件 Example 程序
- 快速掌握小程序组件事件自定义参数的方法