Beispiel #1
0
        public QualityVerification GetQualityVerification()
        {
            if (_qualityVerification == null)
            {
                _domainTransactions.UseTransaction(
                    () =>
                {
                    if (VerificationMsg.SavedVerificationId >= 0)
                    {
                        _qualityVerification =
                            _qualityVerificationRepository.Get(
                                VerificationMsg.SavedVerificationId);

                        Assert.NotNull(_qualityVerification, "Quality verification not found.");

                        _domainTransactions.Initialize(
                            _qualityVerification.ConditionVerifications);
                        _domainTransactions.Initialize(
                            _qualityVerification.VerificationDatasets);
                    }
                    else
                    {
                        _qualityVerification = GetQualityVerificationTx(VerificationMsg);
                    }
                });
            }

            return(_qualityVerification);
        }
Beispiel #2
0
        private static void Initialize(
            [NotNull] QualityVerification verification,
            [NotNull] IDomainTransactionManager domainTransactionManager)
        {
            Assert.ArgumentNotNull(verification, nameof(verification));
            Assert.ArgumentNotNull(domainTransactionManager, nameof(domainTransactionManager));

            if (verification.IsPersistent)
            {
                domainTransactionManager.Reattach(verification);
                domainTransactionManager.Initialize(verification.VerificationDatasets);
            }

            foreach (
                QualityConditionVerification conditionVerification in
                verification.ConditionVerifications)
            {
                QualityCondition qualityCondition =
                    conditionVerification.DisplayableCondition;

                if (qualityCondition.IsPersistent)
                {
                    domainTransactionManager.Reattach(qualityCondition);
                }

                foreach (TestParameterValue value in qualityCondition.ParameterValues)
                {
                    if (value.IsPersistent)
                    {
                        domainTransactionManager.Reattach(value);
                    }
                }
            }

            // NOTE this causes NonUniqueObjectExceptions in case of datasets from other models (only?)
            // But: it does not seem to be really needed
            //foreach (
            //    QualityVerificationDataset verificationDataset in
            //        verification.VerificationDatasets)
            //{
            //    domainTransactionManager.Reattach(verificationDataset.Dataset);
            //}
        }