コード例 #1
0
ファイル: ReportService.cs プロジェクト: PiSim/LDb2
        public Requirement GenerateRequirement(MethodVariant methodVariant)
        {
            Method method = methodVariant.GetMethod(true);

            method.LoadSubMethods();

            Requirement tempReq = new Requirement()
            {
                MethodVariantID = methodVariant.ID,
                Name            = method.Name,
                Description     = methodVariant.Description
            };

            tempReq.Deprecated2 = method.ID;
            tempReq.IsOverride  = false;
            tempReq.Name        = "";
            tempReq.Description = "";
            tempReq.Position    = 0;

            foreach (SubMethod measure in method.SubMethods)
            {
                SubRequirement tempSub = new SubRequirement()
                {
                    SubMethodID = measure.ID
                };

                tempReq.SubRequirements.Add(tempSub);
            }

            return(tempReq);
        }
コード例 #2
0
 private void EvaluateUsing(MethodVariant theClassifier, ClassificationDeclaration classificationDeclaration)
 {
     classificationDeclaration.MethodVariant = theClassifier;
     foreach (var classifier in EnumUtil.GetAllValues <Method>())
     {
         EvaluateUsing(classifier, classificationDeclaration);
     }
 }
コード例 #3
0
ファイル: ExternalResultPresenter.cs プロジェクト: PiSim/LDb2
 public ExternalResultPresenter(MethodVariant methodVariant,
                                IEnumerable <Test> testList)
 {
     _methodVariant    = methodVariant;
     _resultDictionary = new Dictionary <int, Test>();
     foreach (Test tst in testList)
     {
         _resultDictionary.Add(tst.TestRecord.BatchID,
                               tst);
     }
 }
コード例 #4
0
ファイル: SpecificationService.cs プロジェクト: PiSim/LDb2
        /// <summary>
        /// Updates all the Requirement entities for an Updated MethodVariant.
        /// Creates/Updates/Deletes Corresponding SubRequirements in order to Match the current SubMethod list of the Method
        /// </summary>
        /// <param name="oldVariant">The MethodVariant to be replaced</param>
        /// <param name="newVariant">The MethodVariant that will replace the old one</param>
        /// <param name="newMethod">A reference to the new Method instance</param>
        /// <param name="entities">A reference to the DB transaction instance</param>
        private void BuildUpdatedRequirementsForMethodVariant(MethodVariant oldVariant,
                                                              MethodVariant newVariant,
                                                              Method newMethod,
                                                              LabDbEntities entities)
        {
            foreach (Requirement req in oldVariant.Requirements.ToList())
            {
                req.MethodVariant = newVariant;

                foreach (SubMethod smtd in newMethod.SubMethods)
                {
                    SubRequirement updateTarget = req.SubRequirements.FirstOrDefault(sreq => sreq.SubMethodID == smtd.OldVersionID);

                    if (updateTarget != null)
                    {
                        updateTarget.SubMethod = smtd;
                        updateTarget.IsUpdated = true;
                    }
                    else
                    {
                        req.SubRequirements.Add(new SubRequirement()
                        {
                            IsUpdated     = true,
                            RequiredValue = "",
                            SubMethod     = smtd,
                        });
                    }
                }

                foreach (SubRequirement sreq in req.SubRequirements.Where(nn => !nn.IsUpdated)
                         .ToList())
                {
                    entities.Entry(sreq).State = EntityState.Deleted;
                }
            }
        }
コード例 #5
0
ファイル: SpecificationService.cs プロジェクト: PiSim/LDb2
        /// <summary>
        /// Begins the process of Modifying a Method's subMethod list
        /// </summary>
        /// <param name="toBeModified"> an instance of the method to alter</param>
        public void ModifyMethodTestList(Method toBeModified)
        {
            toBeModified.LoadSubMethods();

            Views.ModifyMethodSubMethodListDialog modificationDialog = new Views.ModifyMethodSubMethodListDialog();

            modificationDialog.OldVersion = toBeModified;

            if (modificationDialog.ShowDialog() == true)
            {
                using (LabDbEntities entities = _dbContextFactory.Create())
                {
                    /// Retrieves references to up to date entities from the Database

                    Method attachedOldMethod = entities.Methods.FirstOrDefault(mtd => mtd.ID == toBeModified.ID);

                    if (attachedOldMethod == null)
                    {
                        return;
                    }

                    /// Creates a new method Instance from the old one

                    Method newMethod = new Method()
                    {
                        Description      = attachedOldMethod.Description,
                        ShortDescription = attachedOldMethod.ShortDescription,
                        OldVersionID     = attachedOldMethod.ID,
                        PropertyID       = attachedOldMethod.PropertyID,
                        StandardID       = attachedOldMethod.StandardID
                    };

                    entities.Methods.Add(newMethod);

                    attachedOldMethod.IsOld = true;

                    /// Adds the new SubMethod list to the instance

                    int subMethodPositionCounter = 0;

                    foreach (SubMethod smtd in modificationDialog.SubMethodList)
                    {
                        smtd.Position = subMethodPositionCounter++;
                        newMethod.SubMethods.Add(smtd);
                    }

                    /// Updates all the variants

                    ICollection <MethodVariant> oldVariantList = attachedOldMethod.MethodVariants.ToList();

                    foreach (MethodVariant mtdvar in oldVariantList)
                    {
                        mtdvar.IsOld = true;

                        MethodVariant newVariant = new MethodVariant()
                        {
                            Description       = mtdvar.Description,
                            Name              = mtdvar.Name,
                            PreviousVersionID = mtdvar.ID
                        };

                        newMethod.MethodVariants.Add(newVariant);

                        BuildUpdatedRequirementsForMethodVariant(mtdvar,
                                                                 newVariant,
                                                                 newMethod,
                                                                 entities);
                    }

                    entities.SaveChanges();

                    _eventAggregator.GetEvent <BatchChanged>()
                    .Publish(new EntityChangedToken(newMethod,
                                                    EntityChangedToken.EntityChangedAction.Created));
                };
            }
        }