Пример #1
0
        /// <summary>
        /// Helper method for assigning common proxy-specific settings for impersonation, early-bound types, and channel timeout
        /// </summary>
        /// <param name="proxy">The service proxy</param>
        /// <param name="options">The options to configure on the service proxy</param>
        //public static void SetProxyOptions(this OrganizationServiceProxy proxy, OrganizationServiceProxyOptions options)
        //{
        //    if (!options.CallerId.Equals(Guid.Empty))
        //        proxy.CallerId = options.CallerId;

        //    if (options.ShouldEnableProxyTypes)
        //        proxy.EnableProxyTypes();

        //    if (!options.Timeout.Equals(TimeSpan.Zero)
        //        && options.Timeout > TimeSpan.Zero)
        //        proxy.Timeout = options.Timeout;
        //}

        /// <summary>
        /// Helper method for assigning common proxy-specific settings for impersonation, early-bound types, and channel timeout
        /// </summary>
        /// <param name="proxy">The service proxy</param>
        /// <param name="options">The options to configure on the service proxy</param>
        public static void SetProxyOptions(this CrmServiceClient proxy, OrganizationServiceProxyOptions options)
        {
            if (!options.CallerId.Equals(Guid.Empty))
            {
                proxy.CallerId = options.CallerId;
            }

            if (!options.Timeout.Equals(TimeSpan.Zero) && options.Timeout > TimeSpan.Zero)
            {
                proxy.OrganizationWebProxyClient.ChannelFactory.Endpoint.Binding.OpenTimeout    = options.Timeout;
                proxy.OrganizationWebProxyClient.ChannelFactory.Endpoint.Binding.CloseTimeout   = options.Timeout;
                proxy.OrganizationWebProxyClient.ChannelFactory.Endpoint.Binding.ReceiveTimeout = options.Timeout;
                proxy.OrganizationWebProxyClient.ChannelFactory.Endpoint.Binding.SendTimeout    = options.Timeout;
            }
        }
Пример #2
0
        /// <summary>
        /// Helper method for assigning common proxy-specific settings for impersonation, early-bound types, and channel timeout
        /// </summary>
        /// <param name="proxy">The service proxy</param>
        /// <param name="options">The options to configure on the service proxy</param>
        public static void SetProxyOptions(this OrganizationServiceProxy proxy, OrganizationServiceProxyOptions options)
        {
            if (!options.CallerId.Equals(Guid.Empty))
            {
                proxy.CallerId = options.CallerId;
            }

            if (options.ShouldEnableProxyTypes)
            {
                proxy.EnableProxyTypes();
            }

            if (!options.Timeout.Equals(TimeSpan.Zero) &&
                options.Timeout > TimeSpan.Zero)
            {
                proxy.Timeout = options.Timeout;
            }
        }