Exemplo n.º 1
0
        public void TestXsdValidation()
        {
            string    source_file_path = "../../DataFiles/SalesOrder/Sample_SO[8303].xml";
            XDocument doc             = XDocument.Load(source_file_path);
            IEngine   validatorEngine = new ValidatorEngine(doc);

            Assert.AreEqual(false, validatorEngine.Validation());
            // Write ValidatorEngine(XDocument) which will make inline calls
            // configure, start and stop.
            // and returns true/false based on successful validation.
            // TODO: 1). Implement the logic for IsEditable
            // TODO: 2). Implement the logic for IsViewable
            // TODO: 3). Implement bool ValidationEngine.Validate() method
            // TODO: 4). Implement Validation.onFailureHalt attribute
            // TODO: 5). Save ValidatorType value in ErrorInboundData.errorType
            // TODO: 6). In XSD implement the logic to handle NonPrintableCharacters
            // TODO: 7). Local Custom Attributes should work with both rules, validators & actions level.
            // TODO: 8). Log all errors using Log4net
            // TODO: 9). In ValidationEngine contructor implement xsd validation of the config file.
            // TODO: 10). Unit test all task before commit it to Git.
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            //SalesOrders salesOrders = new SalesOrders();
            //XMLHelper<SalesOrders>.Instance.UnMarshalingFromXML("../../DataFiles/SalesOrder/Sample_SO[8303].xml", out salesOrders);
            //XMLHelper<SalesOrders>.Instance.MarshalingToXML(salesOrders, "../../DataFiles/SalesOrder/SalesOrderOutput.xml");

            //XMLHelper<SalesOrders>.Instance.UnMarshalingFromXML("../../SalesOrder1.xml", out salesOrders);
            //XMLHelper<SalesOrders>.Instance.MarshalingToXML(salesOrders, "../../SalesOrder1Output.xml");

            //string path = System.Reflection.Assembly.GetExecutingAssembly().Location;

            ////To get the location the assembly normally resides on disk or the install directory
            //string path1 = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;

            ////once you have the path you get the directory with:
            //var directory = System.IO.Path.GetDirectoryName(path);
            //directory = System.IO.Path.GetDirectoryName(path1);
            //SendEmail();
            //STEInterfacesEntities entities = new STEInterfacesEntities();
            //LocationRepository locRepository = new LocationRepository(entities);

            //IGenericRepository<Location_SYD> locationRepository = new GenericRepository<Location_SYD>();
            //IEnumerable<Location_SYD> locations = locationRepository.SelectAll();
            //LocationCustomRepository locCustomRepo = new LocationCustomRepository();


            //Location_SYD obj = locCustomRepo.SelectByLocationAndPostCodeAndState("CALLIGNEE SOUTH", "3844", "VIC");
            //Console.WriteLine(obj.location);
            //List<Location_SYD> list = locRepository.GetLocation("4817", "WILLOWS (TOWNSVILLE)", "QLD");

            try
            {
                //Customizations.XsdValidation instance = (Customizations.XsdValidation)Activator.CreateInstance(type);
                //Validation val = new Validation();
                //throw new Exception("testing Logger");
                string    source_file_path = "../../DataFiles/SalesOrder/Sample_SO[8303].xml";
                XDocument doc             = XDocument.Load(source_file_path);
                IEngine   validatorEngine = new ValidatorEngine(doc);
                validatorEngine.Validation();
                Console.ReadKey();
                //Console.WriteLine(Constants.EventType.Validation_Engine_Configured);
                //Console.WriteLine(Constants.EventType.Validation_Engine_Started);
                //Console.WriteLine(Constants.EventType.Validation_Engine_Stopped);

                //Console.WriteLine(Constants.EventType.Standard_Xml_Validation_Started);
                //Console.WriteLine(Constants.EventType.Standard_Xml_Validation_Succeeded);
                //Console.WriteLine(Constants.EventType.Standard_Xml_Validation_Failed);

                //Console.WriteLine(Constants.LocationMatch.WithoutModification);
                //Console.WriteLine(Constants.LocationMatch.StripParenthesis);
                //Console.WriteLine(Constants.LocationMatch.MatchStringAfterSpace);
                //Console.WriteLine(Constants.LocationMatch.MatchFirst5Chars);

                //Console.WriteLine(Constants.ApplicationId);

                //Console.WriteLine(Constants.ExecuteOn.success);
                //Console.WriteLine(Constants.ExecuteOn.failure);

                //Console.WriteLine(Constants.Suggestions.InvalidSuburb);
                //Console.WriteLine(Constants.Suggestions.InvalidPostCode);
                //Console.WriteLine(Constants.Suggestions.InvalidState);
                //Console.WriteLine(Constants.Suggestions.InvalidSuburbPostCodeState);

                //Console.WriteLine(Constants.Suggestions.XSD_Invalid_Integer);
                //Console.WriteLine(Constants.Suggestions.XSD_Invalid_Float);
                //Console.WriteLine(Constants.Suggestions.XSD_Invalid_DateTime);
                //Console.WriteLine(Constants.Suggestions.XSD_Invalid_Boolean);
                //Console.WriteLine(Constants.Suggestions.XSD_Duplicate_Element);
                //Console.WriteLine(Constants.Suggestions.XSD_Invalid_String);

                //Console.WriteLine(Constants.MandatoryField_NameTags.WarehouseCode);
                //Console.WriteLine(Constants.MandatoryField_NameTags.ClientCode);
                //Console.WriteLine(Constants.MandatoryField_NameTags.CompanyCode);
                //Console.WriteLine(Constants.MandatoryField_NameTags.OrderNumber);
                //Console.WriteLine(Constants.MandatoryField_NameTags.OrderDate);
                //Console.WriteLine(Constants.MandatoryField_NameTags.DocumentType);

                //Console.WriteLine(Constants.LengthValidation_CustomFields.OrderNumber);
                //Console.WriteLine(Constants.AddressValidator_CustomFields.postCode);
                //Console.WriteLine(Constants.AddressValidator_CustomFields.location);
                //Console.WriteLine(Constants.AddressValidator_CustomFields.state);

                //Console.WriteLine(Constants.XsdValidator_CustomFields.xsd_file_path);
                //Console.WriteLine(Constants.XsdValidator_CustomFields.xsd_ns);
            }
            catch (Exception ex)
            {
                Logger.Instance.GetLogInstance().Error(JsonConvert.SerializeObject(ex));
            }


            //var configFilePath = ConfigurationManager.AppSettings["ConfigXmlPath"];
            //if (String.IsNullOrEmpty(configFilePath))
            //{
            //    throw new Exception(@"XML Configuration file path is not set in ""ConfigXmlPath"" configuration");
            //}
            //var configXml = XDocument.Load(configFilePath);

            //Console.WriteLine("Configuring CustomValidatorEngineObsolete....");
            //ruleEngine.Configure();
            //Console.WriteLine("CustomValidatorEngineObsolete Configurtion finished.");

            //// read sample xml to validate
            //var sampleXml = XDocument.Load("SampleXml1.xml");

            //Console.WriteLine("Starting CustomValidatorEngineObsolete....");
            //ruleEngine.StartValidation(sampleXml);
            //Console.WriteLine("CustomValidatorEngineObsolete start finished.");

            //Console.WriteLine("Stopping CustomValidatorEngineObsolete....");
            //ruleEngine.Stop();

            //Console.WriteLine("CustomValidatorEngineObsolete stopped.");
            //Console.ReadLine();


            //Console.ReadKey();
        }