public override Rule AddNewRule(string name, string pageTypeLeft, string pageTypeRight, string ruleTextLeft, string ruleTextRight)
 {
     if (!RuleExists(name))
     {
         RuleEventArgs e = new RuleEventArgs();
         e.RuleName    = name;
         e.CurrentRule = null;
         if (OnCreatingRule != null)
         {
             OnCreatingRule(null, e);
         }
         if (!e.CancelEvent)
         {
             Rule newRule = new Rule(name, pageTypeLeft, pageTypeRight);
             newRule.RuleTextLeft  = ruleTextLeft;
             newRule.RuleTextRight = ruleTextRight;
             RuleDataStore.Save(newRule);
             e.CurrentRule = newRule;
             if (OnCreatedRule != null)
             {
                 OnCreatedRule(null, e);
             }
             UpdateCache();
             return(newRule);
         }
         else
         {
             return(null);
         }
     }
     return(null);
 }
        public override Identity Save(Rule rel)
        {
            Identity      id;
            RuleEventArgs e = new RuleEventArgs();

            e.RuleName    = rel.RuleName;
            e.CurrentRule = rel;
            if (OnSavingRule != null)
            {
                OnSavingRule(null, e);
            }
            if (e.CurrentRule != null && e.CurrentRule.Id != null && !e.CancelEvent && RuleExists(rel.Id))
            {
                Rule existingRule = GetRule(rel.Id);
                id = RuleDataStore.Save(rel, existingRule.Id);
                if (OnSavedRule != null)
                {
                    OnSavedRule(null, e);
                }
                UpdateCache();
                return(id);
            }
            UpdateCache();
            throw new Exception("Rule not found.");
        }
示例#3
0
 private void OnRuleSelectionChanged(RuleEventArgs e)
 {
     if (RuleSelectionChanged != null)
     {
         RuleSelectionChanged(this, e);
     }
 }
 public override Rule AddNewRule(string name, string pageTypeLeft, string pageTypeRight, string ruleTextLeft, string ruleTextRight)
 {
     if (!RuleExists(name))
     {
         RuleEventArgs e = new RuleEventArgs();
         e.RuleName = name;
         e.CurrentRule = null;
         if (OnCreatingRule != null)
             OnCreatingRule(null, e);
         if (!e.CancelEvent)
         {
             Rule newRule = new Rule(name, pageTypeLeft, pageTypeRight);
             newRule.RuleTextLeft = ruleTextLeft;
             newRule.RuleTextRight = ruleTextRight;
             RuleDataStore.Save(newRule);
             e.CurrentRule = newRule;
             if (OnCreatedRule != null)
                 OnCreatedRule(null, e);
             UpdateCache();
             return newRule;
         }
         else
             return null;
     }
     return null;
 }
示例#5
0
 private void FireRuleProcessed(string rule)
 {
     if (this.OnRuleProcessing != null)
     {
         RuleEventArgs args = new RuleEventArgs(rule);
         this.OnRuleProcessed(this, args);
     }
 }
示例#6
0
            /// <summary>
            /// Helper method for raising the <see cref="Changed">Changed</see> event
            /// </summary>
            /// <param name="args">Rule Event Arguments</param>
            protected void RaisePrologMtChanged(RuleEventArgs args)
            {
                PrologMtEventHandler d = this.Changed;

                if (d != null)
                {
                    d(this, new PrologMtEventArgs((PNode)this, args));
                }
            }
示例#7
0
 /// <summary>
 /// The engine rule matched event handler.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The event args.
 /// </param>
 private void EngineRuleMatched(object sender, RuleEventArgs e)
 {
     if (Preferences.Current.EnableLogging)
     {
         this.LogQueue.Enqueue(new LogModel {
             RuleName = e.Rule.Name, Url = e.Path, Message = e.Message, Referer = e.Referer
         });
     }
 }
示例#8
0
        public override void Invoke(object sender, RuleEventArgs e)
        {
            OnBeginRuleEvaluation(this);

            employee.OverTimeHours = 1.5 * 15 + 2 * (employee.HoursWorked - 60);

            OnRulePassed(this);

            OnEndRuleEvaluation(this);
        }
示例#9
0
            /// <summary>
            /// Helper method for raising the <see cref="RuleRetracted">Rule Retracted</see> event manually
            /// </summary>
            /// <param name="args"></param>
            protected void RaiseRuleRetracted(RuleEventArgs args)
            {
                RuleEventHandler d = this.RuleRetracted;

                args.PrologKB = this;
                if (d != null)
                {
                    d(this, args);
                }
                this.RaisePrologMtChanged(args);
            }
示例#10
0
        private void tvRules_AfterSelect(object sender, TreeViewEventArgs e)
        {
            RuleEventArgs args = new RuleEventArgs(null);

            if (e.Node.Nodes.Count == 0)
            {
                args = new RuleEventArgs(_ruleNodeMap[e.Node]);
            }

            OnRuleSelectionChanged(args);
        }
示例#11
0
        public override void Invoke(object sender, RuleEventArgs e)
        {
            bool pass = (GenerateRandomNumbers.GetRandomNumber(999)) % 2 == 0;

            _logger.Log(string.Format("Results: {1} :: Rule Name: {0}, ", Name, pass ? "PASSED" : "FAILED"));
            if (pass)
            {
                OnRulePassed(this);
            }
            else
            {
                OnRuleFailed(this);
            }
        }
示例#12
0
        public override void Invoke(object sender, RuleEventArgs e)
        {
            OnBeginRuleEvaluation(this);

            if (employee.EmployeeType == EmployeeType.Salary)
            {
                OnRulePassed(this);
            }
            else
            {
                OnRuleFailed(this);
            }

            OnEndRuleEvaluation(this);
        }
