您的位置:首页 > 其它

AgileEAS.NET SOA平台多帐套的实现

2014-09-22 12:07 330 查看
这里的多帐套的意思是指:程序可以连接到不同的具体数据库。

准备工作:

下载最新平台

本文涉及到两个数据库MulDb1和MulDb2。

这两个数据库都是由平台自带数据库生成工具EAS.DbInitializer.exe生成。

下面开始编码:

建立一个MultipleAccountDemo工程

引用

EAS.Data.dll

EAS.Explorer.dll

EAS.MicroKernel.dll

EAS.Windows.dll

新建一个FrmLogin窗体,一个Resource.cs c#文件。

FrmLogin窗体实现EAS.Explorer.ILoginForm接口。

关键代码

try

{

//帐套登录

(EAS.Application.Instance as EAS.Windows.Application).Login(cboAccount.Text, txtUserName.Text,

txtPwd.Text);

_passed = 1;

MessageBox.Show("登录成功,帐套为:" + EAS.Application.Instance.Session.DataSet);

}

catch (System.Exception exc)

{

_passed = -1;

MessageBox.Show(exc.ToString());

}

Resource.cs实现EAS.Explorer.IResource接口。

关键代码

public ILoginForm GetLoginForm()

{

return new FrmLogin();

}

实现之后,编译成Dll。之后就是配置的问题了。

配置详解:

1.在服务端新增SAAS.config文件,内容如下:

<?xml version="1.0" encoding="utf-8"?>

<MultiTenant>

<Items>

<Item DataSet="帐套一" Organization ="帐套一" Assembly="EAS.Data" Type="EAS.Data.Access.SqlClientProvider" Min="5" Max ="100">

<ConnectionString>Data Source=.;Initial Catalog=MulDb1;User ID=sa;Password=sa</ConnectionString>

</Item>

<Item DataSet="帐套二" Organization ="帐套二" Assembly="EAS.Data" Type="EAS.Data.Access.SqlClientProvider" Min="5" Max ="100">

<ConnectionString>Data Source=.;Initial Catalog=MulDb2;User ID=sa;Password=sa</ConnectionString>

</Item>

</Items>

</MultiTenant>

2.配置EAS.SOA.Server.exe.config

<!--数据访问器-->

<object name="DataAccessor" assembly="EAS.Data" type="EAS.Data.Access.DataAccessor" LifestyleType="Thread">

<property name="MultiTenant" type="object" value="MultiTenant"/>

<property name="Language" type="object" value="TSqlLanguage"/>

</object>

<!--XML多帐套-->

<object name="MultiTenant" assembly="EAS.Data" type="EAS.SAAS.XMLMultiTenant" LifestyleType="Singleton"/>

3.在客户端配置文件中加入资源配置

<!--资源-->

<object name="EAS.Explorer.Resource" assembly="MultipleAccountDemo" type="MultipleAccountDemo.Resources" LifestyleType="Singleton" />

运行即可。
http://download.csdn.net/detail/xueshaoyu/7957177 href="http://download.csdn.net/detail/xueshaoyu/7957177" target=_blank>点击打开链接
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