yanweiyuan3
2023-08-09 fd693f0faf305ec98d7ea03e09fe6787817e71d7
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
Quintiq file version 2.0
#parent: #root
Method DownloadFiles (
  structured[String] filenames
) id:Method_DialogEDIExportDEV_DownloadFiles
{
  #keys: '[108486.1.1111202994]'
  Body:
  [*
    // Download files to client
    exportpath := EditorImportExportPath.Text()
    datasetname := ExternalMDSEditor::Editor().ObjectInfo( MacroPlan.MDSID() ).Name();
    downloadfiles := construct( Strings );
    
    traverse( filenames, Elements, filename )
    {
      filepath := exportpath + filename;
      clientfile := Application.GetClientFile( filepath );
      clientfilename := clientfile.LocalFileName();
      modeldatamanager := ExternalModelDataManager::Create();
      if( filename.StartsWith( 'SM' ) )
      {
        filename := filename.InsertBefore( '_ObjectMDS_' + 'ScenarioManager', '.xlsx' );
      }
      else
      {
        filename := filename.InsertBefore( '_ObjectMDS_' + datasetname, '.xlsx' );
      }
    
      if( not modeldatamanager.FileExists( filename ) )
      {
        error( filename, ' not found in server data' )
      }
    
    
      downloaded := modeldatamanager.Download( filename, clientfilename );
      Application.TransferToClient( clientfile );
    
      if ( downloaded )
      {
        downloadfiles.Add( filepath );
      }
      Application.RemoveLocalCopy( clientfile );
    }
    
    info('Downloaded files:', downloadfiles.Size() );
    
    if ( downloadfiles.Size() > 0 )
    {
      info('The following files have been exported:' );
      traverse( downloadfiles, Elements, e )
      {
        info("'", e, "'");
      }
    }
    info('------------------------------')
  *]
}