chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
Quintiq file version 2.0
#parent: ListRun
Response OnClick (
  structured[LibOpt_Run] selection
) id:Response_ListRun_MenuDeleteRun_OnClick
{
  #keys: '[139164.0.261222300]'
  Body:
  [*
    // Delete a Run
    // Update status of snapshots to ensure that the list that is shown in the messagebox is up to date.
    LibOpt_FormRun.Optimization().UpdateReplannableSnapshots();
    
    // Select the snapshots that were created by the runs that were started from the current dataset 
    datasetsnapshots := selectsortedset( selection,
                                         Elements.Snapshot.astype( LibOpt_SnapshotReplannableCopyDataset ),
                                         snapshot,
                                         not snapshot.IsDatasetDeleted()
                                         and snapshot.Run().MDSIDRun() = snapshot.MDSID(),
                                         not snapshot.IsDatasetLoaded(), // First show the loaded datasets
                                         snapshot.DatasetName() // Then sort on the name of the dataset. 
                                         ); 
    
    message := Translations::LibOpt_Run_MessageBox_DeleteRuns();
    if( datasetsnapshots.Size() > 0 )
    {
      datasetnamessorted := selectvalues( datasetsnapshots, // The sorting order from datasetsnapshots is maintained.
                                          Elements,
                                          snapshot,
                                          true,
                                          snapshot.DatasetName() 
                                          + ifexpr( snapshot.IsDatasetLoaded(), " - Dataset is loaded", "" )
                                          );
    
      // Add a list of all datasets that will be deleted to the message box.
      message := Translations::LibOpt_Run_MessageBox_DeleteRuns_And_Datasets( datasetnamessorted );            
    }
    
    if ( MessageBox::Question( this, message, '&Yes|&No' ) = 0 )
    {
      LibOpt_Run::Delete( selection );
    }
  *]
  CanBindMultiple: false
  DefinitionID => /ListRun/Responsedef_ListRun_Menu_OnClick
  Initiator: 'MenuDeleteRun'
}