|
发表于 2007-3-1 16:31:43
|
显示全部楼层
那是我创建的一个资源集:
unit TaskPubFunc;
interface
uses
Business.System, Business.Model, Business.Model.Flow, Business.Model.Org;
type
TTaskPubFunc = class(TBizLibrary)
private
{private declarations}
public
procedure UserStartFlow(AFlowUrl,ADept,ARole,APerson,AStartProc,AFlowID,
ASubject,ADescription:string);
procedure UserStartTask(AFuncURL, ATaskTypeName, ATaskTypeID, ASubject,
ABizField, ABizFieldValue, ADept, APosition, APerson : string);
end;
implementation
{无流程任务
任务表,任务业务数据表,业务数据表: 通过任务guid, 业务数据guid关联}
procedure TTaskPubFunc.UserStartTask(AFuncURL, ATaskTypeName, ATaskTypeID,
ASubject, ABizField, ABizFieldValue, ADept, APosition, APerson : string);
VAR
lOrgURL : TOrgURL;
lTask : TTask;
lTaskBizData : TTaskBizData;
lTaskBizDataRec : TTaskBizDataRec;
begin
lTask := TTask.Create;
{任务接受者}
lOrgURl := TOrgURL.Create(ADept, APosition, APerson);
{任务业务关联数据定义}
lTaskBizData := TTaskBizData.Create;
lTaskBizDataRec := TTaskBizDataRec.Create;
try
lTaskBizDatarec.BizField := ABizField; //业务数据的关键字段,用于检索业务数据
lTaskBizDataRec.Value := ABizFieldValue; //业务数据的关键字段值
lTaskBizData.BizDataKeys.Add(lTaskBizDataRec);
//lTaskBizData.BizDatas.Add(lTaskBizDataRec);
{任务信息的定义}
lTask.Subject := ASubject;
lTask.Kind:= ''; //无流程任务为空
lTask.TaskType := ATaskTypeID; //任务类型,如:工作任务:WORKTASKDEAL, WORKTASK
lTask.TaskTypeName := ATaskTypeName;
lTask.FuncURL := AFuncURL; //处理任务的功能
lTask.SenderDeptID := ADept;
lTask.SenderPositionID := APosition;
lTask.SenderID := APerson;
lTask.BizDatas.Add(lTaskBizData); //设置业务数据与任务关联关系, 保存任务业务关联信息到‘系统空间\系统数据库\任务业务数据表’
lTask.TaskMessages.AddTaskMessage(nil, lOrgURl, TTaskmessagestate.tmsSend, 0,
False); //添加到任务列表
{保存任务}
Flow.FlowEngine.SaveTask(lTask); //保存任务信息到‘系统空间\系统数据库\任务表’,任务消息到‘任务消息表’
finally
//lTaskBizDataRec.Free;
//lTaskBizData.Free;
lTask .Free;
lOrgURL.Free;
end;
end;
{流程表,流程ID表,任务表,任务消息表}
procedure TTaskPubFunc.UserStartFlow(AFlowUrl, ADept, ARole, APerson, AStartProc, AFlowID,
ASubject, ADescription:string);
var
lBizURL: TBizURL;
lFlowValue: TFlowValue;
lFlowControl: TFlowControl;
lExecutor: TOrgURL;
begin
lBizURL := TBizURL.Create;
lFlowValue := TFlowValue.Create; //流程实例
lFlowControl := TFlowControl.Create(Self.Context); //流程控制组件
lExecutor := TOrgURL.Create(ADept, ARole, APerson); //执行者
lBizURL.URL := AFlowUrl; //流程url
try
lFlowValue.IDs.Add(AFlowID); //流程ID
lFlowValue.Subject := ASubject+AFlowID; //流程主题
lFlowValue.Description := ADescription; //流程描述
//启动流程实例 过程url 环节ID 执行者 流程实例值
lFlowControl.StartupFlow(lBizURL, AStartProc, lExecutor, lFlowValue);
//流程发送者信息
lFlowControl.FlowRunnerbyIndex[0].CurrentTask.SenderDeptID := ADept;
lFlowControl.FlowRunnerbyIndex[0].CurrentTask.SenderPositionID := ARole;
lFlowControl.FlowRunnerbyIndex[0].CurrentTask.SenderID := APerson;
//流程实例数据保存到数据库
lFlowControl.FlowRunnerbyIndex[0].CurrentTask.SaveToDB;
finally
lFlowControl.Free;
lFlowValue.Free;
lBizURL.Free;
end;
end;
end. |
|