Esempio n. 1
0
        private bool EvaluateNxBREOperator(object individualValue, string operatorName, string[] arguments)
        {
            if (arguments.Length != 1)
            {
                throw new BREException("Only one argument must be passed to " +
                                       operatorName +
                                       " because the evaluated individual provides the other one.");
            }

            return(FlowEngineBinder.EvaluateFERIOperator(name, individualValue, arguments[0]));
        }
Esempio n. 2
0
        private static void InitMainEngine()
        {
            IBinder binderObject = null;

            if (binder)
            {
                if (csharpBinder)
                {
                    String code;
                    using (StreamReader sr = File.OpenText(RuleBaseFile + ".ccb")) code = sr.ReadToEnd();
                    binderObject = CSharpBinderFactory.LoadFromString("NxBRE.StressTests." + ActiveRule.ToUpper() + "_Binder", code);
                }
                else
                {
                    binderObject = new FlowEngineBinder(RuleBaseFile + ".xbre", BindingTypes.BeforeAfter);
                }
            }

            MAIN_IE.LoadRuleBase(new RuleML09NafDatalogAdapter(RuleBaseFile, System.IO.FileAccess.Read), binderObject);
        }
Esempio n. 3
0
        public void LoadRuleBase(MainForm mf, string uri, bool onlyFacts)
        {
            IBinder binder = null;

            // give priority to custom compiled binders
            if (File.Exists(uri + ".ccb"))
            {
                up.lastBinderClassName = mf.PromptForString("C# Custom Binder - " + uri + ".ccb",
                                                            "Enter the fully qualified name of the binder class:",
                                                            up.lastBinderClassName);
                binder = CSharpBinderFactory.LoadFromFile(up.lastBinderClassName, uri + ".ccb");
            }
            else if (File.Exists(uri + ".vcb"))
            {
                up.lastBinderClassName = mf.PromptForString("VB.NET Custom Binder - " + uri + ".vcb",
                                                            "Enter the fully qualified name of the binder class:",
                                                            up.lastBinderClassName);
                binder = VisualBasicBinderFactory.LoadFromFile(up.lastBinderClassName, uri + ".vcb");
            }
            else if (File.Exists(uri + ".xbre"))
            {
                bool isBeforeAfter = mf.AskYesNoQuestion("Flow Engine Binder - " + uri + ".xbre",
                                                         uri + ".xbre\n\nIs this binder running in Before/After mode ?\n\n(No would mean that it runs in Control Process mode)");

                binder = new FlowEngineBinder(uri + ".xbre", isBeforeAfter?BindingTypes.BeforeAfter:BindingTypes.Control);
            }

            if (!onlyFacts)
            {
                ie = new IEImpl(binder);
            }

            switch (Path.GetExtension(uri).ToLower())
            {
            case ".ruleml":
                try {
                    if (onlyFacts)
                    {
                        ie.LoadFacts(new RuleML09NafDatalogAdapter(uri, FileAccess.Read));
                    }
                    else
                    {
                        ie.LoadRuleBase(new RuleML09NafDatalogAdapter(uri, FileAccess.Read));
                    }
                }
                catch (Exception firstAttemptException) {
                    try {
                        if (onlyFacts)
                        {
                            ie.LoadFacts(new RuleML086NafDatalogAdapter(uri, FileAccess.Read));
                        }
                        else
                        {
                            ie.LoadRuleBase(new RuleML086NafDatalogAdapter(uri, FileAccess.Read));
                        }
                    }
                    catch (Exception) {
                        try {
                            if (onlyFacts)
                            {
                                ie.LoadFacts(new RuleML086DatalogAdapter(uri, FileAccess.Read));
                            }
                            else
                            {
                                ie.LoadRuleBase(new RuleML086DatalogAdapter(uri, FileAccess.Read));
                            }
                        }
                        catch (Exception) {
                            try {
                                if (onlyFacts)
                                {
                                    ie.LoadFacts(new RuleML08DatalogAdapter(uri, FileAccess.Read));
                                }
                                else
                                {
                                    ie.LoadRuleBase(new RuleML08DatalogAdapter(uri, FileAccess.Read));
                                }
                            } catch (Exception) {
                                // the fall-back policy failed, hence throw the original exception
                                throw firstAttemptException;
                            }
                        }
                    }
                }
                break;

            case ".hrf":
                if (onlyFacts)
                {
                    ie.LoadFacts(new HRF086Adapter(uri, FileAccess.Read));
                }
                else
                {
                    ie.LoadRuleBase(new HRF086Adapter(uri, FileAccess.Read));
                }
                break;

            case ".vdx":
                string[] selectedPages = mf.PromptForVisioPageNameSelection(Visio2003Adapter.GetPageNames(uri));
                if (selectedPages != null)
                {
                    if (onlyFacts)
                    {
                        ie.LoadFacts(new Visio2003Adapter(uri, FileAccess.Read, selectedPages));
                    }
                    else
                    {
                        ie.LoadRuleBase(new Visio2003Adapter(uri, FileAccess.Read, (DialogResult.Yes == MessageBox.Show(mf,
                                                                                                                        "Is your Visio rule base using strict syntax?",
                                                                                                                        "Visio strictness",
                                                                                                                        MessageBoxButtons.YesNo,
                                                                                                                        MessageBoxIcon.Question,
                                                                                                                        MessageBoxDefaultButton.Button2)), selectedPages));
                    }
                }
                break;

            default:
                throw new Exception(Path.GetExtension(uri) + " is an unknown extension.");
            }
        }