Everything you ever wanted to know about pipelines but were afraid to ask (Part IV)
So far you if you have followed this on going Pipeline posts, you should be very familiar with how to work with pipelines how to configure them using Pipeline Editor, how to manage your pipelines in the web.config as well as creating your own custom pipelines. I also hinted that you can use some undocumented APIs to automate some administration tasks (of course since this is undocumented its not supported :p). You should also be very familiar with creating custom UIs for your custom pipeline components and saving it's data.
As promised in this post I will show you how to debug your custom components and do how to test them and this will conclude the final post.
Before we jump into this I would like to offer you some readings, the UE team for CS2007 have done a fantastic job at documenting this version of Commerce Server so in a very nice way I would like to say please take a moment and make sure that you "Read The Fine Manual" :). Should you not agree I encourage you to take a moment and send feedback using the help docs.
There are two other great blog post that you should read David Messner's Transactional pipeline components and error handling and Nihit Kaul's Running Pipelines in a Console Application.
Creating PropertyPages for your Pipeline Component
This is a bit off topic but if you are like me you want to know everything there is to know when developing and dealing with Pipelines. So I have been asked how do you create a property page for the pipeline components. The short answer is that you can not create a property page using .NET. You will have to develop with C++. Here is how:
We are going to work with what you have created so far in the previous posts. So launch your Custom Pipeline Project.
Now that you have Visual Studio up and running with our project Select File then Add and next select New Project...
Form the Add New Project dialog navigate and select C++ then ATL and in the right pane select ATL Project.
Enter a descriptive name for the project then select OK.
From the ATL Project Wizard dialog select Next.
From the ATL Project Wizard dialog Application Settings make sure that only Dynamic-Link Library (DLL) radio button is selected and next select Finish.
The wizard will create two projects see image below.
Now you need to implement the ISpecifyPropertyPages Interface. This interface has only one method you need to implement GetPages. This interface is implemented in your custom pipeline component class.
using System;using System.Collections.Generic;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;using Microsoft.CommerceServer.Interop;using Microsoft.CommerceServer.Interop.Orders;using Microsoft.CommerceServer.Runtime;using Microsoft.CommerceServer.Runtime.Orders;using Microsoft.CommerceServer.Internal;namespace CustomPipeline{ [ComVisible(true)] [GuidAttribute ("5904C354-F1B8-485c-89DD-883D26BCE85D")] public class Class1 : IPipelineComponent, IPipelineComponentAdmin, IPersistDictionary, ISpecifyPipelineComponentUI, IPipelineComponentDescription, ISpecifyPropertyPages//.......// code commented out for clarity//.......#region ISpecifyPropertyPages Members public void GetPages(out tagCAUUID pPages) { throw new Exception("The method or operation is not implemented."); }#endregion//.......// code commented out for clarity//....... Select your ATL Project and right click then select Add and next select Class.
From the Add Class Wizard navigate to ATL then from the right pane select ATL Property Page and select the Add button.
In the ATL Page Wizard enter a descriptive name for your class then select Next.
In the next page make sure that Apartment Threaded for Thread Modeling is selected and No for Aggregation then select Next and finally select Finish.
The wizard will create a basic Property Page.
In the ATL project Select the project resource file and double click. This will bring you the Resource View.
FrFrom the Resource View navigate to Dialog and double click our newly created property page.
Next drag and drop a text box and use the existing Static Text.
Now we need to add some code to the GetPages method to display our property page.
public void GetPages(out tagCAUUID pPages){ pPages = new tagCAUUID(); pPages.cElems = 1; byte[] buffer1 = new Guid("{2879AC98-0A80-4F6B-AC0C-EE8A1E0391E3}").ToByteArray(); pPages.pElems = Marshal.AllocCoTaskMem(buffer1.Length); for (int num1 = 0; num1 < buffer1.Length; num1++) { Marshal.WriteByte(pPages.pElems, num1, buffer1[num1]); }} The GUID must be of that of your property page. You can get this by opening the .rgs file of your property page.
Now build your solution.
Run the steps for registering your custom component with pipereg.exe.
TeTest your new Property Page in Pipeline Editor.
Congratulation you have now created a new property page for you pipeline component.
How to Use MessageManager
Take a moment to read the following help topic How to Use MessageManager. This topic will help you localize your error messages.
Error Handling in Pipelines
Take a moment and read the following help topic Error Handling in Pipelines. . This will familiarize you with where to add errors so you can display it to the user.
Troubleshooting Pipelines
Debug pipelines in ASP.NET
To debug your pipelines in ASP.NET unpackage the CSharp site and set the correct security permissions.
Open the Custom Pipeline Solution.
Right Click on your Solution and add a Existing Web Project and select CSharpSite.
Modify the CSharpSite's Web.config so you can execute the basket pipeline.
Modify the basket pipeline and add your custom pipeline anywhere (make sure that you had compiled your code in debug mode).
Now add code to the default.aspx page to execute your basket pipeline.
Basket basket = CommerceContext.Current.OrderSystem.GetBasket(Guid.NewGuid());basket.OrderForms.Add(new OrderForm());PipelineInfo pipeinfo = new PipelineInfo("basket");PipelineExecutionResult pipeResult = basket.RunPipeline(pipeinfo);Response.Write(pipeResult.ToString());
**Now add the custom pipeline dll and pdb files under the bin directory of your CSharp Site.
Now go to your Custom Pipeline project and create a breakpoint anywhere under the Execute method.
Check the web.config to make sure it's set for debugging:
<application siteName="CSharpSite" debugLevel="Debug"/>and<compilation defaultLanguage="c#" debug="true"> Launch Internet Explore and navigate to the CSharpSite default.aspx page (For the advanced folks you can do the next steps by adding the URL in the debug properties of your project).
Now in your Visual Studio select the Debug menu then select Attach to Process...
In the Attach to Process dialog find the w3wp.exe process and attach to it (your Visual Studio solution will now be in debug mode).
Refresh your Internet Explorer.
Notice that you now hit your breakpoint.
Using the XMLTracer Pipeline Component
David Messner originally wrote the Troubleshooting Commerce Server Pipelines and in that article he wrote the XMLTracer that has now made it's way into the product. You can read more about the XMLTracer here.
How to Debug the Scriptor Component
As a best practice never use the scriptor component for production use. You can however use the DumpOrder.vbs for debugging pruposes or only use the scriptor for proof of concept applications. Please read the documentation for How to Use the Scriptor Component. To setup the scriptor debugging please read David Messner's article Troubleshooting Commerce Server Pipelines chapter 3.
Using Pipeline Logging
This section of the help files will guide you through How to Use an Order Log.
When you set the loggingEnabled section of the pipeline make sure to create a folder under the pipeline folder called log and give ASP.NET access to write\read\modify.
<pipelines siteName="CSharpSite"><pipeline name="basket" path="pipelines\basket.pcf" transacted="true" type="OrderPipeline" loggingEnabled="true"/></pipelines> |
Using the Scriptor to dump pipeline values to a file
In my second post I mentioned the DumpOrder.vbs file, you can also find more information about it here.
Test your Pipelines
Since you have written your pipeline component in .NET testing becomes very simple all you have to do is write a test that calls the execute method. Make sure to read Nihit Kaul's Running Pipelines in a Console Application.
Pipeline Performance
The pipeline performance counters are used for performance monitoring and tuning. The object name for the performance counters is Commerce : Pipelines. Counter instances are created per site, per a pipeline and pipeline component (.pcf file) combination. You will first need to execute your pipeline before you can collect data.
Summary
Now you know all there is to know about pipelines, good luck.
Comments
Anonymous
November 11, 2006
As previously discussed the pipeline system enables sequential workflow processing. It is a COM-based...Anonymous
July 10, 2007
The comment has been removedAnonymous
July 11, 2007
The comment has been removedAnonymous
October 30, 2007
The comment has been removedAnonymous
November 03, 2007
The comment has been removedAnonymous
November 07, 2007
The comment has been removedAnonymous
November 07, 2007
If you have issues with the DTC then you need to lookup DTC ping tool do a search and you will find it. If the DTC ping test fails then you have either a network issue or don't have the ports open. Good luck, -MaxAnonymous
November 10, 2007
Not solved it and both DTCPING and DTCTester shows success. I have also installed startersite on the same machine, and I get the same error, when it is doing the transacted checkout. Do you have any tips where to search? Or should I reinstall the machine?Anonymous
November 11, 2007
Checked out http://support.microsoft.com/kb/306843. Also, check and make sure that you have a recent version of MDAC on the client and which protocol being used. Are there any messages in the SQL Server Error Log? Do you have avirus checker if so check the settings. Try running SQL Profiler may give you an indication on what is happening when this error occurs. Good luck, -Max