Esempio n. 1
0
        private OrganizationDetailCollection DiscoverOrganizations()
        {
            var request  = new RetrieveOrganizationsRequest();
            var response = (RetrieveOrganizationsResponse)_service.Execute(request);

            return(response.Details);
        }
Esempio n. 2
0
        /// <summary>Discovers the organizations that the calling user belongs to.</summary>
        /// <param name="service">A Discovery service proxy instance.</param>
        /// <returns>Array containing detailed information on each organization that
        /// the user belongs to.</returns>
        public static OrganizationDetailCollection DiscoverOrganizations(IDiscoveryService service)
        {
            var orgRequest  = new RetrieveOrganizationsRequest();
            var orgResponse = (RetrieveOrganizationsResponse)service.Execute(orgRequest);

            return(orgResponse.Details);
        }
        /// <summary>
        /// Discovers the organizations that the calling user belongs to.
        /// </summary>
        /// <param name="service">A Discovery service proxy instance.</param>
        /// <returns>Array containing detailed information on each organization that the user belongs to.</returns>
        public static OrganizationDetailCollection DiscoverOrganizations(IDiscoveryService service)
        {
            if (service == null)
            {
                throw new AdapterException(string.Format(CultureInfo.CurrentCulture, Resources.ParamterNullExceptionMessage), new ArgumentNullException("service"))
                      {
                          ExceptionId = AdapterException.SystemExceptionGuid
                      };
            }

            RetrieveOrganizationsResponse orgResponse = null;

            try
            {
                orgResponse = (RetrieveOrganizationsResponse)service.Execute(new RetrieveOrganizationsRequest());
            }
            catch (SecurityNegotiationException ex)
            {
                throw new AdapterException(string.Format(CultureInfo.CurrentCulture, ex.InnerException != null ? ex.InnerException.Message : ex.Message), ex)
                      {
                          ExceptionId = AdapterException.SystemExceptionGuid
                      };
            }

            return(orgResponse != null ? orgResponse.Details : null);
        }
Esempio n. 4
0
        /// <summary>
        /// получение всех организаций
        /// </summary>
        /// <param name="service"></param>
        /// <returns></returns>
        private static OrganizationDetailCollection DiscoverOrganizations(IDiscoveryService service)
        {
            RetrieveOrganizationsRequest  request  = new RetrieveOrganizationsRequest();
            RetrieveOrganizationsResponse response = (RetrieveOrganizationsResponse)service.Execute(request);

            return(response.Details);
        }
Esempio n. 5
0
        public OrganizationDetailCollection DiscoverOrganizations(IDiscoveryService service)
        {
            if (service == null) throw new ArgumentNullException("service");
            RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();
            RetrieveOrganizationsResponse orgResponse =
                (RetrieveOrganizationsResponse)service.Execute(orgRequest);

            return orgResponse.Details;
        }
        /// <summary>
        ///     Discovers the organizations that the calling user belongs to.
        /// </summary>
        /// <param name="service">A Discovery service proxy instance.</param>
        /// <returns>
        ///     Array containing detailed information on each organization that
        ///     the user belongs to.
        /// </returns>
        public OrganizationDetailCollection DiscoverOrganizations(IDiscoveryService service)
        {
            if (service == null) throw new ArgumentNullException("service");
            var orgRequest = new RetrieveOrganizationsRequest();
            var orgResponse =
                (RetrieveOrganizationsResponse)service.Execute(orgRequest);

            return orgResponse.Details;
        }
Esempio n. 7
0
        public static OrganizationDetail[] GetAllOrganizations(this IDiscoveryService service)
        {
            var request  = new RetrieveOrganizationsRequest();
            var response = (RetrieveOrganizationsResponse)service.Execute(request);

            var details = response.Details.ToArray();

            return(details);
        }
        private OrganizationDetailCollection DiscoverOrganizations(IDiscoveryService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }
            RetrieveOrganizationsRequest  orgRequest  = new RetrieveOrganizationsRequest();
            RetrieveOrganizationsResponse orgResponse =
                (RetrieveOrganizationsResponse)service.Execute(orgRequest);

            return(orgResponse.Details);
        }
Esempio n. 9
0
        /// <summary>Executes a discovery service message in the form of a request, and returns a response. </summary>
        /// <returns>Type: <see cref="T:Microsoft.Xrm.Sdk.Discovery.DiscoveryResponse"></see>. The response from processing the request. You must cast the return value of this method to the specific instance of the response that corresponds to the Request parameter.</returns>
        /// <param name="request">Type: <see cref="T:Microsoft.Xrm.Sdk.Discovery.DiscoveryRequest"></see>. A request instance that defines the action to be performed.</param>
        /// <param name="cancellationToken"></param>
        /// <param name="service">The service instance</param>
        public static Task <DiscoveryResponse> ExecuteAsync(this IDiscoveryService service, DiscoveryRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (service is IAsyncDiscoveryService asyncService)
            {
                return(asyncService.ExecuteAsync(request, cancellationToken));
            }

            if (service is IWcfAsyncDiscoveryService wcfAsyncService)
            {
                return(Task <DiscoveryResponse> .Factory.FromAsync(wcfAsyncService.BeginExecute, wcfAsyncService.EndExecute, request, state : null));
            }

            return(Task.Run(() => service.Execute(request)));
        }
