yanweiyuan3
2023-10-27 d1d15b61dfcf7fd0f800b32359f082cf580ed556
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
Quintiq file version 2.0
#parent: #root
Method Update () id:Method_SCK_ButtonSanityCheckBase_Update
{
  #keys: '[132254.0.10701001]'
  Body:
  [*
    // PRIVATE - Update the image and issue count on the sanity check button 
    
    // Pick one of the severities with highest level from all managers (from all datasets)
    sanity_panel := this.GetPanelSanityCheck();
    all_highest_severities := selectset( sanity_panel.DataHolderSanityManagers().Data(), Elements.HighestViolatedSeverity, svr, true );
    max_level := max( all_highest_severities, Elements, svr, true, svr.Level() );
    picked_highest_severity := select( all_highest_severities, Elements, svr, svr.Level() = max_level );
    
    // Determine the icon and nr of violations to show in the sanity check button
    picked_manager := select( sanity_panel.DataHolderSanityManagers().Data(), Elements, mgr, true );
    icon := "SMILEY-GREEN";
    tooltip := guard( picked_manager.TRANSLATION_SanityCheck_Passed(), "" );
    nr_of_violations := 0;
    if ( not isnull( picked_highest_severity ) )
    {  
      icon := picked_highest_severity.Icon();  
      tooltip := picked_manager.TRANSLATION_SanityCheck_Failed( picked_highest_severity );
     //get all the highest violated severity and sum the nrofviolationnotignored
      nr_of_violations := sum( sanity_panel.DataHolderSanityManagers().Data(), 
                               Elements.HighestViolatedSeverity, 
                               hvs, 
                               hvs.Level() = max_level, 
                               hvs.NrOfViolationsNotIgnored() );
    }
    
    // Update the button
    this.SetProperty( "Image", icon );
    this.SetProperty( "Tooltip", tooltip );
    this.SetProperty( "Text", ifexpr( nr_of_violations > 0, [String] nr_of_violations, "" ) );
  *]
}