Local Mode Programming
Commerce Server Core Systems provides a way to access the management functionality of the following Commerce Server Core Systems systems through more traditional, in-process APIs. These local APIs provide the best performance but do not provide the ability to run remotely across a network.
Catalog System (CatalogContext)
Marketing System (MarketingContext)
Orders System (OrderManagementContext)
Profiles System (ProfileManagementContext)
The difference between accessing one of these Commerce Server Core Systems systems using the local APIs versus using the agent APIs is in how objects of the corresponding context class (shown parenthetically above) are created. After you create the context class for a particular Commerce Server Core Systems system, you can use it to access the full object model for that system. For more information about developing with the individual systems, see the following topics:
The remainder of this topic summarizes how to create the various context objects so that subsequent operations are performed in local mode.
Using the Catalog and Inventory Systems API in Local Mode
In order to use the local APIs that access both the run-time and management functionality of the Catalog and Inventory Systems, use one of the correct versions of the Create factory method of the CatalogContext class. The two correct versions both take an instance of the CatalogSiteAgent class as a parameter: CatalogContext.Create(CatalogSiteAgent) and CatalogContext.Create(CatalogSiteAgent, CacheConfiguration).
Note
An obsolete version of the local API Create factory method takes instances of the CatalogSiteAgent class and the DebugContext class as parameters: CatalogContext.Create(CatalogSiteAgent, DebugContext). You should avoid using this version.
After you have created a local-mode instance of the CatalogContext class, and assuming that you have an Inventory System enabled for your implementation of (the InventorySystemExists property is set to True), you can retrieve a local-mode instance of the InventoryContext class using the InventoryContext property.
Using the Marketing System Management API in Local Mode
In order to use the local API that accesses the management functionality of the Marketing System, use one of the three correct versions of the Create factory method of the MarketingContext class. The correct versions take multiple parameters, including the name of the Commerce Server Core Systems site, two authorization parameters, and optionally, several SQL Server time-out parameters: MarketingContext.Create(String, String, AuthorizationMode) or MarketingContext.Create(String, String, AuthorizationMode, Int32, Int32) and MarketingContext.Create(String, String, AuthorizationMode, Int32, Int32, Int32, Int32).
Which method you choose depends on whether you need to set the relevant SQL Server time-out values.
For an example of using the management functionality of the Marketing System in local mode, see Local Mode Programming Sample.
Using the Orders System Management API in Local Mode
In order to use the local API for the Orders System, use the correct version of the Create factory method of the OrderManagementContext class. The correct version takes an instance of the OrderSiteAgent class as its only parameter: OrderManagementContext.Create(OrderSiteAgent).
Using the Profiles System Management API in Local Mode
There is no local mode access to the ProfileManagementContext class, and therefore, no local mode access to the designated management functionality of the Profiles System. However, you can use the classes in the Microsoft.CommerceServer.Runtime.Profiles namespace to get local mode access to much of the functionality of the Profiles System. To do so, create an instance of the ProfileContext class using one of its three constructors. All three constructors take various combinations of connection strings and profile definition catalog names, as well as an instance of the DebugContext class: ProfileContext(String, DebugContext),ProfileContext(String, String, DebugContext), or ProfileContext(String, String, String, DebugContext).
Which constructor you choose depends on which connection strings you choose to pass as parameters and whether or not you need to pass in a profile definition catalog name.