.net工作流引擎ccflow集成并增加自定义功能

.net工作流引擎ccflow集成并增加自定义功能,第1张

.net工作流引擎ccflow集成并增加自定义功能


一、为什么需要自定义扩展

1、第三方类库已满足大部分需求,剩下的根据具体业务需求抽象成公共功能进行扩展

2、第三方呈现的web页面与原类库耦合度较高,希望在原页面上扩展而不影响原来的功能

3、在完全不修改第三方类库及web页面的情况下,加入自己的代码

4、未来可以同步更新第三方类库


二、主要实现思路

1、类库通过继承的方式扩展

2、asp.net页面通过增加一个分部类来调用扩展后的类库


三、具体集成ccflow *** 作步骤

1、解决方案引入ccflow核心三大类库,确保三大类库的与解决方案不在同一个目录,由ccflow维护更新

2、新建自己业务的扩展类库,扩展类库命名空间必须以BP开头,与ccflow类库命名规则保持一致,否则无法反射完成初始化

3、在扩展类库中新建一个BP.Def.FlowExt类,以继承BP.WF.Template.FlowExt类为例,关键是重写子类的EnMap属性

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BP.En;
using BP.Web;
using BP.Sys; namespace BP.Def
{ public class FlowExtAttr : BP.WF.Template.FlowAttr
{
/// <summary>
/// 自定义业务编号
/// </summary>
public const string DefNoFormat = "DefNoFormat";
/// <summary>
/// 自定义业务名称
/// </summary>
public const string DefNameFormat = "DefNameFormat";
/// <summary>
/// 删除流程时是否同时删除自定义
/// </summary>
public static string IsDeleteDef = "IsDeleteDef";
} public class FlowExt : BP.WF.Template.FlowExt
{
public FlowExt()
{ } public FlowExt(string _No)
{
this.No = _No;
this.Retrieve();
} /// <summary>
/// 重写基类方法
/// </summary>
public override Map EnMap
{
get
{
//web界面中的Tab展示控制
EnCfg en = new EnCfg(this.ToString());
if (en.GroupTitle.Contains(FlowExtAttr.DefNoFormat) == false)
{
en.SetValByKey(EnCfgAttr.GroupTitle, en.GroupTitle + "@" + FlowExtAttr.DefNoFormat + "=自定义扩展");
en.Save();
} //首次构造返回基类
if (this._enMap == null)
{
this._enMap = base.EnMap;
return this._enMap;
} //基类构造完成后,后续使用子类
int index = this._enMap.Attrs.GetIndexByKey(FlowExtAttr.DefNoFormat); //新增加的配置
if (this._enMap != null && this.Row.Count > && string.IsNullOrEmpty(this.No) == false && index < )
{
this._enMap.AddTBString(FlowExtAttr.DefNoFormat, "", "自定义业务编号", true, false, , , , true);
this._enMap.AddTBString(FlowExtAttr.DefNameFormat, "", "自定义业务名称", true, false, , , , true);
this._enMap.AddBoolean(FlowExtAttr.IsDeleteDef, false, "删除流程时是否同时删除自定义", true, true, true);
} return this._enMap;
}
} /// <summary>
/// 自定义业务编号
/// </summary>
public string DefNoFormat
{
get
{
return this.GetValStrByKey(FlowExtAttr.DefNoFormat);
}
set
{
this.SetValByKey(FlowExtAttr.DefNoFormat, value);
}
} /// <summary>
///自定义业务名称
/// </summary>
public string DefNameFormat
{
get
{
return this.GetValStrByKey(FlowExtAttr.DefNameFormat);
}
set
{
this.SetValByKey(FlowExtAttr.DefNameFormat, value);
}
} /// <summary>
/// 删除流程时是否同时删除自定义
/// </summary>
public bool IsDeleteDef
{
get
{
return this.GetValBooleanByKey(FlowExtAttr.IsDeleteDef);
}
}
} public class FlowExts : BP.WF.Template.FlowExts
{
public FlowExts()
{
} public override Entity GetNewEntity
{
get { return new FlowExt(); }
}
}
}

4、在解决方案新建一个web项目,完全拷贝ccflow下的WF、DataUser目录到web项目里,最终整个结构如下

5、为后台页面增加一个分部类,在分部类里修改asp.net页面入口,转向访问自定义的BP.Def类库

6、最终效果达到在完全不修改ccflow的前后台源码下实现自定义功能的扩展

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/585983.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存