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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Quintiq file version 2.0
#parent: #root
Method ImportNVT (BinaryValue binaryValue, LibWiz_InitProcess process) as LibWiz_InitProcess
{
  TextBody:
  [*
    // Import from binary file 
    
    canImport := binaryValue.Size() > 0;
    objImport := null( Object, owning );
    wizardType := this.GetType();
    processType := process.GetType();
    copyProcess := null( LibWiz_InitProcess );
    processName := process.Name();
    
    if( canImport )
    {
      binaryData := binaryValue.AsBinaryData();
      importNVT := NamedValueTreeBinaryIO::NamedValueTreeFromBinaryData( binaryData );
      nameValue := select( importNVT.Root().Children(), Elements, e, e.Name() = wizardType.Name() ); 
    
      canImport := not isnull( nameValue );
      if( canImport )
      {     
        // Flush old process
        process.Delete();
        
        // Generate new IDs on NVT in order to avoid type index error
        // when importing a workflow for a feature process that results from the export of another feature process 
        rootObj := select( importNVT.Root().Children(), Elements, e, true );
        LibWiz_NVTTools::GenerateIds( rootObj, '' );
    
        objImport := NamedValueTreeIO::ImportObject( importNVT, nameValue, wizardType );   
    
        wizardManager := objImport.astype( LibWiz_Wizard );
        if( processType = typeof( LibWiz_InitProcessBase ) )
        {
          copyProcess := guard( wizardManager.LibWiz_InitProcessBase(), null( LibWiz_InitProcessBase ) );
          canImport := not isnull( copyProcess );
          if( canImport )
          { 
            this.LibWiz_InitProcessBase( relmove, copyProcess.astype( LibWiz_InitProcessBase ) ); 
          }
        }
        else if( processType = typeof( LibWiz_InitProcessFeature ) )
        {
          copyProcess := select( wizardManager, LibWiz_InitProcessFeature, p, true );
          canImport := not isnull( copyProcess );
          if( canImport )
          {
            copyProcess.Name( processName ); // Keep old process name
            this.LibWiz_InitProcessFeature( relmove, copyProcess.astype( LibWiz_InitProcessFeature ) ); 
          }
        }
      }
    }
    
    if( not canImport )
    {
      info( 'Import of Wizard Process failed.' );
    }
    
    return copyProcess;
  *]
}