a) 审批日志和关系保存对象(ProcessRelationLog)
这个类主要实现审批日志和关系的保存;
对象成员:
属性:
|
属性名称 |
属性类型 |
属性说明 |
|
ProcessID |
string |
Process ID,必须设置 |
|
TaskID |
string |
Task ID,必须设置 |
|
LogonName |
string |
用户登录名,必须设置 |
|
UserID |
string |
用户ID,只读 |
|
DisplayName |
string |
用户的显示名 |
|
Type |
string |
关系类型,必须设置 |
|
Source |
string |
流程发起人 |
|
FormNo |
string |
流程流水号 |
|
Dept |
string |
部门信息 |
|
Category |
string |
类别 |
|
Description |
string |
描述 |
|
Detail |
string |
细节内容 |
|
Others |
string |
其它业务信息 |
补充说明:从Source起往下的属性是用于保存流程的业务信息,如果客户有需要,可选择相应的属性保存,不需要的属性允许为空,可不予理会。
方法:
|
方法名称 |
属性说明 |
|
AddTaskRelation |
保存任务关系 |
|
WriteLog |
写日志 |
Sample:下面的这个例子是我们在做精量项目时使用的一个调用工作流流转程序的基类,在这个基类当中的流程流转方法中我加入了写日志和任务关系的代码(代码中突出显示的部分),做为本文的最后一个Sample,请大家仔细研究。
namespace TeamplateBase
{
///<summary>
/// TeamplateWebFormBase 的摘要说明。
///</summary>
public class TeamplateWebFormBase : System.Web.UI.Page
{
public TeamplateWebFormBase()
{
}
protected void LoadBindingData(BProcess process)
{
BProcess pro = null;
try
{
if(process == null)
{
pro = this.LoadProcess();
}
else
{
pro = process;
}
this.LoadData(pro);
}
catch(Exception ex)
{
throw ex;
}
finally
{
if(process == null && pro != null)
{
pro.Dispose();
pro = null;
}
}
}
protected BProcess LoadProcess()
{
int taskId;
int processId;
string token;
BProcess process = new BProcess();
try
{
taskId = Convert.ToInt32(Request.QueryString["TID"]);
processId = Convert.ToInt32(Request.QueryString["PID"]);
token = Request.QueryString["token"];
if (token==null || taskId==0)
{
throw new Exception("Error, Invalid process id or token!");
}
process.SetSessionToken(token);
process.Load(processId);
}
catch(Exception ex)
{
throw ex;
}
return process;
}
protected virtual void LoadData(BProcess process)
{
}
protected void PromoteProcess(System.Web.UI.Page page)
{
int taskId = Convert.ToInt32(Request.QueryString["TID"]);
int processId = Convert.ToInt32(Request.QueryString["PID"]);
string token = Request.QueryString["TOKEN"];
BProcess process = null;
// 关系日志对象 Add by Sunmf
ProcessRelationLog relationlog = new ProcessRelationLog();
try
{
process = new BProcess();
process.SetSessionToken(token);
process.Load(processId);
this.SaveBindingData(process);
process.WorkflowAdvance(taskId, null);
this.SaveRelationLog(relationlog, process);
}
finally
{
if(process != null)
{
process.Dispose();
process = null;
}
}
}
//由继承的窗体完成关系和日志信息的赋值
protected virtual void SaveRelationLog(ProcessRelationLog relationlog, BProcess process)
{
relationlog.AddTaskRelation();
relationlog.WriteLog();
}
protected void SaveBindingData(BProcess process)
{
BProcess pro = null;
try
{
if(process == null)
{
pro = this.LoadProcess();
}
else
{
pro = process;
}
this.SaveData(pro);
}
catch(Exception ex)
{
throw ex;
}
finally
{
if(process == null && pro != null)
{
pro.Dispose();
pro = null;
}
}
}
protected virtual void SaveData(BProcess process)
{
}
protected void closeWindow(System.Web.UI.Page page)
{
string client;
client = page.Request.ServerVariables["HTTP_USER_AGENT"];
int index = client.IndexOf("Windows CE", 0);
if(index == -1)
{
this.RegisterClientScriptBlock("tpCloseAndReloadParentWindow","<script language=JavaScript> opener.window.location.replace(opener.window.location.href); window.close();</script>");
}
}
}
}
//使用这个基类例子代码片断:
protected override void SaveRelationLog(TeamplateLib.ProcessRelationLog relationlog, BProcess process)
{
relationlog.TaskID =Request.QueryString["TID"].ToString();
relationlog.ProcessID = Request.QueryString["PID"].ToString();
relationlog.LogonName = this.CurrentUser;
relationlog.DisplayName = this.ApproveControl1.lblApproverDisName.Text;
relationlog.Type = "Actor";
relationlog.Source = process.GetTextValue("Common","Root/Request/RequestBy");
relationlog.Dept = process.GetTextValue("Common","Root/Request/Dept");
relationlog.FormNo ="Purchase Request";
relationlog.Detail =process.GetTextValue("Common","Root/Request/Supplier");
relationlog.Description =process.GetTextValue("Common","Root/Request/Description");
switch (this.ApproveControl1.ddlApproveStatus.SelectedValue)
{
case "1":
relationlog.ApproveStatus = "Approved";
break;
case "2":
relationlog.ApproveStatus = "Declined";
break;
case "3":
relationlog.ApproveStatus = "Cancelled";
break;
}
relationlog.ApproveComment = this.ApproveControl1.txtComment.Text;
relationlog.ApproveRemark = this.ApproveControl1.txtApproveRemark.Text;
base.SaveRelationLog (relationlog, process);
}
浙公网安备 33010602011771号