起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 1231|回复: 0

如何已知人员列表代码指定下一个环节的执行者范围

[复制链接]
发表于 2006-6-23 18:23:14 | 显示全部楼层 |阅读模式
Static procedure TFlowUtils.ModifyExecutorRangeByPersonList(Command:TFlowOutCommand;ANextProcUnit:string;APersonList:Tstrings;AAssignMode:TTaskAssignMode;AExecutorAmount:TTaskExecutorAmount);
var
  lFlowTask:TFlowTask;
  lRange:String;
  i:integer;
  lDeptList:TStrings;
  lPositionList:TStrings;
  lPersonList:TStrings;
begin
  lRange := '';
  lFlowTask := Command.FlowTasks.FindFlowTask(ANextProcUnit);
  if lFlowTask <> nil then
  begin
    lDeptList:=TStringList.Create;
    lPositionList:=TStringList.Create;
    lPersonList:=TStringList.Create;
    try
      GetDeptPositionListByPersonList(APersonList,lPersonList,lDeptList,lPositionList);
      for i := 0 to  lPersonList.Count -1 do
      begin
        if  lRange ='' then
          lRange:='OrgKey('''+lDeptList.Strings+''','''+lPositionList.Strings+''','''+lPersonList.Strings+''')'
        else
          lRange:=lRange + ' or '+'OrgKey('''+lDeptList.Strings+''','''+lPositionList.Strings+''','''+lPersonList.Strings+''')'
      end;
      if  lRange='' then
        lFlowTask.ExecutorMustBeFuncOwner:=True
      else
        lFlowTask.ExecutorMustBeFuncOwner:=False;
      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.AllowExecutorRange:=lRange;
      lFlowTask.ExecutorRange:=lRange;
    finally
      lDeptList.Free;
      lPositionList.Free;
      lPersonList.Free;
    end;
  end;

end;


Static procedure TFlowUtils.GetDeptPositionListByPersonList(APersonList:Tstrings;var APersonMember,ADeptList,APositionList:TStrings);
var
  lPersonMembers: TList;
  lPersonMember: TOrgUnit;
  i,j: integer;
begin
  lPersonMembers := TList.Create;
  APersonMember.Clear;
  ADeptList.Clear;
  APositionList.Clear;
  try
    for j:=0 to APersonList.Count-1 do
    begin
      lPersonMembers.Clear;
      OrgSys.OrgSystem.GetPersonMembers(APersonList.Strings[j], lPersonMembers); //
      for i := 0 to lPersonMembers.count-1 do
      begin
        lPersonMember := TOrgUnit(lPersonMembers.Items);
        APersonMember.Add(lPersonMember.ID);
        APositionList.Add(lPersonMember.Parent.ID);
        ADeptList.Add(lPersonMember.Parent.Parent.ID);
      end;
    end;
  finally
    lPersonMembers.Free;
  end;
end;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2024-3-29 22:57 , Processed in 0.039282 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表