using System;
using System.Collections;
using BP.DA;
using BP.En;
using BP.Port;
using BP.Sys;
using BP.WF.Template.SFlow;
using BP.WF.Template.Frm;
namespace BP.WF.Template
{
///
/// 节点表单属性
///
public class FrmNodeAttr
{
///
/// 节点
///
public const string FK_Frm = "FK_Frm";
///
/// 工作节点
///
public const string FK_Node = "FK_Node";
///
/// 是否readonly.
///
public const string IsEdit = "IsEdit";
///
/// IsPrint
///
public const string IsPrint = "IsPrint";
///
/// 是否启用装载填充事件.
///
public const string IsEnableLoadData = "IsEnableLoadData";
///
/// 打开表单时是否覆盖其他节点页面?
///
public const string IsCloseEtcFrm = "IsCloseEtcFrm";
///
/// 是否1变N(对于分流节点有效)
///
public const string Is1ToN = "Is1ToN";
///
/// 是否默认打开
///
public const string IsDefaultOpen = "IsDefaultOpen";
///
/// Idx
///
public const string Idx = "Idx";
///
/// FK_Flow
///
public const string FK_Flow = "FK_Flow";
///
/// 表单类型
///
public const string FrmType = "FrmType";
///
/// 方案
///
public const string FrmSln = "FrmSln";
///
/// 是否启用审核组件
///
public const string IsEnableFWC = "IsEnableFWC";
///
/// 谁是主键?
///
public const string WhoIsPK = "WhoIsPK";
///
/// 模版文件
///
public const string TempleteFile = "TempleteFile";
///
/// 是否显示
///
public const string IsEnable = "IsEnable";
///
/// 汇总
///
public const string HuiZong = "HuiZong";
///
/// 表单启用规则
///
public const string FrmEnableRole = "FrmEnableRole";
///
/// 表单启动表达式.
///
public const string FrmEnableExp = "FrmEnableExp";
///
/// 表单显示的名字
///
public const string FrmNameShow = "FrmNameShow";
///
/// 父子流程组件
///
public const string SFSta = "SFSta";
}
///
/// 谁是主键?
///
public enum WhoIsPK
{
///
/// 流程ID是主键
///
OID,
///
/// FID是主键(干流程的WorkID)
///
FID,
///
/// 父流程ID是主键
///
PWorkID,
///
/// 延续流程ID是主键
///
CWorkID,
///
/// 爷爷流程ID是主键
///
P2WorkID,
///
/// 太爷爷流程ID是主键
///
P3WorkID,
///
/// 根流程的WorkID
///
RootFlowWorkID
}
///
/// 方案类型
///
public enum FrmSln
{
///
/// 默认方案
///
Default,
///
/// 只读方案
///
Readonly,
///
/// 自定义方案
///
Self
}
///
/// 表单启用规则
///
public enum FrmEnableRole
{
///
/// 始终启用
///
Allways=0,
///
/// 有数据时启用
///
WhenHaveData=1,
///
/// 有参数时启用
///
WhenHaveFrmPara=2,
///
/// 按表单的字段表达式
///
ByFrmFields=3,
///
/// 按SQL表达式
///
BySQL=4,
///
/// 不启用
///
Disable=5,
///
/// 按角色
///
ByStation=6,
///
/// 按部门
///
ByDept=7
}
///
/// 节点表单
/// 节点的工作节点有两部分组成.
/// 记录了从一个节点到其他的多个节点.
/// 也记录了到这个节点的其他的节点.
///
public class FrmNode : EntityMyPK
{
#region 关于节点与office表单的toolbar权限控制方案.
#endregion 关于节点与office表单的toolbar权限控制方案.
#region 基本属性
public string FrmUrl
{
get
{
switch (this.HisFrmType)
{
case FrmType.FoolForm:
return Glo.CCFlowAppPath + "/WF/CCForm/FrmFix";
case FrmType.Develop:
return Glo.CCFlowAppPath + "/WF/CCForm/Frm";
default:
throw new Exception("err,未处理。");
}
}
}
private CCFrm _hisFrm = null;
public CCFrm HisFrm
{
get
{
if (this._hisFrm == null)
{
this._hisFrm = new CCFrm(this.FK_Frm);
this._hisFrm.HisFrmNode = this;
}
return this._hisFrm;
}
}
///
/// UI界面上的访问控制
///
public override UAC HisUAC
{
get
{
UAC uac = new UAC();
uac.OpenForSysAdmin();
return uac;
}
}
///
/// 表单类型
///
public BP.Sys.FrmType HisFrmType
{
get
{
return (BP.Sys.FrmType)this.GetValIntByKey(FrmNodeAttr.FrmType);
}
set
{
this.SetValByKey(FrmNodeAttr.FrmType, (int)value);
}
}
///
/// 表单类型
///
public string HisFrmTypeText
{
get
{
SysEnum se = new SysEnum(FrmNodeAttr.FrmType, (int)this.HisFrmType);
return se.Lab;
// return (BP.Sys.FrmType)this.GetValIntByKey(FrmNodeAttr.FrmType);
}
}
///
/// 是否启用装载填充事件
///
public bool IsEnableLoadData
{
get
{
return this.GetValBooleanByKey(FrmNodeAttr.IsEnableLoadData);
}
set
{
this.SetValByKey(FrmNodeAttr.IsEnableLoadData, value);
}
}
///
/// 是否启用节点组件?
///
public FrmWorkCheckSta IsEnableFWC
{
get
{
return (FrmWorkCheckSta)this.GetValIntByKey(FrmNodeAttr.IsEnableFWC);
}
set
{
this.SetValByKey(FrmNodeAttr.IsEnableFWC, (int)value);
}
}
public FrmSubFlowSta SFSta
{
get
{
return (FrmSubFlowSta)this.GetValIntByKey(FrmNodeAttr.SFSta);
}
set
{
this.SetValByKey(FrmNodeAttr.SFSta, (int)value);
}
}
///
/// 是否执行1变n
///
public bool Is1ToN
{
get
{
return this.GetValBooleanByKey(FrmNodeAttr.Is1ToN);
}
set
{
this.SetValByKey(FrmNodeAttr.Is1ToN, value);
}
}
///
/// 是否默认打开
///
public bool IsDefaultOpen
{
get
{
return this.GetValBooleanByKey(FrmNodeAttr.IsDefaultOpen);
}
set
{
this.SetValByKey(FrmNodeAttr.IsDefaultOpen, value);
}
}
///
///节点
///
public int FK_Node
{
get
{
return this.GetValIntByKey(FrmNodeAttr.FK_Node);
}
set
{
this.SetValByKey(FrmNodeAttr.FK_Node, value);
}
}
///
/// 顺序号
///
public int Idx
{
get
{
return this.GetValIntByKey(FrmNodeAttr.Idx);
}
set
{
this.SetValByKey(FrmNodeAttr.Idx, value);
}
}
///
/// 谁是主键?
///
public WhoIsPK WhoIsPK
{
get
{
return (WhoIsPK)this.GetValIntByKey(FrmNodeAttr.WhoIsPK);
}
set
{
this.SetValByKey(FrmNodeAttr.WhoIsPK, (int)value);
}
}
///
/// 表单ID
///
public string FK_Frm
{
get
{
return this.GetValStringByKey(FrmNodeAttr.FK_Frm);
}
set
{
this.SetValByKey(FrmNodeAttr.FK_Frm, value);
}
}
///
/// 模版文件
///
public string TempleteFile
{
get
{
string str = this.GetValStringByKey(FrmNodeAttr.TempleteFile);
if (DataType.IsNullOrEmpty(str))
return this.FK_Frm + ".xls";
return str;
}
set
{
this.SetValByKey(FrmNodeAttr.TempleteFile, value);
}
}
///
/// 是否显示
///
public bool IsEnable
{
get
{
return this.GetValBooleanByKey(FrmNodeAttr.IsEnable);
}
set
{
this.SetValByKey(FrmNodeAttr.IsEnable, value);
}
}
///
/// 显示的名字
///
public string FrmNameShow
{
get
{
return this.GetValStringByKey(FrmNodeAttr.FrmNameShow);
}
set
{
this.SetValByKey(FrmNodeAttr.FrmNameShow, value);
}
}
///
/// 对应的解决方案
/// 0=默认方案.节点编号 1=自定义方案, 1=不可编辑.
///
public FrmSln FrmSln
{
get
{
if (this.GetValIntByKey(FrmNodeAttr.FrmSln) > 5)
return Template.FrmSln.Self;
return (FrmSln)this.GetValIntByKey(FrmNodeAttr.FrmSln);
}
set
{
this.SetValByKey(FrmNodeAttr.FrmSln, (int)value);
}
}
///
/// 启用规则
///
public int FrmEnableRoleInt
{
get
{
return this.GetValIntByKey(FrmNodeAttr.FrmEnableRole);
}
set
{
this.SetValByKey(FrmNodeAttr.FrmEnableRole, value);
}
}
///
/// 表单启用规则
///
public FrmEnableRole FrmEnableRole
{
get
{
return (FrmEnableRole)this.GetValIntByKey(FrmNodeAttr.FrmEnableRole);
}
set
{
this.SetValByKey(FrmNodeAttr.FrmEnableRole, (int)value);
}
}
///
/// 启用规则.
///
public string FrmEnableRoleText
{
get
{
if (this.FrmEnableRole == FrmEnableRole.WhenHaveFrmPara && this.FK_Frm == "ND" + this.FK_Node)
return "不启用";
SysEnum se = new SysEnum(FrmNodeAttr.FrmEnableRole, this.FrmEnableRoleInt);
return se.Lab;
}
}
///
/// 表单启动表达式
///
public string FrmEnableExp
{
get
{
return this.GetValStringByKey(FrmNodeAttr.FrmEnableExp);
}
set
{
this.SetValByKey(FrmNodeAttr.FrmEnableExp, value);
}
}
///
/// 流程编号
///
public string FK_Flow
{
get
{
return this.GetValStringByKey(FrmNodeAttr.FK_Flow);
}
set
{
this.SetValByKey(FrmNodeAttr.FK_Flow, value);
}
}
///
/// 是否可以编辑?
///
public bool IsEdit
{
get
{
if (this.FrmSln == FrmSln.Readonly)
return false;
return true;
}
}
///
/// 是否可以编辑?
///
public int IsEditInt
{
get
{
if (this.IsEdit)
return 1;
return 0;
}
}
///
/// 是否可以打印
///
public bool IsPrint
{
get
{
return this.GetValBooleanByKey(FrmNodeAttr.IsPrint);
}
set
{
this.SetValByKey(FrmNodeAttr.IsPrint, value);
}
}
///
/// 是否可以打印
///
public int IsPrintInt
{
get
{
return this.GetValIntByKey(FrmNodeAttr.IsPrint);
}
}
///
/// 汇总
///
public string HuiZong
{
get
{
return this.GetValStringByKey(FrmNodeAttr.HuiZong);
}
set
{
this.SetValByKey(FrmNodeAttr.HuiZong, value);
}
}
///
///打开时是否关闭其它的页面?
///
public bool IsCloseEtcFrm
{
get
{
return this.GetValBooleanByKey(FrmNodeAttr.IsCloseEtcFrm);
}
}
public int IsCloseEtcFrmInt
{
get
{
if (this.IsCloseEtcFrm)
return 1;
return 0;
}
}
public string CheckField
{
get
{
return this.GetValStringByKey(NodeWorkCheckAttr.CheckField);
}
set
{
this.SetValByKey(NodeWorkCheckAttr.CheckField, value);
}
}
///
/// 单据编号字段
///
public string BillNoField
{
get
{
return this.GetValStringByKey(NodeWorkCheckAttr.BillNoField);
}
set
{
this.SetValByKey(NodeWorkCheckAttr.BillNoField, value);
}
}
#endregion
#region 构造方法
///
/// 节点表单
///
public FrmNode() { }
///
/// 节点表单
///
///
public FrmNode(string mypk)
: base(mypk)
{
}
///
/// 节点表单
///
/// 节点
/// 表单
public FrmNode(int fk_node, string fk_frm)
{
//设置属性.
this.FK_Node = fk_node;
this.FK_Frm = fk_frm;
int i = this.Retrieve(FrmNodeAttr.FK_Node, fk_node, FrmNodeAttr.FK_Frm, fk_frm);
if (i == 0)
{
this.IsPrint = false;
//不可以编辑.
this.FrmSln = FrmSln.Default;
Node node = new Node(fk_node);
if (node.FrmWorkCheckSta != FrmWorkCheckSta.Disable)
this.IsEnableFWC = node.FrmWorkCheckSta;
this.FK_Flow = node.FK_Flow;
return;
}
}
///
/// 重写基类方法
///
public override Map EnMap
{
get
{
if (this._enMap != null)
return this._enMap;
Map map = new Map("WF_FrmNode", "节点表单");
map.AddMyPK();
map.AddTBString(FrmNodeAttr.FK_Frm, null, "表单ID", true, true, 1, 200, 200);
map.AddTBInt(FrmNodeAttr.FK_Node, 0, "节点编号", true, false);
map.AddTBString(FrmNodeAttr.FK_Flow, null, "流程编号", true, true, 1, 10, 20);
map.AddTBString(FrmNodeAttr.FrmType, "0", "表单类型", true, true, 1, 20, 20);
//菜单在本节点的权限控制.
// map.AddTBInt(FrmNodeAttr.IsEdit, 1, "是否可以更新", true, false);
map.AddTBInt(FrmNodeAttr.IsPrint, 0, "是否可以打印", true, false);
map.AddTBInt(FrmNodeAttr.IsEnableLoadData, 0, "是否启用装载填充事件", true, false);
map.AddTBInt(FrmNodeAttr.IsDefaultOpen, 0, "是否默认打开", true, false);
map.AddTBInt(FrmNodeAttr.IsCloseEtcFrm, 0, "打开时是否关闭其它的页面?", true, false);
map.AddTBInt(FrmNodeAttr.IsEnableFWC, 0, "是否启用审核组件?", true, false);
map.AddTBInt(FrmNodeAttr.SFSta, 0, "是否启用父子流程组件?", true, false);
//显示的
map.AddTBInt(FrmNodeAttr.Idx, 0, "顺序号", true, false);
map.AddTBInt(FrmNodeAttr.FrmSln, 0, "表单控制方案", true, false);
// add 2014-01-26
map.AddTBInt(FrmNodeAttr.WhoIsPK, 0, "谁是主键?", true, false);
//add 2016.3.25.
map.AddTBInt(FrmNodeAttr.Is1ToN, 0, "是否1变N?", true, false);
map.AddTBString(FrmNodeAttr.HuiZong, null, "子线程要汇总的数据表", true, true, 0, 300, 20);
map.AddTBInt(FrmNodeAttr.FrmEnableRole, 0, "表单启用规则", true, false);
map.AddTBString(FrmNodeAttr.FrmEnableExp, null, "启用的表达式", true, true, 0, 900, 20);
//模版文件,对于office表单有效.
map.AddTBString(FrmNodeAttr.TempleteFile, null, "模版文件", true, true, 0, 500, 20);
//是否显示
map.AddTBInt(FrmNodeAttr.IsEnable, 1, "是否显示", true, false);
// map.AddTBString(FrmNodeAttr.GuanJianZiDuan, null, "关键字段", true, true, 0, 20, 20);
//@2019.09.30 by zhoupeng.
map.AddTBString(FrmNodeAttr.FrmNameShow, null, "表单显示名字", true, false, 0, 100, 20);
// map.SetHelperAlert(FrmNodeAttr.FrmNameShow, "显示在表单树上的名字,默认为空,表示与表单的实际名字相同.多用于节点表单的名字在表单树上显示.");
//签批字段不可见
map.AddTBString(NodeWorkCheckAttr.CheckField, null, "签批字段", false, false, 0, 50, 10, false);
map.AddTBString(NodeWorkCheckAttr.BillNoField, null, "单据编号字段", false, false, 0, 50, 10, false);
this._enMap = map;
return this._enMap;
}
}
#endregion
#region 方法.
public void DoUp()
{
this.DoOrderUp(FrmNodeAttr.FK_Node, this.FK_Node.ToString(), FrmNodeAttr.Idx);
}
public void DoDown()
{
this.DoOrderDown(FrmNodeAttr.FK_Node, this.FK_Node.ToString(), FrmNodeAttr.Idx);
}
protected override bool beforeUpdateInsertAction()
{
if (this.FK_Frm.Length == 0)
throw new Exception("@表单编号为空");
if (this.FK_Node == 0)
throw new Exception("@节点ID为空");
if (this.FK_Flow.Length == 0)
throw new Exception("@流程编号为空");
this.setMyPK(this.FK_Frm + "_" + this.FK_Node + "_" + this.FK_Flow);
//获取表单的类型
MapData mapData = new MapData();
mapData.No = this.FK_Frm;
if (mapData.RetrieveFromDBSources() == 1)
this.HisFrmType = mapData.HisFrmType;
else
this.HisFrmType = FrmType.FoolForm;
return base.beforeUpdateInsertAction();
}
#endregion 方法.
protected override bool beforeInsert()
{
//如果不是开始节点,默认为只读方案.
if (this.FK_Node.ToString().EndsWith("01") == false)
this.FrmSln = FrmSln.Readonly;
return base.beforeInsert();
}
}
///
/// 节点表单s
///
public class FrmNodes : EntitiesMyPK
{
#region 属性.
///
/// 他的工作节点
///
public Nodes HisNodes
{
get
{
Nodes ens = new Nodes();
foreach (FrmNode ns in this)
{
ens.AddEntity(new Node(ns.FK_Node));
}
return ens;
}
}
#endregion 属性.
#region 构造方法..
///
/// 节点表单
///
public FrmNodes() { }
///
/// 节点表单
///
/// 节点ID
public FrmNodes(string fk_flow, int nodeID)
{
QueryObject qo = new QueryObject(this);
qo.AddWhere(FrmNodeAttr.FK_Flow, fk_flow);
qo.addAnd();
qo.AddWhere(FrmNodeAttr.FK_Node, nodeID);
qo.addOrderBy(FrmNodeAttr.Idx);
qo.DoQuery();
}
///
/// 节点表单
///
/// NodeNo
public FrmNodes(int nodeID)
{
QueryObject qo = new QueryObject(this);
qo.AddWhere(FrmNodeAttr.FK_Node, nodeID);
qo.addOrderBy(FrmNodeAttr.Idx);
qo.DoQuery();
}
#endregion 构造方法..
#region 公共方法.
///
/// 得到它的 Entity
///
public override Entity GetNewEntity
{
get
{
return new FrmNode();
}
}
///
/// 节点表单s
///
/// 节点表单
///
public Nodes GetHisNodes(Nodes sts)
{
Nodes nds = new Nodes();
Nodes tmp = new Nodes();
foreach (Node st in sts)
{
tmp = this.GetHisNodes(st.No);
foreach (Node nd in tmp)
{
if (nds.Contains(nd))
continue;
nds.AddEntity(nd);
}
}
return nds;
}
///
/// 节点表单
///
/// 工作节点编号
/// 节点s
public Nodes GetHisNodes(string NodeNo)
{
QueryObject qo = new QueryObject(this);
qo.AddWhere(FrmNodeAttr.FK_Node, NodeNo);
qo.DoQuery();
Nodes ens = new Nodes();
foreach (FrmNode en in this)
{
ens.AddEntity(new Node(en.FK_Frm));
}
return ens;
}
///
/// 转向此节点的集合的Nodes
///
/// 此节点的ID
/// 转向此节点的集合的Nodes (FromNodes)
public Nodes GetHisNodes(int nodeID)
{
QueryObject qo = new QueryObject(this);
qo.AddWhere(FrmNodeAttr.FK_Frm, nodeID);
qo.DoQuery();
Nodes ens = new Nodes();
foreach (FrmNode en in this)
{
ens.AddEntity(new Node(en.FK_Node));
}
return ens;
}
#endregion 公共方法.
#region 为了适应自动翻译成java的需要,把实体转换成List.
///
/// 转化成 java list,C#不能调用.
///
/// List
public System.Collections.Generic.IList ToJavaList()
{
return (System.Collections.Generic.IList)this;
}
///
/// 转化成list
///
/// List
public System.Collections.Generic.List Tolist()
{
System.Collections.Generic.List list = new System.Collections.Generic.List();
for (int i = 0; i < this.Count; i++)
{
list.Add((FrmNode)this[i]);
}
return list;
}
#endregion 为了适应自动翻译成java的需要,把实体转换成List.
}
}