源码见百度云:wikesoft-WorkFlow-master
1.项目引用
wikeflow使用的是微软的EntityFramework.6.1.3,所以在使用的时候,要先引用EntityFramework.dll,EntityFramework.SqlServer.dll
2.数据库连接
<connectionStrings>
<add name="FlowEngine" connectionString="Data Source=.;Initial Catalog=Flow;User ID=sa;Password=123456;" providerName="System.Data.SqlClient" />
</connectionStrings>
注意:连接名必须是FlowEngine,“name="FlowEngine" ”
3.WikeFlow的表结构
Flow_FlowDef
Flow_NodeDef
Flow_NodeLink
Flow_FlowRecord
Flow_NodeRecord
4.WikeFlow的两个核心类
(1)IFlowDesignService
string AddFlowDef(FlowDefModel flowDef); 添加流程定义
FlowMessage UpdateFlowDef(FlowDefModel model); 修改流程定义
FlowMessage DeleteFlowDef(IList ids) 删除流程定义
FlowDefModel GetFlowDef(string id); 得到流程定义对象
FlowMessage SaveDiagram(FlowModel flowDef); 保存流程设置
Bitmap GetBitmap(string flowDefId); 返回流程图
PagedResult GetList(FlowDefFilter filter); 分页查询流程定义
(2)IFlowInstanceService
InstanceMessage CreateInstance(string flowDefKey,string userId, string userName,string condition) 创建实例
InstanceMessage Complete(string nodeRecordId,string userId,string userName,string userMsg,string condition)处理流程
FlowInstance GetRunFlowInstance(string flowId); 得到当前运行的实例
List GetHistoryFlowInstances(string flowId); 得到历史流程处理记录列表
Bitmap GetRunBitmap(string flowId) 得到运行中的流程图
5. 发起流程
InstanceMessage flowInstance = _flowInstanceService.CreateInstance("flow_holiday", "创建人用户ID", "管理员", "条件");
6. 处理流程
_flowInstanceService.Complete("节点ID", "处理人用户ID", "处理人用户", "处理意见", "条件");
6. 多数据库支出
(1)Oracle配置
注意事项:
EF必须设置defaultSchema,且必须和用户名一致,不然会报权限不够的问题
如下图
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> </configSections> <!--oracle--> <entityFramework> <contexts> <context type="WikeSoft.Enterprise.Entities.WikeDbContext,WikeSoft.Enterprise" disableDatabaseInitialization="false"> <databaseInitializer type="WikeSoft.Enterprise.Entities.DataModelInitializer,WikeSoft.Enterprise"></databaseInitializer> </context> </contexts> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/> <provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/> </providers> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="v13.0"/> </parameters> </defaultConnectionFactory> </entityFramework> <connectionStrings> <!--oracle--> <add name="WikeFlowEngine" connectionString="DATA SOURCE=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=WIN-VDUSS12FV48)(PORT=1521)))(CONNECT_DATA=(SID=orcl)));PASSWORD=123456;USER ID=WORKFLOW;" providerName="Oracle.ManagedDataAccess.Client"/> </connectionStrings> <appSettings> <!--Oracle,必须是连接字符串登录名(USER ID)的值,且必须是全大写--> <add key="defaultSchema" value="WORKFLOW" /> </appSettings> <system.data> <DbProviderFactories> <!--mysql--> <remove invariant="MySql.Data.MySqlClient"/> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/> <!--oracle--> <remove invariant="Oracle.ManagedDataAccess.Client"/> <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/> </DbProviderFactories> </system.data> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/> </startup> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <publisherPolicy apply="no"/> <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/> <bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.122.1.0"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
(2)Sql server配置
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> </configSections> <!--SQLServer--> <entityFramework> <contexts> <context type="WikeSoft.Enterprise.Entities.WikeDbContext,WikeSoft.Enterprise" disableDatabaseInitialization="false"> <databaseInitializer type="WikeSoft.Enterprise.Entities.DataModelInitializer,WikeSoft.Enterprise"></databaseInitializer> </context> </contexts> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="mssqllocaldb" /> </parameters> </defaultConnectionFactory> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> </providers> </entityFramework> <connectionStrings> <!--SQL SERVER --> <add name="WikeFlowEngine" connectionString="Data Source=.;database=workflow;uid=sa;pwd=123456;" providerName="System.Data.SqlClient"/> </connectionStrings> <appSettings> <!--sqlServer--> <add key="defaultSchema" value="dbo" /> </appSettings> <system.data> <DbProviderFactories> <!--mysql--> <remove invariant="MySql.Data.MySqlClient"/> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/> <!--oracle--> <remove invariant="Oracle.ManagedDataAccess.Client"/> <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/> </DbProviderFactories> </system.data> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/> </startup> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <publisherPolicy apply="no"/> <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/> <bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.122.1.0"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
(3)Mysql配置
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> </configSections> <!--MySQL--> <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6"> <contexts> <context type="WikeSoft.Enterprise.Entities.WikeDbContext,WikeSoft.Enterprise" disableDatabaseInitialization="false"> <databaseInitializer type="WikeSoft.Enterprise.Entities.DataModelInitializer,WikeSoft.Enterprise"></databaseInitializer> </context> </contexts> <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6"> <parameters> <parameter value="v11.0" /> </parameters> </defaultConnectionFactory> <providers> <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider> </providers> </entityFramework> <connectionStrings> <!--MySQL--> <add name="WikeFlowEngine" connectionString="Data Source=localhost;port=3306;Initial Catalog=WORKFLOW;user id=root;password=123456;" providerName="MySql.Data.MySqlClient" /> </connectionStrings> <appSettings> <!--mysql--> <add key="defaultSchema" value="" /> </appSettings> <system.data> <DbProviderFactories> <!--mysql--> <remove invariant="MySql.Data.MySqlClient"/> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/> <!--oracle--> <remove invariant="Oracle.ManagedDataAccess.Client"/> <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/> </DbProviderFactories> </system.data> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/> </startup> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <publisherPolicy apply="no"/> <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/> <bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.122.1.0"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>