using System;
using System.Data;
using BP.DA;
using BP.WF;
using BP.Port;
using BP.Sys;
using BP.En;
namespace BP.Cloud
{
///
/// 流程管理
///
public class GWFAdminAttr
{
#region 基本属性
///
/// 工作ID
///
public const string WorkID = "WorkID";
///
/// 工作流
///
public const string FK_Flow = "FK_Flow";
///
/// 流程状态
///
public const string WFState = "WFState";
///
/// 流程状态(简单)
///
public const string WFSta = "WFSta";
///
/// TSpan
///
public const string TSpan = "TSpan";
///
/// 标题
///
public const string Title = "Title";
///
/// 发起人
///
public const string Starter = "Starter";
///
/// 产生时间
///
public const string RDT = "RDT";
///
/// 完成时间
///
public const string CDT = "CDT";
///
/// 得分
///
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 PRI = "PRI";
///
/// 流程应完成时间
///
public const string SDTOfFlow = "SDTOfFlow";
///
/// 节点应完成时间
///
public const string SDTOfNode = "SDTOfNode";
///
/// 父流程ID
///
public const string PWorkID = "PWorkID";
///
/// 父流程编号
///
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 FlowNote = "FlowNote";
///
/// 待办人员
///
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 OrgNo = "OrgNo";
#endregion
}
///
/// 流程管理
///
public class GWFAdmin : Entity
{
#region 基本属性
public override UAC HisUAC
{
get
{
UAC uac = new UAC();
uac.Readonly();
uac.IsExp = UserRegedit.HaveRoleForExp(this.ToString());
return uac;
}
}
///
/// 主键
///
public override string PK
{
get
{
return GWFAdminAttr.WorkID;
}
}
///
/// 备注
///
public string FlowNote
{
get
{
return this.GetValStrByKey(GWFAdminAttr.FlowNote);
}
set
{
SetValByKey(GWFAdminAttr.FlowNote, value);
}
}
///
/// 工作流程编号
///
public string FK_Flow
{
get
{
return this.GetValStrByKey(GWFAdminAttr.FK_Flow);
}
set
{
SetValByKey(GWFAdminAttr.FK_Flow, value);
}
}
///
/// BillNo
///
public string BillNo
{
get
{
return this.GetValStrByKey(GWFAdminAttr.BillNo);
}
set
{
SetValByKey(GWFAdminAttr.BillNo, value);
}
}
///
/// 流程名称
///
public string FlowName
{
get
{
return this.GetValStrByKey(GWFAdminAttr.FlowName);
}
set
{
SetValByKey(GWFAdminAttr.FlowName, value);
}
}
///
/// 优先级
///
public int PRI
{
get
{
return this.GetValIntByKey(GWFAdminAttr.PRI);
}
set
{
SetValByKey(GWFAdminAttr.PRI, value);
}
}
///
/// 待办人员数量
///
public int TodoEmpsNum
{
get
{
return this.GetValIntByKey(GWFAdminAttr.TodoEmpsNum);
}
set
{
SetValByKey(GWFAdminAttr.TodoEmpsNum, value);
}
}
///
/// 待办人员列表
///
public string TodoEmps
{
get
{
return this.GetValStrByKey(GWFAdminAttr.TodoEmps);
}
set
{
SetValByKey(GWFAdminAttr.TodoEmps, value);
}
}
///
/// 参与人
///
public string Emps
{
get
{
return this.GetValStrByKey(GWFAdminAttr.Emps);
}
set
{
SetValByKey(GWFAdminAttr.Emps, value);
}
}
///
/// 状态
///
public TaskSta TaskSta
{
get
{
return (TaskSta)this.GetValIntByKey(GWFAdminAttr.TaskSta);
}
set
{
SetValByKey(GWFAdminAttr.TaskSta, (int)value);
}
}
///
/// 类别编号
///
public string FK_FlowSort
{
get
{
return this.GetValStrByKey(GWFAdminAttr.FK_FlowSort);
}
set
{
SetValByKey(GWFAdminAttr.FK_FlowSort, value);
}
}
///
/// 部门编号
///
public string FK_Dept
{
get
{
return this.GetValStrByKey(GWFAdminAttr.FK_Dept);
}
set
{
SetValByKey(GWFAdminAttr.FK_Dept, value);
}
}
///
/// 标题
///
public string Title
{
get
{
return this.GetValStrByKey(GWFAdminAttr.Title);
}
set
{
SetValByKey(GWFAdminAttr.Title, value);
}
}
///
/// 客户编号
///
public string GuestNo
{
get
{
return this.GetValStrByKey(GWFAdminAttr.GuestNo);
}
set
{
SetValByKey(GWFAdminAttr.GuestNo, value);
}
}
///
/// 客户名称
///
public string GuestName
{
get
{
return this.GetValStrByKey(GWFAdminAttr.GuestName);
}
set
{
SetValByKey(GWFAdminAttr.GuestName, value);
}
}
///
/// 产生时间
///
public string RDT
{
get
{
return this.GetValStrByKey(GWFAdminAttr.RDT);
}
set
{
SetValByKey(GWFAdminAttr.RDT, value);
}
}
///
/// 节点应完成时间
///
public string SDTOfNode
{
get
{
return this.GetValStrByKey(GWFAdminAttr.SDTOfNode);
}
set
{
SetValByKey(GWFAdminAttr.SDTOfNode, value);
}
}
///
/// 流程应完成时间
///
public string SDTOfFlow
{
get
{
return this.GetValStrByKey(GWFAdminAttr.SDTOfFlow);
}
set
{
SetValByKey(GWFAdminAttr.SDTOfFlow, value);
}
}
///
/// 流程ID
///
public Int64 WorkID
{
get
{
return this.GetValInt64ByKey(GWFAdminAttr.WorkID);
}
set
{
SetValByKey(GWFAdminAttr.WorkID, value);
}
}
///
/// 主线程ID
///
public Int64 FID
{
get
{
return this.GetValInt64ByKey(GWFAdminAttr.FID);
}
set
{
SetValByKey(GWFAdminAttr.FID, value);
}
}
///
/// 父节点流程编号.
///
public Int64 PWorkID
{
get
{
return this.GetValInt64ByKey(GWFAdminAttr.PWorkID);
}
set
{
SetValByKey(GWFAdminAttr.PWorkID, value);
}
}
///
/// 父流程调用的节点
///
public int PNodeID
{
get
{
return this.GetValIntByKey(GWFAdminAttr.PNodeID);
}
set
{
SetValByKey(GWFAdminAttr.PNodeID, value);
}
}
///
/// PFlowNo
///
public string PFlowNo
{
get
{
return this.GetValStrByKey(GWFAdminAttr.PFlowNo);
}
set
{
SetValByKey(GWFAdminAttr.PFlowNo, value);
}
}
///
/// 吊起子流程的人员
///
public string PEmp
{
get
{
return this.GetValStrByKey(GWFAdminAttr.PEmp);
}
set
{
SetValByKey(GWFAdminAttr.PEmp, value);
}
}
///
/// 发起人
///
public string Starter
{
get
{
return this.GetValStrByKey(GWFAdminAttr.Starter);
}
set
{
SetValByKey(GWFAdminAttr.Starter, value);
}
}
///
/// 发起人名称
///
public string StarterName
{
get
{
return this.GetValStrByKey(GWFAdminAttr.StarterName);
}
set
{
this.SetValByKey(GWFAdminAttr.StarterName, value);
}
}
///
/// 发起人部门名称
///
public string DeptName
{
get
{
return this.GetValStrByKey(GWFAdminAttr.DeptName);
}
set
{
this.SetValByKey(GWFAdminAttr.DeptName, value);
}
}
///
/// 当前节点名称
///
public string NodeName
{
get
{
return this.GetValStrByKey(GWFAdminAttr.NodeName);
}
set
{
this.SetValByKey(GWFAdminAttr.NodeName, value);
}
}
///
/// 当前工作到的节点
///
public int FK_Node
{
get
{
return this.GetValIntByKey(GWFAdminAttr.FK_Node);
}
set
{
SetValByKey(GWFAdminAttr.FK_Node, value);
}
}
///
/// 工作流程状态
///
public WFState WFState
{
get
{
return (WFState)this.GetValIntByKey(GWFAdminAttr.WFState);
}
set
{
if (value == WF.WFState.Complete)
SetValByKey(GWFAdminAttr.WFSta, (int)WFSta.Complete);
else if (value == WF.WFState.Delete)
SetValByKey(GWFAdminAttr.WFSta, (int)WFSta.Etc);
else
SetValByKey(GWFAdminAttr.WFSta, (int)WFSta.Runing);
SetValByKey(GWFAdminAttr.WFState, (int)value);
}
}
///
/// 状态(简单)
///
public WFSta WFSta
{
get
{
return (WFSta)this.GetValIntByKey(GWFAdminAttr.WFSta);
}
set
{
SetValByKey(GWFAdminAttr.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 "加签";
default:
return "未判断";
}
}
}
///
/// GUID
///
public string GUID
{
get
{
return this.GetValStrByKey(GWFAdminAttr.GUID);
}
set
{
SetValByKey(GWFAdminAttr.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 GWFAdmin()
{
}
public GWFAdmin(Int64 workId)
{
QueryObject qo = new QueryObject(this);
qo.AddWhere(GWFAdminAttr.WorkID, workId);
if (qo.DoQuery() == 0)
throw new Exception("工作 GWFAdmin [" + workId + "]不存在。");
}
///
/// 执行修复
///
public void DoRepair()
{
}
///
/// 重写基类方法
///
public override Map EnMap
{
get
{
if (this._enMap != null)
return this._enMap;
Map map = new Map("WF_GenerWorkFlow", "流程管理");
map.setEnType(EnType.View);
map.AddTBIntPK(GWFAdminAttr.WorkID, 0, "WorkID", false, false);
map.AddTBString(GWFAdminAttr.Title, null, "标题", true, false, 0, 300, 200, true);
map.AddDDLEntities(GWFAdminAttr.FK_Flow, null, "流程", new Flows(), false);
map.AddTBString(GWFAdminAttr.BillNo, null, "单据编号", true, true, 0, 100, 50);
map.AddTBInt(GWFAdminAttr.FK_Node, 0, "节点编号", false, false);
map.AddDDLSysEnum(GWFAdminAttr.WFSta, 0, "状态", true, true, GWFAdminAttr.WFSta, "@0=运行中@1=已完成@2=其他");
map.AddTBString(GWFAdminAttr.Starter, null, "发起人", false, false, 0, 100, 100);
map.AddTBDate(GWFAdminAttr.RDT, "发起日期", true, true);
map.AddTBString(GWFAdminAttr.NodeName, null, "停留节点", true, true, 0, 100, 100, false);
map.AddTBString(GWFAdminAttr.TodoEmps, null, "当前处理人", true, false, 0, 100, 100, false);
map.AddTBString(GWFAdminAttr.Emps, null, "参与人", false, false, 0, 4000, 100, true);
//map.AddDDLSysEnum(GWFAdminAttr.TSpan, 0, "时间段", true, false,
// GWFAdminAttr.TSpan, "@0=本周@1=上周@2=两周以前@3=三周以前@4=更早");
//隐藏字段.
map.AddTBInt(GWFAdminAttr.WFState, 0, "状态", false, false);
map.AddTBInt(GWFAdminAttr.FID, 0, "FID", false, false);
map.AddTBInt(GWFAdminAttr.PWorkID, 0, "PWorkID", false, false);
map.AddTBString(GWFAdminAttr.OrgNo, null, "OrgNo", false, false, 0, 4000, 100, false);
// map.AddSearchAttr(GWFAdminAttr.FK_Flow);
map.AddSearchAttr(GWFAdminAttr.WFSta);
//map.AddSearchAttr(GWFAdminAttr.TSpan,4000);
map.AddHidden(GWFAdminAttr.FID, "=", "0");
map.AddHidden(GWFAdminAttr.OrgNo, "=", BP.Web.WebUser.OrgNo);
map.AddHidden(GWFAdminAttr.WFState, ">", "1");
map.DTSearchWay = DTSearchWay.ByDate;
map.DTSearchLabel = "发起日期";
map.DTSearchKey = GWFAdminAttr.RDT;
SearchNormal search = new SearchNormal(GWFAdminAttr.WFState, "流程状态",
GWFAdminAttr.WFState, "not in", "('0')", 0, true);
map.SearchNormals.Add(search);
RefMethod rm = new RefMethod();
rm.Title = "轨迹";
rm.ClassMethodName = this.ToString() + ".DoTrack";
rm.RefMethodType = RefMethodType.LinkeWinOpen;
rm.IsForEns = true;
map.AddRefMethod(rm);
rm = new RefMethod();
rm.Title = "删除";
rm.ClassMethodName = this.ToString() + ".DoDelete";
rm.Warning = "您确定要删除吗?";
rm.Icon = "../../WF/Img/Btn/Delete.gif";
rm.IsForEns = false;
map.AddRefMethod(rm);
rm = new RefMethod();
rm.Icon = "../../WF/Img/Btn/CC.gif";
rm.Title = "移交";
rm.ClassMethodName = this.ToString() + ".DoFlowShift";
rm.RefMethodType = RefMethodType.LinkeWinOpen;
map.AddRefMethod(rm);
rm = new RefMethod();
rm.Icon = "../../WF/Img/Btn/Back.png";
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.Title = "跳转";
//rm.IsForEns = false;
//rm.ClassMethodName = this.ToString() + ".DoFlowSkip";
//rm.RefMethodType = RefMethodType.RightFrameOpen;
//map.AddRefMethod(rm);
rm = new RefMethod();
rm.Icon = "../../WF/Img/Btn/CC.gif";
rm.Title = "修复该流程数据实例";
rm.IsForEns = false;
rm.ClassMethodName = this.ToString() + ".RepairDataIt";
rm.RefMethodType = RefMethodType.Func;
map.AddRefMethod(rm);
rm = new RefMethod();
rm.Title = "调整";
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() + ".DoTest";
map.AddRefMethod(rm);
rm = new RefMethod();
rm.Title = "轨迹";
rm.ClassMethodName = this.ToString() + ".DoTrack";
rm.Icon = "../../WF/Img/Track.png";
rm.IsForEns = true;
rm.Visable = true;
rm.RefMethodType = RefMethodType.RightFrameOpen;
map.AddRefMethod(rm);
rm = new RefMethod();
rm.Title = "修改轨迹";
rm.IsForEns = false;
rm.ClassMethodName = this.ToString() + ".DoEditTrack";
rm.RefMethodType = RefMethodType.RightFrameOpen;
map.AddRefMethod(rm);
rm = new RefMethod();
rm.Title = "调整数据";
rm.IsForEns = false;
rm.ClassMethodName = this.ToString() + ".DoEditFrm";
rm.RefMethodType = RefMethodType.RightFrameOpen;
map.AddRefMethod(rm);
this._enMap = map;
return this._enMap;
}
}
#endregion
///
/// 轨迹
///
///
public string DoTrack()
{
//PubClass.WinOpen(Glo.CCFlowAppPath + "WF/WFRpt.htm?WorkID=" + this.WorkID + "&FID=" + this.FID + "&FK_Flow=" + this.FK_Flow, 900, 800);
return "/WF/WFRpt.htm?CurrTab=Truck&WorkID=" + this.WorkID + "&FID=" + this.FID + "&FK_Flow=" + this.FK_Flow + "&FK_Node=" + this.FK_Node;
}
///
/// 修改表单
///
///
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 "/WF/Admin/AttrFlow/AdminFrmList.htm?FK_Flow=" + this.FK_Flow + "&FrmID=" + frmID + "&WorkID=" + this.WorkID;
}
public string DoTest(string toEmpNo, string toNodeID)
{
return BP.WF.Dev2Interface.Flow_ReSend(this.WorkID, int.Parse(toNodeID),
toEmpNo, BP.Web.WebUser.Name + ":调整.");
}
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 = DBAccess.GetBigTextFromDB(trackTable, "MyPK", mypk, "FrmDB");
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;
}
///
/// 回滚
///
/// 节点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 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 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;
}
}
///
/// 流程管理s
///
public class GWFAdmins : Entities
{
#region 方法
///
/// 得到它的 Entity
///
public override Entity GetNewEntity
{
get
{
return new GWFAdmin();
}
}
///
/// 流程管理集合
///
public GWFAdmins() { }
#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((GWFAdmin)this[i]);
}
return list;
}
#endregion 为了适应自动翻译成java的需要,把实体转换成List.
}
}