admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
48
Quintiq file version 2.0
#parent: #root
Method ImportXML (
  BinaryValue xml,
  Scenario scenario
)
{
  Description: 'Import data from XML'
  TextBody:
  [*
    // Import from XML
    tempfilename := OS::TempFilename( OS::TempPath() );
    progress( 'Creating temporary xml', DateTime::ActualTime() );
    tempfile := OSFile::Construct( tempfilename );
    if( not isnull( tempfile ) )
    {
      tempfile.ReadWriteMode( 'ReadWrite' );
      tempfile.Open();
      tempfile.WriteBinary( xml );
      tempfile.Flush();
      tempfile.Close();
    
      progress( 'Delete all data', DateTime::ActualTime() );
      this.DeleteAllData();
    
      progress( 'Propagation', DateTime::ActualTime() );
      // Recalculate the declarative attributes and relations after data deletion.
      Transaction::Transaction().Propagate();
    
      info( 'Import from xml file', DateTime::ActualTime() );
      XMLIO::Import( tempfilename, this );
      
      progress( 'Removing xml file', DateTime::ActualTime() );
      OS::RemoveFile( tempfilename );
    
      //re-create supply chain view in case it is deleted (only happens in thin client)
      this.CreateSupplyChainView( GlobalParameters_MP::GetUserName() );
    }
    
    if( not isnull(  this.PeriodParameter_MP() ) )
    {
      progress( 'Synchronizing periods', DateTime::ActualTime() );
      this.CalculateKPIScore( false );
    }
    
    this.ScenarioName( scenario.Name() );
  *]
}