Esempio n. 1
0
        public CRMState CRMSetStateStatus(CRMState crmState)
        {
            OrganizationServiceProxy _serviceProxy;
            IOrganizationService     _service;
            string res = "";

            using (_serviceProxy = GetCRMConnection())
            {
                // This statement is required to enable early-bound type support.
                _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

                _service = (IOrganizationService)_serviceProxy;

                Microsoft.Crm.Sdk.Messages.SetStateRequest ssr = new Microsoft.Crm.Sdk.Messages.SetStateRequest();
                ssr.State         = new OptionSetValue(crmState.State);
                ssr.Status        = new OptionSetValue(crmState.Status);
                ssr.EntityMoniker = new EntityReference(crmState.Entity, new Guid(crmState.EntityId));

                try
                {
                    Microsoft.Crm.Sdk.Messages.SetStateResponse resp = (Microsoft.Crm.Sdk.Messages.SetStateResponse)_service.Execute(ssr);
                    res = resp.ResponseName;
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return(crmState);
        }
        public CRMState CRMSetStateStatus(CRMState crmState)
        {
            OrganizationServiceProxy _serviceProxy;
            IOrganizationService _service;
            string res = "";

            using (_serviceProxy = GetCRMConnection())
            {
                // This statement is required to enable early-bound type support.
                _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

                _service = (IOrganizationService)_serviceProxy;

                Microsoft.Crm.Sdk.Messages.SetStateRequest ssr = new Microsoft.Crm.Sdk.Messages.SetStateRequest();
                ssr.State = new OptionSetValue(crmState.State);
                ssr.Status = new OptionSetValue(crmState.Status);
                ssr.EntityMoniker = new EntityReference(crmState.Entity, new Guid(crmState.EntityId));

                try
                {
                    Microsoft.Crm.Sdk.Messages.SetStateResponse resp = (Microsoft.Crm.Sdk.Messages.SetStateResponse)_service.Execute(ssr);
                    res = resp.ResponseName;
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return crmState;
        }