Esempio n. 10
0
        /// <summary>
        /// Метод получает список организаций на сервере CRM.
        /// </summary>
        /// <param name="service">Ссылка на сервис обнаружения CRM.</param>
        private static void ShowOrganizations(IDiscoveryService service)
        {
            var request = new RetrieveOrganizationsRequest
            {
                AccessType = EndpointAccessType.Default,
                Release    = OrganizationRelease.Current
            };
            var response = (RetrieveOrganizationsResponse)service.Execute(request);

            foreach (var organization in response.Details)
            {
                Console.WriteLine($"{organization.UniqueName}\t{organization.OrganizationVersion}\t{organization.FriendlyName}");
            }
        }
        /// <summary>
        /// Discovers the organizations that the calling user belongs to.
        /// </summary>
        /// <param name="service">A Discovery service proxy instance.</param>
        /// <returns>Array containing detailed information on each organization that the user belongs to.</returns>
        public static OrganizationDetailCollection DiscoverOrganizations(IDiscoveryService service)
        {
            if (service == null)
            {
                throw new AdapterException(string.Format(CultureInfo.CurrentCulture, Resources.ParamterNullExceptionMessage), new ArgumentNullException("service")) { ExceptionId = AdapterException.SystemExceptionGuid };
            }

            RetrieveOrganizationsResponse orgResponse = null;
            try
            {
                orgResponse = (RetrieveOrganizationsResponse)service.Execute(new RetrieveOrganizationsRequest());
            }
            catch (SecurityNegotiationException ex)
            {
                throw new AdapterException(string.Format(CultureInfo.CurrentCulture, ex.InnerException != null ? ex.InnerException.Message : ex.Message), ex) { ExceptionId = AdapterException.SystemExceptionGuid };
            }

            return orgResponse != null ? orgResponse.Details : null;
        }
Esempio n. 12
0
        /// <summary>
        /// Demonstrates the RetrieveOrganization and RetrieveOrganizations messages
        /// of the Discovery service.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete)
        {
            try
            {
                //<snippetDiscoveryService1>
                // Connect to the Discovery service.
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new DiscoveryServiceProxy(serverConfig.DiscoveryUri,
                                                                 serverConfig.HomeRealmUri,
                                                                 serverConfig.Credentials,
                                                                 serverConfig.DeviceCredentials))
                {
                    // You can choose to use the interface instead of the proxy.
                    IDiscoveryService service = _serviceProxy;

                    #region RetrieveOrganizations Message

                    //<snippetDiscoveryService2>
                    // Retrieve details about all organizations discoverable via the
                    // Discovery service.
                    RetrieveOrganizationsRequest orgsRequest =
                        new RetrieveOrganizationsRequest()
                    {
                        AccessType = EndpointAccessType.Default,
                        Release    = OrganizationRelease.Current
                    };
                    RetrieveOrganizationsResponse organizations =
                        (RetrieveOrganizationsResponse)service.Execute(orgsRequest);
                    //</snippetDiscoveryService2>

                    // Print each organization's friendly name, unique name and URLs
                    // for each of its endpoints.
                    Console.WriteLine();
                    Console.WriteLine("Retrieving details of each organization:");
                    foreach (OrganizationDetail organization in organizations.Details)
                    {
                        Console.WriteLine("Organization Name: {0}", organization.FriendlyName);
                        Console.WriteLine("Unique Name: {0}", organization.UniqueName);
                        Console.WriteLine("Endpoints:");
                        foreach (var endpoint in organization.Endpoints)
                        {
                            Console.WriteLine("  Name: {0}", endpoint.Key);
                            Console.WriteLine("  URL: {0}", endpoint.Value);
                        }
                    }
                    Console.WriteLine("End of listing");
                    Console.WriteLine();

                    #endregion RetrieveOrganizations Message

                    #region RetrieveOrganization Message

                    //<snippetDiscoveryService3>
                    // Retrieve details about a single organization discoverable via the Discovery service.
                    //
                    RetrieveOrganizationRequest orgRequest =
                        new RetrieveOrganizationRequest()
                    {
                        UniqueName = organizations.Details[organizations.Details.Count - 1].UniqueName,
                        AccessType = EndpointAccessType.Default,
                        Release    = OrganizationRelease.Current
                    };
                    RetrieveOrganizationResponse org =
                        (RetrieveOrganizationResponse)service.Execute(orgRequest);
                    //</snippetDiscoveryService3>

                    // Print the organization's friendly name, unique name and URLs
                    // for each of its endpoints.
                    Console.WriteLine();
                    Console.WriteLine("Retrieving details of specific organization:");
                    Console.WriteLine("Organization Name: {0}", org.Detail.FriendlyName);
                    Console.WriteLine("Unique Name: {0}", org.Detail.UniqueName);
                    Console.WriteLine("Endpoints:");
                    foreach (KeyValuePair <EndpointType, string> endpoint in org.Detail.Endpoints)
                    {
                        Console.WriteLine("  Name: {0}", endpoint.Key);
                        Console.WriteLine("  URL: {0}", endpoint.Value);
                    }
                    Console.WriteLine("End of listing");
                    Console.WriteLine();

                    #endregion RetrieveOrganization Message
                }
                //</snippetDiscoveryService1>
            }

            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException <Microsoft.Xrm.Sdk.DiscoveryServiceFault> )
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Executa a consulta do DiscoveryService.
        /// </summary>
        /// <param name="service">DiscoveryService</param>
        /// <returns></returns>
        public OrganizationDetailCollection DiscoverOrganizations(IDiscoveryService service)
        {
            if (Organizations == null)
            {
                RetrieveOrganizationsRequest  orgRequest  = new RetrieveOrganizationsRequest();
                RetrieveOrganizationsResponse orgResponse = (RetrieveOrganizationsResponse)service.Execute(orgRequest);
                Organizations = orgResponse.Details;
            }

            return(Organizations);
        }
Esempio n. 14
0
 public DiscoveryResponse Execute(DiscoveryRequest request)
 => _service.Execute(request);