private StatsUploadResults(bool success, FailedReason failedReason, IEnumerable <StatsUploadResult> uploadResults) { Success = success; FailedReason = failedReason; UploadResults = uploadResults; }
private async Task <(bool isAvailable, FailedReason failedReason)> IsDataStoreAvailable() { bool isAvailable = await dataStoreService.IsAvailable(); FailedReason failedReason = isAvailable ? FailedReason.None : FailedReason.DataStoreUnavailable; return(isAvailable, failedReason); }
public void SendEmail(StatsUploadResults statsUploadResults) { FailedReason failedReason = statsUploadResults.FailedReason; string errorMessage = errorMessageService.GetErrorMessage(failedReason, StatsDownloadService.StatsUpload); SendEmail(StatsUploadFailedSubject, errorMessage); }
private OverlapAnnotation(uint who, MatchEnum what, [CanBeNull] IInterval <uint> wow, BorderDistance where, FailedReason why) { Who = who; What = what; Wow = wow; Where = where; Why = why; }
public void SendEmail(FileDownloadResult fileDownloadResult) { FailedReason failedReason = fileDownloadResult.FailedReason; string errorMessage = errorMessageService.GetErrorMessage(failedReason, fileDownloadResult.FilePayload, StatsDownloadService.FileDownload); SendEmail(FileDownloadFailedSubject, errorMessage); }
private FileDownloadResult HandleDownloadNotReadyToRun(FailedReason failedReason, FilePayload filePayload) { FileDownloadResult failedResult = NewFailedFileDownloadResult(failedReason, filePayload); LogResult(failedResult); FileDownloadError(failedResult); SendEmail(failedResult); return(failedResult); }
private bool IsFileDownloadReadyToRun(FilePayload filePayload, out FailedReason failedReason) { if (IsMinimumWaitTimeNotMet(filePayload)) { failedReason = FailedReason.MinimumWaitTimeNotMet; return(false); } failedReason = FailedReason.None; return(true); }
public string GetErrorMessage(FailedReason failedReason, FilePayload filePayload, StatsDownloadService service) { if (failedReason == FailedReason.MinimumWaitTimeNotMet) { TimeSpan minimumWaitTimeSpan = MinimumWait.TimeSpan; TimeSpan configuredWaitTime = filePayload.MinimumWaitTimeSpan; return(string.Format(ErrorMessages.MinimumWaitTimeNotMet, minimumWaitTimeSpan, configuredWaitTime)); } return(GetErrorMessage(failedReason, service)); }
public void IsAvailable_WhenInvoked_ReturnsDatabaseAvailability(bool expectedIsAvailable, DatabaseFailedReason failedReason, FailedReason expectedReason) { statsDownloadDatabaseServiceMock.IsAvailable(Constants.FileDownloadDatabase.FileDownloadObjects) .Returns((expectedIsAvailable, failedReason)); (bool isAvailable, FailedReason reason)actual = InvokeIsAvailable(); Assert.That(actual.isAvailable, Is.EqualTo(expectedIsAvailable)); Assert.That(actual.reason, Is.EqualTo(expectedReason)); }
internal static IVcfVariant CreateUnsupportedVariant([NotNull] IVcfVariant baseVariant, [CanBeNull] IVcfSample sample, FailedReason why, bool isTruth) { var realName = (isTruth ? SamplePair.Default.TruthSampleName : SamplePair.Default.QuerySampleName) ?? throw new InvalidDataException( $"Somehow, {nameof(SamplePair)}.{nameof(SamplePair.Default)} was null!!"); var sampleBuilder = SampleDictionaries.CreateBuilder() .AddSample(realName).MoveOnToDictionaries(); var dicts = (sample?.SampleDictionary ?? ImmutableDictionary <string, string> .Empty.AsEnumerable()) .Select(kvp => (kvp.Key, kvp.Value)) .FollowedWith( (WittyerConstants.WittyerMetaInfoLineKeys.Wit, NotAssessed), (WittyerConstants.WittyerMetaInfoLineKeys.Why, why.ToString())); foreach (var tuple in dicts) { sampleBuilder.SetSampleField(realName, tuple); } return(baseVariant.ToBuilder().SetSamples(sampleBuilder.Build()).Build()); }
public async Task <FileDownloadResult> DownloadStatsFile() { FilePayload filePayload = NewStatsPayload(); try { LogMethodInvoked(nameof(DownloadStatsFile)); (bool isAvailable, FailedReason failedReason)result = await IsDataStoreAvailable(); bool dataStoreUnavailable = !result.isAvailable; FailedReason failedReason = result.failedReason; if (dataStoreUnavailable || DatabaseUnavailable(out failedReason)) { FileDownloadResult failedResult = NewFailedFileDownloadResult(failedReason, filePayload); LogResult(failedResult); SendEmail(failedResult); return(failedResult); } UpdateToLatest(); LogVerbose($"Stats file download started: {DateTimeNow()}"); FileDownloadStarted(filePayload); if (IsFileDownloadNotReadyToRun(filePayload, out failedReason)) { return(HandleDownloadNotReadyToRun(failedReason, filePayload)); } SetDownloadFileDetails(filePayload); DownloadFile(filePayload); return(await HandleSuccessAndUpload(filePayload)); } catch (Exception exception) { return(HandleException(exception, filePayload)); } }
public FailedCopy(string fullName, FailedReason reason) { FullName = fullName; Reason = reason; }
public StatsUploadResults(FailedReason failedReason) : this(false, failedReason, null) { }
private FileDownloadResult(bool success, FailedReason failedReason, FilePayload filePayload) { Success = success; FailedReason = failedReason; FilePayload = filePayload; }
public FileDownloadResult(FailedReason failedReason, FilePayload filePayload) : this(false, failedReason, filePayload) { }
public FailedEventArgs(FailedReason reason) { Reason = reason; }
public static OverlapAnnotation Create(uint who, MatchEnum what, [CanBeNull] IInterval <uint> wow, [NotNull] BorderDistance where, FailedReason why) => new OverlapAnnotation(who, what, wow, where, why);
private FileDownloadResult NewFailedFileDownloadResult(FailedReason failedReason, FilePayload filePayload) { return(new FileDownloadResult(failedReason, filePayload)); }
public string GetErrorMessage(FailedReason failedReason, StatsDownloadService service) { if (failedReason == FailedReason.DatabaseUnavailable) { return(GetErrorMessageByServiceType(service, ErrorMessages.FileDownloadDatabaseUnavailable, ErrorMessages.StatsUploadDatabaseUnavailable, ErrorMessages.DefaultDatabaseUnavailable)); } if (failedReason == FailedReason.DataStoreUnavailable) { return(ErrorMessages.DataStoreUnavailable); } if (failedReason == FailedReason.DatabaseMissingRequiredObjects) { return(GetErrorMessageByServiceType(service, ErrorMessages.FileDownloadMissingRequiredObjects, ErrorMessages.StatsUploadMissingRequiredObjects, ErrorMessages.DefaultMissingRequiredObjects)); } if (failedReason == FailedReason.RequiredSettingsInvalid) { return(ErrorMessages.RequiredSettingsAreInvalid); } if (failedReason == FailedReason.FileDownloadTimeout) { return(ErrorMessages.FileDownloadTimedOut); } if (failedReason == FailedReason.FileDownloadNotFound) { return(ErrorMessages.FileDownloadNotFound); } if (failedReason == FailedReason.FileDownloadFailedDecompression) { return(ErrorMessages.FileDownloadFailedDecompression); } if (failedReason == FailedReason.InvalidStatsFileUpload) { return(ErrorMessages.InvalidStatsFile); } if (failedReason == FailedReason.UnexpectedDatabaseException) { return(ErrorMessages.StatsUploadTimeout); } if (failedReason == FailedReason.UnexpectedException) { return(GetErrorMessageByServiceType(service, ErrorMessages.FileDownloadUnexpectedException, ErrorMessages.StatsUploadUnexpectedException, ErrorMessages.DefaultUnexpectedException)); } if (failedReason == FailedReason.UnexpectedValidationException) { return(ErrorMessages.UnexpectedValidationException); } return(string.Empty); }
private bool IsFileDownloadNotReadyToRun(FilePayload filePayload, out FailedReason failedReason) { return(!IsFileDownloadReadyToRun(filePayload, out failedReason)); }
public void GenerateWhatAndWhyWorksWithCnSample(bool isAlleleMatch, uint posStart, uint posEnd, uint endStart, uint endEnd, bool isGtMatch, uint cn, MatchEnum matchResult, FailedReason reasonResult) { var originalVariant = GetOriginalCnvGtVariant(); var otherVariant = SetupBasicVariant(isAlleleMatch ? PrimaryContigAndInterval : PrimaryFailedContigAndInterval); otherVariant.SetupGet(v => v.PosInterval).Returns(ContigAndInterval.Create(PrimaryContig, posStart, posEnd)); otherVariant.SetupGet(v => v.EndInterval).Returns(ContigAndInterval.Create(PrimaryContig, endStart, endEnd)); var otherSample = new Mock <IWittyerGenotypedCopyNumberSample>(); var gt = new Mock <IGenotypeInfo>(); if (originalVariant.Sample is IWittyerGenotypedSample gtSample) { gt.Setup(g => g.Equals(gtSample.Gt)).Returns(isGtMatch); } otherSample.SetupGet(s => s.Gt).Returns(gt.Object); otherSample.SetupGet(s => s.Cn).Returns(cn); otherVariant.SetupGet(v => v.Sample).Returns(otherSample.Object); var actual = OverlappingUtils.GenerateWhatAndWhy(otherVariant.Object, new List <FailedReason>(), originalVariant, OverlappingUtils.IsVariantAlleleMatch, false); Assert.Equal((matchResult, reasonResult), actual); }
public StatsUploadResult(int downloadId, FailedReason failedReason) : this(false, downloadId, failedReason) { }
/// <summary> /// The fail. /// </summary> /// <param name="retry"> /// The retry. /// </param> /// <param name="reason"> /// The reason. /// </param> public void Fail(bool retry, FailedReason reason) { this.Failed = true; this.CanRetry = retry; this.FailedReason = reason; }
private StatsUploadResult(bool success, int downloadId, FailedReason failedReason) { Success = success; DownloadId = downloadId; FailedReason = failedReason; }
private bool DatabaseUnavailable(out FailedReason failedReason) { (bool isAvailable, FailedReason reason) = fileDownloadDatabaseService.IsAvailable(); failedReason = reason; return(!isAvailable); }