yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
Method Update (MDSObjectInfos objectinfos, MDSObjectInfo infocurrentdataset)
{
  Description:
  [*
    The attributes of `this` might be outdated, because the status of the dataset that is attached to `this` might have changed while user was working in another dataset.
    The attributes of `this` that are updated in this method are mainly used for the 'Status' image attribute column. This image attribute column is used in the 'Snapshots' and 'Replannable snapshots' forms.
  *]
  TextBody:
  [*
    datasetinfo := objectinfos.Find( this.DatasetName() );
    if( isnull( datasetinfo ) )
    {
      // The snapshot of a quick dataset copy is created before the dataset copy creation method is called, because this method is called reactively.
      // Therefore, objectinfos.Find( snapshot.DatasetName() ) will be null when it is called between the creation of the snapshot and the reactive dataset copy call. 
      // Without the below if-statement, snapshot.IsDatasetDeletedUnspecifiedReason() would be set to true, which would result in various issues.
      // For example, a precondition would be set on the 'Select dataset' context menu item of a snapshot.
      if( this.HasCreatedDataset() 
          // Dataset copy transactions have a higher priority than normal transactions, so the dataset copy creation method should typically be called after a few seconds have passed.
          or DateTime::ActualTime() - this.TimeStamp() > this.Run().Optimization().UpdateReplannableSnapshotsDelayDuration() 
          )  
      {
        // The dataset has been deleted. This might have happened in other datasets. The current dataset does not know why.
        this.IsDatasetDeletedUnspecifiedReason( true );
        this.IsDatasetLoaded( false );
      }
    }
    else
    {
      this.IsDatasetLoaded( datasetinfo.IsLoaded() );
      // When two datasets are being copied at the same time, then the HasCreatedDataset attribute of the first dataset is false when opening the second dataset.
      // Therefore, the HasCreatedDataset attribute should be updated. 
      this.HasCreatedDataset( true );
    }  
    this.IsDatasetSelected( infocurrentdataset.Name() = this.DatasetName() );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}