using System; using System.Data; using BP.DA; using BP.WF; using BP.Port; using BP.Sys; using BP.En; using BP.WF.Template; namespace BP.WF { /// /// 流程实例 /// public class GenerWorkFlowAttr:EntityNoNameAttr { #region 基本属性 /// /// 工作ID /// public const string WorkID = "WorkID"; /// /// 工作流 /// public const string FK_Flow = "FK_Flow"; /// /// 流程状态 /// public const string WFState = "WFState"; /// /// 流程状态 /// public const string WFSta = "WFSta"; /// /// 标题 /// public const string Title = "Title"; /// /// 发起人 /// public const string Starter = "Starter"; /// /// 产生时间 /// public const string RDT = "RDT"; /// /// 完成时间 /// public const string CDT = "CDT"; /// /// 挂起时间 /// public const string HungupTime = "HungupTime"; /// /// 得分 /// public const string Cent = "Cent"; /// /// 当前工作到的节点. /// public const string FK_Node = "FK_Node"; /// /// 当前工作角色 /// public const string FK_Station = "FK_Station"; /// /// 部门 /// public const string FK_Dept = "FK_Dept"; /// /// 流程ID /// public const string FID = "FID"; /// /// 是否启用 /// public const string IsEnable = "IsEnable"; /// /// 流程名称 /// public const string FlowName = "FlowName"; /// /// 发起人名称 /// public const string StarterName = "StarterName"; /// /// 节点名称 /// public const string NodeName = "NodeName"; /// /// 部门名称 /// public const string DeptName = "DeptName"; /// /// 流程类别 /// public const string FK_FlowSort = "FK_FlowSort"; /// /// 系统类别 /// public const string SysType = "SysType"; /// /// 优先级 /// public const string PRI = "PRI"; /// /// 流程应完成时间 /// public const string SDTOfFlow = "SDTOfFlow"; /// /// 流程预警时间 /// public const string SDTOfFlowWarning = "SDTOfFlowWarning"; /// /// 节点应完成时间 /// public const string SDTOfNode = "SDTOfNode"; /// /// 父流程ID /// public const string PWorkID = "PWorkID"; /// /// 父亲流程的FID /// public const string PFID = "PFID"; /// /// 父流程编号 /// public const string PFlowNo = "PFlowNo"; /// /// 父流程节点 /// public const string PNodeID = "PNodeID"; /// /// 子流程的调用人. /// public const string PEmp = "PEmp"; /// /// 客户编号(对于客户发起的流程有效) /// public const string GuestNo = "GuestNo"; /// /// 客户名称 /// public const string GuestName = "GuestName"; /// /// 单据编号 /// public const string BillNo = "BillNo"; /// /// 待办人员 /// public const string TodoEmps = "TodoEmps"; /// /// 待办人员数量 /// public const string TodoEmpsNum = "TodoEmpsNum"; /// /// 任务状态 /// public const string TaskSta = "TaskSta"; /// /// 临时存放的参数 /// public const string AtPara = "AtPara"; /// /// 参与人 /// public const string Emps = "Emps"; /// /// GUID /// public const string GUID = "GUID"; public const string FK_NY = "FK_NY"; /// /// 周次 /// public const string WeekNum = "WeekNum"; /// /// 发送人 /// public const string Sender = "Sender"; /// /// 发送日期 /// public const string SendDT = "SendDT"; /// /// 时间范围 /// public const string TSpan = "TSpan"; /// /// 待办状态(0=待办中,1=预警中,2=逾期中,3=按期完成,4=逾期完成) /// public const string TodoSta = "TodoSta"; /// /// 会签状态 /// public const string HuiQianTaskSta = "HuiQianTaskSta"; /// /// 域/系统编号 /// public const string Domain = "Domain"; public const string PrjNo = "PrjNo"; public const string PrjName = "PrjName"; public const string OrgNo = "OrgNo"; public const string FlowNote = "FlowNote"; /// /// 耗时 /// public const string LostTimeHH = "LostTimeHH"; #endregion } /// /// 流程实例 /// public class GenerWorkFlow : Entity { #region 基本属性 /// /// 主键 /// public override string PK { get { return GenerWorkFlowAttr.WorkID; } } public string OrgNo { get { return this.GetValStrByKey(GenerWorkFlowAttr.OrgNo); } set { SetValByKey(GenerWorkFlowAttr.OrgNo, value); } } /// /// 所在的域 /// public string Domain { get { return this.GetValStrByKey(GenerWorkFlowAttr.Domain); } set { SetValByKey(GenerWorkFlowAttr.Domain, value); } } public string BuessFields { get { return this.GetParaString("BuessFields"); } set { this.SetPara("BuessFields", 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 Sender { get { return this.GetValStrByKey(GenerWorkFlowAttr.Sender); } set { //检查数据正确性. if (DataType.IsNullOrEmpty(value) == true) throw new Exception("err@设置的人员不能为空."); if (value.Contains(";") == false) value = value + ";"; //检查数据正确性. if (value.Contains(",") == false || value.Contains(";") == false) throw new Exception("err@设置的Sender人员格式不正确,请联系管理员,格式为:No,Name; 您设置的值为:" + value); //发送人. this.SetValByKey(GenerWorkFlowAttr.Sender, value); //当前日期. this.SetValByKey(GenerWorkFlowAttr.SendDT, DataType.CurrentDateTime); } } /// /// 发送日期 /// public string SendDT { get { return this.GetValStrByKey(GenerWorkFlowAttr.SendDT); } set { SetValByKey(GenerWorkFlowAttr.SendDT, 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 { string str = value; str = str.Replace(" ", ""); //TodoEmps在会签完去掉人员此判断去不掉,暂时注释掉 //string val = this.GetValStrByKey(GenerWorkFlowAttr.TodoEmps); //if (val.Contains(str) == true) // return; SetValByKey(GenerWorkFlowAttr.TodoEmps, str); } } /// /// 参与人 /// public string Emps { get { return this.GetValStrByKey(GenerWorkFlowAttr.Emps); } set { this.SetValByKey(GenerWorkFlowAttr.Emps, value); } } /// /// 会签状态 /// public HuiQianTaskSta HuiQianTaskSta { get { //如果有方向信息,并且方向不包含到达的节点. if (this.HuiQianSendToNodeIDStr.Length > 3 && this.HuiQianSendToNodeIDStr.Contains(this.FK_Node + ",") == false) return WF.HuiQianTaskSta.None; return (HuiQianTaskSta)this.GetParaInt(GenerWorkFlowAttr.HuiQianTaskSta, 0); } set { SetPara(GenerWorkFlowAttr.HuiQianTaskSta, (int)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 SysType { get { return this.GetValStrByKey(GenerWorkFlowAttr.SysType); } set { SetValByKey(GenerWorkFlowAttr.SysType, 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 FK_NY { get { return this.GetValStrByKey(GenerWorkFlowAttr.FK_NY); } set { SetValByKey(GenerWorkFlowAttr.FK_NY, value); } } /// /// 实际开始时间 /// public string RDT { get { //string rdt = this.GetParaString(""); return this.GetValStrByKey(GenerWorkFlowAttr.RDT); } set { this.SetValByKey(GenerWorkFlowAttr.RDT, value); this.FK_NY = value.Substring(0, 7); } } public string HungupTime { get { return this.GetValStrByKey(GenerWorkFlowAttr.HungupTime); } set { this.SetValByKey(GenerWorkFlowAttr.HungupTime, value); } } /// /// 计划开始时间 /// SDTOfFlow 就是计划完成日期. /// public string RDTOfSetting { get { string str = this.GetParaString("RDTOfSetting"); if (DataType.IsNullOrEmpty(str) == true) return this.RDT; return str; } set { this.SetPara("RDTOfSetting", value); } } /// /// 节点应完成时间 /// public string SDTOfNode { get { return this.GetValStrByKey(GenerWorkFlowAttr.SDTOfNode); } set { SetValByKey(GenerWorkFlowAttr.SDTOfNode, value); } } /// /// 流程应完成时间 /// RDTOfSetting 是计划开始日期,如果为空就是发起日期. /// public string SDTOfFlow { get { return this.GetValStrByKey(GenerWorkFlowAttr.SDTOfFlow); } set { SetValByKey(GenerWorkFlowAttr.SDTOfFlow, value); } } /// /// 流程预警时间时间 /// public string SDTOfFlowWarning { get { return this.GetValStrByKey(GenerWorkFlowAttr.SDTOfFlowWarning); } set { SetValByKey(GenerWorkFlowAttr.SDTOfFlowWarning, 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 Int64 PFID { get { return this.GetValInt64ByKey(GenerWorkFlowAttr.PFID); } set { SetValByKey(GenerWorkFlowAttr.PFID, 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 PrjNo { get { return this.GetValStrByKey(GenerWorkFlowAttr.PrjNo); } set { SetValByKey(GenerWorkFlowAttr.PrjNo, value); } } /// /// 项目名称 /// public string PrjName { get { return this.GetValStrByKey(GenerWorkFlowAttr.PrjName); } set { SetValByKey(GenerWorkFlowAttr.PrjName, 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); //设置耗时. @hongyan. TimeSpan ts = DateTime.Now - this.GetValDate(this.RDT); this.SetValByKey(GenerWorkFlowAttr.LostTimeHH, ts.TotalHours.ToString("0.00")); } } /// /// 工作流程状态 /// 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 || value == WF.WFState.Blank) SetValByKey(GenerWorkFlowAttr.WFSta, (int)WFSta.Etc); else SetValByKey(GenerWorkFlowAttr.WFSta, (int)WFSta.Runing); SetValByKey(GenerWorkFlowAttr.WFState, (int)value); //设置耗时. @hongyan. TimeSpan ts = DateTime.Now - this.GetValDate(this.RDT); this.SetValByKey(GenerWorkFlowAttr.LostTimeHH, ts.TotalHours.ToString("0.00")); } } /// /// 状态(简单) /// public WFSta WFSta { get { return (WFSta)this.GetValIntByKey(GenerWorkFlowAttr.WFSta); } } /// /// 是否可以批处理? /// public bool IsCanBatch { get { return this.GetParaBoolen("IsCanBatch"); } set { this.SetPara("IsCanBatch", 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.Draft: return "草稿"; case WF.WFState.ReturnSta: return "退回"; default: return "其他" + ws.ToString(); } } } /// /// GUID /// public string GUID { get { return this.GetValStrByKey(GenerWorkFlowAttr.GUID); } set { SetValByKey(GenerWorkFlowAttr.GUID, value); } } #endregion #region 扩展属性 /// /// 它的子流程 /// public GenerWorkFlows HisSubFlowGenerWorkFlows { get { GenerWorkFlows ens = new GenerWorkFlows(); ens.Retrieve(GenerWorkFlowAttr.PWorkID, this.WorkID); return ens; } } /// /// 0=待办中,1=预警中,2=逾期中,3=按期完成,4=逾期完成 /// public int TodoSta { get { return this.GetValIntByKey(GenerWorkFlowAttr.TodoSta); } } #endregion 扩展属性 #region 参数属性. /// /// 是否是流程模版? /// public bool Paras_DBTemplate { get { return this.GetParaBoolen("DBTemplate"); } set { this.SetPara("DBTemplate", value); } } /// /// 模版名称 /// public string Paras_DBTemplateName { get { return this.GetParaString("DBTemplateName"); } set { this.SetPara("DBTemplateName", value); } } /// /// 选择的表单(用于子流程列表里,打开草稿,记录当初选择的表单.) /// public string Paras_Frms { get { return this.GetParaString("Frms"); } set { this.SetPara("Frms", value); } } /// /// 到达的节点 /// public string Paras_ToNodes { get { return this.GetParaString("ToNodes"); } set { this.SetPara("ToNodes", value); } } /// /// 关注&取消关注 /// public bool Paras_Focus { get { return this.GetParaBoolen("F_" + BP.Web.WebUser.No, false); } set { this.SetPara("F_" + BP.Web.WebUser.No, value); } } /// /// 确认与取消确认 /// public bool Paras_Confirm { get { return this.GetParaBoolen("C_" + BP.Web.WebUser.No, false); } set { this.SetPara("C_" + BP.Web.WebUser.No, value); } } /// /// 最后一个执行发送动作的ID. /// public string Paras_LastSendTruckID { get { string str = this.GetParaString("LastTruckID"); if (str == "") str = this.WorkID.ToString(); return str; } set { this.SetPara("LastTruckID", value); } } /// /// 加签信息 /// public string Paras_AskForReply { get { return this.GetParaString("AskForReply"); } set { this.SetPara("AskForReply", value); } } /// /// 是否是退回并原路返回. /// public bool Paras_IsTrackBack { get { return this.GetParaBoolen("IsTrackBack"); } set { this.SetPara("IsTrackBack", value); } } /// /// 分组Mark /// public string Paras_GroupMark { get { return this.GetParaString(GenerWorkerListAttr.GroupMark); } set { this.SetPara(GenerWorkerListAttr.GroupMark, value); } } /// /// 是否是自动运行 /// 0=自动运行(默认,无需人工干涉). 1=手工运行(按照手工设置的模式运行,人工干涉模式). /// 用于自由流程中. /// public TransferCustomType TransferCustomType { get { return (TransferCustomType)this.GetParaInt("IsAutoRun"); } set { this.SetPara("IsAutoRun", (int)value); } } /// /// 多人待办处理模式 /// public TodolistModel TodolistModel { get { return (TodolistModel)this.GetParaInt("TodolistModel"); } set { this.SetPara("TodolistModel", (int)value); } } /// /// 会签到达人员 /// public string HuiQianSendToEmps { get { return this.GetParaString("HuiQianSendToEmps"); } set { this.SetPara("HuiQianSendToEmps", value); } } /// /// 会签到达节点: 101@102 /// public string HuiQianSendToNodeIDStr { get { return this.GetParaString("HuiQianSendToNodeID"); } set { this.SetPara("HuiQianSendToNodeID", value); } } /// /// 会签主持人 /// public string HuiQianZhuChiRen { get { return this.GetParaString("HuiQianZhuChiRen"); } set { this.SetPara("HuiQianZhuChiRen", value); } } /// /// 会签主持人名称 /// public string HuiQianZhuChiRenName { get { return this.GetParaString("HuiQianZhuChiRenName"); } set { this.SetPara("HuiQianZhuChiRenName", value); } } public int ScripNodeID { get { return this.GetParaInt("ScripNodeID"); } set { this.SetPara("ScripNodeID", value); } } public string ScripMsg { set { this.SetPara("ScripMsg", value); } } #endregion 参数属性. #region 构造函数 /// /// 产生的工作流程 /// public GenerWorkFlow() { } /// /// 按照WorkID查询. /// /// public GenerWorkFlow(Int64 workId) { //this.WorkID = workId //this.Retrieve(); if (workId == 0) throw new Exception("工作 GenerWorkFlow 查询参数错误,WorkID不能为 0 ."); QueryObject qo = new QueryObject(this); qo.AddWhere(GenerWorkFlowAttr.WorkID, workId); if (qo.DoQuery() == 0) throw new Exception("工作 GenerWorkFlow [" + workId + "]不存在。"); } /// /// 按照GUID查询. /// /// public GenerWorkFlow(string guid) { QueryObject qo = new QueryObject(this); qo.AddWhere(GenerWorkFlowAttr.GUID, guid); if (qo.DoQuery() == 0) throw new Exception("工作 GenerWorkFlow [" + guid + "]不存在。"); } /// /// 重写基类方法 /// public override Map EnMap { get { if (this._enMap != null) return this._enMap; Map map = new Map("WF_GenerWorkFlow", "流程实例"); map.AddTBIntPK(GenerWorkFlowAttr.WorkID, 0, "WorkID", true, true); //主键. map.AddTBInt(GenerWorkFlowAttr.FID, 0, "流程ID", true, true); map.AddTBString(GenerWorkFlowAttr.FK_FlowSort, null, "流程类别", true, false, 0, 10, 10); //等于流程类别的Domain字段值. map.AddTBString(GenerWorkFlowAttr.SysType, null, "系统类别", true, false, 0, 10, 10); map.AddTBString(GenerWorkFlowAttr.FK_Flow, null, "流程", true, false, 0, 5, 10); map.AddTBString(GenerWorkFlowAttr.FlowName, null, "流程名称", true, false, 0, 100, 10); map.AddTBString(GenerWorkFlowAttr.Title, null, "标题", true, false, 0, 300, 10); //两个状态,在不同的情况下使用. WFState状态 可以查询到SELECT * FROM Sys_Enum WHERE EnumKey='WFState' // WFState 的状态 @0=空白@1=草稿@2=运行中@3=已经完成@4=挂起@5=退回. map.AddTBInt(GenerWorkFlowAttr.WFSta, 0, "状态", true, false); map.AddTBInt(GenerWorkFlowAttr.WFState, 0, "状态", true, false); // map.AddDDLSysEnum(GenerWorkFlowAttr.WFSta, 0, "状态", true, false, GenerWorkFlowAttr.WFSta, "@0=运行中@1=已完成@2=其他"); // map.AddDDLSysEnum(GenerWorkFlowAttr.WFState, 0, "流程状态", true, false, GenerWorkFlowAttr.WFState); map.AddTBString(GenerWorkFlowAttr.Starter, null, "发起人", true, false, 0, 200, 10); map.AddTBString(GenerWorkFlowAttr.StarterName, null, "发起人名称", true, false, 0, 200, 10); map.AddTBString(GenerWorkFlowAttr.Sender, null, "发送人", true, false, 0, 200, 10); map.AddTBDateTime(GenerWorkFlowAttr.RDT, "记录日期", true, true); map.AddTBString(GenerWorkFlowAttr.HungupTime, null, "挂起日期", true, false, 0, 50, 10); map.AddTBDateTime(GenerWorkFlowAttr.SendDT, "流程活动时间", true, true); map.AddTBInt(GenerWorkFlowAttr.FK_Node, 0, "节点", true, false); map.AddTBString(GenerWorkFlowAttr.NodeName, null, "节点名称", true, false, 0, 100, 10); map.AddTBString(GenerWorkFlowAttr.FK_Dept, null, "部门", true, false, 0, 100, 10); map.AddTBString(GenerWorkFlowAttr.DeptName, null, "部门名称", true, false, 0, 100, 10); map.AddTBInt(GenerWorkFlowAttr.PRI, 1, "优先级", true, true); map.AddTBDateTime(GenerWorkFlowAttr.SDTOfNode, "节点应完成时间", true, true); map.AddTBDateTime(GenerWorkFlowAttr.SDTOfFlow, null, "流程应完成时间", true, true); map.AddTBDateTime(GenerWorkFlowAttr.SDTOfFlowWarning, null, "流程预警时间", true, true); //父子流程信息. map.AddTBString(GenerWorkFlowAttr.PFlowNo, null, "父流程编号", true, false, 0, 100, 10); map.AddTBInt(GenerWorkFlowAttr.PWorkID, 0, "父流程ID", true, true); map.AddTBInt(GenerWorkFlowAttr.PNodeID, 0, "父流程调用节点", true, true); map.AddTBInt(GenerWorkFlowAttr.PFID, 0, "父流程调用的PFID", true, true); map.AddTBString(GenerWorkFlowAttr.PEmp, null, "子流程的调用人", true, false, 0, 100, 10); //客户流程信息. map.AddTBString(GenerWorkFlowAttr.GuestNo, null, "客户编号", true, false, 0, 100, 10); map.AddTBString(GenerWorkFlowAttr.GuestName, null, "客户名称", true, false, 0, 100, 10); map.AddTBString(GenerWorkFlowAttr.BillNo, null, "单据编号", true, false, 0, 100, 10); //任务池相关。 map.AddTBString(GenerWorkFlowAttr.TodoEmps, null, "待办人员", true, false, 0, 4000, 10); map.AddTBInt(GenerWorkFlowAttr.TodoEmpsNum, 0, "待办人员数量", true, true); map.AddTBInt(GenerWorkFlowAttr.TaskSta, 0, "共享状态", true, true); //参数. (流程运行设置临时存储的参数) map.AddTBString(GenerWorkFlowAttr.AtPara, null, "参数", true, false, 0, 2000, 10); //(格式:@zhangshan,张三@lishi,李四) map.AddTBString(GenerWorkFlowAttr.Emps, null, "参与人", true, false, 0, 4000, 10); map.AddTBString(GenerWorkFlowAttr.GUID, null, "GUID", false, false, 0, 36, 10); map.AddTBString(GenerWorkFlowAttr.FK_NY, null, "年月", false, false, 0, 7, 7); map.AddTBInt(GenerWorkFlowAttr.WeekNum, 0, "周次", true, true); map.AddTBInt(GenerWorkFlowAttr.TSpan, 0, "时间间隔", true, true); //待办状态(0=待办中,1=预警中,2=逾期中,3=按期完成,4=逾期完成) map.AddTBInt(GenerWorkFlowAttr.TodoSta, 0, "待办状态", true, true); map.AddTBString(GenerWorkFlowAttr.Domain, null, "域/系统编号", true, false, 0, 100, 30); //map.SetHelperAlert(GenerWorkFlowAttr.Domain, "用于区分不同系统的流程,比如:一个集团有多个子系统每个子系统都有自己的流程,就需要标记那些流程是那个子系统的."); map.AddTBString(GenerWorkFlowAttr.PrjNo, null, "PrjNo", true, false, 0, 100, 10); map.AddTBString(GenerWorkFlowAttr.PrjName, null, "PrjNo", true, false, 0, 100, 10); //隶属组织. map.AddTBString(GenerWorkFlowAttr.OrgNo, null, "OrgNo", true, false, 0, 50, 10); // 审核组件,签批组件最后一个人的意见填写到这里. map.AddTBString(GenerWorkFlowAttr.FlowNote, null, "流程备注", true, false, 0, 500, 200); // map.AddTBString(GenerWorkFlowAttr.LostTimeHH, null, "流程备注", true, false, 0, 500, 200); // map.AddTBFloat(GenerWorkFlowAttr.LostTimeHH, 0, "耗时", true, true); RefMethod rm = new RefMethod(); rm.Title = "工作轨迹"; // "工作报告"; rm.ClassMethodName = this.ToString() + ".DoRpt"; rm.Icon = "../../WF/Img/FileType/doc.gif"; map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "流程自检"; // "流程自检"; rm.ClassMethodName = this.ToString() + ".DoSelfTestInfo"; map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "流程自检并修复"; rm.ClassMethodName = this.ToString() + ".DoRepare"; rm.Warning = "您确定要执行此功能吗? \t\n 1)如果是断流程,并且停留在第一个节点上,系统为执行删除它。\t\n 2)如果是非地第一个节点,系统会返回到上次发起的位置。"; map.AddRefMethod(rm); this._enMap = map; return this._enMap; } } #endregion #region 重载基类方法 /// /// 删除后,需要把工作者列表也要删除. /// protected override void afterDelete() { switch (BP.Difference.SystemConfig.AppCenterDBType) { case DBType.MSSQL: case DBType.Oracle: case DBType.KingBaseR3: case DBType.KingBaseR6: DBAccess.RunSQL("DELETE FROM WF_GenerWorkerlist WHERE WorkID in ( select WorkID from WF_GenerWorkerlist WHERE WorkID not in (select WorkID from WF_GenerWorkFlow) )"); break; case DBType.MySQL: DBAccess.RunSQL("DELETE A FROM WF_GenerWorkerlist A, WF_GenerWorkerlist B WHERE A.WorkID = B.WorkID And B.WorkID Not IN(select WorkID from WF_GenerWorkFlow)"); break; case DBType.PostgreSQL: case DBType.UX: DBAccess.RunSQL("DELETE FROM WF_GenerWorkerlist A USING WF_GenerWorkerlist B WHERE A.WorkID = B.WorkID And B.WorkID Not IN(select WorkID from WF_GenerWorkFlow)"); break; default: break; } WorkFlow wf = new WorkFlow(new Flow(this.FK_Flow), this.WorkID, this.FID); wf.DoDeleteWorkFlowByReal(true); /* 删除下面的工作。*/ base.afterDelete(); } protected override bool beforeInsert() { if (this.Starter == "Guest") { this.StarterName = BP.Web.GuestUser.Name; this.GuestName = this.StarterName; this.GuestNo = BP.Web.GuestUser.No; } //加入组织no. if (Glo.CCBPMRunModel != CCBPMRunModel.Single) this.OrgNo = BP.Web.WebUser.OrgNo; //生成GUID. this.GUID = BP.DA.DBAccess.GenerGUID(); return base.beforeInsert(); } #endregion #region 执行诊断 /// /// 生成父子流程的甘特图 /// /// public string GenerGantt() { return BP.WF.Glo.GenerGanttDataOfSubFlows(this.WorkID); } /// /// 终止流程 /// /// 终止的信息 /// 终止结果 public string DoFix(string msg) { return BP.WF.Dev2Interface.Flow_DoFix(this.WorkID, true, msg); } public string DoRpt() { return "WFRpt.htm?WorkID=" + this.WorkID + "&FID=" + this.FID + "&FK_Flow=" + this.FK_Flow; } /// /// 增加子线程 /// /// 要增加的人员多个用都好分开. /// public string DoSubFlowAddEmps(string empStrs,int toNodeID) { //获得当前的干流程的gwf. long workID = this.FID; if (workID == 0) workID = this.WorkID; return BP.WF.Dev2Interface.Node_FHL_AddSubThread(workID, empStrs, toNodeID); } /// /// 执行修复 /// /// public string DoRepare() { if (this.DoSelfTestInfo() == "没有发现异常。") return "没有发现异常。"; string sql = "SELECT FK_Node FROM WF_GenerWorkerlist WHERE WORKID='" + this.WorkID + "' ORDER BY FK_Node desc"; DataTable dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { /*如果是开始工作节点,就删除它。*/ WorkFlow wf = new WorkFlow(new Flow(this.FK_Flow), this.WorkID, this.FID); wf.DoDeleteWorkFlowByReal(true); return "此流程是因为发起工作失败被系统删除。"; } int FK_Node = int.Parse(dt.Rows[0][0].ToString()); Node nd = new Node(FK_Node); if (nd.IsStartNode) { /*如果是开始工作节点,就删除它。*/ WorkFlow wf = new WorkFlow(new Flow(this.FK_Flow), this.WorkID, this.FID); wf.DoDeleteWorkFlowByReal(true); return "此流程是因为发起工作失败被系统删除。"; } this.FK_Node = nd.NodeID; this.NodeName = nd.Name; this.Update(); string str = ""; GenerWorkerLists wls = new GenerWorkerLists(); wls.Retrieve(GenerWorkerListAttr.FK_Node, FK_Node, GenerWorkerListAttr.WorkID, this.WorkID); foreach (GenerWorkerList wl in wls) { str += wl.FK_Emp + wl.FK_EmpText + ","; } return "此流程是因为[" + nd.Name + "]工作发送失败被回滚到当前位置,请转告[" + str + "]流程修复成功。"; } public string DoSelfTestInfo() { GenerWorkerLists wls = new GenerWorkerLists(this.WorkID, this.FK_Flow); #region 查看一下当前的节点是否开始工作节点。 Node nd = new Node(this.FK_Node); if (nd.IsStartNode) { /* 判断是否是退回的节点 */ Work wk = nd.HisWork; wk.OID = this.WorkID; wk.Retrieve(); } #endregion #region 查看一下是否有当前的工作节点信息。 bool isHave = false; foreach (GenerWorkerList wl in wls) { if (wl.FK_Node == this.FK_Node) isHave = true; } if (isHave == false) { /* */ return "已经不存在当前的工作节点信息,造成此流程的原因可能是没有捕获的系统异常,建议删除此流程或者交给系统自动修复它。"; } #endregion return "没有发现异常。"; } #endregion } /// /// 流程实例s /// public class GenerWorkFlows : Entities { /// /// 根据工作流程,工作人员 ID 查询出来他当前的能做的工作. /// /// 流程编号 /// 工作人员ID /// public static DataTable QuByFlowAndEmp(string flowNo, int empId) { string sql = "SELECT a.WorkID FROM WF_GenerWorkFlow a, WF_GenerWorkerlist b WHERE a.WorkID=b.WorkID AND b.FK_Node=a.FK_Node AND b.FK_Emp='" + empId.ToString() + "' AND a.FK_Flow='" + flowNo + "'"; return DBAccess.RunSQLReturnTable(sql); } /// /// 根据流程编号,标题模糊查询 /// /// /// /// public string QueryByLike(string flowNo, string likeKey) { QueryObject qo = new QueryObject(this); qo.AddWhere("FK_Flow", flowNo); if (DataType.IsNullOrEmpty(likeKey) == false) { qo.addAnd(); if (BP.Difference.SystemConfig.AppCenterDBVarStr == "@" || BP.Difference.SystemConfig.AppCenterDBVarStr == "?") qo.AddWhere("Title", " LIKE ", BP.Difference.SystemConfig.AppCenterDBType == DBType.MySQL ? (" CONCAT('%'," + BP.Difference.SystemConfig.AppCenterDBVarStr + "Title" + ",'%')") : (" '%'+" + BP.Difference.SystemConfig.AppCenterDBVarStr + "Title" + "+'%'")); else qo.AddWhere("Title", " LIKE ", " '%'||" + BP.Difference.SystemConfig.AppCenterDBVarStr + "Title" + "||'%'"); qo.MyParas.Add("Title", likeKey); } qo.addOrderBy("WorkID"); qo.DoQuery(); return BP.Tools.Json.ToJson(this.ToDataTableField("WF_GenerWorkFlow")); } #region 方法 /// /// 得到它的 Entity /// public override Entity GetNewEntity { get { return new GenerWorkFlow(); } } /// /// 流程实例集合 /// public GenerWorkFlows() { } #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((BP.WF.GenerWorkFlow)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成List. } }