Пример #1
0
        public RequestLog[] Get()
        {
            var sqliteUtil = new SqliteUtil(this.GetDbPath(), RequestLogUtil.GetSql4CreateTables());
            var result     = sqliteUtil.Select <RequestLogInDb>("RequestLog",
                                                                " CreatedOn >= '" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss") + "'"
                                                                ).OrderByDescending(o => o.CreatedOn).ToList();
            var entities = new RequestLogUtil().ConvertTo(result);

            return(entities.ToArray());
        }
Пример #2
0
        public RequestLog Get(string id)
        {
            var sqliteUtil = new SqliteUtil(this.GetDbPath(), RequestLogUtil.GetSql4CreateTables());
            //demo用,注意SQLInjection。
            var result = sqliteUtil.Select <RequestLog>("RequestLog",
                                                        " Id = '" + id + "'"
                                                        ).FirstOrDefault();

            return(result != null ? result : new RequestLog()
            {
                Id = "", WebIp = "", ApiIp = "", CreatedOn = DateTime.Now
            });
Пример #3
0
 public bool Get()
 {
     try
     {
         var sqliteUtil = new SqliteUtil(this.GetDbPath(), RequestLogUtil.GetSql4CreateTables());
         var result     = sqliteUtil.GetCount("RequestLog");
         if (result >= 0)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }