Beispiel #1
0
        /// <summary>
        /// Deletes a solutoion.
        /// </summary>
        /// <param name="solutionUniqueName">The unique name of the solution.</param>
        /// <returns>Information regarding the deleted solution.</returns>
        public async Task <DynamicsCrmSolution> DeleteSolutionAsync(string solutionUniqueName)
        {
            DynamicsCrmSolution solution = await GetSolutionAsync(solutionUniqueName);

            if (solution == null)
            {
                return(null);
            }

            LogInformation("Acquiring access token...");
            IHttpClient httpClient = TokenProvider.GetHttpClient(_audience);

            LogInformation($"Deleting solution from Dynamics CRM instance with id '{solution.SolutionId}'...");
            HttpResponseMessage response = await httpClient.DeleteAsync(
                $"{_baseAddress}solutions({solution.SolutionId})");

            if (response.StatusCode == HttpStatusCode.NoContent)
            {
                return(solution);
            }
            else
            {
                LogError($"ERROR: ({response.StatusCode}) {response.ReasonPhrase}");
                throw new RequestException(response);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Updates an existing solution.
        /// </summary>
        /// <param name="solutionUniqueName">The unique name of the solution.</param>
        /// <param name="solutionFilePath">Path to the solution ZIP archive.</param>
        /// <returns>Information regarding the updated solution.</returns>
        public async Task <DynamicsCrmSolution> UpdateSolutionAsync(string solutionUniqueName, string solutionFilePath)
        {
            DynamicsCrmSolution solution = await GetSolutionAsync(solutionUniqueName);

            if (solution == null)
            {
                throw new Exception("Solution does not exists!");
            }
            else
            {
                string importResult = await ImportSolutionAsync(solutionFilePath);

                return(await GetSolutionAsync(solutionUniqueName));
            }
        }
Beispiel #3
0
        public void GetSolutionAsyncSuccess()
        {
            string expectedUniqueName         = "orgtest1";
            string expectedDomainName         = "orgtest5";
            string expectedOrgId              = Guid.NewGuid().ToString();
            string expectedSolutionId         = Guid.NewGuid().ToString();
            string expectedSolutionUniqueName = "TestSolution";
            string expectedSolutionVersion    = "1.0.0.5";
            string expectedRequestUri         = $"https://{expectedDomainName}.crm.dynamics.com/api/data/v9.0/solutions?$filter=uniquename%20eq%20'{expectedSolutionUniqueName}'";
            string responseFilePath           = @"./data/templates/responses/dynamicsCrm/getSolutions.json";

            HttpRequestMessage expectedRequest = TestHelper.CreateHttpRequest(
                HttpMethod.Get,
                expectedRequestUri);

            _httpClient.RegisterExpectedRequest(new ExpectedRequest(expectedRequest));

            HttpResponseMessage expectedResponse = TestHelper.CreateHttpResponse(
                HttpStatusCode.OK,
                null,
                responseFilePath,
                "application/json",
                new Dictionary <string, string>()
            {
                { "orgId", expectedOrgId },
                { "solutionId", expectedSolutionId },
                { "uniqueName", expectedSolutionUniqueName },
                { "version", expectedSolutionVersion },
            });

            _httpClient.RegisterExpectedResponse(
                expectedRequestUri,
                new ExpectedResponse(expectedResponse));

            IDynamicsCrmClient client = new DynamicsCrmClient(
                expectedUniqueName,
                expectedDomainName,
                _tokenProvider);

            DynamicsCrmSolution response = client.GetSolutionAsync(expectedSolutionUniqueName).Result;

            Assert.IsNotNull(response, "The response should not be null!");
            Assert.AreEqual(expectedSolutionId, response.SolutionId, $"Unexpected solution id ('{expectedSolutionId}' != '{response.SolutionId}')");
            Assert.AreEqual(expectedSolutionUniqueName, response.UniqueName, $"Unexpected solution id ('{expectedSolutionUniqueName}' != '{response.UniqueName}')");
            Assert.AreEqual(expectedSolutionVersion, response.Version, $"Unexpected solution id ('{expectedSolutionVersion}' != '{response.Version}')");
        }
Beispiel #4
0
        private object DeployDynamicsCRMSolutionAsync(OperationRunner context)
        {
            DataModel.ShowStatus    = true;
            DataModel.StatusMessage = "Deploying Advocacy Platform Dynamics 365 CRM managed solution...";

            DataModel.ShowProgress        = true;
            DataModel.OperationInProgress = true;

            DataModel.NextEnabled     = false;
            DataModel.PreviousEnabled = false;

            DynamicsCrmSolution solution = _dynamicsCrmClient.GetSolutionAsync("AdvocacyPlatformSolution").Result;

            if (solution == null)
            {
                return(_dynamicsCrmClient.ImportSolutionAsync(DataModel.InstallationConfiguration.DynamicsCrm.SolutionZipFilePath).Result);
            }

            return(solution);
        }