public List <ProjectLog> GetAzureDevOpsProjectLog(string organization, string project, string repository) { string partitionKey = PartitionKeys.CreateAzureDevOpsSettingsPartitionKey(organization, project, repository); 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)); }
public async Task <bool> UpdateAzureDevOpsProjectLog(string organization, string project, string repository, int buildsUpdated, int prsUpdated, string buildUrl, string prUrl, string exceptionMessage, string exceptionStackTrace) { ProjectLog log = new( PartitionKeys.CreateAzureDevOpsSettingsPartitionKey(organization, project, repository), buildsUpdated, prsUpdated, HttpUtility.UrlDecode(buildUrl), HttpUtility.UrlDecode(prUrl), exceptionMessage, exceptionStackTrace); TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration); return(await AzureTableStorageDA.UpdateProjectLogInStorage(tableStorageConfig, log)); }
public void AzGetSamLearnsAzureLogsDAIntegrationTest() { //Arrange TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration); string organization = "samsmithnz"; string project = "SamLearnsAzure"; string repository = "SamLearnsAzure"; //Act AzureTableStorageDA da = new(); List <ProjectLog> logs = da.GetProjectLogsFromStorage(tableStorageConfig, PartitionKeys.CreateAzureDevOpsSettingsPartitionKey(organization, project, repository)); //Assert Assert.IsTrue(logs != null); Assert.IsTrue(logs.Count > 0); }