简体   繁体   English

如何使用C#/ VB.Net和WCF部署服务或CRM 2011 SDK启用和禁用CRM 2011组织?

[英]How to enable and disable a CRM 2011 Organization using C#/VB.Net and WCF Deployment Service or CRM 2011 SDK?

I want to be able to enable/disable a CRM 2011 Organization using Deployment Service (Deployment.Svc) or using CRM 2011 SDK (Microsoft.Xrm.Sdk.Deployment Namespace) using C# or VB.Net application. 我希望能够使用C#或VB.Net应用程序使用部署服务(Deployment.Svc)使用CRM 2011 SDK (Microsoft.Xrm.Sdk.Deployment命名空间)启用/禁用CRM 2011组织。

I am using some code like this: 我正在使用这样的代码:

 Dim StateReq As CRM2011DeploymentSvc.DeleteRequest
                Dim StateResp As CRM2011DeploymentSvc.DeleteResponse

                StateReq.EntityType = DeploymentEntityType.Organization
                StateReq.InstanceTag.Id = FoundOrganization.OrganizationId
                StateReq.InstanceTag.Name = FoundOrganization.UniqueName


                StateResp = CType(_CrmDeployService.Execute(StateReq), DeleteResponse)

1. Q1: This code is OK as far as deletion of entities(Organization, accounts etc) is concerned. 1.问题1 :就删除实体(组织,帐户等)而言,此代码是可以的。 but i am more interested in Enabling and disabling the organization (occasionally) along deleting (when required) . 但我对启用和禁用组织(有时)以及删除时(需要时)更感兴趣。

2. Q2: Lets say if i Delete an Organization, will i be able to undo delete or recover it. 2.问题 2:可以说,如果我删除组织,则可以撤消删除或恢复它。 If yes then how and if not what else is the alternative? 如果是,那又如何,如果不是,那还有什么替代方案? 3. Q3: In CRM 4.0 we can disable/Enable the organization using 3.问题 3:在CRM 4.0中,我们可以使用以下方法禁用/启用组织

**SetStateOrganizationRequest**



**SetStateOrganizationResponse**

Classes using the Deployment web service but in CRM 2011 , the Deployment WCF Service does not contain any such method. 使用Deployment Web服务进行分类,但在CRM 2011中 ,Deployment WCF服务不包含任何此类方法。 What should i do to enable or disable the organization ? 我应该怎么做才能启用或禁用组织

Replies are much appreciated. 感谢您的答复。

Thank you. 谢谢。

ok i got the solution courtesy of ResultOnDemand 好吧,我得到了ResultOnDemand的解决方案

The following code worked for me 以下代码为我工作

EntityInstanceId i = new EntityInstanceId();
i.Id = OrganisationId; //Organisation Id

DeploymentService.Organization organization = (DeploymentService.Organization)Provider.deploymentservice.Retrieve(DeploymentEntityType.Organization, i);

//Update status to disabled
organization.State = OrganizationState.Disabled;

DeploymentService.UpdateRequest updateRequest = new UpdateRequest();
updateRequest.Entity = organization;

//update status
Provider.deploymentservice.Execute(updateRequest);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM