yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Quintiq file version 2.0
#parent: #root
Method Execute (LibOpt_Task parent, LibOpt_Scope scope) as stream[JSON]
{
  Description: 'This method sends the given `LibOpt_Task` and `LibOpt_Scope` to the destination'
  TextBody:
  [*
    subtask := null( LibOpt_Task );
    if( isnull( parent ) )
    {
      run := this.Destination().Run();
      subtask := LibOpt_Task::Create( run, this.Destination(), this, scope, null( LibOpt_Task ) );
    }
    else
    {
      // Stop continuing the breakpoint on the parent
      parent.BreakpointEvent( relflush );
      
      subtask := parent.SubTask( scope, this.Destination(), this );
    }
    
    transporter := this.TaskTransporter();
    
    if( isnull( this.Destination() ) )
    {
      origin := this.GetOrigin()
      error( Translations::LibOpt_Link_Destination_Null( origin.Name() ) );
    }
    
    // Conditionally create a dataset copy.
    // If transporter.InOneTransaction is true, then the next task will run in one transaction, so user errors or rollbacks might occur.
    // Therefore, the dataset should be created in a robust way (so the last argument = true). 
    // If transporter.InOneTransaction is false, then we can create a quick copy, because the current transaction ends shortly after this method ends (so the last argument = false).
    LibOpt_DatasetCopyConditional::CopyDatasetConditionally( LibOpt_Component::ComponentPosition_Initialize(), subtask, transporter.InOneTransaction() );
    
    return transporter.Send( subtask );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}