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
Quintiq file version 2.0
#parent: #root
StaticMethod CanSetAvailable (
  output String feedback_o,
  ScenarioManager scenariomanager,
  ScenarioNodes nodes,
  Boolean isDatasetStoreEnabled
) remote as Boolean
{
  Description: 'Check the selected nodes if they can be set available'
  TextBody:
  [*
    scenarios := ScenarioNode::GetScenarios( nodes );
    resourcemaanger := scenariomanager.ResourceManager_SM();
    
    // This is to check for folders and selected nodes
    invalidScenario := select( nodes, Elements, e, not e.CanSetAvailable( isDatasetStoreEnabled, feedback_o ) );
    
    // This is to check all scenarios in the folder
    if( isnull( invalidScenario ) )
    {
      activeScenario := selectset( scenariomanager, ScenarioMP, scenario, true, scenario.IsLoaded() or scenario.IsLoadingInProgress() );
      
      selectedInactiveScenario :=  selectset( scenarios, Elements, e, not e.IsLoaded() and not e.IsLoadingInProgress() )
    
      isValid := not scenariomanager.IsSizingParameterOn()
                 or ( activeScenario.Size() + selectedInactiveScenario.Size() ) <= resourcemaanger.MaxNrOfOnlineScenario();
      
      if( not isValid )
      {
        feedback_o:= Translations::Scenario_CanSetAvailable_ExceedTotalNrAllowedOnline( resourcemaanger.MaxNrOfOnlineScenario() )
      }
    }
    
    return feedback_o = '';
  *]
}