Exemplo n.º 1
0
 private static IEnumerable <int> GetVerifiedConditionIds(
     [NotNull] QualityVerificationMsg msg)
 {
     foreach (var conditionVerificationMsg in msg.ConditionVerifications)
     {
         yield return(conditionVerificationMsg.QualityConditionId);
     }
 }
Exemplo n.º 2
0
        private static void AddVerification([NotNull] QualityVerificationMsg verificationMsg,
                                            [CanBeNull] QualityVerification toOverallVerification)
        {
            if (toOverallVerification == null)
            {
                return;
            }

            if (verificationMsg.Cancelled)
            {
                toOverallVerification.Cancelled = true;
            }

            foreach (var conditionVerificationMsg in verificationMsg.ConditionVerifications)
            {
                int conditionId = conditionVerificationMsg.QualityConditionId;

                QualityConditionVerification conditionVerification =
                    FindQualityConditionVerification(toOverallVerification, conditionId);

                conditionVerification.ErrorCount      += conditionVerificationMsg.ErrorCount;
                conditionVerification.ExecuteTime     += conditionVerificationMsg.ExecuteTime;
                conditionVerification.RowExecuteTime  += conditionVerificationMsg.RowExecuteTime;
                conditionVerification.TileExecuteTime += conditionVerificationMsg.TileExecuteTime;

                if (!conditionVerificationMsg.Fulfilled)
                {
                    conditionVerification.Fulfilled = false;
                }

                if (conditionVerificationMsg.StopConditionId >= 0)
                {
                    conditionVerification.StopCondition =
                        FindQualityConditionVerification(toOverallVerification,
                                                         conditionVerificationMsg.StopConditionId)
                        .QualityCondition;
                }
            }

            foreach (var datasetMsg in verificationMsg.VerificationDatasets)
            {
                QualityVerificationDataset qualityVerificationDataset =
                    toOverallVerification.VerificationDatasets.First(
                        d => d.Dataset.Id == datasetMsg.DatasetId);

                qualityVerificationDataset.LoadTime += datasetMsg.LoadTime;
            }

            toOverallVerification.ContextName             = verificationMsg.ContextName;
            toOverallVerification.ContextType             = verificationMsg.ContextType;
            toOverallVerification.ProcessorTimeSeconds   += verificationMsg.ProcessorTimeSeconds;
            toOverallVerification.RowsWithStopConditions += verificationMsg.RowsWithStopConditions;
            toOverallVerification.Operator = verificationMsg.UserName;
        }
Exemplo n.º 3
0
        private List <QualityConditionVerification> GetQualityConditionVerifications(
            [NotNull] QualityVerificationMsg msg)
        {
            List <QualityConditionVerification> conditionVerifications =
                new List <QualityConditionVerification>();

            Dictionary <int, QualityCondition> conditionsById =
                new Dictionary <int, QualityCondition>();

            foreach (var conditionVerificationMsg in msg.ConditionVerifications)
            {
                int qualityConditionId = conditionVerificationMsg.QualityConditionId;

                QualityCondition qualityCondition = GetQualityCondition(
                    qualityConditionId, conditionsById);

                Assert.NotNull(qualityCondition, $"Condition {qualityConditionId} not found");

                // TODO: AllowError/StopOnError
                QualitySpecificationElement element =
                    new QualitySpecificationElement(qualityCondition);

                var conditionVerification = new QualityConditionVerification(element);

                conditionVerification.Fulfilled  = conditionVerificationMsg.Fulfilled;
                conditionVerification.ErrorCount = conditionVerificationMsg.ErrorCount;

                conditionVerification.ExecuteTime     = conditionVerificationMsg.ExecuteTime;
                conditionVerification.RowExecuteTime  = conditionVerificationMsg.RowExecuteTime;
                conditionVerification.TileExecuteTime = conditionVerificationMsg.TileExecuteTime;

                if (conditionVerificationMsg.StopConditionId >= 0)
                {
                    conditionVerification.StopCondition = GetQualityCondition(
                        conditionVerificationMsg.StopConditionId, conditionsById);
                }

                conditionVerifications.Add(conditionVerification);
            }

            return(conditionVerifications);
        }
