Connector Implementation: How Data Is Prepared for Synchronization
The preparation for data synchronization can be started by an automation schedule, as a result of a push notification, or manually if a user clicks Prepare on the toolbar of the Prepare Data (BC501000) form. The following sections describe the general steps involved in the preparation of data for synchronization, presented in the order in which they occur; the process diagram at the end of this topic shows the entire data preparation process.
Starting of the Data Preparation
When the data preparation is started (see Item 1 in the process diagram at the end of the topic), the system executes the ProcessSync() method of the PX.Commerce.Core.BCPrepareData graph. This method creates an instance of the connector class that corresponds to the store with which the synchronization is performed. The method also specifies the information about the current operation in a PX.Commerce.Core.ConnectorOperation object and runs the implementation of the IConnector.Process() method available in the connector class (Item 2).
For each entity that should be prepared for synchronization, the implementation of the IConnector.Process() method creates an instance of the processor class, initializes it with the information about the current operation, and runs its IProcessor.Process() method (Item 3), whose default implementation is available in the BCProcessorSingleBase<> class.
Fetching of the Data from MYOB Acumatica and the External System
The processor calls the FetchBucketsImport() (see Item 4a in the process diagram) or FetchBucketsExport() (Item 4b) method, depending on the sync direction of the entity. These methods do the following:
- Retrieve the information about the synchronization of the entity from the
BCEntityStats
database table (Items 5a and 5b) - Determine the time frame for the entities that should be prepared based on the preparation mode, which for manual preparation is specified in the Prepare Mode box on the Prepare Data (BC501000) form)
- Call the BCProcessorSingleBase<>.FetchBucketsForImport() (Item 6a) or BCProcessorSingleBase<>.FetchBucketsForExport() (Item 6b) method
The FetchBucketsForImport() method retrieves entity records from the external system (Item 7a). The FetchBucketsForExport() method obtains entity records from MYOB Acumatica (Item 7b).
Saving of the Synchronization Data to the Database
For each entity record retrieved by the processor, the method creates a bucket of the entities by using the BCProcessorBase<>.CreateBucket() method, initializes an object that implements the PX.Commerce.Core.IMappedEntity interface for the entity type, and checks the preparation status of the object by using the BCProcessorBase<>.EnsureStatus() method.
Finally, in the BCProcessorBase<>.UpdateEntity() method (see Item 8
in the process diagram), the processor saves data about the synchronization status of the
entity to the BCEntityStats
and BCSyncStatus
database tables (Item
9).
Process Diagram
