private bool ValidateNewReport( BrokenExternalReferencesReport report, ItInterface includedInterfaceWhichFails, EndpointValidationError expectedInterfaceError, BrokenLinkCause brokenLinkCauseForInterface, ExternalReference includedReferenceWhichFails, EndpointValidationError expectedReferenceError, BrokenLinkCause brokenLinkCauseForReference) { Assert.Equal(_now, report.Created); var brokenLinkInInterface = Assert.Single(report.BrokenInterfaceLinks); Assert.Same(includedInterfaceWhichFails, brokenLinkInInterface.BrokenReferenceOrigin); Assert.Equal(brokenLinkInInterface.ErrorResponseCode, (int?)expectedInterfaceError.StatusCode); Assert.Equal(brokenLinkInInterface.Cause, brokenLinkCauseForInterface); Assert.Equal(brokenLinkInInterface.ValueOfCheckedUrl, includedInterfaceWhichFails.Url); var brokenLinkInExternalReference = Assert.Single(report.BrokenExternalReferences); Assert.Same(includedReferenceWhichFails, brokenLinkInExternalReference.BrokenReferenceOrigin); Assert.Equal(brokenLinkInExternalReference.ErrorResponseCode, (int?)expectedReferenceError.StatusCode); Assert.Equal(brokenLinkInExternalReference.ValueOfCheckedUrl, includedReferenceWhichFails.URL); Assert.Equal(brokenLinkInExternalReference.Cause, brokenLinkCauseForReference); return(true); }
public async Task <Result <string, OperationError> > ExecuteAsync(CancellationToken token = default) { var brokenInterfaceLinks = await CheckInterfaceLinksAsync().ConfigureAwait(false); var brokenSystemLinks = await CheckSystemLinksAsync().ConfigureAwait(false); var report = new BrokenExternalReferencesReport { Created = _operationClock.Now, BrokenInterfaceLinks = brokenInterfaceLinks.ToList(), BrokenExternalReferences = brokenSystemLinks.ToList() }; _reportRepository.ReplaceCurrentReport(report); return($"Created report with timestamp:{report.Created} and id '{report.Id}'. {report.BrokenExternalReferences.Count + report.BrokenInterfaceLinks.Count} broken links found."); }
public static HttpResponseMessage CreateReportCsvResponse(BrokenExternalReferencesReport report) { var csvResponseBuilder = new CsvResponseBuilder <IBrokenLink>(); csvResponseBuilder = csvResponseBuilder .WithFileName(MapFileName(report)) .WithColumn(BrokenExternalReferencesReportColumns.Origin, MapBrokenLinkOriginType) .WithColumn(BrokenExternalReferencesReportColumns.OriginObjectName, MapBrokenLinkOriginName) .WithColumn(BrokenExternalReferencesReportColumns.RefName, MapReferenceName) .WithColumn(BrokenExternalReferencesReportColumns.ErrorCategory, MapErrorCategory) .WithColumn(BrokenExternalReferencesReportColumns.ErrorCode, MapErrorCode) .WithColumn(BrokenExternalReferencesReportColumns.Url, link => link.ValueOfCheckedUrl); csvResponseBuilder = report .GetBrokenLinks() .Aggregate(csvResponseBuilder, (builder, brokenLink) => builder.WithRow(brokenLink)); return(csvResponseBuilder.Build()); }
public void ReplaceCurrentReport(BrokenExternalReferencesReport report) { if (report == null) { throw new ArgumentNullException(nameof(report)); } using (var transaction = _transactionManager.Begin(IsolationLevel.Serializable)) { var existing = _repository.AsQueryable().FirstOrDefault(); if (existing != null) { if (existing.Id == report.Id) { throw new ArgumentException("Incoming report is the same as the existing report"); } _repository.DeleteWithReferencePreload(existing); } _repository.Insert(report); _repository.Save(); transaction.Commit(); } }
public ViewBrokenExternalReferencesReportPermission(BrokenExternalReferencesReport target) { Target = target; }
private static string MapFileName(BrokenExternalReferencesReport report) { return($"kitos_external_references_report-{report.Created:yyyy-MM-dd}.csv"); }