Exemplo n.º 4
0
        private QualityVerification GetQualityVerificationTx([NotNull] QualityVerificationMsg msg)
        {
            List <QualityConditionVerification> conditionVerifications =
                GetQualityConditionVerifications(msg);

            var result = new QualityVerification(
                msg.SpecificationId, msg.SpecificationName, msg.SpecificationDescription,
                msg.UserName, conditionVerifications);

            result.Cancelled   = msg.Cancelled;
            result.ContextName = msg.ContextName;
            result.ContextType = msg.ContextType;
            result.StartDate   = new DateTime(msg.StartTimeTicks);
            result.EndDate     = new DateTime(msg.EndTimeTicks);

            result.ProcessorTimeSeconds   = msg.ProcessorTimeSeconds;
            result.RowsWithStopConditions = msg.RowsWithStopConditions;

            result.CalculateStatistics();

            return(result);
        }
Exemplo n.º 5
0
        private void ProcessFinalResult(Task <bool> task, SubResponse subVerification)
        {
            if (task.IsFaulted)
            {
                _msg.WarnFormat("Sub-verification has faulted: {0}", subVerification);

                CancellationTokenSource.Cancel();
                CancellationMessage = task.Exception?.InnerException?.Message;
            }

            if (!string.IsNullOrEmpty(subVerification.CancellationMessage))
            {
                CancellationMessage = subVerification.CancellationMessage;
            }

            QualityVerificationMsg verificationMsg = subVerification.VerificationMsg;

            if (verificationMsg != null)
            {
                AddVerification(verificationMsg, QualityVerification);
            }

            DrainIssues(subVerification);
        }
Exemplo n.º 6
0
        private static void PackVerification([CanBeNull] QualityVerification verification,
                                             [NotNull] VerificationResponse response)
        {
            if (verification == null)
            {
                return;
            }

            QualityVerificationMsg result = new QualityVerificationMsg();

            result.SavedVerificationId = verification.Id;
            result.SpecificationId     = verification.SpecificationId;

            CallbackUtils.DoWithNonNull(
                verification.SpecificationName, s => result.SpecificationName = s);

            CallbackUtils.DoWithNonNull(
                verification.SpecificationDescription,
                s => result.SpecificationDescription = s);

            CallbackUtils.DoWithNonNull(verification.Operator, s => result.UserName = s);

            result.StartTimeTicks = verification.StartDate.Ticks;
            result.EndTimeTicks   = verification.EndDate.Ticks;

            result.Fulfilled = verification.Fulfilled;
            result.Cancelled = verification.Cancelled;

            result.ProcessorTimeSeconds = verification.ProcessorTimeSeconds;

            CallbackUtils.DoWithNonNull(verification.ContextType, (s) => result.ContextType = s);
            CallbackUtils.DoWithNonNull(verification.ContextName, (s) => result.ContextName = s);

            result.RowsWithStopConditions = verification.RowsWithStopConditions;

            foreach (var conditionVerification in verification.ConditionVerifications)
            {
                var conditionVerificationMsg =
                    new QualityConditionVerificationMsg
                {
                    QualityConditionId =
                        Assert.NotNull(conditionVerification.QualityCondition).Id,
                    StopConditionId = conditionVerification.StopCondition?.Id ?? -1,
                    Fulfilled       = conditionVerification.Fulfilled,
                    ErrorCount      = conditionVerification.ErrorCount,
                    ExecuteTime     = conditionVerification.ExecuteTime,
                    RowExecuteTime  = conditionVerification.RowExecuteTime,
                    TileExecuteTime = conditionVerification.TileExecuteTime
                };

                result.ConditionVerifications.Add(conditionVerificationMsg);
            }

            foreach (var verificationDataset in verification.VerificationDatasets)
            {
                var verificationDatasetMsg =
                    new QualityVerificationDatasetMsg
                {
                    DatasetId = verificationDataset.Dataset.Id,
                    LoadTime  = verificationDataset.LoadTime
                };

                result.VerificationDatasets.Add(verificationDatasetMsg);
            }

            response.QualityVerification = result;
        }