using System; using System.Collections; using BP.DA; using BP.En; using BP.Port; using BP.WF.Template; namespace BP.WF.Template { /// /// 节点方向属性 /// public class DirectionAttr { /// /// 节点 /// public const string Node = "Node"; /// /// 转向的节点 /// public const string ToNode = "ToNode"; /// /// 到达节点名称 /// public const string ToNodeName = "ToNodeName"; /// /// 流程编号 /// public const string FK_Flow = "FK_Flow"; /// /// 描述 /// public const string Des = "Des"; /// /// 是否显示网关? /// public const string GateWay = "GateWay"; /// /// 节点类型 /// public const string NodeType = "NodeType"; /// /// 顺序 /// public const string Idx = "Idx"; } /// /// 节点方向 /// 节点的方向有两部分组成. /// 1, Node. /// 2, toNode. /// 记录了从一个节点到其他的多个节点. /// 也记录了到这个节点的其他的节点. /// public class Direction : EntityMyPK { #region 基本属性 /// ///节点 /// public int Node { get { return this.GetValIntByKey(DirectionAttr.Node); } set { this.SetValByKey(DirectionAttr.Node, value); } } public string FK_Flow { get { return this.GetValStringByKey(DirectionAttr.FK_Flow); } set { this.SetValByKey(DirectionAttr.FK_Flow, value); } } /// /// 转向的节点 /// public int ToNode { get { return this.GetValIntByKey(DirectionAttr.ToNode); } set { this.SetValByKey(DirectionAttr.ToNode, value); } } public int Idx { get { return this.GetValIntByKey(DirectionAttr.Idx); } set { this.SetValByKey(DirectionAttr.Idx, value); } } public string Des { get { return this.GetValStringByKey(DirectionAttr.Des); } set { this.SetValByKey(DirectionAttr.Des, value); } } #endregion #region 构造方法 /// /// 节点方向 /// public Direction() { } /// /// 重写基类方法 /// public override Map EnMap { get { if (this._enMap != null) return this._enMap; Map map = new Map("WF_Direction", "节点方向信息"); map.IndexField = DirectionAttr.FK_Flow; /* * MyPK 是一个复合主键 是由 Node+'_'+ToNode+'_'+DirType 组合的. 比如: 101_102_1 */ map.AddMyPK(); map.AddTBString(DirectionAttr.FK_Flow, null, "流程", true, true, 0, 4, 0, false); map.AddTBInt(DirectionAttr.Node, 0, "从节点", false, true); map.AddTBInt(DirectionAttr.ToNode, 0, "到节点", false, true); map.AddTBString(DirectionAttr.ToNodeName, null, "到达节点名称", true, true, 0, 300, 300, false); map.AddTBInt(DirectionAttr.GateWay, 0, "网关显示?", true, true); map.AddTBInt(DirectionAttr.NodeType, 0, "ToNode类型0=工作,1=路由,2=抄送,3=子流程,4=结束", true, true); map.AddTBString(DirectionAttr.Des, null, "描述", true, true, 0, 100, 0, false); map.AddTBInt(DirectionAttr.Idx, 0, "计算优先级顺序", true, true); ////相关功能。 //map.AttrsOfOneVSM.Add(new BP.WF.Template.DirectionStations(), new BP.Port.Stations(), // NodeStationAttr.FK_Node, NodeStationAttr.FK_Station, // StationAttr.Name, StationAttr.No, "方向条件与角色"); //map.AddTBInt(DirectionAttr.CondExpModel, 0, "条件计算方式", false, true); //map.AttrsOfOneVSM.Add(new BP.WF.Template.NodeDepts(), new BP.Port.Depts(), NodeDeptAttr.FK_Node, NodeDeptAttr.FK_Dept, DeptAttr.Name, //DeptAttr.No, "节点部门", Dot2DotModel.TreeDept); this._enMap = map; return this._enMap; } } #endregion protected override bool beforeUpdateInsertAction() { this.setMyPK(this.FK_Flow + "_" + this.Node + "_" + this.ToNode); return base.beforeUpdateInsertAction(); } /// /// 处理pk /// /// protected override bool beforeInsert() { this.setMyPK(this.FK_Flow + "_" + this.Node + "_" + this.ToNode); return base.beforeInsert(); } protected override bool beforeDelete() { this.setMyPK(this.FK_Flow + "_" + this.Node + "_" + this.ToNode); //删除条件. Conds nds = new Conds(); nds.Delete(CondAttr.FK_Node, this.Node, CondAttr.ToNodeID, this.ToNode); return base.beforeDelete(); } /// /// 上移 /// public void DoUp() { this.DoOrderUp(DirectionAttr.Node, this.Node.ToString(), DirectionAttr.Idx); this.UpdateHisToNDs(); } /// /// 下移 /// public void DoDown() { this.DoOrderDown(DirectionAttr.Node, this.Node.ToString(), DirectionAttr.Idx); this.UpdateHisToNDs(); } public void UpdateHisToNDs() { //获得方向集合处理toNodes Directions mydirs = new Directions(this.Node); Node nd = new Node(this.Node); string strs = ""; foreach (Direction dir in mydirs) { strs += "@" + dir.ToNode; } nd.HisToNDs = strs; nd.Update(); } } /// /// 节点方向 /// public class Directions : Entities { /// /// 节点方向 /// public Directions() { } /// /// 方向 /// /// public Directions(string flowNo) { QueryObject qo = new QueryObject(this); qo.AddWhere(DirectionAttr.FK_Flow, flowNo); qo.addOrderBy("Node,Idx"); qo.DoQuery(); } /// /// 节点方向 /// /// 节点ID public Directions(int NodeID) { QueryObject qo = new QueryObject(this); qo.AddWhere(DirectionAttr.Node, NodeID); qo.addAnd(); qo.AddWhereIn(DirectionAttr.NodeType, "(0,1)"); //普通节点+路由节点 qo.addOrderBy(DirectionAttr.Idx); //方向条件的优先级. qo.DoQuery(); } /// /// 得到它的 Entity /// public override Entity GetNewEntity { get { return new Direction(); } } /// /// 此节点的转向方向集合 /// /// 此节点的ID /// 是不是判断在节点的生存期内 /// 转向方向集合(ToNodes) public Nodes GetHisToNodes(int nodeID, bool isLifecyle) { Nodes nds = new Nodes(); QueryObject qo = new QueryObject(nds); qo.AddWhereInSQL(NodeAttr.NodeID, "SELECT ToNode FROM WF_Direction WHERE Node=" + nodeID+ " AND (NodeType=0 OR NodeType=1) "); qo.DoQuery(); return nds; } /// /// 转向此节点的集合的Nodes /// /// 此节点的ID /// 转向此节点的集合的Nodes (FromNodes) public Nodes GetHisFromNodes(int nodeID) { QueryObject qo = new QueryObject(this); qo.AddWhere(DirectionAttr.ToNode, nodeID); qo.DoQuery(); Nodes ens = new Nodes(); foreach (Direction en in this) { ens.AddEntity(new Node(en.Node)); } return ens; } #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((Direction)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成List. } }