haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
Quintiq file version 2.0
#parent: #root
Method CreateStatisticsAndIssues
{
  Description: 'Create `LibOpt_Statistics` and `LibOpt_Issues` to highlight potential issues about this `LibOpt_Run`.'
  TextBody:
  [*
    LibOpt_Statistic::CleanUp( this );
    //in order for statistics to be calculated properly you must enable iterations
    //capture the HasIterations value here, turn on iterations and we will reset HasIterations at the end of this method
    iterationsBefore := this.HasIterations();
    if( not iterationsBefore )
    {
      this.HasIterations( true );
    }
    Transaction::Transaction().Propagate( method( LibOpt_Run, CreateStatistics ) );
    this.CreateStatistics();
    
    Transaction::Transaction().Propagate( method( LibOpt_Run, CreateIssues ) );
    
    // We may need to redo the partial propagate as there is a bug in the propagator
    failquick := 10;
    while( failquick >= 0 and
           exists( this, Statistic, statistic, statistic.CheckIsSummaryStatisticsRequired() = isnull( statistic.Summary() ) ) )
    {
      if( this.AutoFixPartialPropagateBug() )
      {
        info( 'Partial propagation incorrect' );
      }
      else
      {
        error( 'Partial propagation incorrect. Please contact support. In the meantime, have an ORS extend LibOpt_Run.AutoFixPartialPropagateBug to return true to attempt to fix it.' );
      }
      
      Transaction::Transaction().Propagate( method( LibOpt_Run, CreateIssues ) );
      failquick--;
    }
    
    if( failquick < 0 )
    {
      error( 'Could not recover from the incorrect partial propagation after 10 attempts. Please contact support.' );
    }
    
    this.CreateIssues();
    //reset has iterations
    this.HasIterations( iterationsBefore );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}