PurchaseOrder Record Creation
问题描述:
当用户提交并确认订单时,如何在PurchaseOrder表中创建实际的PurchaseOrder记录?我已经扩展了采购订单,需要设置我在创建订单时添加的新属性。我正在寻找可扩展性工具包,我不清楚这实际发生的时间。
How is the actual PurchaseOrder record created in the PurchaseOrder table when a user submits and confirms an order? I have extended the purchase order and need to set a new property that I added when the order gets created. I am looking in the extensibility kit and I'm not clear when this actually happens.
答
John,
看看微软。 Microsoft.Commerce.Providers程序集中的Commerce.Providers.Components.BasketCommitter。特别是执行方法。
这是来自反射器:
John,
Look in the Microsoft.Commerce.Providers.Components.BasketCommitter in the Microsoft.Commerce.Providers assembly. Specifically the Execute Method.
Here is from reflector:
public override void ExecuteUpdate(CommerceUpdateOperation updateOperation, OperationCacheDictionary operationCache, CommerceUpdateOperationResponse response)
{
OrderGroup cachedCommerceServerOrderGroup = operationCache.GetCachedCommerceServerOrderGroup();
Basket commerceBasket = cachedCommerceServerOrderGroup as Basket;
if (commerceBasket != null)
{
OrderHelper.SaveOrderGroup(cachedCommerceServerOrderGroup);
if ("Ordered".Equals(commerceBasket.Status, StringComparison.OrdinalIgnoreCase))
{
string orderGroupId = cachedCommerceServerOrderGroup.OrderGroupId.ToString("B");
PurchaseOrder orderGroup = OrderHelper.SaveAsNewOrder(commerceBasket);
operationCache.RemoveOrderGroupFromCache(orderGroupId);
operationCache.CacheCommerceServerOrderGroup(orderGroup);
}
}
else
{
PurchaseOrder order2 = cachedCommerceServerOrderGroup as PurchaseOrder;
if (order2 != null)
{
order2.Save(OperationContext.CurrentInstance.RequestContext.Channel);
}
}
}
}