| Quintiq file version 2.0 | 
| #parent: #root | 
| Method Synchronize ( | 
|   Boolean importgeneral, | 
|   Boolean importglobalparameters, | 
|   Boolean importperiods, | 
|   Boolean importinventoryspecifications, | 
|   Boolean importinventorysupplies, | 
|   Boolean importproducts, | 
|   Boolean importsalesdemands, | 
|   Boolean importservicelevel, | 
|   Boolean importcampaigns, | 
|   Boolean importentities, | 
|   Boolean importentitycosts, | 
|   Boolean importlanes, | 
|   Boolean importroutings, | 
|   Boolean importcapacities, | 
|   Boolean importsupplyspecifications, | 
|   Boolean importrecipes, | 
|   Boolean importactuals, | 
|   Boolean importfeedbacks, | 
|   Boolean importoptimizerpuzzles, | 
|   Boolean importpostponementandfulfillmentrestriction, | 
|   Boolean importcustomerorder, | 
|   Boolean isimportbinary, | 
|   BinaryValues binaryValues, | 
|   Strings brokers, | 
|   Boolean is3DDrive, | 
|   FileItems fileItems, | 
|   Strings fileNames | 
| ) | 
| { | 
|   Description: 'Synchronizes model with external data' | 
|   TextBody: | 
|   [* | 
|     // Flag the MP dataset as is importing data | 
|     this.IsImporting( true ); | 
|     this.ImportMessage( '' ); | 
|      | 
|     // Flush all fixed/non-ignore sanity check message before import | 
|     SanityCheckMessage::DeleteAllShownMessages( this ); | 
|      | 
|     periods                 := BinaryValue::Construct(); | 
|     uoms                    := BinaryValue::Construct(); | 
|     currencies              := BinaryValue::Construct(); | 
|     priorities              := BinaryValue::Construct() | 
|     shiftpatterns           := BinaryValue::Construct(); | 
|     globalparameter         := BinaryValue::Construct(); | 
|     salesdemand             := BinaryValue::Construct(); | 
|     postponesalesdemandcost := BinaryValue::Construct(); | 
|     groups                  := BinaryValue::Construct(); | 
|     units                   := BinaryValue::Construct(); | 
|     stockingpoints          := BinaryValue::Construct(); | 
|     salessegments           := BinaryValue::Construct(); | 
|     products                := BinaryValue::Construct(); | 
|     lanes                   := BinaryValue::Construct(); | 
|     routings                := BinaryValue::Construct(); | 
|     campaigns               := BinaryValue::Construct(); | 
|     servicelevels           := BinaryValue::Construct(); | 
|     inventoryspecifications := BinaryValue::Construct(); | 
|     stockingpointcapacities := BinaryValue::Construct(); | 
|     supplyspecifications    := BinaryValue::Construct(); | 
|     entitiescost            := BinaryValue::Construct(); | 
|     unitcapacities          := BinaryValue::Construct();   | 
|     unitavailabilities      := BinaryValue::Construct();   | 
|     transportcapacities     := BinaryValue::Construct(); | 
|     transportavailabilities := BinaryValue::Construct(); | 
|     unitcalendars           := BinaryValue::Construct();   | 
|     recipes                 := BinaryValue::Construct();   | 
|     actualpispips           := BinaryValue::Construct();    | 
|     actualunitperiods       := BinaryValue::Construct();    | 
|     feedbacks               := BinaryValue::Construct();    | 
|     inventorysupplies       := BinaryValue::Construct(); | 
|     optimizerpuzzles        := BinaryValue::Construct(); | 
|     customerorder           := BinaryValue::Construct(); | 
|      | 
|     postponementspecandfulfillment := BinaryValue::Construct(); | 
|      | 
|     if( is3DDrive ) | 
|     { | 
|        binaryValues := MPSyncUtility::ImportFrom3DDrive( fileNames, fileItems ); | 
|     } | 
|      | 
|     this.ImportBinaryData( binaryValues, brokers, periods, uoms, currencies, priorities, shiftpatterns,  | 
|                            globalparameter, salesdemand, postponesalesdemandcost, groups, units, | 
|                            stockingpoints, salessegments, products, lanes, routings, | 
|                            campaigns, servicelevels, inventoryspecifications, stockingpointcapacities,  | 
|                            supplyspecifications, inventorysupplies, entitiescost, | 
|                            unitcapacities, unitavailabilities, transportcapacities, transportavailabilities, | 
|                            unitcalendars, recipes, actualpispips, feedbacks, actualunitperiods, optimizerpuzzles, postponementspecandfulfillment, customerorder ); | 
|      | 
|     /* ======================================================================================= | 
|                       NOTE! The sequence of importing is IMPORTANT | 
|     Objects own by MacroPlan and without foreign key reference, therefore will be imported first. | 
|     ==========================================================================================*/ | 
|     if( importgeneral )               // Currencies, UOMs, Priorities, Shift patterns | 
|     { | 
|       // info('import general') | 
|       this.ImportGeneral( uoms.AsBinaryData(), currencies.AsBinaryData(), priorities.AsBinaryData() ); | 
|       // info('import general ok') | 
|     } | 
|      | 
|     // The import statements are in the sequence where owners will first be imported | 
|     if( importglobalparameters )      // Global Parameters | 
|     { | 
|       this.ImportGlobalParameters( globalparameter.AsBinaryData() );   | 
|     } | 
|      | 
|     if( importperiods )               // Period specifications, Period definitions, Period parameters | 
|     { | 
|       // info('import periods') | 
|       this.ImportPeriods( periods.AsBinaryData() ); | 
|       // info('import periods ok') | 
|     } | 
|      | 
|     if( importentities )              // Groups, Units, Stocking points, Sales segments, Stocking point units | 
|     { | 
|       // info('import entities') | 
|       this.ImportEntities( groups.AsBinaryData(), stockingpoints.AsBinaryData(), units.AsBinaryData(), salessegments.AsBinaryData() ); | 
|       // info('import entities ok') | 
|     } | 
|      | 
|     if( importproducts )              // Products, Product in stocking points | 
|     { | 
|       // info('import products') | 
|       this.ImportProducts( products.AsBinaryData() ); | 
|       // info('import products ok') | 
|     } | 
|      | 
|     if( importsalesdemands )            // Sales demands, Postponed sales demand costs. | 
|     { | 
|       // info('import sales demands') | 
|       this.ImportSalesDemands( salesdemand.AsBinaryData(), postponesalesdemandcost.AsBinaryData() ); | 
|       // info('import sales demands ok') | 
|     }   | 
|      | 
|     if( importcustomerorder )            // Customer order | 
|     { | 
|       // info('import customer orders') | 
|       this.ImportCustomerOrder( customerorder.AsBinaryData() ); | 
|       // info('import customer orders ok') | 
|     }   | 
|       | 
|     if ( importpostponementandfulfillmentrestriction ) | 
|     {  | 
|       this.ImportPostponementSpecAndFulfillmentRestriction( postponementspecandfulfillment.AsBinaryData() ); | 
|     } | 
|      | 
|     /* ======================================================================================= | 
|                       NOTE! The sequence of importing is IMPORTANT | 
|     Objects own by entities and with foreign key reference, therefore need to be imported after entities had been imported. | 
|     ======================================================================================= */ | 
|     if( importlanes )                // Lanes | 
|     { | 
|       // info('import lanes') | 
|       this.ImportLanes( lanes.AsBinaryData() ); | 
|       // info('import lanes ok') | 
|     } | 
|      | 
|     if( importroutings )             // Routings, Routing steps, Operations | 
|     { | 
|       // info('import routings') | 
|       this.ImportRoutings( routings.AsBinaryData() ); | 
|       // info('import routings ok') | 
|     } | 
|      | 
|     /* ======================================================================================= | 
|                       NOTE! The sequence of importing is IMPORTANT | 
|     Objects own by Processes (Routing/Lane/LaneLeg/Operation) and with foreign key reference, therefore need to be imported after processes had been imported. | 
|     ======================================================================================= */ | 
|     if( importcampaigns )             // Campaign types, Campaigns, Operation in campaign types and Transitions | 
|     { | 
|       // info('import campaign') | 
|       this.ImportCampaigns( campaigns.AsBinaryData() ); | 
|       // info('import campaign ok') | 
|     } | 
|      | 
|     /* ======================================================================================= | 
|                       NOTE! The sequence of importing is IMPORTANT | 
|     Objects own by product/stocking point/unit and with foreign key reference, therefore need to be imported after entities had been imported. | 
|     ============================================================================================ */ | 
|     if( importservicelevel ) | 
|     { | 
|       this.ImportServiceLevels( servicelevels.AsBinaryData() ); | 
|       //This method mainly to convert data from 2016 Q4 to 2017 Q1 service level that with isusedForPlanningFulfillment to fulfillment target,  | 
|       //once the data converted the method can be removed | 
|       ServiceLevel::ConvertToFulfillmentGoal( this, true ); | 
|     } | 
|      | 
|     if( importinventoryspecifications )   // Inventory specifications | 
|     { | 
|       // info('import inventory spec') | 
|       this.ImportInventorySpecifications( inventoryspecifications.AsBinaryData() ); | 
|       // info('import inventory spec ok') | 
|     } | 
|      | 
|     if( importinventorysupplies )         // Inventory supplies and inventory supply cost | 
|     { | 
|       // info('import supplies') | 
|       this.ImportInventorySupplies( inventorysupplies.AsBinaryData() ); | 
|       // info('import supplies ok') | 
|     } | 
|      | 
|     if( importcapacities )   // Stocking point capacities | 
|     { | 
|       // info('import sp capacities') | 
|       this.ImportStockingPointCapacities( stockingpointcapacities.AsBinaryData() ); | 
|       // info('import sp capacities ok') | 
|     } | 
|      | 
|     if( importsupplyspecifications )      // Supply specifications | 
|     { | 
|       // info('import supply specifications') | 
|       this.ImportSupplySpecifications( supplyspecifications.AsBinaryData() ); | 
|       // info('import supply specifications ok') | 
|     } | 
|      | 
|     if( importentitycosts )             // Unit costs, Lane costs, Lane leg costs, Operation costs, Stocking point costs, PISP costs  | 
|     { | 
|       // info('import inventory costs') | 
|       this.ImportEntityCosts( entitiescost.AsBinaryData() ); | 
|       // info('import inventory costs ok')a | 
|     } | 
|      | 
|     if( importcapacities )        // Unit capacities, Unit availabilities, Unit calendar elements. | 
|     { | 
|       // info('import unit capacities') | 
|       this.ImportUnitCapacities( unitcapacities.AsBinaryData(),  | 
|                                  unitavailabilities.AsBinaryData(),  | 
|                                  transportcapacities.AsBinaryData(),  | 
|                                  transportavailabilities.AsBinaryData(), | 
|                                  unitcalendars.AsBinaryData(),  | 
|                                  shiftpatterns.AsBinaryData() ); | 
|       // info('import unit capacities ok') | 
|     } | 
|      | 
|     if( importrecipes )                   // Recipes | 
|     { | 
|       // info('import recipes') | 
|       this.ImportRecipes( recipes.AsBinaryData() ); | 
|       // info('import recipes ok') | 
|     } | 
|      | 
|     if( importactuals )          // Actual product in stocking in period and actual unit periods | 
|     { | 
|       // info('import actual unit periods') | 
|       this.ImportActualProductInStockingPointInPeriods( actualpispips.AsBinaryData() ); | 
|       // info('import actual unit periods ok') | 
|       // info('import actual unit periods') | 
|       this.ImportActualUnitPeriods( actualunitperiods.AsBinaryData() ); | 
|       // info('import actual unit periods ok') | 
|     } | 
|      | 
|     if( importoptimizerpuzzles )         // Optimizer puzzles | 
|     { | 
|       // info('import optimizer puzzles') | 
|       this.ImportOptimizerPuzzles( optimizerpuzzles.AsBinaryData() ); | 
|       // info('import optimizer puzzles ok') | 
|     } | 
|      | 
|     this.InitializeNonEntitiesDataAfterImport( importsalesdemands, importcustomerorder, importproducts, importentities, importroutings, importperiods ); | 
|      | 
|     if( importglobalparameters ) | 
|     { | 
|       this.InitializeGlobalParameterAfterImport(); | 
|     } | 
|      | 
|     if( importentitycosts ) | 
|     { | 
|       this.InitializeEntityCostsAfterImport(); | 
|     } | 
|      | 
|     if( importfeedbacks )          // Feedbacks | 
|     { | 
|       // info('import feedbacks') | 
|       this.ImportFeedbacks( feedbacks.AsBinaryData() ); | 
|       // info('import feedbacks') | 
|     } | 
|      | 
|     this.UpdateUnitCalendar(); | 
|     // Update changes, Calculate KPI score | 
|     this.CalculateKPIScore( false ); | 
|      | 
|     // Flag the MP dataset as not importing | 
|     this.IsImporting( false ); | 
|     this.IsImportSucceed( this.ImportMessage() = '' ); | 
|   *] | 
| } |