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

  1. Create an OrderContext object.

    In the code example, the Main method performs this step.

  2. Create and populate a Basket object.

    In the code example, the Main method and the PopulateCart method perform this step.

  3. Create a PipelineInfo object.

    In the code example, the CreatePipelineInfo method performs this step.

  4. 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.

  5. 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.

  6. Add error message text to the MessageManagerClass object to describe the pipeline error codes.

    In the code example, the AddMessagesToMessageManager method performs this step.

  7. Populate the marketing elements of the pipeline and the cache:

    1. Create a DictionaryClass object to represent the marketing cache dictionary, and populate the dictionary.

    2. Create an ExpressionEvaluator object, and set the PipelineInfo object's class indexer named "Evaluator" to the ExpressionEvaluator object.

    3. 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.

  8. Populate the orders elements of the pipeline and the cache:

    1. Create a DictionaryClass object to represent the shipping methods dictionary, and populate the dictionary.

    2. 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.

  9. Populate the catalog elements of the pipeline and the cache:

    1. Create and configure a CatalogSiteAgent object.

    2. Create and configure a CacheConfiguration object.

    3. Create a CatalogContext object, and include the CatalogSiteAgent object and the CacheConfiguration object.

    In the code example, the ConfigureCatalogSystem method performs these steps.

  10. Set the PipelineInfo object's class indexer named "MessageManager" to the MessageManager object.

    In the code example, the AddDataToPipelineInfo method performs this step.

  11. Create a CommerceResourceCollection object for the site, and set the PipelineInfo object's class indexer named "CommerceResources" to the CommerceResourceCollection object.

  12. Set the PipelineInfo object's class indexer named "CacheManager" to the CacheManager object.

  13. Create an OrderPipeline object.

    In the code example, the RunPipeline method performs this step.

  14. Run the pipeline.

    In the code example, the RunPipeline method performs this step.

  15. Handle any warnings that the pipeline generated.

    In the code example, the CheckPipelineResultAndPrintWarnings method performs this step.

  16. Call the Dispose method of the PipelineInfo object.

    In the code example, the RunPipeline method performs this step.

  17. 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