1

SDK を使用して Dynamics CRM 2011 を定期的に更新するためのスタンドアロン サービス (厳密にはプラグインではありません) を作成しています。

私のコードには以下が含まれます:

// Get entity metadata so we can process attributes correctly
IPluginExecutionContext context = (IPluginExecutionContext)ServiceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)ServiceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
... (etc)

これには、[IServiceProvider を実装する] ServiceProvider クラスのインスタンスが必要ですが、それを取得する方法がわかりません。

それで、どうやってそれを手に入れますか?

ありがとう

[編集]

現在、代わりに ServerConnection を使用することを検討しています。

http://msdn.microsoft.com/en-us/library/gg309393.aspx

[/編集]

4

1 に答える 1

0

整理しました。

http://markuserlandsson.wordpress.com/2011/01/26/my-first-crm-2011-project-part-1/より

(安全のためにここに転載)

ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;

IServiceConfiguration<IOrganizationService> config = 
        ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(
        new Uri(Properties.Settings.Default.CrmUrl));
config.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

OrganizationServiceProxy proxy = new OrganizationServiceProxy(config, credentials);
OrganizationServiceContext context = new OrganizationServiceContext(proxy);

次に、これを使用するproxycontext、必要なことを行います。

于 2012-08-31T15:55:52.820 に答える