using System; using System.Data; using BP.DA; using BP.En; using BP.WF.Template; namespace BP.WF.Data { /// /// 流程实例 /// public class GenerWorkFlowExt : Entity { #region 基本属性 /// /// 主键 /// public override string PK { get { return GenerWorkFlowAttr.WorkID; } } /// /// 备注 /// public string FlowNote { get { return this.GetValStrByKey(GenerWorkFlowAttr.FlowNote); } set { SetValByKey(GenerWorkFlowAttr.FlowNote, value); } } /// /// 工作流程编号 /// public string FK_Flow { get { return this.GetValStrByKey(GenerWorkFlowAttr.FK_Flow); } set { SetValByKey(GenerWorkFlowAttr.FK_Flow, value); } } /// /// BillNo /// public string BillNo { get { return this.GetValStrByKey(GenerWorkFlowAttr.BillNo); } set { SetValByKey(GenerWorkFlowAttr.BillNo, value); } } /// /// 流程名称 /// public string FlowName { get { return this.GetValStrByKey(GenerWorkFlowAttr.FlowName); } set { SetValByKey(GenerWorkFlowAttr.FlowName, value); } } /// /// 优先级 /// public int PRI { get { return this.GetValIntByKey(GenerWorkFlowAttr.PRI); } set { SetValByKey(GenerWorkFlowAttr.PRI, value); } } /// /// 待办人员数量 /// public int TodoEmpsNum { get { return this.GetValIntByKey(GenerWorkFlowAttr.TodoEmpsNum); } set { SetValByKey(GenerWorkFlowAttr.TodoEmpsNum, value); } } /// /// 待办人员列表 /// public string TodoEmps { get { return this.GetValStrByKey(GenerWorkFlowAttr.TodoEmps); } set { SetValByKey(GenerWorkFlowAttr.TodoEmps, value); } } /// /// 参与人 /// public string Emps { get { return this.GetValStrByKey(GenerWorkFlowAttr.Emps); } set { SetValByKey(GenerWorkFlowAttr.Emps, value); } } /// /// 状态 /// public TaskSta TaskSta { get { return (TaskSta)this.GetValIntByKey(GenerWorkFlowAttr.TaskSta); } set { SetValByKey(GenerWorkFlowAttr.TaskSta, (int)value); } } /// /// 类别编号 /// public string FK_FlowSort { get { return this.GetValStrByKey(GenerWorkFlowAttr.FK_FlowSort); } set { SetValByKey(GenerWorkFlowAttr.FK_FlowSort, value); } } /// /// 部门编号 /// public string FK_Dept { get { return this.GetValStrByKey(GenerWorkFlowAttr.FK_Dept); } set { SetValByKey(GenerWorkFlowAttr.FK_Dept, value); } } /// /// 标题 /// public string Title { get { return this.GetValStrByKey(GenerWorkFlowAttr.Title); } set { SetValByKey(GenerWorkFlowAttr.Title, value); } } /// /// 客户编号 /// public string GuestNo { get { return this.GetValStrByKey(GenerWorkFlowAttr.GuestNo); } set { SetValByKey(GenerWorkFlowAttr.GuestNo, value); } } /// /// 客户名称 /// public string GuestName { get { return this.GetValStrByKey(GenerWorkFlowAttr.GuestName); } set { SetValByKey(GenerWorkFlowAttr.GuestName, value); } } /// /// 产生时间 /// public string RDT { get { return this.GetValStrByKey(GenerWorkFlowAttr.RDT); } set { SetValByKey(GenerWorkFlowAttr.RDT, value); } } /// /// 节点应完成时间 /// public string SDTOfNode { get { return this.GetValStrByKey(GenerWorkFlowAttr.SDTOfNode); } set { SetValByKey(GenerWorkFlowAttr.SDTOfNode, value); } } /// /// 流程应完成时间 /// public string SDTOfFlow { get { return this.GetValStrByKey(GenerWorkFlowAttr.SDTOfFlow); } set { SetValByKey(GenerWorkFlowAttr.SDTOfFlow, value); } } /// /// 流程ID /// public Int64 WorkID { get { return this.GetValInt64ByKey(GenerWorkFlowAttr.WorkID); } set { SetValByKey(GenerWorkFlowAttr.WorkID, value); } } /// /// 主线程ID /// public Int64 FID { get { return this.GetValInt64ByKey(GenerWorkFlowAttr.FID); } set { SetValByKey(GenerWorkFlowAttr.FID, value); } } /// /// 父节点流程编号. /// public Int64 PWorkID { get { return this.GetValInt64ByKey(GenerWorkFlowAttr.PWorkID); } set { SetValByKey(GenerWorkFlowAttr.PWorkID, value); } } /// /// 父流程调用的节点 /// public int PNodeID { get { return this.GetValIntByKey(GenerWorkFlowAttr.PNodeID); } set { SetValByKey(GenerWorkFlowAttr.PNodeID, value); } } /// /// PFlowNo /// public string PFlowNo { get { return this.GetValStrByKey(GenerWorkFlowAttr.PFlowNo); } set { SetValByKey(GenerWorkFlowAttr.PFlowNo, value); } } /// /// 吊起子流程的人员 /// public string PEmp { get { return this.GetValStrByKey(GenerWorkFlowAttr.PEmp); } set { SetValByKey(GenerWorkFlowAttr.PEmp, value); } } /// /// 发起人 /// public string Starter { get { return this.GetValStrByKey(GenerWorkFlowAttr.Starter); } set { SetValByKey(GenerWorkFlowAttr.Starter, value); } } /// /// 发起人名称 /// public string StarterName { get { return this.GetValStrByKey(GenerWorkFlowAttr.StarterName); } set { this.SetValByKey(GenerWorkFlowAttr.StarterName, value); } } /// /// 发起人部门名称 /// public string DeptName { get { return this.GetValStrByKey(GenerWorkFlowAttr.DeptName); } set { this.SetValByKey(GenerWorkFlowAttr.DeptName, value); } } /// /// 当前节点名称 /// public string NodeName { get { return this.GetValStrByKey(GenerWorkFlowAttr.NodeName); } set { this.SetValByKey(GenerWorkFlowAttr.NodeName, value); } } /// /// 当前工作到的节点 /// public int FK_Node { get { return this.GetValIntByKey(GenerWorkFlowAttr.FK_Node); } set { SetValByKey(GenerWorkFlowAttr.FK_Node, value); } } /// /// 工作流程状态 /// public WFState WFState { get { return (WFState)this.GetValIntByKey(GenerWorkFlowAttr.WFState); } set { if (value == WF.WFState.Complete) SetValByKey(GenerWorkFlowAttr.WFSta, (int)WFSta.Complete); else if (value == WF.WFState.Delete) SetValByKey(GenerWorkFlowAttr.WFSta, (int)WFSta.Etc); else SetValByKey(GenerWorkFlowAttr.WFSta, (int)WFSta.Runing); SetValByKey(GenerWorkFlowAttr.WFState, (int)value); } } /// /// 状态(简单) /// public WFSta WFSta { get { return (WFSta)this.GetValIntByKey(GenerWorkFlowAttr.WFSta); } set { SetValByKey(GenerWorkFlowAttr.WFSta, (int)value); } } public string WFStateText { get { BP.WF.WFState ws = (WFState)this.WFState; switch (ws) { case WF.WFState.Complete: return "已完成"; case WF.WFState.Runing: return "在运行"; case WF.WFState.Hungup: return "挂起"; case WF.WFState.Askfor: return "加签"; case WF.WFState.ReturnSta: return "退回"; case WF.WFState.Draft: return "草稿"; default: return "未判断"; } } } /// /// GUID /// public string GUID { get { return this.GetValStrByKey(GenerWorkFlowAttr.GUID); } set { SetValByKey(GenerWorkFlowAttr.GUID, value); } } #endregion #region 参数属性. public string Paras_ToNodes { get { return this.GetParaString("ToNodes"); } set { this.SetPara("ToNodes", value); } } /// /// 加签信息 /// public string Paras_AskForReply { get { return this.GetParaString("AskForReply"); } set { this.SetPara("AskForReply", value); } } #endregion 参数属性. #region 构造函数 /// /// 访问权限 /// public override UAC HisUAC { get { UAC uac = new UAC(); uac.Readonly(); return uac; } } /// /// 产生的工作流程 /// public GenerWorkFlowExt() { } /// /// 产生的工作流程 /// /// public GenerWorkFlowExt(Int64 workId) { QueryObject qo = new QueryObject(this); qo.AddWhere(GenerWorkFlowAttr.WorkID, workId); if (qo.DoQuery() == 0) throw new Exception("工作 GenerWorkFlowExt [" + workId + "]不存在。"); } /// /// 重写基类方法 /// public override Map EnMap { get { if (this._enMap != null) return this._enMap; Map map = new Map("WF_GenerWorkFlow", "流程查询"); map.AddTBIntPK(GenerWorkFlowAttr.WorkID, 0, "WorkID", false, true); map.AddTBString(GenerWorkFlowAttr.StarterName, null, "发起人", true, true, 0, 30, 10); map.AddTBString(GenerWorkFlowAttr.Title, null, "标题", true, true, 0, 100, 10, true); map.AddDDLSysEnum(GenerWorkFlowAttr.WFSta, 0, "流程状态", true, false, GenerWorkFlowAttr.WFSta, "@0=运行中@1=已完成@2=其他"); map.AddDDLSysEnum(GenerWorkFlowAttr.WFState, 0, "大状态", true, false, MyStartFlowAttr.WFState); map.AddTBString(GenerWorkFlowAttr.NodeName, null, "当前节点名称", true, true, 0, 100, 10); map.AddTBDateTime(GenerWorkFlowAttr.RDT, "记录日期", true, true); map.AddTBString(GenerWorkFlowAttr.BillNo, null, "单据编号", true, true, 0, 100, 10); //map.AddTBStringDoc(GenerWorkFlowAttr.FlowNote, null, "备注", true, false, true); map.AddDDLEntities(GenerWorkFlowAttr.FK_FlowSort, null, "类别", new FlowSorts(), false); map.AddDDLEntities(GenerWorkFlowAttr.FK_Flow, null, "流程", new Flows(), false); map.AddDDLEntities(GenerWorkFlowAttr.FK_Dept, null, "隶属部门", new BP.Port.Depts(), false); map.AddTBInt(GenerWorkFlowAttr.FID, 0, "FID", false, false); map.AddTBInt(GenerWorkFlowAttr.FK_Node, 0, "FK_Node", false, false); map.AddTBString(GenerWorkFlowAttr.FK_NY, null, "发起月份", true, true, 0, 100, 10); map.AddTBFloat(GenerWorkFlowAttr.LostTimeHH, 0, "耗时", true, true); // map.AddSearchAttr(GenerWorkFlowAttr.FK_Flow); map.AddSearchAttr(GenerWorkFlowAttr.WFSta); map.DTSearchKey = GenerWorkFlowAttr.RDT; map.DTSearchLabel = "时间"; map.DTSearchWay = Sys.DTSearchWay.ByDate; //把不等于 0 的去掉. map.AddHidden(GenerWorkFlowAttr.WFState, "!=", "0"); RefMethod rm = new RefMethod(); rm = new RefMethod(); rm.Title = "轨迹查看"; rm.ClassMethodName = this.ToString() + ".DoTrack"; // rm.Icon = "../../WF/Img/Track.png"; rm.Icon = "icon-graph"; // rm.IsForEns = true; rm.Visable = true; rm.RefMethodType = RefMethodType.RightFrameOpen; map.AddRefMethod(rm); rm = new RefMethod(); // rm.Icon = "../../WF/Img/Btn/Back.png"; rm.Icon = "icon-reload"; rm.Title = "回滚"; rm.ClassMethodName = this.ToString() + ".DoRollback"; rm.HisAttrs.AddDDLSQL("NodeID", "0", "回滚到节点", "SELECT NodeID+'' as No,Name FROM WF_Node WHERE FK_Flow='@FK_Flow'", true); rm.HisAttrs.AddTBString("Note", null, "回滚原因", true, false, 0, 100, 100); map.AddRefMethod(rm); //rm = new RefMethod(); ////rm.Icon = "../../WF/Img/Btn/CC.gif"; //rm.Icon = "icon-social-tumblr"; //rm.Title = "跳转"; //rm.IsForEns = false; //rm.ClassMethodName = this.ToString() + ".DoFlowSkip"; //rm.RefMethodType = RefMethodType.RightFrameOpen; //map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "轨迹修改"; rm.Icon = "icon-graph"; // rm.IsForEns = false; rm.ClassMethodName = this.ToString() + ".DoEditTrack"; rm.RefMethodType = RefMethodType.RightFrameOpen; map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "调整流程"; rm.Icon = "icon-target"; //rm.HisAttrs.AddTBString("RenYuan", null, "调整到人员", true, false, 0, 100, 100); //rm.HisAttrs.AddTBInt("shuzi", 0, "调整到节点", true, false); //rm.HisAttrs.AddDDLSQL("nodeID", "0", "调整到节点", // "SELECT NodeID as No,Name FROM WF_Node WHERE FK_Flow='@FK_Flow'", true); rm.ClassMethodName = this.ToString() + ".DoFlowReSend"; rm.RefMethodType = RefMethodType.RightFrameOpen; map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "调整数据"; rm.IsForEns = false; rm.Icon = "icon-target"; rm.ClassMethodName = this.ToString() + ".DoEditFrm"; rm.RefMethodType = RefMethodType.RightFrameOpen; map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "彻底删除"; rm.ClassMethodName = this.ToString() + ".DoDelete"; rm.Warning = "您确定要删除吗?包括该流程的所有数据。"; // rm.Icon = "../../WF/Img/Btn/Delete.gif"; rm.Icon = "icon-close"; rm.IsForEns = false; map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "逻辑删除"; rm.ClassMethodName = this.ToString() + ".DoDeleteFlag"; rm.HisAttrs.AddTBString("Note", null, "删除原因", true, false, 0, 100, 100); // rm.Warning = "您确定要删除吗?"; // rm.Icon = "../../WF/Img/Btn/Delete.gif"; rm.Icon = "icon-close"; rm.IsForEns = false; map.AddRefMethod(rm); rm = new RefMethod(); //rm.Icon = "../../WF/Img/Btn/CC.gif"; rm.Icon = "icon-wrench"; rm.Title = "修复数据"; // rm.Title = "修复该流程数据实例"; rm.IsForEns = false; rm.ClassMethodName = this.ToString() + ".RepairDataIt"; rm.RefMethodType = RefMethodType.Func; map.AddRefMethod(rm); rm = new RefMethod(); rm.Icon = "icon-key"; rm.Title = "移交"; rm.ClassMethodName = this.ToString() + ".DoFlowShift"; rm.RefMethodType = RefMethodType.RightFrameOpen; map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "催办"; rm.ClassMethodName = this.ToString() + ".DoPress"; rm.HisAttrs.AddTBString("Note", null, "催办信息", true, false, 0, 500, 200); // rm.Warning = "您确定要删除吗?"; // rm.Icon = "../../WF/Img/Btn/Delete.gif"; rm.IsForEns = false; map.AddRefMethod(rm); rm = new RefMethod(); rm.Icon = "icon-key"; rm.Title = "强制结束"; rm.Warning = "您确定要结束吗?"; rm.ClassMethodName = this.ToString() + ".DoFlowOver"; rm.HisAttrs.AddTBString("BeiZhu", null, "备注", true, false, 0, 100, 300); map.AddRefMethod(rm); this._enMap = map; return this._enMap; } } #endregion public string DoFlowOver(string msg) { BP.WF.Dev2Interface.Flow_DoFlowOver(this.WorkID, msg,0); return "执行成功."; } /// /// 修改表单 /// /// public string DoEditFrm() { Node nd = new Node(this.FK_Node); if (nd.FormType == NodeFormType.SelfForm || nd.FormType == NodeFormType.SDKForm || nd.FormType == NodeFormType.SheetAutoTree || nd.FormType == NodeFormType.SheetTree || nd.FormType == NodeFormType.WebOffice || nd.FormType == NodeFormType.WordForm) return "err@当前节点表单类型不同."; string frmID = nd.NodeFrmID; return "../../Admin/AttrFlow/AdminFrmList.htm?FK_Flow=" + this.FK_Flow + "&FrmID=" + frmID + "&WorkID=" + this.WorkID; } #region 执行功能. //,string isOK, int wfstate, string fk_emp public string DoFlowReSend() { return "../../WorkOpt/FlowOperation/ReSend.htm?WorkID=" + this.WorkID + "&FID=" + this.FID + "&FK_Flow=" + this.FK_Flow + "&FK_Node=" + this.FK_Node; } /// /// 修复数据 /// 1. 当前的节点的数据不小心丢失. /// 2. 从轨迹里把数据找到溯源到业务表里. /// /// public string RepairDataIt() { string infos = ""; Flow fl = new Flow(this.FK_Flow); Node nd = new Node(int.Parse(fl.No + "01")); Work wk = nd.HisWork; string trackTable = "ND" + int.Parse(fl.No) + "Track"; string sql = "SELECT MyPK FROM " + trackTable + " WHERE WorkID=" + this.WorkID + " AND ACTIONTYPE=1 and NDFrom=" + nd.NodeID; string mypk = DBAccess.RunSQLReturnString(sql); if (DataType.IsNullOrEmpty(mypk) == true) return "err@没有找到track主键。"; wk.OID = this.WorkID; wk.RetrieveFromDBSources(); string json = ""; try { json = DBAccess.GetBigTextFromDB(trackTable, "MyPK", mypk, "FrmDB"); } catch (Exception ex) { infos += "@ 错误:" + fl.No + " - Rec" + wk.Rec + " db=" + wk.OID; } if (DataType.IsNullOrEmpty(json) == true) return "没有保存历史数据不能修复"; DataTable dtVal = BP.Tools.Json.ToDataTable(json); DataRow mydr = dtVal.Rows[0]; Attrs attrs = wk.EnMap.Attrs; bool isHave = false; foreach (Attr attr in attrs) { string jsonVal = mydr[attr.Key].ToString(); string enVal = wk.GetValStringByKey(attr.Key); if (DataType.IsNullOrEmpty(enVal) == true) { wk.SetValByKey(attr.Key, jsonVal); isHave = true; } } if (isHave == true) { wk.DirectUpdate(); return "不需要更新数据."; } infos += "@WorkID=" + wk.OID + " =" + wk.Rec + " 被修复."; return infos; } public string RepairDataAll() { string infos = ""; Flows fls = new Flows(); fls.RetrieveAll(); foreach (Flow fl in fls) { string sql = "SELECT OID FROM " + fl.PTable + " WHERE BillNo IS NULL AND OID=" + this.WorkID; DataTable dt = DBAccess.RunSQLReturnTable(sql); Node nd = new Node(int.Parse(fl.No + "01")); Work wk = nd.HisWork; string trackTable = "ND" + int.Parse(fl.No) + "Track"; foreach (DataRow dr in dt.Rows) { Int64 workid = Int64.Parse(dr["OID"].ToString()); sql = "SELECT MyPK FROM " + trackTable + " WHERE WorkID=" + workid + " AND ACTIONTYPE=1 and NDFrom=" + nd.NodeID; string mypk = DBAccess.RunSQLReturnString(sql); if (DataType.IsNullOrEmpty(mypk) == true) continue; wk.OID = workid; wk.RetrieveFromDBSources(); string file = "c:/temp/" + mypk + ".txt"; try { DBAccess.GetFileFromDB(file, trackTable, "MyPK", mypk, "FrmDB"); } catch (Exception ex) { infos += "@ 错误:" + fl.No + " - Rec" + wk.Rec + " db=" + wk.OID + " - " + fl.Name; } string json = DataType.ReadTextFile(file); DataTable dtVal = BP.Tools.Json.ToDataTable(json); DataRow mydr = dtVal.Rows[0]; Attrs attrs = wk.EnMap.Attrs; bool isHave = false; foreach (Attr attr in attrs) { string jsonVal = mydr[attr.Key].ToString(); string enVal = wk.GetValStringByKey(attr.Key); if (DataType.IsNullOrEmpty(enVal) == true) { wk.SetValByKey(attr.Key, jsonVal); isHave = true; } } if (isHave == true) { wk.DirectUpdate(); continue; } infos += "@WorkID=" + wk.OID + " =" + wk.Rec + " 被修复."; } } return infos; } /// /// 回滚 /// /// 节点ID /// 回滚原因 /// 回滚的结果 public string DoRollback(string nodeID, string note) { try { return BP.WF.Dev2Interface.Flow_DoRebackWorkFlow(this.FK_Flow, this.WorkID, int.Parse(nodeID), note); } catch (Exception ex) { return "err@" + ex.Message; } } /// /// 修改轨迹 /// /// public string DoEditTrack() { return "../../Admin/AttrFlow/EditTrack.htm?WorkID=" + this.WorkID + "&FID=" + this.FID + "&FK_Flow=" + this.FK_Flow; } /// /// /// /// public string DoTrack() { return "../../WFRpt.htm?WorkID=" + this.WorkID + "&FID=" + this.FID + "&FK_Flow=" + this.FK_Flow; } /// /// 执行移交 /// /// /// /// public string DoShift(string ToEmp, string Note) { if (BP.WF.Dev2Interface.Flow_IsCanViewTruck(this.FK_Flow, this.WorkID) == false) return "您没有操作该流程数据的权限."; try { BP.WF.Dev2Interface.Node_Shift(this.WorkID, ToEmp, Note); return "移交成功"; } catch (Exception ex) { return "移交失败@" + ex.Message; } } /// /// 催办 /// /// public string DoPress(string msg) { try { string doPressMsg = BP.WF.Dev2Interface.Flow_DoPress(this.WorkID, msg, true); return doPressMsg; } catch (Exception ex) { return "催办失败@" + ex.Message; } } /// /// 逻辑删除 /// /// public string DoDeleteFlag(string msg) { if (BP.WF.Dev2Interface.Flow_IsCanViewTruck(this.FK_Flow, this.WorkID) == false) return "您没有操作该流程数据的权限."; try { BP.WF.Dev2Interface.Flow_DoDeleteFlowByFlag(this.WorkID, msg, true); return "删除成功"; } catch (Exception ex) { return "删除失败@" + ex.Message; } } /// /// 执行删除 /// /// public string DoDelete() { if (BP.WF.Dev2Interface.Flow_IsCanViewTruck(this.FK_Flow, this.WorkID) == false) return "您没有操作该流程数据的权限."; try { BP.WF.Dev2Interface.Flow_DoDeleteFlowByReal(this.WorkID, true); return "删除成功"; } catch (Exception ex) { return "删除失败@" + ex.Message; } } /// /// 移交 /// /// public string DoFlowShift() { return "../../WorkOpt/Shift.htm?WorkID=" + this.WorkID + "&FID=" + this.FID + "&FK_Flow=" + this.FK_Flow + "&FK_Node=" + this.FK_Node; } /// /// 回滚流程 /// /// public string Rollback() { return "../../WorkOpt/Rollback.htm?WorkID=" + this.WorkID + "&FID=" + this.FID + "&FK_Flow=" + this.FK_Flow + "&FK_Node=" + this.FK_Node; } /// /// 执行跳转 /// /// public string DoFlowSkip() { return "../../WorkOpt/FlowSkip.htm?WorkID=" + this.WorkID + "&FID=" + this.FID + "&FK_Flow=" + this.FK_Flow + "&FK_Node=" + this.FK_Node; } #endregion } /// /// 流程实例s /// public class GenerWorkFlowExts : Entities { #region 方法 /// /// 得到它的 Entity /// public override Entity GetNewEntity { get { return new GenerWorkFlowView(); } } /// /// 流程实例集合 /// public GenerWorkFlowExts() { } #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((GenerWorkFlowView)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成List. } }