yanyuan
2023-11-10 143ef74e2eeee697ac8fda3d9032a790fbb4e146
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
Quintiq file version 2.0
#parent: #root
Method ImportFromJSON (String integratorID_i, String dataTransformationID_i, Boolean doSynchronize_i) as Boolean id:Method_LibDIF_GlobalState_ImportFromJSON
{
  #keys: '[131092.1.704922554]'
  Body:
  [*
    // Import data from JSON.
    success := false;
    
    // Ask the user for the filename.
    filename := Application.GetOpenFileName( "json" );
    
    if( filename <> "" )
    {
      // Make sure that the Integration-dataset is selected.
      if( this.EnsureIntegrationDataset() )
      {
        json := Application.ReadTextFile( filename );
    
        // Call the QIntegrator to import the data as integration objects.
        // Synchronize the data if applicable.
        api := this.GetIntegrationAPI();
        if( not isnull( api ) )
        {
          if( doSynchronize_i )
          {
            api.ImportFromJSONAndSynchronize( json, integratorID_i, dataTransformationID_i );
          }
          else
          {
            api.ImportFromJSON( json, integratorID_i, dataTransformationID_i );
          }
    
          success := true;
        }
      }
    }
    
    return success;
  *]
}