Exemple #1
0
        public List <ProjectLog> GetGitHubProjectLog(string owner, string repo)
        {
            string partitionKey = PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo);

            TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration);

            return(AzureTableStorageDA.GetProjectLogsFromStorage(tableStorageConfig, partitionKey));
        }
        public async Task <IActionResult> Logs(string projectId = null)
        {
            //Get a list of settings
            ServiceApiClient           serviceApiClient    = new(Configuration);
            List <AzureDevOpsSettings> azureDevOpsSettings = await serviceApiClient.GetAzureDevOpsSettings();

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

            List <KeyValuePair <string, string> > projects = new()
            {
                new("", "<Select project>")
            };

            foreach (AzureDevOpsSettings item in azureDevOpsSettings)
            {
                //if (item.ShowSetting == true)
                //{
                string partitionKey = PartitionKeys.CreateAzureDevOpsSettingsPartitionKey(item.Organization, item.Project, item.Repository);
                projects.Add(new KeyValuePair <string, string>(partitionKey, item.Project));
                //}
            }
            foreach (GitHubSettings item in githubSettings)
            {
                //if (item.ShowSetting == true)
                //{
                string partitionKey = PartitionKeys.CreateGitHubSettingsPartitionKey(item.Owner, item.Repo);
                projects.Add(new KeyValuePair <string, string>(partitionKey, item.Repo));
                //}
            }

            List <ProjectLog> logs = new();

            if (string.IsNullOrEmpty(projectId) == false)
            {
                //TODO: This is gross. Fix this, making it easier to maintain and more efficient
                if (projectId.Split("_").Length == 3)
                {
                    logs = await serviceApiClient.GetAzureDevOpsProjectLogs(projectId.Split("_")[0], projectId.Split("_")[1], projectId.Split("_")[2]);
                }
                else
                {
                    logs = await serviceApiClient.GetGitHubProjectLogs(projectId.Split("_")[0], projectId.Split("_")[1]);
                }
            }

            //Flip the logs/ reverse the list of log items
            logs.Reverse();

            ProjectLogViewModel logViewModel = new()
            {
                ProjectId = projectId,
                Logs      = logs,
                Projects  = new SelectList(projects, "Key", "Value")
            };

            return(View(logViewModel));
        }
Exemple #3
0
        public async Task <bool> UpdateGitHubProjectLog(string owner, string repo,
                                                        int buildsUpdated, int prsUpdated, string buildUrl, string prUrl,
                                                        string exceptionMessage, string exceptionStackTrace)
        {
            ProjectLog log = new(
                PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo),
                buildsUpdated, prsUpdated, HttpUtility.UrlDecode(buildUrl), HttpUtility.UrlDecode(prUrl), exceptionMessage, exceptionStackTrace);

            TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration);

            return(await AzureTableStorageDA.UpdateProjectLogInStorage(tableStorageConfig, log));
        }
Exemple #4
0
        public void GHGetSamsFeatureFlagsLogsDAIntegrationTest()
        {
            //Arrange
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration);
            string owner = "samsmithnz";
            string repo  = "SamsFeatureFlags";

            //Act
            AzureTableStorageDA da   = new();
            List <ProjectLog>   logs = da.GetProjectLogsFromStorage(tableStorageConfig, PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo));

            //Assert
            Assert.IsTrue(logs != null);
            Assert.IsTrue(logs.Count > 0);
        }