| Quintiq file version 2.0 | 
| #parent: #root | 
| Method ExecuteUserImportProfiles ( | 
|   MacroPlan macroplan, | 
|   BaseImportProfiles importprofiles, | 
|   BaseImportObjectGroupInProfiles uniqueimportobjectgroupinprofiles, | 
|   Boolean isrefreshfromsource, | 
|   Boolean isoverwritemanualconfig, | 
|   BinaryValues binarydatas, | 
|   Strings brokers | 
| ) | 
| { | 
|   Description: 'Execute user import profiles' | 
|   TextBody: | 
|   [* | 
|     progress( 'Executing import profiles...', DateTime::ActualTime() ); | 
|     // Initialize synchronization status and reset error message | 
|     if( not isnull( macroplan ) ) | 
|     { | 
|       macroplan.InitializeSynchronizationStatus(); | 
|     } | 
|      | 
|     // Establish relationship for last executed user import profiles | 
|     this.SetLastExecutedUserImportProfiles( importprofiles ); | 
|     // Clean up all selected import profile's error message before we start executing the profiles | 
|     this.ClearAllUserImportProfilesErrorMessages(); | 
|      | 
|     dsspaceExec := this->AsVoid()->GroupAll(); | 
|      | 
|     if( isrefreshfromsource ) | 
|     { | 
|       // Execute the brokers for the selected set of uniqueimportobjectgroupinprofiles and non-messsage based integration | 
|       traverse( uniqueimportobjectgroupinprofiles, Elements, e,  | 
|                 not e.IsMessage() | 
|               ) | 
|       { | 
|         if( e.IsExcel() or e.IsDatabase() ) | 
|         { | 
|           e.Execute( binarydatas, brokers ); | 
|         } | 
|       }   | 
|       //required to refresh the IsValid attribute calculation after db import. | 
|       Transaction::Transaction().Propagate(); | 
|      | 
|       //moved into this if statement because we only need to refresh DB error when the external data changes. | 
|       this.CreateDatabaseSyncErrorObjects(); | 
|     } | 
|      | 
|     dsspaceExec->( exec ) | 
|     { | 
|       if( not isnull( macroplan ) ) | 
|       { | 
|         this.UpdateSalesDemoDataYear(); | 
|          // Switch to macroplan.MPSyncStartSynchronize to run sync in asynchronous way | 
|         macroplan.MPSyncStartSynchronize( isoverwritemanualconfig, | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_SupplyChainParameters() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_GlobalParameters() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Periods() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Products() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_InventorySpecifications() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_InventorySupplies() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Products() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Forecast() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Campaigns() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Entities() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Costs() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Lanes() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Routings() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Capacities() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_SupplySpecifications() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Capacities() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Recipes() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Actuals() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Feedback() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_Actuals() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_ServiceLevels() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_OptimizerPuzzle() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_PostponementSpecAndFulfillmentRestriction() ), | 
|                                           MPSync::GetImportObjectGroupInProfileIncludeExclude( uniqueimportobjectgroupinprofiles, MPSyncUtility::ID_ObjectGroup_CustomerOrder() ) ); | 
|          | 
|         progress( 'Post-processing import from MPSync...', DateTime::ActualTime() ); | 
|          | 
|         if ( isrefreshfromsource ) | 
|         { | 
|           this.LastImportTime( DateTime::Now() );   | 
|         } | 
|         // Update the last refreshed and or executed time for each import profiles | 
|         traverse( importprofiles, Elements, e ) | 
|         { | 
|           if( isrefreshfromsource ) | 
|           { | 
|             e.LastRefreshed( DateTime::Now() ); | 
|           } | 
|           e.LastExecuted( DateTime::Now() ); | 
|         } | 
|       } | 
|     } | 
|      | 
|     // Handle exception | 
|     dsspaceExec->Exception()->( ex ) | 
|     { | 
|       macroplan.UpdateSynchronizationErrorStatus( ex ); | 
|     } | 
|   *] | 
| } |