Quintiq file version 2.0
#parent: #root
Method UploadFiles (
  structured[String] filenames
) id:Method_DialogEDIImport_UploadFiles
{
  #keys: '[132444.0.94011033]'
  Body:
  [*
    // Upload files to server
    importpath := EditorImportExportPath.Text();
    missingfiles := construct( Strings );
    uploadedfiles := construct( Strings );
    
    info('uploading files...');
    traverse( filenames, Elements, filename )
    {
      filepath := importpath + filename;
      info('2 Import path: [', filepath ,']' );
    
      if( Application.ClientFileExists( filepath ) )
      {
        clientfile := Application.GetClientFile( filepath );
        Application.TransferFromClient( clientfile );
        clientfilename := clientfile.LocalFileName();
        modeldatamanager := ExternalModelDataManager::Create();
        uploaded := modeldatamanager.Upload( clientfilename, filename );
    
        if ( uploaded )
        {
          uploadedfiles.Add( filepath );
        }
        Application.RemoveLocalCopy( clientfile );
      }
      else
      {
        missingfiles.Add( filepath );
      }
    }
    
    if ( uploadedfiles.Size() > 0 )
    {
      info('The following files have been loaded:' );
      traverse( uploadedfiles, Elements, e )
      {
        info(e);
      }
    }
    
    if ( missingfiles.Size() > 0 )
    {
      info('');
      info('(!) The following files were missing:' );
      traverse( missingfiles, Elements, e )
      {
        info(e);
      }
      info('Data for the missing files will be loaded from [Default server data]');
    }
    info('------------------------------')
  *]
}
