So far you should be comfortable working with pipeline files creating\modifying components and having a good understanding of basic concepts of creating a custom pipeline components and as promised lets dive deeper into advanced understanding of the pipeline interfaces.Then we will dive into the Order System and learn about the heart of pipelines OrderForms.
In order to create pipeline components you need to implement one or more interfaces. You must always implement the IPipelineComponent Interface, without this Interface the pipeline component will not execute. All other Interfaces and exposes other functionality to fit into the Commerce Pipeline architecture.
As have been noted this Interface must be implemented in order for the pipeline object to execute the component.
The IPipelineComponent interface supports the following methods:
using System;using System.Collections.Generic;using System.Text;using System.Runtime.InteropServices;using Microsoft.CommerceServer.Interop;using Microsoft.CommerceServer.Runtime;using Microsoft.CommerceServer.Interop.Orders;using Microsoft.CommerceServer.Runtime.Orders;namespace CustomPipeline{[ComVisible(true)][GuidAttribute ("5904C354-F1B8-485c-89DD-883D26BCE85D")]public class Class1 : IPipelineComponent { // Status codes for pipeline components private const Int32 StatusSuccess = 1; // success private const Int32 StatusWarning = 2; // warning private const Int32 StatusError = 3; // error #region IPipelineComponent Members public void EnableDesign(int fEnable){} public int Execute(object pdispOrder, object pdispContext, int lFlags) { Int32 ReturnValue = StatusSuccess; // How to get our Custom OrderContext IDictionary Context = (IDictionary)pdispContext; OrderContext myOrderContext = (OrderContext)Context["OrderContext"]; // How to get MessageManager Context IMessageManager MessageManager = (IMessageManager)Context["MessageManager"]; return ReturnValue; } #endregion }}}
The IPipelineComponenetAdmin Interface allows you to save configuration values at design time and they are read at runtime to perform some action based on your logic. For example in the MinMaxShipping sample a UI is presented when editing the component in Pipeline Editor and you set thresholds of minimum shipping cost. Once this value is set during the design time and when the pipeline executes, this value can be used to make sure we don't fall below the shipping cost. In order to show the properties for MinMaxShipping the sample uses a WinForm that implements IPipelineComponentUI Interface, this is an alternative to using the ISpecifyPropertyPages Interface. After going over some concepts of the other Interfaces I will show you an example of how these Interfaces work together.
The IPipelineComponenetAdmin Interface supports the following methods:
The IPipelineComponentUI Interface is implemented to allow a pipeline component to display a dialog box for configuration values. The interface is implemented by a separate Component Object Model (COM) object that displays the dialog box in .NET this can be a WinForm. In order to display the WinForm you must also implement the ISpecifyPipelineComponentUI. The ISpecifyPipelineComponentUI specifies the WinForm to launch which executes the ShowProperties method.The IPipelineComponentUI interface supports the following method:
ShowProperties Called by the Pipeline Editor to display the dialog box for the component.The following is the method signature for the ShowProperties:
The IPersistDictionary Interface is implemented by an object that needs to read or write its data as a Dictionary object. When creating a UI for your pipeline may have need to save it's data if so then use the IPersistDictionary Interface. The configuration data is saved within the Pipeline Configuration File.The IPersistDictionary Interface supports the following methods.
The IPipelineComponentDescription Interface makes it possible for pipeline components to identify the values that they read from the pipeline context, and the keys and values that they read from or write to the OrderForm object.Although pipeline components are not required to implement the IPipelineComponentDescription Interface, implementing this interface makes it possible for the Pipeline Editor to identify and display the elements that your component reads or writes. This information can help developers who are troubleshooting a pipeline configuration.The IPipelineComponentDescription interface supports the following methods.
The ISpecifyPipelineComponentUI Interface is used by a pipeline component to specify the Component Object Model (COM) object that implements the IPipelineComponentUI interface that gets and sets configuration values.The ISpecifyPipelineComponentUI Interface supports the following method.
The ISpecifyPropertyPages Interface is a standard Win32 OLE interface. You implement this interface to allow the pipeline administration tool to invoke the property page user interface of the component. For more information about the ISpecifyPropertyPages Interface, see the OLE Programmer's Reference.The ISpecifyPropertyPages Interface supports the following method:
We are going to work on the sample component created for the last post.
I know I said that I would go over the Pipeline Debugging later on but this is the right place to go over how to debug your .NET Form inside the Pipeline Editor.
An OrderForm represents a collection of items that a user placed in a shopping cart. Depending on how far the user has progressed through the purchasing process, an OrderForm might also contain the locations to ship the products to, the discounts that apply to the OrderGroup, and the ways that the user paid or will pay for the products.There are two types of OrderForms a .NET OrderForm that is used during runtime and a COM OrderForm that is used in the Pipelines. The Commerce Server 2007 has good documentation of how to extend the Order System and there is even an example under the SDK folder OrdersExtensibility.
So what happens when you create a .NET OrderForm then execute the basket Pipeline (or any other Pipeline)? Simply put the managed OrderForm is run through the Pipeline Adapter and mapped into COM OrderForm then the basket Pipeline is executed.The Orders Pipeline Adapter marshals data between the managed-code object model and legacy Dictionary instances in your Orders System. The Pipeline Adapter uses mapping contained in an XML file to map data between the managed code object and the legacy object. Dictionary class instances are simply hierarchical name-value pair collections. Managed classes can be viewed the same way, with strongly-typed properties as the name-value pairing. A mapping between the two models is achieved with an XML format that specifies the managed classes and properties to map, and the target Dictionary and SimpleList layout for those instances in unmanaged code.The default mapping file for the Orders System is called OrderPipelineMappings.xml. The default directory for OrderPipelineMappings.xml is %SystemDrive%\Inetpub\wwwroot\<ApplicationName>.
So you learned more about Pipeline Interfaces and should have an advanced understanding of them and how to use them as well as debugging the WinForm UIs created.
You also learned of the Pipeline Modifier tool to help you with automating the administration task of your PCF files.
You now know how the managed OrderForm is mapped to COM OrdrForm and for more reading on this I would suggest that you work with the sample OrdersExtensibility.
In the next on going post I will discuss how to debug your pipeline components as well as testing your components.