Example #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;
            }
        }
Example #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;
        }
Example #3
0
 private static bool MatchTestingPropertyFailed(CmsEntities cee, Test test, ControlModule cm, out ControlSystemTestingProperty testingProperty)
 {
     testingProperty = (from x in cee.ControlSystemTestingProperties where x.Description.Equals(test.Description, StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
     if (testingProperty == null)
     {
         //log error
         Logger.Out(string.Format("Warning: Control {0} - No matchng ControlSystemTestingPropertyt found in CMS using Test.Description = '{1}'.", cm.Tag, test.Description));
         return true;
     }
     return false;
 }
Example #4
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;
 }
Example #5
0
 private static bool MatchControlSystemTypeFailed(CmsEntities cee, ControlModule cm, out ControlSystemType controlSystemType)
 {
     controlSystemType = (from x in cee.ControlSystemTypes where x.Name.Equals(cm.ControlModuleTypical.Name, StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
     if (controlSystemType == null)
     {
         Logger.Out(string.Format("Warning: Control {0} - No matchng ControlSystemType found in CMS using '{1}'.", cm.Tag, cm.ControlModuleTypical.Name));
         return true;
     }
     return false;
 }
Example #6
0
 private static bool MatchControlSystemFailed(CmsEntities cee, ControlModule cm, ControlSystemType controlSystemType, out ControlSystem controlSystem)
 {
     controlSystem = (from x in cee.ControlSystems where x.Name.Equals(cm.Tag, StringComparison.CurrentCultureIgnoreCase) && x.ControlSystemTypeId == controlSystemType.Id select x).FirstOrDefault();
     if (controlSystem == null)
     {
         Logger.Out(string.Format("Warning: Control {0} - No matchng ControlSystem found in CMS using '{0}'.", cm.Tag));
         return true;
     }
     return false;
 }
Example #7
0
 private static bool GetDefaultViewElementFailed(ControlModule cm, out List<Element> defaultViewElements)
 {
     defaultViewElements = (from x in cm.Elements where x.DefaultView select x).ToList();
     if (!defaultViewElements.Any())
     {
         Logger.Out(string.Format("Warning: Control {0} - No Default Elements.", cm.Tag));
         return true;
     }
     return false;
 }