an ASP.NET Open Source CMS & eCommerce platform
Search:
Skip Navigation LinksHome > DotShoppingCart Forums > Development > General Programming > Auto Regeneration of LIcense Codes
Last Post 11/21/2011 3:58:33 PM By lukezy. 7 replies.
10/31/2011 10:41:44 AM
Guia
Posts: 18
Joined: 8/24/2011
Auto Regeneration of LIcense Codes
Hello.  I wanted to continue the discussion that we started here: http://www.dotshoppingcart.com/View/Article/FAQ/DotShoppingcart%20Functionality/86.aspx.
 
We have looked at the Gift certificate functionality and see how the Admin interface allows for the autogeneration of a code.  Also, as developers, we are very familiar with the autogeneration of GUIDs and other codes.  In looking at the ProductTypeEnum in the Core object model we see references to a LicenseKeyAutoGen value and a RegistrationCodeAutoGen value.  However, we don't see the LicenseKeyAutoGen option of the Miscellaneoius tab for a Product.  And we don't understand the significance of the RegistrationCodeAutoGen value on this same tab.
 
So while we see references to license/registration code generation, we don't see any way to invoke this functionality through the Admin interface.  Again, we are certainly capable of customizing Dot Shopping Cart functionality to generate the license codes, however, we would like to leverage as much of the existing functionality as possible.  Can you elaborate further on what functionality is available and how to invoke it? 
 
Thank you.
11/1/2011 10:46:54 AM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Auto Regeneration of LIcense Codes
Great question. We originally was trying to implement the license code auto generation as part of the out of box features. But we found out that license code generation is just one side of equation. The application (either client or server side software) that checks for the license code needs to be able to read and validate the code. This part has been customized in your own software. So we decided that the license code auto generation would not be part of out of box features since it has to be customized anywhere. However we put the placeholds in the database so that you can implement this easily.
 
Here are the steps that we expect people to do.
1) Create or reuse an enum value in ProductTypeEnum and update table DSC_Product_Type_lkp
2) Use customField in DSC_Order_Item to store license code. You are free to create a new table to store that.
3) Create a new ProcessorProvider which generates the registration code automatically.
 
    public class CreateRegistrationCodeProcessorProvider : OrderProcessorProvider {
        protected override void ProcessOrder(string host, Order order, IConfigurationSource cfgSrc) {
            foreach (OrderItem item in order.OrderItems) {
                if (ProductTypeEnum.RegistrationCodeAutoGen == item.ProductType) {
                    string newcode = ""; //use your own algorithm to create license code here
                    item.UpdateCustomerField(host, newcode);
                }
            }
        }
4) Configure the new ProcessorProvider in DotShoppingCart.Commercial.OrderPipelineService.exe.config
 
    <orderPipelineServiceConfiguration defaultProvider="">
        <providers>
            <add name="CreateRegistrationCode" type="DotShoppingCart.Commercial.OrderPipeline.CreateRegistrationCodeProcessorProvider, DotShoppingCart.Commercial.OrderPipeline"/>
        </providers>
    </orderPipelineServiceConfiguration>
 
Add a new entry to DSC_Order_Status_lkp for the order status that is waiting for creating registration code. E.g. set status to "Awaiting Product Registration Code Generation".
 
Add a new entry to DSC_OrderPipeline_Processor_lkp. Set orderStatusIdSource to the Id that you created above, set both isDownloadBypass and isWebDriven to 0 and displayName to Null
 
Update the orderPipelineConfiguration section in web\DSC.config to start using "CreateRegistrationCode".
 
     <orderPipelineConfiguration>
        <processorConfigurations>
            <clear />
            <add name="CreditCard">
                <processors>
                    <clear />
                    <add name="OrderConfirmationEmail" />
                    <add name="CreditCardAuthorization" />
                    <add name="InventoryStockCheck" />
                    <add name="CreditCardCapture" />
                    <add name="OrderPackageAndShip" />
                    <add name="CreateRegistrationCode" />
                    <add name="CreateGiftCertificate" />
                    <add name="OrderCompleteEmail" />
                </processors>
            </add>
 
5) Customize your application to validate license code in DSC_Order_Item.customField
 
I hope this helps.
DotShoppingCart Staff
11/9/2011 10:39:58 AM
Guia
Posts: 18
Joined: 8/24/2011
Re: Auto Regeneration of LIcense Codes
Thank you for the additional information.  We have steps 1-4 completed.   We have some questions about step 4 and exactly what must be done to invoke this new class and ProcessOrder method.  We noticed in the DotShoppingCart.Commercial.OrderPipelineService.exe.config references to the OrderPipeline and OrderStatus lookup tables.  Do we need entries in these tables for our new class?
 
Second, should we compile a separate DLL file for our CreateRegistrationCodeProcessorProvider class and place it in the OrderPipeline folder, or is there a better method for integrating this additional funcationality with the order pipeline?  We don't have the source code for the OrderPipeline DLL file.
 
Finally, is there any additional configuration that is required to invoke this ProcessOrder method beyond the entry in the configuration file?
 
Thanks again.
11/9/2011 11:25:14 AM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Auto Regeneration of LIcense Codes
Yes, I updated step 4 to refresh that you need to update these tables and DSC.config as well.
 
You can create a seperate DLL file as long as you set the type correct in orderPipelineServiceConfiguration section.
 
Yes, I missed DSC.config file. See step 4 above.
DotShoppingCart Staff
11/11/2011 3:33:19 PM
Guia
Posts: 18
Joined: 8/24/2011
Re: Auto Regeneration of LIcense Codes
Thank you for the additional information.
 
We are having difficultly with the additional entry to the DotShoppingCart.Commercial.OrderPipelineService.exe.config file at the beginning of Step 4.  We have the class compiled in a separate DLL file and have added an entry to the config file similar to the following:
 
<add name="CreateRegistrationCode" type="Guia.DSC.RegistrationCodes.CreateRegistrationCodeProcessorProvider, Guia.DSC.RegistrationCodes"/>
 
Unfortunately, when we add this line to the config file, the ComOrderPipeline service will no longer start.  Our class is named CreateRegistrationCodeProcessorProvider and inherits from OrderProcessorProvider as in your example.  Do you have any idea what might cause this issue?
 
Thanks in advance for any insights.
 
 
 
 
11/16/2011 10:17:36 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Auto Regeneration of LIcense Codes
It's probably unhandled exception. Can you attach a debugger to DotShoppingCart.Commercial.OrderPipelineService.exe to see what goes wrong?
DotShoppingCart Staff
11/21/2011 1:17:54 PM
Guia
Posts: 18
Joined: 8/24/2011
Re: Auto Regeneration of LIcense Codes
Thanks for the feedback.  We were able to get the ComOrderPipeline service started once we straightened out our namespaces.
 
We have the registration code running now and we are in the process of fine tuning it.  One question that arises is the order in which the order pipeline processes the various components listed in the configuration file.   How does one go about manipulating the order of the order pipeline components?  Is it the order they are listed in the config file, or something else?
 
Second, how does this order relate back to the order status?  We notice that the OrderStatus class has an IsCompleted property, however, there is no Is Completed order status in the Admin order interface.  Our goal is to control the sequence of the order pipeline so the registration codes are produced at the appropriate time.  Then we need a mechanism for testing when the order has reached this stage in the processing, through the OrderStatus class, or an alternative method.
 
Thank you for your assistance.
11/21/2011 3:58:33 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Auto Regeneration of LIcense Codes
The order is defined in orderPipelineConfiguration section in web\DSC.config .
DotShoppingCart Staff