|
发表于 2011-2-22 09:59:10
|
显示全部楼层
分享我自己建的公共函数库中的几个相关函数。
static procedure TFlowRelated.ModifyExecutorRangeByPersonList(Command:TFlowOutCommand;ANextProcUnit:string;APersonList:Tstrings;AAssignMode:TTaskAssignMode;AExecutorAmount:TTaskExecutorAmount);
var
lFlowTask:TFlowTask;
i:integer;
lPersonList,lURLList:TStringList;
lRange, deptID, PosID, PsnId: string;
begin
lFlowTask := Command.FlowTasks.FindFlowTask(ANextProcUnit);
if lFlowTask <> nil then
begin
lPersonList:=TStringList.Create;
lURLList:=TStringList.Create;
try
lFlowTask.ExecutorAmount:= AExecutorAmount; //TTaskExecutorAmount.teaMulti;
lFlowTask.ExecutorKinds := [TTaskExecutorKind.ekPersonMember]; //执行者类型 人员成员
lFlowTask.AssignMode := AAssignMode;// TTaskAssignMode.amSingleness;
case AAssignMode of
TTaskAssignMode.amSingleness:
begin
lFlowTask.ExecuteMode := TTaskExecuteMode.emExclusive;
end;
TTaskAssignMode.amTogether:
begin
lFlowTask.ExecuteMode := TTaskExecuteMode.emSimultaneous ; //任务执行方式 同时执行
end;
end;
lFlowTask.AllowExecutors.Clear;
lFlowTask.Executors.Clear;
for i := 0 to APersonList.Count -1 do
begin
lPersonList.Clear;
TPerson.GetPersonURLsByID(ApersonList.Strings,lPersonList);
if lPersonList.Count > 0 then
begin
TPerson.AnalysisURL(lPersonList.Strings[0],DeptID,PosID,PsnID);
if lRange = '' then
lRange:= ' OrgKey('''+ DeptID + ''',''' + PosID + ''',''' + PsnID+ ''') '
else
lRange:= lRange + ' or OrgKey('''+ DeptID + ''',''' + PosID + ''',''' + PsnID+ ''') '
end;
end;
lFlowTask.AllowExecutorRange:= lRange;
lFlowTask.ReLoadAllowExecutors;
lFlowTask.ReLoadExecutors;
finally
lPersonList.Free;
lURLList.Free;
end;
end;
end;
static procedure TPerson.GetPersonURLsByID(ID: string; var URLs: TStringList);
//根据一个ID获取所有的URL
var
lExpr: string;
begin
lExpr:= 'OrgCondition(''' + ID + '.psm'','''','''')';
OrgSys.OrgSystem.GetBizURLsByOrgExpr(lExpr,URLs);
end;
static procedure TPerson.AnalysisURL(URL: string; var DeptID, PositionID, PersonID: string);
var
lOrgUnit: TOrgUnit;
lBizUrl: TBizUrl;
begin
lBizUrl:= TBizUrl.Create;
try
if IsValidUrl(URL) then
begin
lBizUrl.URL:= URL;
lOrgUnit:= OrgSys.OrgSystem.GetUnit(lBizUrl);
case TBizObjectKind(lOrgUnit.OrgKind) of
TBizObjectKind.boDept: //选中部门
begin
DeptID:= lOrgUnit.ID;
PositionID:= '';
PersonID:= '';
end;
TBizObjectKind.boPositionMember: //选中岗位
begin
DeptID:= lOrgUnit.Parent.ID;
PositionID:= lOrgUnit.ID;
PersonID:= '';
end;
TBizObjectKind.boPersonMember: //选中人员
begin
DeptID:= lOrgUnit.Parent.Parent.ID;
PositionID:= lOrgUnit.Parent.ID;
PersonID:= lOrgUnit.ID;
end;
TBizObjectKind.boOrgan:
begin
DeptID:= '';
PositionID:= '';
PersonID:= '';
end;
end; //case
end;
finally
lBizUrl.Free;
end;
end; |
|