How to Run a Pipeline Outside a Web Application
For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.
When you run a Commerce Server Web application, pipelines are configured for you based on information in the Web.config file. When you run a pipeline outside a Web application, you must configure the pipelines yourself.
The following procedure contains the steps to configure and run a pipeline outside a Web application. See Code Example: Running a Pipeline Outside a Web Application for a code example that implements this procedure.
Note
The code example is designed as a realistic set of classes and methods, and does not correspond exactly to the linear procedure that is described in this topic. In the following procedure, each step specifies the name of the method in the code example that implements that step.
To run a pipeline outside a Web application
Create an OrderContext object.
In the code example, the Main method performs this step.
Create and populate a Basket object.
In the code example, the Main method and the PopulateCart method perform this step.
Create a PipelineInfo object.
In the code example, the CreatePipelineInfo method performs this step.
Create a new PipelineCollection object to represent the payment processors, and set the PipelineInfo object's class indexer named "pipelines" to the PipelineCollection object.
In the code example, the AddDataToPipelineInfo method performs this step.
Create a CacheManagerClass object and a MessageManagerClass object.
Note
Because the CacheManagerClass and MessageManagerClass objects wrap unmanaged classes, you should put the code that creates and uses these objects in a try/finally block. The code in the finally block should release the references to the CacheManagerClass and MessageManagerClass objects.
In the code example, the AddDataToPipelineInfo method performs this step.
Add error message text to the MessageManagerClass object to describe the pipeline error codes.
In the code example, the AddMessagesToMessageManager method performs this step.
Populate the marketing elements of the pipeline and the cache:
Create a DictionaryClass object to represent the marketing cache dictionary, and populate the dictionary.
Create an ExpressionEvaluator object, and set the PipelineInfo object's class indexer named "Evaluator" to the ExpressionEvaluator object.
Configure the discount cache and the advertising cache.
Note
Because the DictionaryClass and ExpressionEvaluator objects wrap unmanaged classes, you should put the code that creates and uses these objects in a try/finally block. The code in the finally block should release the references to the DictionaryClass and ExpressionEvaluator objects.
In the code example, the ConfigureMarketingSystem method performs these steps.
Populate the orders elements of the pipeline and the cache:
Create a DictionaryClass object to represent the shipping methods dictionary, and populate the dictionary.
Create a DictionaryClass object to represent the payment methods dictionary, and populate the dictionary.
Note
Because the DictionaryClass object wraps an unmanaged class, you should put the code that creates and uses the DictionaryClass object in a try/finally block. The code in the finally block should release the reference to the DictionaryClass object.
In the code example, the ConfigureOrdersSystem method performs these steps.
Populate the catalog elements of the pipeline and the cache:
Create and configure a CatalogSiteAgent object.
Create and configure a CacheConfiguration object.
Create a CatalogContext object, and include the CatalogSiteAgent object and the CacheConfiguration object.
In the code example, the ConfigureCatalogSystem method performs these steps.
Set the PipelineInfo object's class indexer named "MessageManager" to the MessageManager object.
In the code example, the AddDataToPipelineInfo method performs this step.
Create a CommerceResourceCollection object for the site, and set the PipelineInfo object's class indexer named "CommerceResources" to the CommerceResourceCollection object.
Set the PipelineInfo object's class indexer named "CacheManager" to the CacheManager object.
Create an OrderPipeline object.
In the code example, the RunPipeline method performs this step.
Run the pipeline.
In the code example, the RunPipeline method performs this step.
Handle any warnings that the pipeline generated.
In the code example, the CheckPipelineResultAndPrintWarnings method performs this step.
Call the Dispose method of the PipelineInfo object.
In the code example, the RunPipeline method performs this step.
If it is appropriate in your scenario, save the Basket object as a purchase order.
In the code example, the Main method performs this step.
See Also
Other Resources
Code Example: Running a Pipeline Outside a Web Application
Working with Orders Runtime Objects Outside a Web Application