using System;
using System.Data;
using BP.DA;
using BP.En;
using BP.WF;
using BP.Port;
using BP.WF.Template;
namespace BP.WF
{
///
/// 自定义运行路径 属性
///
public class TransferCustomAttr : EntityMyPKAttr
{
#region 基本属性
///
/// 工作ID
///
public const string WorkID = "WorkID";
///
/// 节点ID
///
public const string FK_Node = "FK_Node";
///
/// 节点名称
///
public const string NodeName = "NodeName";
///
/// 处理人编号(多个人用逗号分开)
///
public const string Worker = "Worker";
///
/// 处理人显示(多个人用逗号分开)
///
public const string WorkerName = "WorkerName";
///
/// 顺序
///
public const string Idx = "Idx";
///
/// 发起时间
///
public const string StartDT = "StartDT";
///
/// 计划完成日期
///
public const string PlanDT = "PlanDT";
///
/// 要启用的子流程编号
///
public const string SubFlowNo = "SubFlowNo";
///
/// 是否通过了
///
public const string TodolistModel = "TodolistModel";
///
/// 是否启用
///
public const string IsEnable = "IsEnable";
#endregion
}
///
/// 自定义运行路径
///
public class TransferCustom : EntityMyPK
{
#region 属性
///
/// 节点ID
///
public int NodeID
{
get
{
return this.GetValIntByKey(TransferCustomAttr.FK_Node);
}
set
{
this.SetValByKey(TransferCustomAttr.FK_Node, value);
}
}
public Int64 WorkID
{
get
{
return this.GetValInt64ByKey(TransferCustomAttr.WorkID);
}
set
{
this.SetValByKey(TransferCustomAttr.WorkID, value);
}
}
///
/// 节点名称
///
public string NodeName
{
get
{
return this.GetValStringByKey(TransferCustomAttr.NodeName);
}
set
{
this.SetValByKey(TransferCustomAttr.NodeName, value);
}
}
///
/// 计划完成日期
///
public string PlanDT
{
get
{
return this.GetValStringByKey(TransferCustomAttr.PlanDT);
}
set
{
this.SetValByKey(TransferCustomAttr.PlanDT, value);
}
}
///
/// 处理人(多个人用逗号分开)
///
public string Worker
{
get
{
return this.GetValStringByKey(TransferCustomAttr.Worker);
}
set
{
this.SetValByKey(TransferCustomAttr.Worker, value);
}
}
///
/// 处理人显示(多个人用逗号分开)
///
public string WorkerName
{
get
{
return this.GetValStringByKey(TransferCustomAttr.WorkerName);
}
set
{
this.SetValByKey(TransferCustomAttr.WorkerName, value);
}
}
///
/// 要启用的子流程编号
///
public string SubFlowNo
{
get
{
return this.GetValStringByKey(TransferCustomAttr.SubFlowNo);
}
set
{
this.SetValByKey(TransferCustomAttr.SubFlowNo, value);
}
}
///
/// 多人处理工作模式
///
public TodolistModel TodolistModel
{
get
{
return (TodolistModel)this.GetValIntByKey(TransferCustomAttr.TodolistModel);
}
set
{
this.SetValByKey(TransferCustomAttr.TodolistModel, (int)value);
}
}
///
/// 发起时间(可以为空)
///
public string StartDT
{
get
{
return this.GetValStringByKey(TransferCustomAttr.StartDT);
}
set
{
this.SetValByKey(TransferCustomAttr.StartDT, value);
}
}
///
/// 顺序
///
public int Idx
{
get
{
return this.GetValIntByKey(TransferCustomAttr.Idx);
}
set
{
this.SetValByKey(TransferCustomAttr.Idx, value);
}
}
public bool ItIsEnable
{
get
{
return this.GetValBooleanByKey(TransferCustomAttr.IsEnable);
}
set
{
this.SetValByKey(TransferCustomAttr.IsEnable, value);
}
}
#endregion
#region 构造函数
///
/// TransferCustom
///
public TransferCustom()
{
}
///
/// 重写基类方法
///
public override Map EnMap
{
get
{
if (this._enMap != null)
return this._enMap;
Map map = new Map("WF_TransferCustom", "自定义运行路径");
map.AddMyPK(); //唯一的主键.
//主键.
map.AddTBInt(TransferCustomAttr.WorkID, 0, "WorkID", true, false);
map.AddTBInt(TransferCustomAttr.FK_Node, 0, "节点ID", true, false);
map.AddTBString(TransferCustomAttr.NodeName, null, "节点名称", true, false, 0, 200, 10);
map.AddTBString(TransferCustomAttr.Worker, null, "处理人(多个人用逗号分开)", true, false, 0, 200, 10);
map.AddTBString(TransferCustomAttr.WorkerName, null, "处理人(多个人用逗号分开)", true, false, 0, 200, 10);
map.AddTBString(TransferCustomAttr.SubFlowNo, null, "要经过的子流程编号", true, false, 0, 3, 10);
map.AddTBDateTime(TransferCustomAttr.PlanDT, null, "计划完成日期", true, false);
map.AddTBInt(TransferCustomAttr.TodolistModel, 0, "多人工作处理模式", true, false);
map.AddTBInt(TransferCustomAttr.IsEnable, 0, "是否启用", true, false);
map.AddTBInt(TransferCustomAttr.Idx, 0, "顺序号", true, false);
//map.AddTBString(TransferCustomAttr.StartDT, null, "发起时间", true, false, 0, 20, 10);
this._enMap = map;
return this._enMap;
}
}
#endregion
public string DoUp()
{
this.DoOrderUp(TransferCustomAttr.WorkID, this.WorkID.ToString(), TransferCustomAttr.Idx);
return "执行成功";
}
public string DoDown()
{
this.DoOrderDown(TransferCustomAttr.WorkID, this.WorkID.ToString(), TransferCustomAttr.Idx);
return "执行成功";
}
protected override bool beforeUpdateInsertAction()
{
this.setMyPK(this.NodeID + "_" + this.WorkID);
return base.beforeInsert();
}
///
/// 获取下一个要到达的定义路径.
/// 要分析如下几种情况:
/// 1, 当前节点不存在队列里面,就返回第一个.
/// 2, 如果当前队列为空,就认为需要结束掉, 返回null.
/// 3, 如果当前节点是最后一个并且没有连接线连到固定节点,就返回null,表示要结束流程.
/// 4. 如果当前节点是最后一个且有连接线连到固定节点
///
/// 当前工作ID
/// 当前节点ID
/// 获取下一个要到达的定义路径,如果没有就返回空.
public static TransferCustom GetNextTransferCustom(Int64 workid, int currNodeID)
{
TransferCustoms ens = new TransferCustoms();
ens.Retrieve(TransferCustomAttr.WorkID, workid, TransferCustomAttr.Idx);
if (ens.Count == 0)
return null;
//寻找当前节点的下一个.
bool isMeet = false;
foreach (TransferCustom item in ens)
{
if (item.NodeID == currNodeID)
{
isMeet = true;
continue;
}
if (isMeet == true && item.ItIsEnable == true)
return item;
}
Node node = new Node(currNodeID);
if(node.GetParaBoolen(NodeAttr.IsYouLiTai)==false)
{
foreach (TransferCustom item in ens)
{
if (item.ItIsEnable == true && item.NodeID != currNodeID)
return (TransferCustom)item;
}
}
//如果当前节点是最后一个自定义节点,且有连接线连到固定节点
if(isMeet == true)
{
//判断当前节点是否连接到固定节点
string sql = "SELECT AtPara FROM WF_Node WHERE NodeID In(SELECT ToNode FROM WF_Direction WHERE Node=" + currNodeID + ")";
Nodes nds = new Nodes();
nds.RetrieveInSQL(NodeAttr.NodeID,"SELECT ToNode FROM WF_Direction WHERE Node = " + currNodeID);
foreach(Node nd in nds)
{
if (nd.GetParaBoolen(NodeAttr.IsYouLiTai) == true)
continue;
TransferCustom en = new TransferCustom();
en.NodeID = nd.NodeID;
//更改流程的运行状态
GenerWorkFlow gwf = new GenerWorkFlow(workid);
gwf.TransferCustomType = TransferCustomType.ByCCBPMDefine;
gwf.Update();
return en;
}
}
return null;
}
}
///
/// 自定义运行路径
///
public class TransferCustoms : EntitiesMyPK
{
#region 方法
///
/// 得到它的 Entity
///
public override Entity GetNewEntity
{
get
{
return new TransferCustom();
}
}
///
/// 自定义运行路径
///
public TransferCustoms()
{
}
///
/// 自定义运行路径
///
/// 工作ID
public TransferCustoms(Int64 workid)
{
this.Retrieve(TransferCustomAttr.WorkID, workid, TransferCustomAttr.Idx);
}
///
/// 自定义运行路径
///
/// 节点ID
/// 工作ID
public TransferCustoms(int nodeID, Int64 workid)
{
this.Retrieve(TransferCustomAttr.WorkID, workid, TransferCustomAttr.FK_Node, nodeID, TransferCustomAttr.Idx);
}
#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((TransferCustom)this[i]);
}
return list;
}
#endregion 为了适应自动翻译成java的需要,把实体转换成List.
}
}