Ejemplo n.º 1
0
        private void SetupDynamics(IServiceCollection services)
        {
            string redisServer = Configuration["REDIS_SERVER"];

            string dynamicsOdataUri = Configuration["DYNAMICS_ODATA_URI"];
            string aadTenantId      = Configuration["DYNAMICS_AAD_TENANT_ID"];
            string serverAppIdUri   = Configuration["DYNAMICS_SERVER_APP_ID_URI"];
            string clientKey        = Configuration["DYNAMICS_CLIENT_KEY"];
            string clientId         = Configuration["DYNAMICS_CLIENT_ID"];

            services.AddDistributedRedisCache(options =>
            {
                options.Configuration = redisServer;
            });

            var authenticationContext = new AuthenticationContext(
                "https://login.windows.net/" + aadTenantId);
            ClientCredential clientCredential = new ClientCredential(clientId, clientKey);
            var task = authenticationContext.AcquireTokenAsync(serverAppIdUri, clientCredential);

            task.Wait();
            AuthenticationResult authenticationResult = task.Result;

            Contexts.Microsoft.Dynamics.CRM.System context = new Contexts.Microsoft.Dynamics.CRM.System(new Uri("https://lclbcannabisdev.crm3.dynamics.com/api/data/v8.2/"));

            context.BuildingRequest += (sender, eventArgs) => eventArgs.Headers.Add(
                "Authorization", authenticationResult.CreateAuthorizationHeader());

            services.AddSingleton <Contexts.Microsoft.Dynamics.CRM.System>(context);
        }
Ejemplo n.º 2
0
 public AccountController(Contexts.Microsoft.Dynamics.CRM.System context, IConfiguration configuration, IDistributedCache distributedCache, IHttpContextAccessor httpContextAccessor)
 {
     Configuration             = configuration;
     this._system              = context;
     this._distributedCache    = distributedCache;
     this._httpContextAccessor = httpContextAccessor;
 }
Ejemplo n.º 3
0
 public SystemFormController(Contexts.Microsoft.Dynamics.CRM.System context, IConfiguration configuration, IDistributedCache distributedCache)
 {
     Configuration          = configuration;
     this._system           = context;
     this._distributedCache = distributedCache;
 }