コード例 #1
0
 private StatsUploadResults(bool success, FailedReason failedReason,
                            IEnumerable <StatsUploadResult> uploadResults)
 {
     Success       = success;
     FailedReason  = failedReason;
     UploadResults = uploadResults;
 }
コード例 #2
0
        private async Task <(bool isAvailable, FailedReason failedReason)> IsDataStoreAvailable()
        {
            bool isAvailable = await dataStoreService.IsAvailable();

            FailedReason failedReason = isAvailable ? FailedReason.None : FailedReason.DataStoreUnavailable;

            return(isAvailable, failedReason);
        }
コード例 #3
0
        public void SendEmail(StatsUploadResults statsUploadResults)
        {
            FailedReason failedReason = statsUploadResults.FailedReason;

            string errorMessage = errorMessageService.GetErrorMessage(failedReason, StatsDownloadService.StatsUpload);

            SendEmail(StatsUploadFailedSubject, errorMessage);
        }
コード例 #4
0
 private OverlapAnnotation(uint who, MatchEnum what, [CanBeNull] IInterval <uint> wow, BorderDistance where,
                           FailedReason why)
 {
     Who   = who;
     What  = what;
     Wow   = wow;
     Where = where;
     Why   = why;
 }
コード例 #5
0
        public void SendEmail(FileDownloadResult fileDownloadResult)
        {
            FailedReason failedReason = fileDownloadResult.FailedReason;

            string errorMessage = errorMessageService.GetErrorMessage(failedReason, fileDownloadResult.FilePayload,
                                                                      StatsDownloadService.FileDownload);

            SendEmail(FileDownloadFailedSubject, errorMessage);
        }
コード例 #6
0
        private FileDownloadResult HandleDownloadNotReadyToRun(FailedReason failedReason, FilePayload filePayload)
        {
            FileDownloadResult failedResult = NewFailedFileDownloadResult(failedReason, filePayload);

            LogResult(failedResult);
            FileDownloadError(failedResult);
            SendEmail(failedResult);
            return(failedResult);
        }
コード例 #7
0
        private bool IsFileDownloadReadyToRun(FilePayload filePayload, out FailedReason failedReason)
        {
            if (IsMinimumWaitTimeNotMet(filePayload))
            {
                failedReason = FailedReason.MinimumWaitTimeNotMet;
                return(false);
            }

            failedReason = FailedReason.None;
            return(true);
        }
コード例 #8
0
        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));
        }
コード例 #10
0
        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());
        }
コード例 #11
0
        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));
            }
        }
コード例 #12
0
 public FailedCopy(string fullName, FailedReason reason)
 {
     FullName = fullName;
     Reason   = reason;
 }
コード例 #13
0
 public StatsUploadResults(FailedReason failedReason)
     : this(false, failedReason, null)
 {
 }
コード例 #14
0
 private FileDownloadResult(bool success, FailedReason failedReason, FilePayload filePayload)
 {
     Success      = success;
     FailedReason = failedReason;
     FilePayload  = filePayload;
 }
コード例 #15
0
 public FileDownloadResult(FailedReason failedReason, FilePayload filePayload)
     : this(false, failedReason, filePayload)
 {
 }
コード例 #16
0
ファイル: Events.cs プロジェクト: Shelim/ResGateClientNet
 public FailedEventArgs(FailedReason reason)
 {
     Reason = reason;
 }
コード例 #17
0
 public static OverlapAnnotation Create(uint who, MatchEnum what, [CanBeNull] IInterval <uint> wow,
                                        [NotNull] BorderDistance where, FailedReason why)
 => new OverlapAnnotation(who, what, wow, where, why);
コード例 #18
0
 private FileDownloadResult NewFailedFileDownloadResult(FailedReason failedReason, FilePayload filePayload)
 {
     return(new FileDownloadResult(failedReason, filePayload));
 }
コード例 #19
0
        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);
        }
コード例 #20
0
 private bool IsFileDownloadNotReadyToRun(FilePayload filePayload, out FailedReason failedReason)
 {
     return(!IsFileDownloadReadyToRun(filePayload, out failedReason));
 }
コード例 #21
0
        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);
        }
コード例 #22
0
 public StatsUploadResult(int downloadId, FailedReason failedReason)
     : this(false, downloadId, failedReason)
 {
 }
コード例 #23
0
ファイル: TransactionInfo.cs プロジェクト: wtcoin/dotblock
 /// <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;
 }
コード例 #24
0
 private StatsUploadResult(bool success, int downloadId, FailedReason failedReason)
 {
     Success      = success;
     DownloadId   = downloadId;
     FailedReason = failedReason;
 }
コード例 #25
0
 private bool DatabaseUnavailable(out FailedReason failedReason)
 {
     (bool isAvailable, FailedReason reason) = fileDownloadDatabaseService.IsAvailable();
     failedReason = reason;
     return(!isAvailable);
 }