예제 #1
0
        private static void SetOrdinalAndGroupOnControlTypeTestingProperty(ARTEntities art, CmsEntities cee, TestResult testResult, ControlModule cm, ControlSystem controlSystem)
        {
            //get the number for this testresult to use on the ControlSystemTypeTestingProperty.Number
            var tp = (from x in cee.ControlSystemTestingProperties where x.Description.Equals(testResult.Test.Description, StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (tp == null)
            {
                //log error
                Logger.Out(string.Format("Control {0} - Trying to set ordinal. No matchng ControlSystemTestingProperty found in CMS using Description = '{1}'.", cm.Tag, testResult.Test.Description));
                return;
            }

            var controlSystemTypeTestingProperty = (from x in cee.ControlSystemTypeTestingProperties
                                                    where x.ControlSystemTypeId == controlSystem.ControlSystemTypeId
                                                          && x.TestPropertyId == tp.Id
                                                    select x).FirstOrDefault();

            if (controlSystemTypeTestingProperty == null)
            {
                Logger.Out(string.Format("Control {0} - Trying to set ordinal. No matchng ControlSystemTypeTestingProperty found in CMS using ControlSystemTypeId = '{1}' and TestPropertyId = {2}.", cm.Tag, controlSystem.ControlSystemTypeId, tp.Id));
                return;
            }

            //matchGroup
            if (testResult.Test == null)
            {
                Logger.Out(string.Format("Control {0} - Trying to set Group Id. No Tests exist on TestResult.Test. ", cm.Tag));
                return;
            }

            if (controlSystemTypeTestingProperty.Ordinal == 0)
            {
                //not been set before.
                controlSystemTypeTestingProperty.GroupOrdinal = testResult.Number;
            }

            Stage stage = (from x in art.Stages where x.Id == testResult.Test.StageId select x).FirstOrDefault();

            if (stage != null)
            {
                if (controlSystemTypeTestingProperty.Ordinal == 0)
                {
                    //not been set before.
                    if (stage.Description.Equals("Stage 2", StringComparison.CurrentCultureIgnoreCase))
                    {
                        controlSystemTypeTestingProperty.Ordinal = 1;
                    }
                    else if (stage.Description.Equals("Stage 3", StringComparison.CurrentCultureIgnoreCase))
                    {
                        controlSystemTypeTestingProperty.Ordinal = 2;
                    }
                    else if (stage.Description.Equals("Stage 4", StringComparison.CurrentCultureIgnoreCase))
                    {
                        controlSystemTypeTestingProperty.Ordinal = 3;
                    }
                }

                //check if we have cee.Group.
                ComponentTypeGroup typeGroup = (from x in cee.ComponentTypeGroups
                                                where x.Name.Equals(stage.Description, StringComparison.InvariantCultureIgnoreCase)
                                                    && x.ComponentPropertyType.Equals(CommonUtils.EquipmentPropertyType.SystemTestingProperty.ToString(), StringComparison.InvariantCultureIgnoreCase)
                                                select x).FirstOrDefault();

                if (typeGroup == null)
                {
                    //CREATE GROUP
                    typeGroup = new ComponentTypeGroup
                    {
                        Name = stage.Description,
                        ComponentPropertyType = CommonUtils.EquipmentPropertyType.SystemTestingProperty.ToString()
                    };

                    cee.ComponentTypeGroups.Add(typeGroup);
                    cee.SaveChanges();
                    Logger.Out(string.Format("Control {0} - Created new CMS ComponentTypeGroup '{1}'. ", cm.Tag, typeGroup.Name));

                }

                controlSystemTypeTestingProperty.ComponentTypeGroupId = typeGroup.Id;
            }
        }
예제 #2
0
        private bool BuildPropertyValueFailed(ControlSystem controlSystem, ControlSystemTestingProperty testingProperty, TestResult testResult, CmsEntities cee, ControlModule cm, out ControlSystemTestingPropertyValue pv)
        {
            pv = new ControlSystemTestingPropertyValue
            {
                ContolSystemId = controlSystem.Id,
                TestPropertyId = testingProperty.Id,
            };

            if (testResult.Notes != null && !string.IsNullOrEmpty(testResult.Notes.Trim()))
            {
                pv.Notes = testResult.Notes; //sets the new Notes property.
            }

            //Numerical
            if (testingProperty.Type.Equals(TestingType.Numerical.ToString(), StringComparison.CurrentCultureIgnoreCase))
            {
                pv.Value = GetNumbers(testResult.Entry); //sets the Numerical checkbox value.
            }

            //VerifiedCheckBox
            else if (testingProperty.Type.Equals(TestingType.VerifiedCheckBox.ToString(), StringComparison.CurrentCultureIgnoreCase))
            {
                pv.Value = testResult.Tested.ToString(); //sets the verified checkbox value.

                if (testResult.TestedDate.HasValue && testResult.TestedUserId.HasValue)
                {
                    var user = (from x in cee.Users where x.Id == testResult.TestedUserId.Value select x).FirstOrDefault();
                    if (user == null)
                    {
                        Logger.Out(string.Format("Warning: Control {0} - No matchng User found in CMS using USer.Idn = '{1}'.", cm.Tag, testResult.TestedUserId.Value));
                        return true;
                    }

                    pv.VerifiedUserDate = string.Format("{0} by {1} {2}", testResult.TestedDate.Value.ToString(DATE_FORMAT), user.FirstName, user.LastName);
                }
            }

            return false;
        }
예제 #3
0
 private static bool MatchTestFailed(ARTEntities art, TestResult testResult, ControlModule cm, out Test test)
 {
     test = (from x in art.Tests where x.Id == testResult.TestId select x).FirstOrDefault();
     if (test == null)
     {
         //log error
         Logger.Out(string.Format("Control {0} - No matchng TestResult.Test found in ART using Test.Id = '{1}'.", cm.Tag, testResult.TestId));
         return true;
     }
     return false;
 }