Exemplo n.º 1
0
        public string BuildSql(SearchlogInput input)
        {
            if (input.All)
            {
                return($"select * from log order by id desc offset {(input.Page - 1) * input.PageSize} rows fetch next {input.PageSize} rows only");
            }

            if (input.ToDay)
            {
                var now = DateTime.Now.ToShortDateString();
                return
                    ($"select * from log where longdate>={now} order by id desc offset {(input.Page - 1) * input.PageSize} rows fetch next {input.PageSize} rows only");
            }

            if (input.Hour)
            {
                var now = DateTime.Now.AddHours(-1);

                return($"select * from log where longDate>={now} order by id desc offset {(input.Page - 1) * input.PageSize} rows fetch next {input.PageSize} rows only");
            }

            if (input.Unique)
            {
                return
                    ($"select b.* from log b where b.Message in(select Message from log a group by a.Message having count(a.Message) = 1) order by b.Id desc  offset {(input.Page - 1) * input.PageSize} rows fetch next {input.PageSize} rows only");
            }

            if (!string.IsNullOrWhiteSpace(input.Level))
            {
                return
                    ($"select * from log where level= {input.Level} order by id desc offset {(input.Page - 1) * input.PageSize} rows fetch next {input.PageSize} rows only");
            }
            return($"select * from log order by id desc offset {(input.Page - 1) * input.PageSize} rows fetch next {input.PageSize} rows only");
        }
Exemplo n.º 2
0
        public async Task <string> Searchlog(SearchlogInput input)
        {
            var result = await Conn.QueryAsync(BuildSql(input));

            return(await View(result, "Views.Dashboard.LogList.cshtml"));
        }