2015-09-15 76 views
1

我正在使用UConnector下載訂單並更新狀態。實際下載按預期工作,但當我嘗試更新狀態時,我收到一個錯誤。我在代碼中導致錯誤的行上發表了評論。我希望有人能告訴我我失蹤了什麼?無法實例化SessionProvider

我Component.config

<configuration> 
<components> 
    <component 
     id="SessionProvider" 
     service="UCommerce.EntitiesV2.ISessionProvider, UCommerce" 
     type="UCommerce.EntitiesV2.SessionProvider, UCommerce"/> 
    <component id="UCommerce.DataMappingsTag" 
     service="UCommerce.EntitiesV2.IContainsNHibernateMappingsTag, UCommerce" 
     type="UCommerce.EntitiesV2.MappingAssemblyTag, UCommerce"/> 
    <component id="OrderService" 
     service="UCommerce.Transactions.IOrderService, UCommerce" 
     type="UCommerce.Transactions.OrderService, UCommerce"/> 
    <component id="Repository" 
     service="UCommerce.EntitiesV2.IRepository`1, UCommerce" 
     type="UCommerce.EntitiesV2.Repository`1, UCommerce"/> 
</components> 
</configuration> 

代碼

var orderService = ObjectFactory.Instance.Resolve<IOrderService>(); 
//var newOrderStatus = OrderStatus.Get((int)OrderStatusCode.Processing); //This line 
var newOrderStatus = OrderStatus.All().SingleOrDefault(x => x.Name == "Processing"); //OR this line give the same error 
orderService.ChangeOrderStatus(item, newOrderStatus); 

錯誤:

ComponentActivator: could not instantiate UCommerce.EntitiesV2.SessionProvider

的InnerException:

{"No component for supporting the service UCommerce.Infrastructure.Configuration.CommerceConfigurationProvider was found"}

堆棧跟蹤:

at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, Object[] arguments, Type implType) at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments) at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context) at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context) at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden) at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally) at Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.<>n__FabricatedMethod3(CreationContext , Boolean) at Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.<>c__DisplayClass1.b__0(Action 1 afterCreated) at Castle.MicroKernel.Lifestyle.Scoped.DefaultLifetimeScope.GetCachedInstance(ComponentModel model, ScopedInstanceActivationCallback createInstance) at Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy) at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden) at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired) at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context) at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernelByType(CreationContext context, ComponentModel model, DependencyModel dependency) at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernel(CreationContext context, ComponentModel model, DependencyModel dependency) at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveCore(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency) at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency) at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate constructor, CreationContext context) at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context) at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context) at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden) at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally) at Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.<>n__FabricatedMethod3(CreationContext , Boolean) at Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.<>c__DisplayClass1.b__0(Action 1 afterCreated) at Castle.MicroKernel.Lifestyle.Scoped.DefaultLifetimeScope.GetCachedInstance(ComponentModel model, ScopedInstanceActivationCallback createInstance) at Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy) at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden) at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired) at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context) at Castle.MicroKernel.Handlers.DefaultGenericHandler.Resolve(CreationContext context, Boolean instanceRequired) at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context) at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy) at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy) at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments) at Castle.Windsor.WindsorContainer.ResolveT at UCommerce.Infrastructure.ObjectFactory.ResolveT at UCommerce.EntitiesV2.OrderStatus.GetRepo() at UCommerce.EntitiesV2.OrderStatus.All() at SiteConnector.Classes.OrdersListToCalClub.Send(IEnumerable`1 input)

+0

我遇到同樣的問題。通過添加對ucommerce.pipelines dll的引用,我確實進一步了。 –

回答

1

我發現你其實需要更多的dll的,那麼你會覺得。 下面是我包含的兩個截圖(項目中的引用和lib文件夾)。我正在與sitecore集成,但是你可以用我認爲的Umbracco對應部分替換這些dll。

下面是我用來更新訂單狀態的代碼。該列表包含我的案例中的命令行(並且我在azure存儲中保存了一個列表,所以您也會看到一些dll)。

ISession session = new SessionProvider("connectionstring").GetSession(); 
OrderStatus status = session.Query<OrderStatus>().FirstOrDefault(os => os.Name.Equals("Processing"));  
foreach (PurchaseOrder order in list.Select(o => o.PurchaseOrder)) 
{ 
    order.OrderStatus = status; 
    session.Save(order);    
} 
session.Flush(); 

enter image description here

enter image description here

+0

這與我最終得到的代碼非常相似。看到我的答案。除非你找到我沒有的東西,否則似乎很少有UCommerce的文檔? – Fred

+0

作爲一個方面說明其Sitecore 8和UCommerce我正在使用以及你有沒有找到很多關於使用這兩個文件? – Fred

+0

不是真的,有些點點滴滴。大多數情況下,我將uconnector示例和masterclass中的代碼組合在一起。當這證明不足時,我開始在我的網站中添加對ullig正在使用的dll的引用。 –

1

此更新採購訂單到任何狀態它ord.OrderStatusName也覺得我還發現,不清除會話可以減緩東西下來大的時候,如果你正在處理超過200個記錄。

foreach (CcOrder ord in input) 
{ 
    PurchaseOrder poOrder = 
    _session.Query<PurchaseOrder>().FirstOrDefault(p => p.OrderNumber == ord.OrderId); 
    OrderStatus newOrderStatus = _session.Query<OrderStatus>().FirstOrDefault(p => p.Name == ord.OrderStatusName); 

    if (poOrder == null || newOrderStatus == null) continue; //If one or both not found go to next 
    poOrder.OrderStatus = newOrderStatus; 
    _session.Save(poOrder); 
    _session.Flush(); 
    _session.Clear(); 
}