lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
40
41
42
43
44
45
46
47
48
49
50
51
Quintiq file version 2.0
#parent: #root
Method DoOperation (LibOpt_Task task) as stream[JSON]
{
  TextBody:
  [*
    result := stream[JSON]::Success();
    
    if( this.Run().HasSnapshots() )
    {
      task.SnapshotComponent().PrecisionTimeStampStartComponent( OS::PrecisionCounter() / OS::PrecisionCounterFrequency() );
    }
    
    if( task.CanContinue() )
    {
      this.NrTimesCalled( this.NrTimesCalled() + 1 );
      transaction := LibOpt_CurrentTransaction::GetCurrentTransaction( this );
      
      if( transaction.IsSafe() )
      {
        istaskregistered := transaction.BeforeMethodCall_ExistingSafeTransaction( task );
        // A user error might occur in Operation or in other methods called by Operation. 
        // However, transaction.IsSafe() is true, so we are inside a try{...} block. We have also called BeforeMethodCall_ExistingSafeTransaction. The error is therefore handled gracefully. 
        result := this.Operation( task );
        transaction.AfterMethodCall_ExistingSafeTransaction( task, istaskregistered );
      }
      else
      {
        try
        {
          istaskregistered := transaction.BeforeMethodCall_TryBlock( task );
          // A user error might occur in Operation or in other methods called by Operation. 
          // However, we are inside a try{...} block. We have also called BeforeMethodCall_TryBlock. The error is therefore handled gracefully. 
          result := this.Operation( task );
          transaction.AfterMethodCall_TryBlock( task, task.Run(), istaskregistered );
        }
        onerror
        {
          transaction.OnError( e );
        }
        onfailure
        {
          transaction.OnFailure( e );
        }
      }
    }
    
    return result;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}