public void InsertLogTest()
        {
            LogEntry log = new LogEntry() { Title = "Test Log", Message = "Testing the log insert", Category = "test", EventID = "test", Severity = "test", Priority = "urgent" };

            LogRepository repository = new LogRepository();
            repository.Insert(log);

            Assert.IsNotNull(log);
        }
 /// <summary>
 /// convert business object to data model
 /// </summary>
 /// <param name="log"></param>
 /// <returns>Log of the entity model</returns>
 private Log LogEntrytoLog(LogEntry log)
 {
     Log _log = new Log();
     _log.Category = log.Category;
     _log.Message = log.Message;
     _log.Priority = log.Priority;
     _log.Severity = log.Severity;
     _log.Title = log.Title;
     return _log;
 }
        public void TestLogEngineExecuteRule()
        {
            LogEngine engine = new LogEngine();
            LogEntry _log = new LogEntry() { Title = "Test Log", Message = "Testing the log engine sample", Category = "test", EventID = "", Severity = "", Priority = "urgent" };

            string[] _args = { "Execute" , "Example", "Simple" , "sample"};
            bool _value = false;

            _value = engine.ReflectBusinessAction(@"C:\Users\Csommers\Documents\visual studio 2010\Projects\BusinessRuleLibrary\BusinessRuleLib\bin\Debug\BusinessRuleLib.dll", "BusinessRuleLib.SearchLogMessage", _log, _args);

            Assert.IsNotNull(_value);
        }
        public void Init(LogEntry log, string[] Args)
        {
            _log = log;

            foreach (string arg in Args)
            {
                if (!string.IsNullOrEmpty(arg))
                {
                    _args.Add(arg);
                    _argsCount++;
                }
            }
        }
        public BusinessAction(LogEntry log, string[] Args)
        {
            _log = log;

            foreach (string arg in Args)
            {
                if (!string.IsNullOrEmpty(arg))
                {
                    _args.Add(arg);
                    _argsCount++;
                }
            }
        }
        public void SubmitLog(Log log)
        {
            LogEntry logentry = new LogEntry();

            logentry.Category = log.Category;
            logentry.EventID = log.EventID;
            logentry.Message = log.Message;
            logentry.Priority = log.Priority;
            logentry.Severity = log.Severity;
            logentry.Title = log.Title;

            LogEngine logengine = new LogEngine(logentry);
            logengine.Process();
        }
 public virtual bool Invoke(LogEntry log, string[] Args)
 {
     return _pass;
 }
 public void Insert(LogEntry log)
 {
     Log dblog = LogEntrytoLog(log);
     repostitory.AddToLogs(dblog);
     repostitory.SaveChanges();
 }
 public LogEngine(LogEntry log)
 {
     _log = log;
         setPaths();
 }
        /// <summary>
        /// dlls of business rules
        /// </summary>
        /// <param name="assembly"></param> string to dll
        /// <param name="namespaceandclass"></param>string of namespace.class
        /// <param name="log"></param>log
        /// <param name="args"></param> 
        /// <returns></returns>
        public bool ReflectBusinessRule(string assembly, string namespaceandclass,  LogEntry log, string[] args)
        {
            string[] _args = args;

            string method = "Invoke";

            bool value = false;

            try
            {
                // dynamically load assembly from file Test.dll
                Assembly BussAssembly = Assembly.LoadFile(assembly);

                // get type of class Calculator from just loaded assembly
                Type BussType = BussAssembly.GetType(namespaceandclass);

                // create instance of class Calculator
                object BussInstance = Activator.CreateInstance(BussType);

                // invoke public instance method: public double Add(double number)

                 value = (bool)BussType.InvokeMember(method,
                 BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public,
                 null, BussInstance, new object[] {log, args});

            }
            catch (Exception ex)
            {
                if (!Directory.Exists(@"C:\LoggingApplication\LogEngine"))
                {
                    Directory.CreateDirectory(@"C:\LoggingApplication\LogEngine");
                }

                using (StreamWriter sw = new StreamWriter(@"C:\LoggingApplication\LogEngine\ExceptionLog.txt"))
                {
                    sw.WriteLine("Exception: " + ex.Message);
                    sw.WriteLine("Message: " + ex.StackTrace);
                    sw.WriteLine("-------------------------");
                }

            }

            return value;
        }