public void TestLoadState() { FileStream fstream = new FileStream("StateDynamic.rlb", FileMode.Open); RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); ruleBase.Load(fstream); WorkingMemory workingMemory = ruleBase.NewWorkingMemory(); State a = new State("A"); State b = new State("B"); State c = new State("C"); State d = new State("D"); State e = new State("E"); // By setting dynamic to TRUE, Drools will use JavaBean // PropertyChangeListeners so you don't have to call modifyObject(). //UPGRADE_NOTE: Final was removed from the declaration of 'dynamic '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'" bool dynamic = true; workingMemory.assertObject(a, dynamic); workingMemory.assertObject(b, dynamic); workingMemory.assertObject(c, dynamic); workingMemory.assertObject(d, dynamic); workingMemory.assertObject(e, dynamic); workingMemory.fireAllRules(); }
private RuleBase readPrecompiled(string fileName) { RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); FileStream fstream = new FileStream(fileName, FileMode.Open); ruleBase.Load(fstream); fstream.Close(); return(ruleBase); }
public void TestBLoadRuleBase() { RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); FileStream fstream = new FileStream("HelloworldRuleBase.rlb", FileMode.Open); ruleBase.Load(fstream); WorkingMemory workingMemory = ruleBase.NewWorkingMemory(); //go ! Message message = new Message(); message.message = "Hello World"; message.status = Message.HELLO; workingMemory.assertObject(message); workingMemory.fireAllRules(); }
public void TestBLoadPkg() { //AppDomain.CurrentDomain.Load("tempAssembly.dll"); FileStream stream = new FileStream("TroubleticketRuleBase.rlb", FileMode.Open); RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); ruleBase.Load(stream); WorkingMemory workingMemory = ruleBase.NewWorkingMemory(); Customer a = new Customer("A", "Gold"); Customer b = new Customer("B", "Platinum"); Customer c = new Customer("C", "Silver"); Customer d = new Customer("D", "Silver"); Ticket t1 = new Ticket(a); Ticket t2 = new Ticket(b); Ticket t3 = new Ticket(c); Ticket t4 = new Ticket(d); FactHandle fa = workingMemory.assertObject(a); FactHandle fb = workingMemory.assertObject(b); FactHandle fc = workingMemory.assertObject(c); FactHandle fd = workingMemory.assertObject(d); FactHandle ft1 = workingMemory.assertObject(t1); FactHandle ft2 = workingMemory.assertObject(t2); FactHandle ft3 = workingMemory.assertObject(t3); FactHandle ft4 = workingMemory.assertObject(t4); workingMemory.fireAllRules(); t3.Status = "Done"; workingMemory.modifyObject(ft3, t3); try { System.Console.Error.WriteLine("[[ Sleeping 5 seconds ]]"); System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 5000)); } catch (System.Threading.ThreadInterruptedException e) { //SupportClass.WriteStackTrace(e, Console.Error); } System.Console.Error.WriteLine("[[ awake ]]"); }
public void TestBLoadAndChangeSavedState() { FileStream fstream = new FileStream("StateDynamic.rlb", FileMode.Open); RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); ruleBase.Load(fstream); fstream.Close(); WorkingMemory workingMemory = ruleBase.NewWorkingMemory(); State a = new State("A"); State b = new State("B"); State c = new State("C"); State d = new State("D"); State e = new State("E"); // By setting dynamic to TRUE, Drools will use JavaBean // PropertyChangeListeners so you don't have to call modifyObject(). //UPGRADE_NOTE: Final was removed from the declaration of 'dynamic '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'" bool dynamic = true; workingMemory.assertObject(a, dynamic); workingMemory.assertObject(b, dynamic); workingMemory.assertObject(c, dynamic); workingMemory.assertObject(d, dynamic); workingMemory.assertObject(e, dynamic); workingMemory.fireAllRules(); Stream stream = Assembly.GetAssembly(this.GetType()).GetManifestResourceStream("org.drools.dotnet.examples.rules.StateExampleDynamicRule.drl"); PackageBuilder builder = new PackageBuilder(); builder.AddPackageFromDrl(stream); Package pkg = builder.GetPackage(); ruleBase.AddPackage(pkg); fstream = new FileStream("StateDynamic.rlb", FileMode.Create); ruleBase.Save(fstream); stream.Close(); fstream.Close(); }