|
发表于 2007-3-27 17:44:46
|
显示全部楼层
1、在需要多人审核的环节,设置执行规则为多人,任务分配方式为独立分配
设置流转规则:选择“任务合并”,任务等待“当前环节尚未结束的任务”
2、在需要多人审核的环节,AfterFlowBack事件编写代码,中止当前环节的其他任务
function TAndFlow.GetTasksByCurrentUnit(AProcUrl, AProcUnitID, AFlowGuid: String;
ACurrentTaskGUID: String): TTasks;
var
lTasks: TTasks;
lLoadTasksParam: TLoadTaskParam;
begin
lTasks := TTasks.Create;
lLoadTasksParam := TLoadTaskParam.Create;
try
lLoadTasksParam.ProcURLs.Add(AProcUrl);
lLoadTasksParam.ProcUnitIDs.Add(AProcUnitID);
lLoadTasksParam.FlowGUIDs.Add(AFlowGuid);
lLoadTasksParam.States := [TTaskState.tsStarted, TTaskState.tsWaited,
TTaskState.tsWaiting];
lLoadTasksParam.IncludeTaskMessage := True;
Flow.FlowEngine.GetTasks(lLoadTasksParam, lTasks);
lTasks.Remove(lTasks.FindTaskByGUID(ACurrentTaskGUID));
finally
lLoadTasksParam.Free;
Result := lTasks;
end;
end;
procedure TAndFlow.TasksAbort(ATasks: TTasks);
var
lResult: Boolean;
lDoTask: TTask;
lTaskMessage: TTaskMessage;
i, j : Integer;
begin
if ATasks = nil then
Exit;
AbortCount := 0;
for i := 0 to ATasks.Count-1 do
begin
lDoTask := ATasks;
for j := 0 to lDoTask.TaskMessages.Count-1 do
begin
lTaskMessage := lDoTask.TaskMessages.Items[j];
if lTaskMessage.State in [TTaskMessageState.tmsProcessing,
TTaskMessageState.tmsSend, TTaskMessageState.tmsWaited,
TTaskMessageState.tmsWaiting] then
lTaskMessage.State := TTaskMessageState.tmsAborted;
end;
lDoTask.State := TTaskState.tsAborted;
lDoTask.SaveToDB;
Inc(AbortCount);
end;
end;
{当前任务回退后,将其他处在同一个环节的任务全部中止}
procedure TAndFlow.ProcUnitMID1UNITAfterFlowBack(Sender: TObject; Command: TFlowBackCommand);
var
lTasks: TTasks;
begin
lTasks := GetTasksByCurrentUnit(Command.FlowControl.Flow.ProcURL,
Command.FlowControl.CurrentTask.ProcUnitID, Command.FlowControl.Flow.GUID,
Command.FlowControl.CurrentTask.GUID);
TasksAbort(lTasks);// then //Command.FlowControl.TaskAbort(lTasks)
jsDialogs.ShowMsg('共有 ' + SysUtils.IntToStr(lTasks.Count) +
' 个任务被中止。', '提示:');
end; |
|