using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Reflection; using System.Text; using MESClassLibrary.BLL.Log; using MESClassLibrary.DAL; using MESClassLibrary.DAL.TruckBox; using MESClassLibrary.Model; using Newtonsoft.Json; using Newtonsoft.Json.Converters; namespace MESClassLibrary.BLL.TruckBox { public class RetrospectSearchBll { RetrospectSearchDal da=new RetrospectSearchDal(); public string SearchInfoAll(string page, string pageSize, string barCode, string startTime, string endTime) { try { string jsonStr = "[]"; int total = 0;//总行数 List list = null; DataTable dt = da.SearchInfo(barCode, startTime, endTime); if (dt != null && dt.Rows.Count > 0) { list = CommonTools.ConvertTo(dt).ToList(); } if (list != null && list.Count > 0) { total = list.Count; int skipCount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pageSize); list = list.Skip(skipCount).Take(Convert.ToInt32(pageSize)).ToList(); JsonDataModel md = new JsonDataModel(); md.total = total.ToString(); md.rows = list; IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }; jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(md, Formatting.Indented, timeConverter); } return jsonStr; } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod()); return ""; } } } }