Problem with multiple e-mails on ToCompletedOrder pipeline
I have extended the ToCompletedOrder pipeline with the ToCompletedOrder.SendPayedEmail component so when a order change status from new to completed the system sends a e-mail. The problem is that if the user clicks multiple times on the "Update status" button in the Change oreder status dialog the system sends multiple emails. How can I prevent this?
Unfortunatly there's no way to override execute on the Orderprocessing pipeline. However the ToCompletedOrder pipeline is executed when the order changes status. You could create a new pipeline that would only trigger if the order is not allready acquired. Here's some pseudo code:
public class MyPipeLine : IPipeline<PurchaseOrder>
{
private readonly IPipelineTask<PurchaseOrder>[] _tasks;
public MyPipeLine(IPipelineTask<PurchaseOrder>[] tasks)
{
_tasks = tasks;
}
public PipelineExecutionResult Execute(PurchaseOrder subject)
{
// if (subject is acquired)
//return
//foreach task run
}
}
In the custom.config you would want to override the ToCompletedOrder component by id so the orderservice wold recieve your pipeline instead of the old one like this:
Just remember to inject the tasks like you do in your current configuration.
Another solution is to do the same thing, but with the orderService instead. You could check if the order status is allready the same as your're trying to change it to. Otherwise call base.changeOrderStatus.
Problem with multiple e-mails on ToCompletedOrder pipeline
I have extended the ToCompletedOrder pipeline with the ToCompletedOrder.SendPayedEmail component so when a order change status from new to completed the system sends a e-mail. The problem is that if the user clicks multiple times on the "Update status" button in the Change oreder status dialog the system sends multiple emails. How can I prevent this?
See config here for details:
Unfortunatly there's no way to override execute on the Orderprocessing pipeline. However the ToCompletedOrder pipeline is executed when the order changes status. You could create a new pipeline that would only trigger if the order is not allready acquired. Here's some pseudo code:
In the custom.config you would want to override the ToCompletedOrder component by id so the orderservice wold recieve your pipeline instead of the old one like this:
Just remember to inject the tasks like you do in your current configuration.
Hope that helps. Otherwise let me know :)
<component id="ToCompletedOrder"
service="UCommerce.Pipelines.IPipeline`1[[UCommerce.EntitiesV2.PurchaseOrder, UCommerce]], UCommerce"
type="My.NameSpace.MyCustomPipeLine, My.Assembly">
Another solution is to do the same thing, but with the orderService instead. You could check if the order status is allready the same as your're trying to change it to. Otherwise call base.changeOrderStatus.
okay thanks is it possible the you fix the issue in the uCommerce interface? Do uCommerce have a backlog or somthing where I can report the bug?
No it's great that you mention it here. We'll take it into consideration and put it into our pipeline. However we cannot tell when it will be fixed.
is working on a reply...