Commerce Server General - Invoking pipelines using OrderPipeline.Execute()

This is Interesting: Free IT Magazines  
Home > Archive > Commerce Server General > August 2005 > Invoking pipelines using OrderPipeline.Execute()





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Invoking pipelines using OrderPipeline.Execute()
techman

2005-08-18, 5:52 pm

Hi,
I am trying to invoke a pipeline using the OrderPipeline.Execute() method. I
am getting the following exception:

InvalidCastException: Specified cast is not valid.]
Microsoft.CommerceServer.Runtime.Pipelines.OrderPipeline.Execute(Object
order, Object context) +108

Is this a proper approach for invoking a pipeline? If so, can someone
provide me details about the arguments passed to this method, especially the
'context' argument?

Thanks
Colin Bowern

2005-08-19, 5:52 pm

Hi,

What sort of pipeline are you trying to execute? Are you executing inside
an ASP.NET application context? I use the following helper function to
execute pipelines against baskets as an example:

private void RunPipeline(string pipelineName)
{
PipelineInfo pipeInfo;
CommerceContext commerceContext = CommerceContext.Current;

pipeInfo = new PipelineInfo(pipelineName);

// Set pipeline object references
pipeInfo[PipelineFields.CatalogLanguage] =
Thread.CurrentThread.CurrentUICulture.Name;
pipeInfo.CatalogContext = commerceContext.CatalogSystem;
pipeInfo.ProfileContext = commerceContext.ProfileSystem;
pipeInfo.Language = Thread.CurrentThread.CurrentUICulture.Name;

// Attach the user profile to the pipeline.
pipeInfo.Profiles.Add("User", commerceContext.UserProfile);

// If it exists attach the targeting context profile.
if (commerceContext.TargetingSystem.TargetingContextProfile != null)
pipeInfo.Profiles.Add("TargetingContext",
commerceContext.TargetingSystem.TargetingContextProfile);

// Run pipeline
try
{
this.currentBasket.RunPipeline(pipeInfo);
}
catch (CommerceOrderSystemException ex)
{
ExceptionManager.Publish(ex);

if( (((SimpleList)this.orderForm[OrderFormFields.BasketErrors]).Count ==
0) &&
(((SimpleList)this.orderForm[OrderFormFields.PurchaseErrors]).Count ==
0) )
this.AddPurchaseError(StringResources.GetString(StringResourceKeys.Checkout_SystemError));
}

// Populate basket error collection
this.basketErrors.Clear();
foreach (object item in
(SimpleList)this.orderForm[OrderFormFields.BasketErrors])
this.AddBasketError((string)item);

// Populate purchase error collection
this.purchaseErrors.Clear();
foreach (object item in
(SimpleList)this.orderForm[OrderFormFields.PurchaseErrors])
this.AddPurchaseError((string)item);
}


"techman" <techman@discussions.microsoft.com> wrote in message
news:36401F79-8016-4252-BAB8-D017A739CB7E@microsoft.com...
> Hi,
> I am trying to invoke a pipeline using the OrderPipeline.Execute() method.
> I
> am getting the following exception:
>
> InvalidCastException: Specified cast is not valid.]
> Microsoft.CommerceServer.Runtime.Pipelines.OrderPipeline.Execute(Object
> order, Object context) +108
>
> Is this a proper approach for invoking a pipeline? If so, can someone
> provide me details about the arguments passed to this method, especially
> the
> 'context' argument?
>
> Thanks



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com