示例#13
0
        public override void Invoke(object sender, RuleEventArgs e)
        {
            OnBeginRuleEvaluation(this);

            if (employee.HoursWorked > 40 && employee.HoursWorked <= 45)
            {
                OnRulePassed(this);
            }
            else
            {
                OnRuleFailed(this);
            }

            OnEndRuleEvaluation(this);
        }
示例#14
0
        private void RuleTreeView_RuleSelectionChanged(object sender, RuleEventArgs e)
        {
            if (e.SelectedRule != null)
            {
                IRuleConfiguration config = _configFactory.GetRuleConfigurationFor(e.SelectedRule.GetType());
                _view.DisplayRuleConfiguration(config);
                CurrentConfiguration = config;
            }
            else
            {
                _view.ClearRuleConfiguration();
                CurrentConfiguration = null;
            }

            HasChanges = false;
        }
示例#15
0
            /// <summary>
            /// Helper method for raising the <see cref="RuleRetracted">Rule Retracted</see> event manually
            /// </summary>
            /// <param name="t">Rule</param>
            protected void RaiseRuleRetracted(Rule t)
            {
                RuleEventHandler     d = this.RuleRetracted;
                PrologMtEventHandler e = this.Changed;

                if (d != null || e != null)
                {
                    RuleEventArgs args = new RuleEventArgs(t, (PNode)this, false);
                    if (d != null)
                    {
                        d(this, args);
                    }
                    if (e != null)
                    {
                        e(this, new PrologMtEventArgs((PNode)this, args));
                    }
                }
            }
示例#16
0
        public override void DeleteRule(string name)
        {
            RuleEventArgs e = new RuleEventArgs();

            e.RuleName    = name;
            e.CurrentRule = GetRule(name);
            if (e.CurrentRule != null && e.CurrentRule.Id != null)
            {
                if (OnDeletingRule != null)
                {
                    OnDeletingRule(null, e);
                }
                if (!e.CancelEvent)
                {
                    RuleDataStore.Delete(e.CurrentRule);
                }
                if (OnDeletedRule != null)
                {
                    OnDeletedRule(null, e);
                }
            }
            UpdateCache();
        }
示例#17
0
 public static void DeleteRule(RuleEventArgs e)
 {
     DeleteRule(e.RuleID);
 }
示例#18
0
        public override void Invoke(object sender, RuleEventArgs e)
        {
            OnBeginRuleEvaluation(this);

            OnEndRuleEvaluation(this);
        }
示例#19
0
 public static string LoadRuleXml(RuleEventArgs e)
 {
     return(LoadRuleXml(e.RuleID));
 }
 public override void DeleteRule(string name)
 {
     RuleEventArgs e = new RuleEventArgs();
     e.RuleName = name;
     e.CurrentRule = GetRule(name);
     if (e.CurrentRule != null && e.CurrentRule.Id != null)
     {
         if (OnDeletingRule != null)
             OnDeletingRule(null, e);
         if (!e.CancelEvent)
         {
             RuleDataStore.Delete(e.CurrentRule);
         }
         if (OnDeletedRule != null)
             OnDeletedRule(null, e);
     }
     UpdateCache();
 }
 public override Identity Save(Rule rel)
 {
     Identity id;
     RuleEventArgs e = new RuleEventArgs();
     e.RuleName = rel.RuleName;
     e.CurrentRule = rel;
     if (OnSavingRule != null)
         OnSavingRule(null, e);
     if (e.CurrentRule != null && e.CurrentRule.Id != null && !e.CancelEvent && RuleExists(rel.Id))
     {
         Rule existingRule = GetRule(rel.Id);
         id = RuleDataStore.Save(rel, existingRule.Id);
         if (OnSavedRule != null)
             OnSavedRule(null, e);
         UpdateCache();
         return id;
     }
     UpdateCache();
     throw new Exception("Rule not found.");
 }
示例#22
0
 private void OnRuleMismatched(object sender, RuleEventArgs e)
 {
     Console.WriteLine(string.Format(Resources.Resources.OnRuleMismatchedEventMessage, e.Rule, e.FileName));
 }
示例#23
0
 /// <summary>
 /// Event Handler which handles the <see cref="RuleList.RuleRemoved">Rule Removed</see> event from the underlying Rule Collection by raising the PrologKB's <see cref="RuleRetracted">Rule Retracted</see> event
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="args">Rule Event Arguments</param>
 protected virtual void OnRuleRetracted(Object sender, RuleEventArgs args)
 {
     this.RaiseRuleRetracted(args);
 }
示例#24
0
 /// <summary>
 /// Creates a new set of PrologKB Event Arguments
 /// </summary>
 /// <param name="g">PrologKB</param>
 /// <param name="args">Rule Event Arguments</param>
 public PrologMtEventArgs(PNode g, RuleEventArgs args)
     : this(g)
 {
     this._args = args;
 }
示例#25
0
 private void TreeViewImp_RuleSelectionChanged(object sender, RuleEventArgs e)
 {
     throw new NotImplementedException();
 }
示例#26
0
 /// <summary>
 /// Creates a new set of Cancellable PrologKB Event Arguments
 /// </summary>
 /// <param name="g">PrologKB</param>
 /// <param name="args">Rule Event Arguments</param>
 public CancellablePrologMtEventArgs(PNode g, RuleEventArgs args)
     : base(g, args)
 {
 }
示例#27
0
 public void HandlePassedRule(object sender, RuleEventArgs args)
 {
     logger.Debug("Handle Passed Rule was called");
     this.calledRules.Push(args.RuleName + " passed");
 }