Esempio n. 1
0
        public static XmlSchemaSet Get(ValidationProfile schemaName)
        {
            var ccsch = _Cache["xmlschema_" + schemaName.ToString()] as XmlSchemaSet;

            if (ccsch == null)
            {
                using (
                    var ms =
                        new MemoryStream(
                            Encoding.UTF8.GetBytes(schemaName == ValidationProfile.Lido
                                                       ? XsdSchemas.Lido
                                                       : XsdSchemas.Edm)))
                {
                    var schema       = XmlSchema.Read(ms, null);
                    var xmlSchemaSet = new XmlSchemaSet();
                    xmlSchemaSet.Add(schema);
                    xmlSchemaSet.Compile();



                    ccsch = xmlSchemaSet;

                    Add(schemaName, xmlSchemaSet);
                }
            }

            return(ccsch);
        }
Esempio n. 2
0
        public List <BrokenRule> ValidateXml(string xml, ValidationProfile validationProfile)
        {
            try
            {
                var xmlReader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(xml)));
                var xdoc      = XDocument.Load(xmlReader);
                var nmspc     = xdoc.Root.Name.Namespace;

                var schemas = CachedSchemas.Get(validationProfile); // new XmlSchemaSet();
                //schemas.Add("http://www.lido-schema.org", "http://www.lido-schema.org/schema/v1.0/lido-v1.0.xsd");
                xdoc.Validate(schemas, ValidationEventHandler);

                //dodatna preverjanja
                if (validationProfile == ValidationProfile.Lido)
                {
                    var additionalBrokenRule = CheckResourceSetRightsType(xdoc, nmspc);
                    if (additionalBrokenRule != null)
                    {
                        _brokenRules.Add(additionalBrokenRule);
                    }
                }
            }
            catch (Exception error)
            {
                _brokenRules.Add(new BrokenRule
                {
                    BrokenRuleCode = "#",
                    Message        = "Error validating document. " + Environment.NewLine + error.Message,
                    Severity       = SeverityType.Error
                });
            }

            return(_brokenRules);
        }
Esempio n. 3
0
        public ActionResult SaveValidationProfile(int?id)
        {
            ValidationProfile model = null;

            if (id.HasValue)
            {
                model = _IFormDesign.GetValidationProfile(id.Value);
                if (model == null)
                {
                    return(Alert("验证配置不存在!"));
                }
            }
            else
            {
                model = new ValidationProfile();
            }
            return(View(model));
        }
Esempio n. 4
0
        public void GetValidationPackageGeneratedTest()
        {
            ValidationService.ValidationService target = new ValidationService.ValidationService();

            List <ValidationProfile> profiles = target.GetValidationProfiles(this.tdb);
            ValidationProfile        firstGeneratedProfile = profiles.FirstOrDefault(y => y.Id < 0);
            ValidationProfile        lastGeneratedProfile  = profiles.LastOrDefault(y => y.Id < 0);

            List <ValidationDocument> actual = target.GetValidationPackage(this.tdb, 2, GenerationOptions.Generate, null);

            Assert.IsNotNull(actual);
            Assert.AreEqual(1, actual.Count);

            actual = target.GetValidationPackage(this.tdb, 1, GenerationOptions.Generate, null);

            Assert.IsNotNull(actual);
            Assert.AreEqual(3, actual.Count);
        }
Esempio n. 5
0
 public ActionResult SaveValidationProfile(ValidationProfile model)
 {
     _IFormDesign.Save <ValidationProfile>(model);
     return(Alert("数据保存成功!", Url.Action("ValidationProfile")));
 }
Esempio n. 6
0
 public static void Add(ValidationProfile schemaName, XmlSchemaSet xmlSchemaSet)
 {
     _Cache.Insert("xmlschema_" + schemaName.ToString(), xmlSchemaSet, null, DateTime.Now.AddDays(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
 }