Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            MetaRepository repository = new MetaRepository();
            List<RuleActionCollection> collection = repository.RuleActionCollection("test");

             var list =  repository.RuleActionCollectionAll();

             foreach (MetaRuleAction item in list)
             {
                 listBox1.Items.Add(item.RuleName);
             }
        }
Пример #2
0
        /// <summary>
        /// Method responsible for processing Logs
        /// </summary>
        public void Process()
        {
            try
                {

                    MetaRepository _metarepository = new MetaRepository();
                    List<RuleActionCollection> _rulecollection = _metarepository.RuleActionCollection(_log.Category.ToLower());

                    if (_rulecollection.Count >= 1)
                    {

                        foreach (RuleActionCollection RAC in _rulecollection)
                        {

                            bool pass = ReflectBusinessRule(_assemblyRulePath + @"\"+ RAC.MetaRule.Assembly, RAC.MetaRule.Class, _log, RAC.MetaRule.Args.ToArray());
                            if (pass == false)
                            {
                                ReflectBusinessAction(_assemblyActionPath + @"\" + RAC.MetaAction.Assembly, RAC.MetaAction.Class, _log, RAC.MetaAction.Args.ToArray());
                            }

                        }

                        _repository.Insert(_log);
                        #region cut code
                        //if (_metarepository.NumberofRules(_log.Category) >= 1)
                        //{
                        //    bool pass = true;
                        //    _assembly = _metarepository.GetRuleAssembly(_log.Category);
                        //    _class =  _metarepository.GetRuleClass(_log.Category);
                        //    _args = _metarepository.GetRuleArgs(_log.Category).ToArray();
                        //    pass = ReflectBusinessRule(_assembly,_class,_log,_args);

                        //    if (!pass)
                        //    {
                        //        _assembly = _metarepository.GetActionAssembly(_log.Category);
                        //        _class = _metarepository.GetActionClass(_log.Category);
                        //        _args = _metarepository.GetActionArgs(_log.Category).ToArray();
                        //        ReflectBusinessAction(_assembly, _class, _log, _args);

                        //    }
                        //    else
                        //    {
                        //        _repository.Insert(_log);
                        //    }
                        //}
                        //else
                        //{
                        //    _repository.Insert(_log);
                        //}
                        #endregion

                    }

                    else
                    {
                        _repository.Insert(_log);
                    }

                }
                catch (Exception ex)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("Date: " + DateTime.Now.ToLongDateString());
                    sb.AppendLine("Message: " + ex.Message);
                    sb.AppendLine("Stacktrace: " + ex.StackTrace);
                    sb.AppendLine("-------------------------------------------");

                    WritetoLog(sb);
                }
        }
 public void RuleActionCollectionNotZero()
 {
     MetaRepository repository = new MetaRepository();
     List<RuleActionCollection> collection = repository.RuleActionCollection("test");
     Assert.AreNotSame(0, collection.Count);
 }
 public void RuleActionCollection()
 {
     MetaRepository repository = new MetaRepository();
        List<RuleActionCollection> collection = repository.RuleActionCollection("test");
        Assert.IsNotNull(collection);
 }