Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

How to traverse all liveblocks of workflow diagram

 Post Reply Post Reply
Author
? ?? View Drop Down
New Member
New Member
Avatar

Joined: 25 Oct 2012
Posts: 18
Post Options Post Options   Quote ? ?? Quote  Post ReplyReply Direct Link To This Post Topic: How to traverse all liveblocks of workflow diagram
    Posted: 08 Aug 2016 at 4:36am
How to traverse all liveblocks of workflow diagram?
  Assuming wkins is a workflowinstance:
1,wkins.Diagram.Liveds[0] is null,I can not access the first node of the diagram,why?
2,I use wkins.Diagram.LastNode and wkins.Diagram.NextNode,but both point to the same node,it is
the current node(TCustomLiveBlock).


thanks.

 2016.8.8
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2432
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 08 Aug 2016 at 1:12pm
You must interact through property BlockCount, Blocks, LinkCount and Links (to get blocks and lines available) and check Blocks[c].Anchoreds[].DControl and/or Links[c].LinkPoints[].Anchor to check what lines are connected to what blocks.

The LastNode, NextNode, etc., are not available since they are only changed when workflow is being executed.
Back to Top
Adrian Morawiec View Drop Down
New Member
New Member
Avatar

Joined: 29 Dec 2015
Posts: 22
Post Options Post Options   Quote Adrian Morawiec Quote  Post ReplyReply Direct Link To This Post Posted: 05 Sep 2016 at 11:48am
Can you show me, how to get next block of current task?
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2432
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 05 Sep 2016 at 7:26pm
What (or maybe better, why) you want to do, exactly? Because strictly speaking, there is no "next block of current task". In a task you have several final status and each of them usually flow to a different block. So the next block of a task is only defined after the task is finished and the task status is computed.
Back to Top
Adrian Morawiec View Drop Down
New Member
New Member
Avatar

Joined: 29 Dec 2015
Posts: 22
Post Options Post Options   Quote Adrian Morawiec Quote  Post ReplyReply Direct Link To This Post Posted: 06 Sep 2016 at 8:26am
I want to read internal status (not completion status) of task after selection correct link and
before save the task.

Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2432
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 06 Sep 2016 at 2:26pm
Sorry, but I didn't understand. What do you mean by internal status, and what you mean by "after selection correct link"?
Back to Top
Adrian Morawiec View Drop Down
New Member
New Member
Avatar

Joined: 29 Dec 2015
Posts: 22
Post Options Post Options   Quote Adrian Morawiec Quote  Post ReplyReply Direct Link To This Post Posted: 06 Sep 2016 at 3:55pm
Each block has its own list status and a list of links
When I select the specific link coming out of the block I want to read a list of statuses in the next block
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2432
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 09 Sep 2016 at 4:15am
Here is a snippet of code from the TMS Diagram Studio "getting links" demo, which shows all incoming and ongoing links of a specific block, and what other blocks are connected to it. With this code you can check the next blocks (in diagram), check if they are a task block and then get the status list from it:

procedure TForm1.CheckBlockLinks(ABlock: TCustomDiagramBlock);

  procedure CheckLink(ALink: TCustomDiagramLine);
  var
    ConnectStr: string;
    ConnectedControl: TDiagramControl;
    ConnectedName: string;
  begin
    {A link has two connection points. We must find out which point has
     the block we are analysing, and which point has the other connected block
     (if any)}
    if ALink.SourceLinkPoint.Anchor = ABlock then
    begin
      ConnectedControl := ALink.TargetLinkPoint.Anchor;
      ConnectStr := '-->';
    end else
    begin
      ConnectedControl := ALink.SourceLinkPoint.Anchor;
      ConnectStr := '<--';
    end;

    if ConnectedControl = nil then
      ConnectedName := 'none'
    else
      ConnectedName := ConnectedControl.Name;
    Memo1.Lines.Add(Format('%s (%s) %s %s',
      [ConnectStr, ALink.Name, ConnectStr, ConnectedName]));
  end;

var
  c: integer;
  d: integer;
begin
  Memo1.Lines.Add(Format('%s links:',[ABlock.Name]));

  {Iterate through each link point (connection point) available in block}
  for c := 0 to ABlock.LinkPoints.Count - 1 do
    {For each link point, iterate through the controls which are anchored to it}
    for d := 0 to ABlock.LinkPoints[c].AnchoredCount - 1 do
    begin
      {If the anchored control is a line, then analise it.
       * for now, only lines can be anchored to a link point, so this
         test is not needed. But in a future version other types of
         controls can be anchored to a link point, so do the test already}
      if ABlock.LinkPoints[c].Anchoreds[d].DControl is TCustomDiagramLine then
        CheckLink(TCustomDiagramLine(ABlock.LinkPoints[c].Anchoreds[d].DControl));
    end;

  Memo1.Lines.Add('---');
