如何改变果园记录库 [英] How to change Orchard record repository

查看:182
本文介绍了如何改变果园记录库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个项目,我们正在考虑使用果园CMS

I work on a project where we're considering using Orchard CMS.

不过,我们要使用Web服务作为数据源的一些内容项目。我想我们必须改变仓库实现,以使这成为可能,但我不知道这一点。

However, we want to use web services as data sources for some of the content items. I guess we have to change the repository implementation in order to make this possible, but I'm not sure about that.

所以我的问题是:是我的猜想正确,或者是更复杂?又如何能不能做到呢?

谢谢!

更新: 我看到果园的IRepository界面要求LINQ提供程序来实现。这就是在这种情况下是不可能的,因为Web服务通过SOAP提供的。

Update: I see that Orchard's IRepository interface requires LINQ provider to be implemented. That's impossible in this scenario since the web services are offered via SOAP.

我会更好地进一步说明情况:

I'll better further describe the scenario:

我们要建立的网站必须使用Web服务来获取有关组织成员和单位的信息。我们想展示一些组织单位的成员,例如,在网站上。我们还需要创建自己的内容类型的事件,应该有一个M:与会员(来自WS)N的关系(与会者)

The website we wish to build has to use web services to get information about an organization members and units. We would like to display members of some organizational unit, for example, on the website. We also want to create our own content type "Event" that should have an M:N relationship (Attendees) with "Member" (from WS).

推荐答案

您不必实施 IRepository 如果你不希望的完全的直接部分存储到别的地方。我目前使用WCF服务在我的果园为基础的项目之一,所以你的情况是相似的。

You don't have to implement an IRepository in case you don't want to fully direct the part storage to somewhere else. I'm currently using WCF service in one of my Orchard-based projects, so your scenario is similar.

您可以这样来做:

  1. 包装你的Web服务代理类实施 IDependency ,所以你可以把它注入到驱动器/处理器/控制器等的的单元测试的易用性和嘲笑你应该创建一个单独的接口,如: IMyWebServiceWrapper:IDependency 并执行它,然后
  2. 创建相应的内容部分和记录。在记录存​​储的必要的信息来定位和WS获取数据。在内容部分创造一切必要的属性 - 它们将被从WS装载
  3. 从注入点1类为适当的内容处理程序构造
  4. 里面的内容处理程序的构造函数的使用是这样的:
  1. Wrap your web service proxy in a class implementing IDependency, so you'd be able to inject it into drivers/handlers/controllers etc. For the ease of unit testing and mocking you should create a separate interface, eg. IMyWebServiceWrapper : IDependency and implement it then.
  2. Create appropriate content parts and records. In the records store only the information necessary to locate and fetch data from WS. In the content parts create all necessary properties - they will be loaded from the WS.
  3. Inject your class from point 1. into appropriate content handlers' constructors
  4. Inside the content handler constructor use something like this:

OnLoaded< MyPart>((CTX,部分)=> {        part.MyProperty = myService.GetMyProperty(part.SomeIdToLookup);    });

OnLoaded<MyPart>((ctx, part) => { part.MyProperty = myService.GetMyProperty(part.SomeIdToLookup); });

  • MyPart 是你的一部分,在乌节路侧。
  • myProperty的是你做一些属性,它会从WS加载。
  • 为myService 是你的包裹WS代理,通过为构造函数的参数。
  • GetMyProperty 是调用WS包装的方法和获取必要的数据。
  • MyPart is your part on the Orchard side.
  • MyProperty is some property on your part which will be loaded from WS.
  • myService is your wrapped WS proxy, passed as a constructor parameter.
  • GetMyProperty is a method in the wrapper which call WS and retrieves the necessary data.

当然你也可以使用其他的处理程序事件(比如OnInitialized,OnCreated,OnPublished等)。你可以阅读更多有关内容处理器这里

Of course you can use other handler events (like OnInitialized, OnCreated, OnPublished etc). You can read more about content handlers here.

我也建议得到一个开发启动模块从codePLEX的快速发展。

I'd also recommend getting a dev startup module from Codeplex for quick development.

这篇关于如何改变果园记录库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