143 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			143 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using FineUIPro; | |||
|  | using System; | |||
|  | using System.Collections; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Linq; | |||
|  | using System.Text; | |||
|  | 
 | |||
|  | 
 | |||
|  | namespace BLL | |||
|  | { | |||
|  | 
 | |||
|  |     public static class SysHttplogService | |||
|  |     { | |||
|  |         public static Model.SGGLDB db = Funs.DB; | |||
|  | 
 | |||
|  | 
 | |||
|  |         #region 获取列表 | |||
|  |         /// <summary> | |||
|  |         /// 记录数 | |||
|  |         /// </summary> | |||
|  |         public static int count | |||
|  |         { | |||
|  |             get; | |||
|  |             set; | |||
|  |         } | |||
|  |         public static List<Model.Sys_HttpLog> GetSys_HttpLogByModle(Model.Sys_HttpLog table) | |||
|  |         { | |||
|  |             var q = from x in db.Sys_HttpLog | |||
|  |                     where | |||
|  |                               (string.IsNullOrEmpty(table.HttpLogId) || x.HttpLogId.Contains(table.HttpLogId)) && | |||
|  |                               (string.IsNullOrEmpty(table.UserName) || x.UserName.Contains(table.UserName)) && | |||
|  |                               (string.IsNullOrEmpty(table.HttpUrl) || x.HttpUrl.Contains(table.HttpUrl)) && | |||
|  |                               (string.IsNullOrEmpty(table.LogTxt) || x.LogTxt.Contains(table.LogTxt)) && | |||
|  |                               (string.IsNullOrEmpty(table.MeThod) || x.MeThod.Contains(table.MeThod)) //&& | |||
|  |                              // (!table.LogTime.HasValue || (x.LogTime.HasValue && x.LogTime.Value.Date == table.LogTime.Value.Date)) | |||
|  | 
 | |||
|  |                     select x  | |||
|  |                   ; | |||
|  |             if (table.LogTime.HasValue) | |||
|  |             { | |||
|  |                 q=q.Where(x=> x.LogTime.Value.Date.CompareTo(table.LogTime.Value.Date) == 0); | |||
|  |             } | |||
|  |             return q.OrderByDescending(x=>x.LogTime ).ToList(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// 获取分页列表 | |||
|  |         /// </summary> | |||
|  |         /// <param name="PageIndex">页码</param> | |||
|  |         /// <param name="PageSize">每页数量</param> | |||
|  |         /// <returns></returns> | |||
|  |         public static IEnumerable getListData(Model.Sys_HttpLog table, Grid Grid1) | |||
|  |         { | |||
|  |             var q = GetSys_HttpLogByModle(table); | |||
|  |             count = q.Count(); | |||
|  |             if (count == 0) | |||
|  |             { | |||
|  |                 return null; | |||
|  |             } | |||
|  |               q=  q.Skip(Grid1.PageSize * (Grid1.PageIndex)).Take(Grid1.PageSize).ToList(); | |||
|  |             // q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); | |||
|  |             return from x in q | |||
|  |                    select new | |||
|  |                    { | |||
|  |                        x.HttpLogId, | |||
|  |                        x.LogTime, | |||
|  |                        x.UserName, | |||
|  |                        x.HttpUrl, | |||
|  |                        x.LogTxt, | |||
|  |                        x.MeThod, | |||
|  | 
 | |||
|  |                    }; | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         public static Model.Sys_HttpLog GetSys_HttpLogById(string HttpLogId) | |||
|  |         { | |||
|  |             return db.Sys_HttpLog.FirstOrDefault(x => x.HttpLogId == HttpLogId); | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |         public static void AddSys_HttpLog(Model.Sys_HttpLog newtable) | |||
|  |         { | |||
|  | 
 | |||
|  |             Model.Sys_HttpLog table = new Model.Sys_HttpLog | |||
|  |             { | |||
|  |                 HttpLogId = newtable.HttpLogId, | |||
|  |                 LogTime = newtable.LogTime, | |||
|  |                 UserName = newtable.UserName, | |||
|  |                 HttpUrl = newtable.HttpUrl, | |||
|  |                 LogTxt = newtable.LogTxt, | |||
|  |                 MeThod = newtable.MeThod, | |||
|  |             }; | |||
|  |             db.Sys_HttpLog.InsertOnSubmit(table); | |||
|  |             db.SubmitChanges(); | |||
|  |         } | |||
|  | 
 | |||
|  |         public static void AddBulkSys_HttpLog(List<Model.Sys_HttpLog> newtables) | |||
|  |         { | |||
|  | 
 | |||
|  |             db.Sys_HttpLog.InsertAllOnSubmit(newtables); | |||
|  |             db.SubmitChanges(); | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |         public static void UpdateSys_HttpLog(Model.Sys_HttpLog newtable) | |||
|  |         { | |||
|  | 
 | |||
|  |             Model.Sys_HttpLog table = db.Sys_HttpLog.FirstOrDefault(x => x.HttpLogId == newtable.HttpLogId); | |||
|  |             if (table != null) | |||
|  |             { | |||
|  |                 table.HttpLogId = newtable.HttpLogId; | |||
|  |                 table.LogTime = newtable.LogTime; | |||
|  |                 table.UserName = newtable.UserName; | |||
|  |                 table.HttpUrl = newtable.HttpUrl; | |||
|  |                 table.LogTxt = newtable.LogTxt; | |||
|  |                 table.MeThod = newtable.MeThod; | |||
|  |                 db.SubmitChanges(); | |||
|  |             } | |||
|  | 
 | |||
|  |         } | |||
|  |         public static void DeleteSys_HttpLogById(string HttpLogId) | |||
|  |         { | |||
|  | 
 | |||
|  |             Model.Sys_HttpLog table = db.Sys_HttpLog.FirstOrDefault(x => x.HttpLogId == HttpLogId); | |||
|  |             if (table != null) | |||
|  |             { | |||
|  |                 db.Sys_HttpLog.DeleteOnSubmit(table); | |||
|  |                 db.SubmitChanges(); | |||
|  |             } | |||
|  | 
 | |||
|  |         } | |||
|  | 
 | |||
|  |         public static void DeleteALLSys_HttpLog() | |||
|  |         { | |||
|  |             if (db.Sys_HttpLog != null) | |||
|  |             { | |||
|  |                 db.Sys_HttpLog.DeleteAllOnSubmit(db.Sys_HttpLog); | |||
|  |                 db.SubmitChanges(); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |     } | |||
|  | } |