Пример #1
0
        public async Task <IActionResult> UpdateChangeFailureRate(string ProjectIdSelected, int CompletionPercentSelected, int NumberOfDaysSelected)
        {
            ServiceApiClient serviceApiClient = new ServiceApiClient(Configuration);

            //Get a list of settings
            List <AzureDevOpsSettings> azureDevOpsSettings = await serviceApiClient.GetAzureDevOpsSettings();

            List <GitHubSettings> githubSettings = await serviceApiClient.GetGitHubSettings();

            //Create project items from each setting and add it to a project list.
            DevOpsPlatform targetDevOpsPlatform   = DevOpsPlatform.Unknown;
            string         organization_owner     = "";
            string         project_repo           = "";
            string         repository             = "";
            string         buildName_workflowName = "";

            foreach (AzureDevOpsSettings item in azureDevOpsSettings)
            {
                if (item.RowKey == ProjectIdSelected)
                {
                    targetDevOpsPlatform   = DevOpsPlatform.AzureDevOps;
                    organization_owner     = item.Organization;
                    project_repo           = item.Project;
                    repository             = item.Repository;
                    buildName_workflowName = item.BuildName;
                }
            }
            foreach (GitHubSettings item in githubSettings)
            {
                if (item.RowKey == ProjectIdSelected)
                {
                    targetDevOpsPlatform   = DevOpsPlatform.GitHub;
                    organization_owner     = item.Owner;
                    project_repo           = item.Repo;
                    repository             = "";
                    buildName_workflowName = item.WorkflowName;
                }
            }

            //Update the change failure rate with the % distribution
            if (organization_owner != "" && project_repo != "" && buildName_workflowName != "")
            {
                await serviceApiClient.UpdateChangeFailureRate(organization_owner, project_repo, buildName_workflowName, CompletionPercentSelected, NumberOfDaysSelected);
            }

            //Redirect to the correct project page to see the changes
            if (targetDevOpsPlatform == DevOpsPlatform.AzureDevOps)
            {
                return(RedirectToAction("Project", "Home", new { rowKey = organization_owner + "_" + project_repo + "_" + repository + "_" + buildName_workflowName }));
            }
            else if (targetDevOpsPlatform == DevOpsPlatform.GitHub)
            {
                return(RedirectToAction("Project", "Home", new { rowKey = organization_owner + "_" + project_repo + "_" + buildName_workflowName }));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }