Quintiq file version 2.0
#parent: #root
Method ImportDataFromExcel (
  internal[GUIComponent] parent
) id:Method_DialogEDIImport_ImportDataFromExcel
{
  #keys: '[132444.0.94011019]'
  Accessibility: 'Public'
  Body:
  [*
    // Import data from excel
    // UserData is set by text box responses depending on whether there is a user-specified path.
    importpath := ifexpr( EditorImportExportPath.UserData() = 0 , EditorImportExportPath.Text(), '' );
    
    binaryvalues := construct( BinaryValues );
    broker := construct( Strings );
    smbinaryvalues := construct ( BinaryValues );
    smbrokers := construct( Strings );
    fileNames := construct( Strings );
    smFileNames := construct( Strings );
    
    isbinary := importpath <>'';
    //format path to correct format
    Dialog.FormatPath( importpath );
    
    is3DDrive := RadioButtonGroupExcelOrDataManager.BoundValue() = MPSyncUtility::ID_Source_3DDrive();
    missingFiles := construct( Strings );
    if( is3DDrive or importpath <> '' )
    {
      Dialog.ImportFiles( importpath, binaryvalues, broker, smbinaryvalues, smbrokers, fileNames, smFileNames, missingFiles );
    }
    
    canimport := true;
    if ( missingFiles.Size() > 0 )
    {  
      canimport := false;
      MessageBox::Warning( Application, 
                           Translations::MP_Import_MissingFiles( missingFiles.ToString( ', ' ) ), 
                           'OK' );
    }
    
    if ( canimport and guard( binaryvalues.Size() >0, false ) )
    {
      // call synchronize
      MacroPlan.Synchronize( Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_SupplyChainParameters() ),   // general
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_GlobalParameters() ),        // globalparameters
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Periods() ),                 // periods
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_InventorySpecifications() ), // inventoryspecifications
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_InventorySupplies() ),       // inventorysupplies
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Products() ),                // products and disaggregation factor
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Forecast() ),             // salesdemands
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_ServiceLevels() ),           // servicelevels
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Campaigns() ),               // campaigns and transition types
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Entities() ),                // entities
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Costs() ),                   // entitiescosts
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Lanes() ),                   // lanes
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Routings() ),                // routings
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Capacities() ),              // stockingpointcapacities and unitcapacities
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_SupplySpecifications() ),    // supplyspecifications
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Recipes() ),                 // recipes
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Actuals() ),                 // actuals pispip and actual unit periods
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Feedback() ),                // feedbacks
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_OptimizerPuzzle() ),           // optimizer puzzles
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_PostponementSpecAndFulfillmentRestriction() ),           // Postponement Spec And Fulfillment Restriction
                             Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_CustomerOrder() ),           // Postponement Spec And Fulfillment Restriction
                             isbinary,
                             binaryvalues,
                             broker,
                             is3DDrive,
                             DataHolderFileItems.Data(),
                             fileNames
                           );  
    }
    
    if ( canimport and guard( smbinaryvalues.Size() >0, false ) )
    {
        ScenarioManager.Import( Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Strategies() ), // strategies
                                Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Accounts() ),   // accounts
                                Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_Bookmarks() ),  // bookmarks
                                Dialog.GetIsIncluded(MPSyncUtility::ID_ObjectGroup_KPISetting() ), // kpi settings
                                smbinaryvalues.Copy(), smbrokers, is3DDrive, DataHolderFileItems.Data(), smFileNames );
    
        MPSync.Import( Dialog.GetIsIncluded( MPSyncUtility::ID_ObjectGroup_ImportProfiles() ),
                       smbinaryvalues, smbrokers, is3DDrive, DataHolderFileItems.Data(), smFileNames ); 
    }
  *]
  UseInheritedAccessibility: false
}
