yypsybs
2023-09-09 3cb5a54def670d97301f07170fcaad213bfc54f2
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 SynchronizeDemoSupplyChainOverview (
  String foldername
)
{
  Description: 'Load sales demo supply chain overview xml file upon sales demo scenario creation'
  TextBody:
  [*
    // Retrieve xml file path
    dataPath := GlobalParameters_MP::GetDefinitonsDir();
    scoPath := dataPath + "\" + GlobalParameters_MP::GetSalesDemoPath() + "\" + foldername + "\" + MacroPlan::SupplyChainOverviewXMLFileName();
    scoPath := scoPath.ReplaceAll( '/', '\' );
    scv := this.CreateSupplyChainView( GlobalParameters_MP::GetUserName() );
    feedback_o := '';
    
    
    
    // After scv has been created, its OnCreate will create StockingPoint nodes, Product nodes and Unit nodes
    // this propagate is mainly used to propagate the declarative attributes in the nodes
    Transaction::Transaction().Propagate();
    
    // Construct OSFile and execute import
    try
    {
      xml := OSFile::Construct( scoPath );
      xml.Open();    
      if( xml.IsOpen() )
      {
        xmlString := xml.ReadBinary().ToString().Erase( 0, 1 );    
        scv.ImportFromXML( xmlString, feedback_o );
        // Also store the view into default so that it can be restored
        this.DefaultSupplyChainViewXMLString( xmlString );
      }
    }
    onerror
    {
      debuginfo( 'XML file not found' );
      debuginfo( 'File path: ' + scoPath );
    }
  *]
}