end;

Back to Top
Adrian Morawiec View Drop Down
New Member
New Member
Avatar

Joined: 29 Dec 2015
Posts: 22
Post Options Post Options   Quote Adrian Morawiec Quote  Post ReplyReply Direct Link To This Post Posted: 09 Sep 2016 at 8:58am
I can't run the code;
TCustomDiagramBlock, TCustomDiagramLine, TDiagramControl  : Undeclared identifier
(what to add to uses clause)?

And how to call the procedure? How to get a current block of taskinstance?
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2432
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 09 Sep 2016 at 8:33pm
Those are declared in atDiagram unit.
You don't have the current block of a task instance. The task is separated from workflow engine. The engine knows it's waiting for a task, but the task doesn't know what block it's related to.
You mentioned you were using NextNode property, can't you use that?
Back to Top
Adrian Morawiec View Drop Down
New Member
New Member
Avatar

Joined: 29 Dec 2015
Posts: 22
Post Options Post Options   Quote Adrian Morawiec Quote  Post ReplyReply Direct Link To This Post Posted: 12 Sep 2016 at 8:33am
I've added atDiagram  to uses clause but TCustomDiagramBlock and TCustomDiagramLine still are Undeclared. 
But I found TCustomWorkflowBlock class. Can I use it?
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2432
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 12 Sep 2016 at 1:10pm
You can use TCustomWorkflowBlock, yes, since it's the base class for all blocks in a workflow diagram. But TCustomDiagramBlock and TCustomDiagramLine are definitely declared in unit atDiagram, something is wrong...
Back to Top
Adrian Morawiec View Drop Down
New Member
New Member
Avatar

Joined: 29 Dec 2015
Posts: 22
Post Options Post Options   Quote Adrian Morawiec Quote  Post ReplyReply Direct Link To This Post Posted: 14 Sep 2016 at 8:19am
workflowinstance.Diagram.NextNode return TCustomLiveBlock, so I changed TCustomDiagramBlock to TCustomLiveBlock and added LiveDiagram to uses clause and the code compiled succesfully.
But, I still don't know how to call CheckBlockLinks procedure, because I don't know how to get taskinstance current block.

Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2432
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 14 Sep 2016 at 3:26pm
As I said, there is no such current block for task instance. All you have is current block for the workflow instance itself, which is NextNode (if the task isn't finished, NextNode points to the task block itself). I still don't understand what exactly you want to achieve.
Back to Top
Adrian Morawiec View Drop Down
New Member
New Member
Avatar

Joined: 29 Dec 2015
Posts: 22
Post Options Post Options   Quote Adrian Morawiec Quote  Post ReplyReply Direct Link To This Post Posted: 03 Oct 2016 at 8:32am
My blocks have few statuses (to note, to edit, to reply etc) (not completion statuses)
I want to change current block and then set status
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2432
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 03 Oct 2016 at 1:58pm
Ok but why do you need that? We have never heard of such need, probably because users used a different solution for a similar problem. Why do you need to change status of a task definition when the task instance is not created yet? Are you aware that to change the status of a task instance you just modify the task instance itself?
Back to Top
Adrian Morawiec View Drop Down
New Member
New Member
Avatar

Joined: 29 Dec 2015
Posts: 22
Post Options Post Options   Quote Adrian Morawiec Quote  Post ReplyReply Direct Link To This Post Posted: 04 Oct 2016 at 2:57pm
Now my program works in this way.
I choose completion status and The Workflow go to the next block. Then I again change not completion status and Workflow stay on current block. And it works fine.
But if I accidentally choose wrong completion status I can't back to previous block
so I want to gather all the informations (current status and status at the next block) and then perform all operations.
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2432
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 04 Oct 2016 at 3:03pm
What "operations"? How are you going to prevent that a user chooses the wrong completion status accidentally? 
Anyway, that's the workflow operation. You can always create a new status in the next block called "rollback" and then when that status is chosen, your workflow goes back to the previous block to recreate the original task. 
Back to Top
Adrian Morawiec View Drop Down
New Member
New Member
Avatar

Joined: 29 Dec 2015
Posts: 22
Post Options Post Options   Quote Adrian Morawiec Quote  Post ReplyReply Direct Link To This Post Posted: 17 Nov 2016 at 9:48am
Unfortunately, my client doesn't likes your solution with extra back arrow.
He wants a Cancel button AFTER get all informations about next diagram block and BEFORE change status of a task;
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down