hongji.li
2023-11-07 1a1ba3ad5ed9e4380185aa1ccad20204a0e5f115
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
Quintiq file version 2.0
#parent: #root
Method CopyDataset () as LibOpt_SnapshotReplannableCopyDataset
{
  Description:
  [*
    This method creates a copy of the current dataset. It also creates a `LibOpt_SnapshotReplannableCopyDataset` snapshot that will be shown in the 'Snapshots' and 'Replannable snapshots' forms.
    Note that if dataset copies are disabled (so if `this.Run().IsCreatingDatasetCopiesEnabled()` is `false`), then this method will return `null( LibOpt_SnapshotReplannableCopyDataset )`.
    If you want to log any additional information, please use `LibOpt_Task.Log( description, snapshot )` and pass the `LibOpt_SnapshotReplannableCopyDataset`.
    This will create a `LibOpt_SnapshotInfo` snapshot in the 'Snapshots' form. This snapshot is a child of the `LibOpt_SnapshotReplannableCopyDataset` snapshot. 
    When the `LibOpt_SnapshotReplannableCopyDataset` snapshot is null, then the `LibOpt_SnapshotInfo` snapshot is added as a child of the `task.SnapshotComponent()` snapshot.
  *]
  TextBody:
  [*
    // evr3 May-20-2020 (created)
    
    snapshot := null( LibOpt_SnapshotReplannableCopyDataset );
    
    // An AE should be able to start a run while being sure that no dataset copies are made. The AE can do this by setting the IsCreatingDatasetCopiesEnabled attribute to false. 
    // If you want to create a dataset copy regardless of the value of the IsCreatingDatasetCopiesEnabled attribute, then please consider calling LibOpt_DatasetCopyConditional::CopyDataset directly. 
    if( this.Run().IsCreatingDatasetCopiesEnabled() )
    {
      snapshot := LibOpt_DatasetCopyConditional::CopyDataset( this,
                                                              "AE Created", // By default, this string will be used as a suffix in the name of the created dataset. The sting will also show up in `Type` column of the snapshot form. 
                                                              true // Create a slow copy that is robust against errors and rollbacks in the same transaction.
                                                              ); 
    }
    
    return snapshot;
  *]
}