You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
3.0 KiB
81 lines
3.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using MESClassLibrary.BLL.Log;
|
|
using MESClassLibrary.EFModel;
|
|
using MESClassLibrary.Model;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
namespace MESClassLibrary.BLL.BasicInfo
|
|
{
|
|
public class LogBLL
|
|
{
|
|
BasicBLL<T_Sys_Log> db=new BasicBLL<T_Sys_Log>();
|
|
|
|
public string SearchSearchInfoAll(string page, string pagesize, string StartTime, string EndTime, string Op)
|
|
{
|
|
try
|
|
{
|
|
string jsonStr = "[]";
|
|
int total = 0;//总行数
|
|
|
|
List<T_Sys_Log> list = db.SearchAllInfo().OrderByDescending(p => p.ID).ToList();
|
|
|
|
DateTime st, et;
|
|
if (!DateTime.TryParse(StartTime, out st)) st = DateTime.Now.AddDays(-1);
|
|
if (!DateTime.TryParse(EndTime, out et)) et = DateTime.Now;
|
|
|
|
if (!String.IsNullOrEmpty(Op))
|
|
{
|
|
list = list.Where(p => p.CreateTime >= st && p.CreateTime <= et && p.Op == Op).OrderByDescending(p => p.ID).ToList();
|
|
|
|
}
|
|
else
|
|
{
|
|
list = list.Where(p => p.CreateTime >= st && p.CreateTime <= et)
|
|
.OrderByDescending(p => p.ID).Take(100).ToList();
|
|
}
|
|
|
|
if (list.Count > 0)
|
|
{
|
|
total = list.Count;
|
|
|
|
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
|
|
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
|
|
|
|
List<LogModel> modelList=new List<LogModel>();
|
|
BasicBLL<T_Sys_Users> userdb=new BasicBLL<T_Sys_Users>();
|
|
|
|
var s_list = userdb.SearchAllInfo();
|
|
foreach (var item in list)
|
|
{
|
|
LogModel dm = Tool.Mapper<LogModel, T_Sys_Log>(item);
|
|
var info = s_list.FirstOrDefault(p => p.UserID.ToString()== item.UserID.ToLower());
|
|
if (info != null)
|
|
{
|
|
dm.UserName = info.UserName;
|
|
}
|
|
modelList.Add(dm);
|
|
}
|
|
|
|
JsonDataModel<LogModel> md=new JsonDataModel<LogModel>();
|
|
md.total = total.ToString();
|
|
md.rows = modelList;
|
|
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
|
|
jsonStr = JsonConvert.SerializeObject(md, Formatting.Indented, timeConverter);
|
|
//jsonStr = JSONTools.ScriptSerialize<JsonDataModel<LogModel>>(md);
|
|
}
|
|
|
|
return jsonStr;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|