Ejemplo n.º 1
0
 public void Process(SchemaProcessorContext context)
 {
     if (context.Type == typeof(ExternalRequirement))
     {
         var schema = context.Schema.Properties.Where(s => s.Key == PropertyHelpers.GetPropertyName(() => new ExternalRequirement().Heading)).FirstOrDefault().Value;
         using (var db = new CSET_Context())
         {
             var categories = db.QUESTION_GROUP_HEADING.Select(s => s.Question_Group_Heading1).Distinct().OrderBy(s => s).ToList();
             categories.ForEach(s => schema.Enumeration.Add(s));
         }
         schema = context.Schema.Properties.Where(s => s.Key == PropertyHelpers.GetPropertyName(() => new ExternalRequirement().Subheading)).FirstOrDefault().Value;
         using (var db = new CSET_Context())
         {
             var tempSchema    = new JsonSchema();
             var subCategories = db.UNIVERSAL_SUB_CATEGORIES.Select(s => s.Universal_Sub_Category).Distinct().OrderBy(s => s).ToList();
             subCategories.ForEach(s => tempSchema.Enumeration.Add(s));
             schema.AnyOf.Add(tempSchema);
             schema.AnyOf.Add(new JsonSchema()
             {
                 Type = JsonObjectType.String
             });
         }
         schema = context.Schema.Properties.Where(s => s.Key == PropertyHelpers.GetPropertyName(() => new ExternalRequirement().SecurityAssuranceLevel)).FirstOrDefault().Value;
         using (var db = new CSET_Context())
         {
             var subCategories = db.UNIVERSAL_SAL_LEVEL.Select(s => s.Sal_Level_Order).Distinct().OrderBy(s => s).ToList();
             subCategories.ForEach(s => schema.Enumeration.Add(s));
         }
     }
     else
     {
         throw new InvalidOperationException("Wrong type");
     }
 }
Ejemplo n.º 2
0
 public void Process(SchemaProcessorContext context)
 {
     if (context.Type == typeof(ExternalStandard))
     {
         var schema = context.Schema.Properties.Where(s => s.Key == PropertyHelpers.GetPropertyName(() => new ExternalStandard().Category)).FirstOrDefault().Value;
         using (var db = new CSET_Context())
         {
             var categories = db.SETS_CATEGORY.Select(s => s.Set_Category_Name).Distinct().OrderBy(s => s).ToList();
             categories.ForEach(s => schema.Enumeration.Add(s));
             var setNames  = db.SETS.Select(s => s.Set_Name).ToList().Union(db.SETS.Select(s => s.Short_Name).ToList()).Distinct().OrderBy(s => s).ToList();
             var newSchema = new JsonSchema();
             setNames.ForEach(s => newSchema.Enumeration.Add(s));
             context.Schema.Properties.Where(s => s.Key == PropertyHelpers.GetPropertyName(() => new ExternalStandard().ShortName)).FirstOrDefault().Value.Not = newSchema;
             var reqs = context.Schema.Properties.Where(s => s.Key == PropertyHelpers.GetPropertyName(() => new ExternalStandard().Requirements)).FirstOrDefault().Value;
             reqs.MinLength = 1;
         }
     }
     else
     {
         throw new InvalidOperationException("Wrong type");
     }
 }