Example #1
0
 public IEnumerable<History> LogTypeQuery(IEnumerable<History> query, SearchOptions options)
 {
     //throw new NotImplementedException();
     if (options.LogTypeId == null)
     {
         return query;
     }
     return query.Where(x => x.LogTypeId == options.LogTypeId.Value);
 }
Example #2
0
 public IEnumerable<History> UserNameQuery(IEnumerable<History> query, SearchOptions options)
 {
     //throw new NotImplementedException();
     if (options.UserName == "")//check case for empty string too
     {
         return query;
     }
        return query.Where(x => x.UserName == options.UserName);
 }
Example #3
0
        public List<History> PerformQuery(SearchOptions options)
        {
            IEnumerable<History> result = _logEngine.CreateQuery();

            try
            {
                result = _logEngine.LogTypeQuery(result, options);
                result = _logEngine.FileOperationQuery(result, options);
                result = _logEngine.UserNameQuery(result, options);
                result = _logEngine.DateRangeQuery(result, options);
            }
            catch (Exception)
            {

                throw;
            }

            return _logEngine.ExecuteQuery(result);
        }
Example #4
0
        public IEnumerable<History> DateRangeQuery(IEnumerable<History> query, SearchOptions options)
        {
            DateTime _start;
            DateTime _end;

            //throw new NotImplementedException();
            if ((options.StartDate == null)&&(options.StopDate == null))
            {
                return query;
            }
            else if (options.StartDate == null)
            {
                _end = DateTime.Now.AddDays(options.StopDate.Value);
                return query.Where(x => x.LogDate <= _end);
            }
            else if (options.StopDate == null)
            {
                _start = DateTime.Now.AddDays(options.StartDate.Value);
                return query.Where(x => x.LogDate >= _start);
            }
            else if ((options.StartDate == 0) && (options.StopDate == 0))//maybe not necessary
            {
                _start = DateTime.Now;
                return query.Where(x => x.LogDate == _start);
            }
            else
            {
                _start = DateTime.Now.AddDays(options.StartDate.Value);
                _end = DateTime.Now.AddDays(options.StopDate.Value);
                return query.Where(x => x.LogDate >= _start)
                            .Where(x => x.LogDate <= _end);
            }
        }
 public void MultiFilterLogQuery2()
 {
     NinjectReg = new Registrator();
     var LogManager = NinjectReg.kernel.Get<LogManager>();
     var options = new SearchOptions
     {
         LogTypeId = 5,
         FileOperationId = 4,
         UserName = "******",
         StartDate = -6,
         StopDate = 1
     };
     var result = LogManager.PerformQuery(options);
     foreach (History a in result)
     {
         Debug.WriteLine(a.LogTime.ToString() + " " + a.LogDate.ToShortDateString() + ", " + a.LogType.Description.ToString() + ", " + a.InteractionType.Description.ToString() + ", " + a.Domain.ToString() + "\\" + a.UserName.ToString());
     }
 }
 public void UserNameQuery()
 {
     NinjectReg = new Registrator();
     var LogEngine = NinjectReg.kernel.Get<LogEngine>();
     var query = LogEngine.CreateQuery();
     var options = new SearchOptions { UserName = "******" };
     IEnumerable<History> result = LogEngine.UserNameQuery(query, options);
     foreach (History x in result.ToList())
     {
         if (!(x.UserName == "drmurtha"))
         {
             Assert.IsFalse(true);
             break;
         }
     }
     Assert.IsTrue(true);
 }
 public void LogTypeQuery()
 {
     NinjectReg = new Registrator();
     var LogEngine = NinjectReg.kernel.Get<LogEngine>();
     var query = LogEngine.CreateQuery();
     var options = new SearchOptions { LogTypeId = 5 };
     LogEngine.LogTypeQuery(query, options);
 }
 public void FileOperationQuery()
 {
     NinjectReg = new Registrator();
     var LogEngine = NinjectReg.kernel.Get<LogEngine>();
     var query = LogEngine.CreateQuery();
     int operation = 4;
     var options = new SearchOptions {FileOperationId = 4 };
     try
     {
         IEnumerable<History> result = LogEngine.FileOperationQuery(query, options);
         foreach (History x in result.ToList())
         {
             if (!(x.FileOperationId == operation))
             {
                 Assert.IsFalse(true);
                 break;
             }
         }
     }
     catch (Exception e)
     {
         Assert.Fail();
     }
     Assert.IsTrue(true);
 }
 public void DateQuery()
 {
     NinjectReg = new Registrator();
     var LogEngine = NinjectReg.kernel.Get<LogEngine>();
     var query = LogEngine.CreateQuery();
     var options = new SearchOptions
     {
         StartDate = -2,
         StopDate = 0
     };
     IEnumerable<History> result = LogEngine.DateRangeQuery(query,options);
     foreach (History x in result.ToList())
     {
         if (!((x.LogDate >= DateTime.Now.AddDays(-2) && (x.LogDate <= DateTime.Now.AddDays(0)))))
         {
             Assert.IsFalse(true);
             break;
         }
     }
     Assert.IsTrue(true);
 }