예제 #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
        public void AddOverride(RequirementWrapper wrapper)
        {
            Requirement newOverride = new Requirement
            {
                Description            = wrapper.RequirementInstance.Description,
                IsOverride             = true,
                MethodVariantID        = wrapper.RequirementInstance.MethodVariantID,
                OverriddenID           = wrapper.RequirementInstance.ID,
                SpecificationVersionID = SpecificationVersionInstance.ID
            };

            foreach (SubRequirement subReq in wrapper.RequirementInstance.SubRequirements)
            {
                SubRequirement tempSub = new SubRequirement
                {
                    SubMethodID   = subReq.SubMethodID,
                    RequiredValue = subReq.RequiredValue
                };

                newOverride.SubRequirements.Add(tempSub);
            }

            _labDbData.Execute(new InsertEntityCommand(newOverride));
            wrapper.RequirementInstance = newOverride;
        }
예제 #3
0
        /// <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;
                }
            }
        }