示例#1
0
        /// <summary>
        /// Setup a Dynamics client.
        /// </summary>
        /// <param name="Configuration"></param>
        /// <returns></returns>
        public static IDynamicsClient SetupDynamics(IConfiguration Configuration)
        {
            string dynamicsOdataUri = Configuration["DYNAMICS_ODATA_URI"]; // Dynamics ODATA endpoint

            if (string.IsNullOrEmpty(dynamicsOdataUri))
            {
                throw new Exception("configuration setting DYNAMICS_ODATA_URI is blank.");
            }

            ServiceClientCredentials serviceClientCredentials = GetServiceClientCredentials(Configuration);

            IDynamicsClient client = new DynamicsClient(new Uri(dynamicsOdataUri), serviceClientCredentials);

            // set the native client URI.  This is required if you have a reverse proxy or IFD in place and the native URI is different from your access URI.
            if (string.IsNullOrEmpty(Configuration["DYNAMICS_NATIVE_ODATA_URI"]))
            {
                client.NativeBaseUri = new Uri(Configuration["DYNAMICS_ODATA_URI"]);
            }
            else
            {
                client.NativeBaseUri = new Uri(Configuration["DYNAMICS_NATIVE_ODATA_URI"]);
            }

            return(client);
        }
示例#2
0
        public static IDynamicsClient SetupDynamics(HttpClient httpClient, IConfiguration Configuration)
        {
            IDynamicsClient client = new DynamicsClient(httpClient, Configuration);

            return(client);
        }