| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  | using FineUIPro; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace BLL | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static class InterFaceLogService | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |     { | 
					
						
							|  |  |  |  |         public static Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public const string Type1 = "上报"; | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |         public const string Type2 = "下发"; | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         public const string Type3 = "回调"; | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 获取列表 | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 记录数 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public static int count | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get; | 
					
						
							|  |  |  |  |             set; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |         public static IQueryable<Model.InterFaceLog> GetInterFaceLogByModle(Model.InterFaceLog table) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var q = from x in db.InterFaceLog | 
					
						
							|  |  |  |  |                     where | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.InterFaceLogId) || x.InterFaceLogId.Contains(table.InterFaceLogId)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.UserId) || x.UserId.Contains(table.UserId)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.UnitId) || x.UnitId.Contains(table.UnitId)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.InterFaceName) || x.InterFaceName.Contains(table.InterFaceName)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.InterFaceUrl) || x.InterFaceUrl.Contains(table.InterFaceUrl)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.InterFaceMehtod) || x.InterFaceMehtod.Contains(table.InterFaceMehtod)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.InterFaceBody) || x.InterFaceBody.Contains(table.InterFaceBody)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.InterFaceReturnData) || x.InterFaceReturnData.Contains(table.InterFaceReturnData)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.InterFaceType) || x.InterFaceType.Contains(table.InterFaceType)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.IP) || x.IP.Contains(table.IP)) | 
					
						
							|  |  |  |  |                     orderby x.InterFaceLogDate descending | 
					
						
							|  |  |  |  |                     select x | 
					
						
							|  |  |  |  |                   ; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return q; | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// 获取分页列表 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="PageIndex">页码</param> | 
					
						
							|  |  |  |  |         /// <param name="PageSize">每页数量</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static IEnumerable getListData(Model.InterFaceLog table, Grid Grid1) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |             var q = GetInterFaceLogByModle(table); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |             count = q.Count(); | 
					
						
							|  |  |  |  |             if (count == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return null; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |             q = q.Skip(Grid1.PageSize * (Grid1.PageIndex)).Take(Grid1.PageSize); | 
					
						
							|  |  |  |  |             // q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |             return (from x in q | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                     select new | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         x.InterFaceLogId, | 
					
						
							|  |  |  |  |                         x.UserId, | 
					
						
							|  |  |  |  |                         x.UnitId, | 
					
						
							|  |  |  |  |                         x.InterFaceName, | 
					
						
							|  |  |  |  |                         x.InterFaceUrl, | 
					
						
							|  |  |  |  |                         x.InterFaceMehtod, | 
					
						
							|  |  |  |  |                         x.InterFaceBody, | 
					
						
							|  |  |  |  |                         x.InterFaceReturnData, | 
					
						
							|  |  |  |  |                         x.InterFaceLogDate, | 
					
						
							|  |  |  |  |                         x.InterFaceType, | 
					
						
							|  |  |  |  |                         x.LogSate, | 
					
						
							|  |  |  |  |                         x.IP, | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     }).ToList(); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |         public static Model.InterFaceLog GetInterFaceLogById(string InterFaceLogId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return db.InterFaceLog.FirstOrDefault(x => x.InterFaceLogId == InterFaceLogId); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public static void AddInterFaceLog(Model.InterFaceLog newtable) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |             Model.InterFaceLog table = new Model.InterFaceLog | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 InterFaceLogId = newtable.InterFaceLogId, | 
					
						
							|  |  |  |  |                 UserId = newtable.UserId, | 
					
						
							|  |  |  |  |                 UnitId = newtable.UnitId, | 
					
						
							|  |  |  |  |                 InterFaceName = newtable.InterFaceName, | 
					
						
							|  |  |  |  |                 InterFaceUrl = newtable.InterFaceUrl, | 
					
						
							|  |  |  |  |                 InterFaceMehtod = newtable.InterFaceMehtod, | 
					
						
							|  |  |  |  |                 InterFaceBody = newtable.InterFaceBody, | 
					
						
							|  |  |  |  |                 InterFaceReturnData = newtable.InterFaceReturnData, | 
					
						
							|  |  |  |  |                 InterFaceLogDate = newtable.InterFaceLogDate, | 
					
						
							|  |  |  |  |                 InterFaceType = newtable.InterFaceType, | 
					
						
							|  |  |  |  |                 LogSate = newtable.LogSate, | 
					
						
							|  |  |  |  |                 IP = newtable.IP, | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |             }; | 
					
						
							|  |  |  |  |             Funs.DB.InterFaceLog.InsertOnSubmit(table); | 
					
						
							|  |  |  |  |             Funs.DB.SubmitChanges(); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |         public static void WriteInterFaceLog(string InterFaceSetlId, string InterFaceBody, string ReturnData, string InterFaceType, bool isSuccess) | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             var InterfaceSetModel = InterFaceSetService.GetInterFaceSetById(InterFaceSetlId); | 
					
						
							|  |  |  |  |             Model.InterFaceLog table = new Model.InterFaceLog(); | 
					
						
							|  |  |  |  |             table.InterFaceLogId = SQLHelper.GetNewID(typeof(Model.InterFaceLog)); | 
					
						
							|  |  |  |  |             table.UserId = Const.sysglyId; | 
					
						
							|  |  |  |  |             table.InterFaceLogDate = DateTime.Now; | 
					
						
							|  |  |  |  |             table.IP = ""; | 
					
						
							|  |  |  |  |             table.InterFaceName = InterfaceSetModel.InterFaceName; | 
					
						
							|  |  |  |  |             table.InterFaceBody = InterFaceBody; | 
					
						
							|  |  |  |  |             table.InterFaceReturnData = ReturnData; | 
					
						
							|  |  |  |  |             table.InterFaceType = InterFaceType; | 
					
						
							|  |  |  |  |             table.LogSate = isSuccess; | 
					
						
							|  |  |  |  |             switch (InterFaceType) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 case Type1: | 
					
						
							|  |  |  |  |                     table.UnitId = InterfaceSetModel.UnitId; | 
					
						
							|  |  |  |  |                     table.InterFaceUrl = InterfaceSetModel.InterFaceUrl; | 
					
						
							|  |  |  |  |                     table.InterFaceMehtod = InterfaceSetModel.UrlReqMethod; | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                     break; | 
					
						
							|  |  |  |  |                 case Type2: | 
					
						
							|  |  |  |  |                     table.UnitId = InterfaceSetModel.AuthUnitIds; | 
					
						
							|  |  |  |  |                     table.InterFaceUrl = InterfaceSetModel.InterFaceForUrl; | 
					
						
							|  |  |  |  |                     table.InterFaceMehtod = InterfaceSetModel.ForUrlReqMethod; | 
					
						
							|  |  |  |  |                     break; | 
					
						
							|  |  |  |  |                 case Type3: | 
					
						
							|  |  |  |  |                     table.UnitId = InterfaceSetModel.UnitId; | 
					
						
							|  |  |  |  |                     table.InterFaceUrl = InterfaceSetModel.InterFaceCallBackUrl; | 
					
						
							|  |  |  |  |                     table.InterFaceMehtod = InterfaceSetModel.CallBackUrlReqMethod; | 
					
						
							|  |  |  |  |                     break; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             Funs.DB.InterFaceLog.InsertOnSubmit(table); | 
					
						
							|  |  |  |  |             Funs.DB.SubmitChanges(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public static void UpdateInterFaceLog(Model.InterFaceLog newtable) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             Model.InterFaceLog table = db.InterFaceLog.FirstOrDefault(x => x.InterFaceLogId == newtable.InterFaceLogId); | 
					
						
							|  |  |  |  |             if (table != null) | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                 table.InterFaceLogId = newtable.InterFaceLogId; | 
					
						
							|  |  |  |  |                 table.UserId = newtable.UserId; | 
					
						
							|  |  |  |  |                 table.UnitId = newtable.UnitId; | 
					
						
							|  |  |  |  |                 table.InterFaceName = newtable.InterFaceName; | 
					
						
							|  |  |  |  |                 table.InterFaceUrl = newtable.InterFaceUrl; | 
					
						
							|  |  |  |  |                 table.InterFaceMehtod = newtable.InterFaceMehtod; | 
					
						
							|  |  |  |  |                 table.InterFaceBody = newtable.InterFaceBody; | 
					
						
							|  |  |  |  |                 table.InterFaceReturnData = newtable.InterFaceReturnData; | 
					
						
							|  |  |  |  |                 table.InterFaceLogDate = newtable.InterFaceLogDate; | 
					
						
							|  |  |  |  |                 table.InterFaceType = newtable.InterFaceType; | 
					
						
							|  |  |  |  |                 table.LogSate = newtable.LogSate; | 
					
						
							|  |  |  |  |                 table.IP = newtable.IP; | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 Funs.DB.SubmitChanges(); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |         public static void DeleteInterFaceLogById(string InterFaceLogId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.InterFaceLog table = Funs.DB.InterFaceLog.FirstOrDefault(x => x.InterFaceLogId == InterFaceLogId); | 
					
						
							|  |  |  |  |             if (table != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 Funs.DB.InterFaceLog.DeleteOnSubmit(table); | 
					
						
							|  |  |  |  |                 Funs.DB.SubmitChanges(); | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |