起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 433|回复: 14

【搞定】加急!2617 流程缺省执行者 1<>1 错误**

[复制链接]
发表于 2007-6-1 11:03:42 | 显示全部楼层 |阅读模式
流程缺省执行者如果设置为 1<>1 在流转时就会出错,去掉1<>1就正常了。
出错单元[流程公共库]红色代码处,见下图

麻烦快一点,等着给客户演示。。。

static procedure TDefaultFlowExecutorsManager.RefreshExecutors(ACommand: TFlowCommand);
var
  I, J: Integer;
  lProcURL, lProcUnitID, lExecutor : String;
  lBizURL: TBizURL;
  lOrgURL: TOrgURL;
  lOrgURLs: TOrgURLs;
  lCommand: TFlowTaskCommand;
  lDefault: TStringList;
  lQuery: TQuery;
  lFlowTask: TFlowTask;
begin
  if not IsManageCommand(ACommand) then
    Exit;

  lCommand := TFlowTaskCommand(ACommand);

  lBizURL := TBizURL.Create;
  lDefault:= TStringList.Create;
  lQuery := TQuery.Create(nil);
  try
    for I := 0 to lCommand.AllowFlowTasks.Count - 1 do
      lDefault.AddObject(GetProcURL(lCommand.AllowFlowTasks[I]) + '[' +
         lCommand.AllowFlowTasks[I].ProcUnit.ID + ']', TOrgURLs.Create);

    lQuery.ConnectionString := cDBConnectStr;
    lQuery.CommandText := SysUtils.Format('SELECT * FROM TFLOWDEFAULTEXECUTOR WHERE FOWNER = ''%s'' AND FSPROCURL = ''%s'' AND FSPROCUNITID = ''%s'' AND FFLOWCOMMANDID = %d',
      [GetOrgURLSaveStr(GetOwner(lCommand)),
       SysUtils.UpperCase(ACommand.FlowControl.CurrentProcUnit.Proc.BizClassURL.BizURL.URL),
       SysUtils.UpperCase(ACommand.FlowControl.CurrentProcUnit.ID),
       ACommand.ID]);
    lQuery.Open;
    while not lQuery.Eof do
    begin
      lProcURL := lQuery.FieldByName('FTPROCURL').AsString;
      lProcUnitID := lQuery.FieldByName('FTPROCUNITID').AsString;
      lExecutor := lQuery.FieldByName('FEXECUTOR').AsString;

      for I := 0 to lCommand.AllowFlowTasks.Count - 1 do
      begin
        lFlowTask := lCommand.AllowFlowTasks[I];
        if not (SysUtils.SameText(GetProcURL(lFlowTask), lProcURL) and
          SysUtils.SameText(lFlowTask.ProcUnit.ID, lProcUnitID)) then
          continue;

        if lFlowTask.Executors.Count = 0 then
          lFlowTask := lCommand.FlowTasks.FindFlowTask(lFlowTask.ProcUnit);
         for J := 0 to lFlowTask.Executors.Count - 1 do
          if SysUtils.SameText(lFlowTask.Executors[J].BizURL.URL, lExecutor) then
          begin
            lBizURL.URL := lExecutor;
            lOrgURL := TOrgURL.Create(lBizURL);
            TOrgURLs(lDefault.Objects[lDefault.IndexOf(lProcURL + '[' + lProcUnitid + ']')]).Add(lORgURL);
            break;
          end;
        if J = lFlowTask.Executors.Count then
          for J := 0 to lFlowTask.AllowExecutors.Count - 1 do
            if SysUtils.SameText(lFlowTask.AllowExecutors[J].BizURL.URL, lExecutor) then
            begin
              lBizURL.URL := lExecutor;
              lOrgURL := TOrgURL.Create(lBizURL);
              TOrgURLs(lDefault.Objects[lDefault.IndexOf(lProcURL + '[' + lProcUnitid + ']')]).Add(lORgURL);
              break;
            end;
      end;
      lQuery.Next;
    end;

    for I := 0 to lCommand.FlowTasks.Count - 1 do
    begin
      lOrgURLs := TOrgURLs(lDefault.Objects[lDefault.IndexOf(GetProcURL(lCommand.FlowTasks[I]) + '[' + lCommand.FlowTasks[I].ProcUnit.ID + ']')]);
      if lOrgURLs.Count > 0 then   //如果未取到交集,跳过,不做处理
        lCommand.FlowTasks[I].Executors.Assign(lOrgURLs);
    end;

    for I := 0 to lCommand.AllowFlowTasks.Count - 1 do
    begin
      lOrgURLs := TOrgURLs(lDefault.Objects[lDefault.IndexOf(GetProcURL(lCommand.AllowFlowTasks[I]) + '[' + lCommand.AllowFlowTasks[I].ProcUnit.ID + ']')]);
      if lOrgURLs.Count > 0 then   //如果未取到交集,跳过,不做处理
        lCommand.AllowFlowTasks[I].Executors.Assign(lOrgURLs);
    end;
  finally
    for I := lDefault.Count - 1 downto 0 do
      lDefault.Objects[I].Free;
    lQuery.Free;
    lDefault.Free;
    lBizURL.Free;
  end;
