예제 #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
            });