Preparation of Data for the Synchronization
The preparation for data synchronization can be started manually on the Prepare Data (BC501000) form, by an automation schedule, or as a result of a push notification. The following sections describe in order the general steps involved in the preparation of data for synchronization; the process diagram in the end of this topic shows the data preparation process in its entirety.
Beginning of the Data Preparation
When the data preparation is started (see Item 1 in the process diagram), 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() (Item 4a) or
FetchBucketsExport() (Item 4b) method, depending on the sync direction
of the entity. These methods 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 (depending on
the prepare mode, which for manual preparation is specified in the Prepare
Mode box on the Prepare Data form), and call
the BCProcessorSingleBase<>.FetchBucketsForImport() (Item 6a) or
BCProcessorSingleBase<>.FetchBucketsForExport() (Item 6b) method,
respectively. 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 (Item 8), the
processor saves data about the synchronization status of the entity to the BCEntityStats
and BCSyncStatus
database tables (Item
9).