end;

flowerror.jpg

39.42 KB, 下载次数: 195

回复

使用道具 举报

发表于 2007-6-1 11:09:45 | 显示全部楼层
for J := 0 to lFlowTask.Executors.Count - 1 do
1<>1,表示没有执行者,也就是lFlowTask.Executors.Count为0 ,那还循环啥呢?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-6-1 11:32:00 | 显示全部楼层
刚刚调试发现第一句红色代码前一句取出的对象为空
if lFlowTask.Executors.Count = 0 then
          lFlowTask := lCommand.FlowTasks.FindFlowTask(lFlowTask.ProcUnit);

然后再执行
for J := 0 to lFlowTask.Executors.Count - 1 do
的时候就找不到对象出错

至于atiger说的循环我们也不清楚"你们"是怎么想的,这是平台的单元不是我们自己写的!!
回复 支持 反对

使用道具 举报

发表于 2007-6-1 11:39:37 | 显示全部楼层
你除了设置1<>1,还设置其他的吗?我测试是正常的,

还有是否有代码参与流程流转动作呢?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-6-1 11:42:31 | 显示全部楼层
没有啊,我没有代码参与流程流转动作
回复 支持 反对

使用道具 举报

发表于 2007-6-1 11:54:19 | 显示全部楼层
怪了,你是在这个版本初始化的新数据库,还是升级上来的?

要不把资源包上传上来,或者做个简单的重现例子,我恢复看看
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-6-1 12:02:16 | 显示全部楼层
我是新初始化的数据库,资源包涉及的东西太多了不好发部,我再做一个简单的例子试试看吧,我这边很明显的,加上1<>1就不行,去掉就可以了,麻烦你也做个例子测试一下吧
回复 支持 反对

使用道具 举报

发表于 2007-6-1 13:35:26 | 显示全部楼层
附件是我的例子

例子11.rar

627.74 KB, 下载次数: 113

回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-6-1 14:38:30 | 显示全部楼层
例子不对吧??运行不起来,窗体上怎么没有流转按钮啊
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-6-1 15:12:16 | 显示全部楼层
我把整个流程都删除了,重新做了一个,目前好用了,不过又发现个新问题,即使是设置上了1<>1有是执行者那还是会自动添加一个,是不是跟自动计算执行者有关?
我现在的情况是A发送任务给B,在B处理时不通过发送给C,C处理过后再发送给A,当A再向B提交任务的时候执行者就默认添加了B
回复 支持 反对

使用道具 举报

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

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-6-21 17:56 , Processed in 0.043188 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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