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.Painting { public class BucketStateBLL { BasicBLL db=new BasicBLL(); public string SearchInfo(string page, string pageSize, string bucketCode, string paintCode) { try { string jsonStr = "[]"; int total = 0;//总行数 List list = db.SearchAllInfo().ToList(); if (!string.IsNullOrWhiteSpace(bucketCode)) { list = list.Where(p => p.BucketCode.Contains(bucketCode)).ToList(); } if (!string.IsNullOrWhiteSpace(paintCode)) { list = list.Where(p => p.PaintCode.Contains(paintCode)).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(); JsonDataModel md = new JsonDataModel(); md.total = total.ToString(); md.rows = list; IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }; jsonStr = JsonConvert.SerializeObject(md, Formatting.Indented, timeConverter); } return jsonStr; } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod()); return ""; } } } }