public void WaitForScanComplete(HttpClient client, HubPagedResponse <ScanSummaryView> currentPagedSummaries) { int currentSummaries = 0; if (currentPagedSummaries != null) { currentSummaries = currentPagedSummaries.TotalCount; } Stopwatch stopwatch = Stopwatch.StartNew(); CodeLocationView codeLocation = null; while (stopwatch.ElapsedMilliseconds / 1000 < HubScanTimeout) { Log.LogMessage("Checking scan summary status"); codeLocation = CodeLocationDataService.GetCodeLocationView(BdioId); if (codeLocation != null) { break; } else { Log.LogMessage("No code locations found. Trying again..."); Thread.Sleep(500); } } if (codeLocation == null) { throw new BlackDuckIntegrationException($"Failed to get the codelocation for {HubProjectName} "); } ScanStatusEnum currentStatus = ScanStatusEnum.UNSTARTED; while (stopwatch.ElapsedMilliseconds / 1000 < HubScanTimeout) { HubPagedResponse <ScanSummaryView> scanSummaries = ScanSummariesDataService.GetScanSummaries(codeLocation); if (scanSummaries == null || scanSummaries.Items == null) { throw new BlackDuckIntegrationException($"There are no scan summaries @: {codeLocation.Metadata.Href}"); } else if (scanSummaries.TotalCount > currentSummaries) { ScanSummaryView scanSummary = scanSummaries.Items[0]; ScanStatusEnum scanStatus = scanSummary.Status; if (!scanStatus.Equals(currentStatus)) { currentStatus = scanStatus; Log.LogMessage($"\tScan Status = {currentStatus} @ {stopwatch.ElapsedMilliseconds / 1000.0}"); } if (currentStatus.Equals(ScanStatusEnum.COMPLETE)) { stopwatch.Stop(); break; } } Thread.Sleep(500); } if (stopwatch.ElapsedMilliseconds / 1000 > HubScanTimeout) { throw new BlackDuckIntegrationException($"Scanning of the codelocation: {codeLocation.Metadata.Href} execeded the {HubScanTimeout} second timeout"); } }
public bool IsDone(ScanStatusEnum statusEnum) { return(DONE_STATES.Contains(statusEnum)); }
public bool IsError(ScanStatusEnum statusEnum) { return(ERROR_STATES.Contains(statusEnum)); }
public bool IsPending(ScanStatusEnum statusEnum) { return(PENDING_STATES.Contains(statusEnum)); }