Example #1
0
        private void uiOuputFile_Click(object sender, EventArgs e)
        {
            List <ActiveRuleValidity> arv = new List <ActiveRuleValidity>();

            foreach (DataGridViewRow row in uiParameters.Rows)
            {
                string ruleName = (string)row.Cells["RuleName"].Value;
                bool   valid    = (bool)row.Cells["Valid"].Value;
                bool   active   = (bool)row.Cells["Active"].Value;
                if (active)
                {
                    arv.Add(new ActiveRuleValidity()
                    {
                        RuleName = ruleName, Valid = valid
                    });
                }
            }

            bool parse = uint.TryParse(uiMultiplication.Text, out uint scale);

            if (!parse)
            {
                scale = 1;
            }


            int UKPRN = int.Parse(uiUKPRN.Text);

            XmlGenerator.CreateAllFiles(_rfp, arv, UKPRN, @"D:\\", scale);
        }
        public static void Main(string[] args)
        {
            var cache = new DataCache();
            var rfp   = new RuleToFunctorParser(cache);

            rfp.CreateFunctors(AddFunctor);

            string folder = @".\";

            CheckForCommandLine(args, pathKeyword, ref folder);
            uint scale = 1;

            CheckForCommandLine(args, scaleKeyword, ref scale);
            CheckForCommandLine(args, supportedKeyword);
            CheckForCommandLine(args, helpKeyword);

            List <ActiveRuleValidity> rules = new List <ActiveRuleValidity>(100);

            for (int i = 0; i != args.Length; ++i)
            {
                if (args[i].ToLower() == rulesKeyword)
                {
                    for (int j = i + 1; j < args.Length - 1; j += 2)
                    {
                        string name  = args[j].ToLower();
                        var    ienum = _functors.Where(s => s.RuleName().ToLower() == name);
                        bool   found = ienum.Count() > 0;
                        if (!found)
                        {
                            break;
                        }

                        bool valid = false;
                        if (bool.TryParse(args[j + 1], out valid))
                        {
                            rules.Add(new ActiveRuleValidity()
                            {
                                RuleName = ienum.First().RuleName(),
                                Valid    = valid
                            });
                        }
                    }

                    break;
                }
            }

            if (rules.Count > 0)
            {
                XmlGenerator.CreateAllFiles(rfp, rules, UKPRN, folder, scale);
            }
            else
            {
                DisplayUsage();
            }
        }