Wednesday, November 14, 2007

Extending the Purchase Order table in CS 2007

I extended the Purchase Order table of CS 2007 and inserted a new Column. The objective of my extension was to see when we execute the DTS package of Datawarehouse, and if we are to customize the purchase order table with our own column, does it populate the Order Group table of Data warehouse for that particular site. For e.g I created a column called GroupStatus in Purchase Order table in the Site_transactions database. Following are the steps required to reflect the new column in the Site_dataware database.

1. OrderObjectMapping.xml -- Add the new property name in this XML file located in the [SiteName]OrdersWebService.

2.Execute the OrderMapping.exe with respective switches.

3. Run the generated SQL file, for e.g., OrdeStorage.sql in the site_transactions database. It will create the newly added property in the Purchase Order table as column name. Related views will also be updated.

4.Manually add some data in the newly created column in the purchase order table.

5. Add the property name in the transdimension table.

6. Execute the datawarehouse DTS packages.

The newly created column value will be reflected in the [Site]_dataware database.

After doing this I wanted to check whether I can insert value in the newly created column using Code and instead of manually adding the values. Basically to treat the column name as a property of the Purchase Order class. Following are the steps required.

1. Create a class library and inherit from purchase order Class. One can refer the OrderExtensibility solution located in the C:\Program Files\Microsoft Commerce Server 2007\Sdk\Samples folder. Build the class library and add a reference to the DLL in the commerce server site. If the dll is not placed in the GAC then in the AssembelType attribute you need to specify AttributeType="Local" else AttributeType="GAC". To place a dll in GAC (Ofcource one needs to check the security aspect of putting a dll in the GAC)we need to have strong name. Following are the steps required to generate the strong name for a assembly.

a) sn -k c:\Testkey.snk //Run this command in the CMD

b) [assembly:AssemblyKeyFileAttribute(@"C:\TestKey.snk")] // Add this line in the assemblyInfo.cs file.

c) Build the file and place the dll in the GAC.

Once the assembly is placed in the GAC and is referred by the cousuming code from GAC and later down the line if you want to refer this assembly from the local folder instead of GAC you need to do the following steps.

a) [assembly:AssemblyKeyFileAttribute(@"C:\TestKey.snk")] //remove this line. If you don't remove this line then in the consuming code where it will not be added as a reference.

b) In the assemblies section in the Site Web.Config file comment the line that refers your assembly.

c) Build the Class library.

2. Update OrderObjectMapping.xml & OrderPipeLineMapping.xml (web site & order web service) in the respective places.

3. In the respective web.config files change the UserTypeName to your class name for the key Purchase Order. Namespace to your namespace provided in the derived Class. Assembly is the name of the assembly. If the assmebly is in GAC

4. Execute the Ordermapping.exe in the [Site]OrdersWebService. I got an error while executing the Ordermapping.exe in the Site directory. The errors are

Warning O0019 - Class MyPurchaseClass is present in Object Mapping file but is not present in web.config as a UserTypeName. Is this desired?
Error G0010 - Mapping defined for class MyPurchaseClass which does not exist in any provided assembly.

I resolved the above error by executing the Ordermapping.exe in the [Site]OrdersWebService.

That's it you can build your site and create an instance of your assembly and can treat the column name as a property. Asign any value in the property and save it to the database tables.

I took help from the following links. You can also refer those links for more details. Thank you very much.

http://blogs.msdn.com/sathishcg/archive/2006/11/08/extending-commerce-server-order-system.aspx

http://www.webservertalk.com/archive167-2006-10-1691421.html

http://msdn2.microsoft.com/en-us/library/aa544672.aspx

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2283202&SiteID=1

Monday, November 12, 2007

LINQ

I am learning LINQ, one of the powerful technology from Microsoft. Its amazing. After two decades, the industry has reached a stable point in the evolution of object oriented programming technologies. Query is an integrated feature of the developer’s primary programming languages. Language integrated query allows query expressions to benefit from the rich metadata, compile-time syntax checking, static typing and IntelliSense that was previously available only to imperative code. I am still in the learning phase and would appreciate anyone if they can provide some more inputs in LINQ.

Sunday, November 11, 2007

OSO

I watched Om Shanti Om. Its a good movie, good entertainer. But don't watch the movie in small screen you may not like it.