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
52
53
54
55
56
57
58
59
60
61
62
Quintiq file version 2.0
#parent: #root
Method PostProcessSanityCheckMessage
{
  TextBody:
  [*
    // Post-process all created SanityCheckMessages to trim the number of messages
    // Get the maximum number of messages that can be shown
    msglimit := this.MacroPlan().GlobalParameters_MP().SanityCheckLimit();
    
    // Get all SanityCheckMessages
    allmessages := selectset( this, SanityCheckMessage, msg, true, true );                                                                                   
    
    shownmessage := construct( SanityCheckMessages );
    
    currentmsgcount := 0;
    
    // Traverse all SanityCheckMessages of data issue category and add them to the shownmessage set if the message count hasn't exceeded to limit yet
    traverse( this, SanityCheckMessage, msg, msg.CategoryLevel() = SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue() and currentmsgcount < msglimit )
    {
      shownmessage.Add( msg );
      currentmsgcount++;
    } 
    
    // Traverse all SanityCheckMessages of data warning category and add them to the shownmessage set if the message count hasn't exceeded to limit yet
    traverse( this, SanityCheckMessage, msg, msg.CategoryLevel() = SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning() and currentmsgcount < msglimit )
    {
      shownmessage.Add( msg );
      currentmsgcount++;
    } 
    
    // Traverse all SanityCheckMessages of planning issue category and add them to the shownmessage set if the message count hasn't exceeded to limit yet
    traverse( this, SanityCheckMessage, msg, msg.CategoryLevel() = SanityCheckCategoryLevel::GetSanityCheckCategoryPlanningIssue() and currentmsgcount < msglimit )
    {
      shownmessage.Add( msg );
      currentmsgcount++;
    }
    
    // Traverse all SanityCheckMessages of planning warning category and add them to the shownmessage set if the message count hasn't exceeded to limit yet
    traverse( this, SanityCheckMessage, msg, msg.CategoryLevel() = SanityCheckCategoryLevel::GetSanityCheckCategoryPlanningWarning() and currentmsgcount < msglimit )
    {
      shownmessage.Add( msg );
      currentmsgcount++;
    }
    
    // Traverse all SanityCheckMessages of unclassified error category and add them to the shownmessage set if the message count hasn't exceeded to limit yet
    traverse( this, SanityCheckMessage, msg, msg.CategoryLevel() = SanityCheckCategoryLevel::GetSanityCheckCategoryUnclassifiedError() and currentmsgcount < msglimit )
    {
      shownmessage.Add( msg );
      currentmsgcount++;
    }
    
    // Get messages to be deleted
    msgtoclear := allmessages.Difference( shownmessage );
    
    // Delete the selected set of messages
    traverse( msgtoclear, Elements, ele )
    {
      ele.Delete();
    }
  *]
}