public RatingEngine(int verbosityLevel, int nbDodecaCalls, string ruleBaseFile) { this.nbDodecaCalls = nbDodecaCalls; ie = new IEImpl(CSharpBinderFactory.LoadFromFile("NxBRE.Examples.TelcoRatingBinder", ruleBaseFile + ".ccb")); if (verbosityLevel >= 1) { ie.NewFactHandler += new NewFactEvent(HandleNewFactEvent); } ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleBaseFile, System.IO.FileAccess.Read)); }
/// <summary> /// Starts the FraudControl system. /// </summary> /// <param name="args"> /// args[0] the number of tens of customers to create /// args[1] the full path of fraudcontrol.ruleml /// </param> public static void Main(string[] args) { FraudControl fc = new FraudControl(Int32.Parse(args[0]), args[1]); /// Demonstrates how to use a Custom Binder Class Console.WriteLine("\n\n************ Using Custom Binder Class ************\n"); fc.PerformProcess(new CustomBinder()); /// Demonstrates how to use a Custom Compiled Binder Console.WriteLine("\n\n************ Using Compiled Custom Binder ************\n"); fc.PerformProcess(CSharpBinderFactory.LoadFromFile("NxBRE.Examples.CompiledCustomBinder", args[1] + ".ccb")); /// Demonstrates how to use the Flow Engine Binder Console.WriteLine("************ Using Flow Engine Binder ************\n"); fc.PerformProcess(new FlowEngineBinder(args[1] + ".xbre", BindingTypes.BeforeAfter)); }
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."); } }