| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  | using FineUIPro; | 
					
						
							|  |  |  |  | using Model; | 
					
						
							|  |  |  |  | using Newtonsoft.Json; | 
					
						
							|  |  |  |  | using Quartz; | 
					
						
							|  |  |  |  | using RestSharp; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace BLL | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static class InterFaceTaskService | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |         public static Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #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 List<Model.InterFaceTask> GetInterFaceTaskByModle(Model.InterFaceTask table) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var q = from x in db.InterFaceTask | 
					
						
							|  |  |  |  |                     where | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.InterFaceTaskId) || x.InterFaceTaskId.Contains(table.InterFaceTaskId)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.InterFaceName) || x.InterFaceName.Contains(table.InterFaceName)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.InterFaceSetLists) || x.InterFaceSetLists.Contains(table.InterFaceSetLists)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.Frequency) || x.Frequency.Contains(table.Frequency)) && | 
					
						
							|  |  |  |  |                               (table.Enable == null || x.Enable == table.Enable) | 
					
						
							|  |  |  |  |                     select x | 
					
						
							|  |  |  |  |                   ; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return q.ToList(); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// 获取分页列表 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="PageIndex">页码</param> | 
					
						
							|  |  |  |  |         /// <param name="PageSize">每页数量</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static IEnumerable getListData(Model.InterFaceTask table, Grid Grid1) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |             var q = GetInterFaceTaskByModle(table); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |             count = q.Count(); | 
					
						
							|  |  |  |  |             if (count == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return null; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             //  q=  q.Take(Grid1.PageSize * Grid1.PageIndex).Skip(Grid1.PageSize * (Grid1.PageIndex)).ToList(); | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |             // 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 | 
					
						
							|  |  |  |  |                    select new | 
					
						
							|  |  |  |  |                    { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                        x.InterFaceTaskId, | 
					
						
							|  |  |  |  |                        x.InterFaceName, | 
					
						
							|  |  |  |  |                        x.InterFaceSetLists, | 
					
						
							|  |  |  |  |                        x.Frequency, | 
					
						
							|  |  |  |  |                        x.CreateTime, | 
					
						
							|  |  |  |  |                        x.Enable, | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                    }; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |         public static Model.InterFaceTask GetInterFaceTaskById(string InterFaceTaskId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return db.InterFaceTask.FirstOrDefault(x => x.InterFaceTaskId == InterFaceTaskId); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |         public static void AddInterFaceTask(Model.InterFaceTask newtable) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             Model.InterFaceTask table = new Model.InterFaceTask | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 InterFaceTaskId = newtable.InterFaceTaskId, | 
					
						
							|  |  |  |  |                 InterFaceName = newtable.InterFaceName, | 
					
						
							|  |  |  |  |                 InterFaceSetLists = newtable.InterFaceSetLists, | 
					
						
							|  |  |  |  |                 Frequency = newtable.Frequency, | 
					
						
							|  |  |  |  |                 CreateTime = newtable.CreateTime, | 
					
						
							|  |  |  |  |                 Enable = newtable.Enable, | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |             }; | 
					
						
							|  |  |  |  |             db.InterFaceTask.InsertOnSubmit(table); | 
					
						
							|  |  |  |  |             db.SubmitChanges(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         public static void UpdateInterFaceTask(Model.InterFaceTask newtable) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             Model.InterFaceTask table = db.InterFaceTask.FirstOrDefault(x => x.InterFaceTaskId == newtable.InterFaceTaskId); | 
					
						
							|  |  |  |  |             if (table != null) | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                 table.InterFaceTaskId = newtable.InterFaceTaskId; | 
					
						
							|  |  |  |  |                 table.InterFaceName = newtable.InterFaceName; | 
					
						
							|  |  |  |  |                 table.InterFaceSetLists = newtable.InterFaceSetLists; | 
					
						
							|  |  |  |  |                 table.Frequency = newtable.Frequency; | 
					
						
							|  |  |  |  |                 table.CreateTime = newtable.CreateTime; | 
					
						
							|  |  |  |  |                 table.Enable = newtable.Enable; | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 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 DeleteInterFaceTaskById(string InterFaceTaskId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             Model.InterFaceTask table = db.InterFaceTask.FirstOrDefault(x => x.InterFaceTaskId == InterFaceTaskId); | 
					
						
							|  |  |  |  |             if (table != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 db.InterFaceTask.DeleteOnSubmit(table); | 
					
						
							|  |  |  |  |                 db.SubmitChanges(); | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |         #region 执行任务 | 
					
						
							|  |  |  |  |         public static void ExecuteTasks(string InterFaceTaskId) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |             var model = GetInterFaceTaskById(InterFaceTaskId); | 
					
						
							|  |  |  |  |             var InterFaceSetlIds = model.InterFaceSetLists.Split(','); | 
					
						
							|  |  |  |  |             foreach (var item in InterFaceSetlIds) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ExecuteTasksByInterFaceSetlId(item); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 执行接口 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="InterFaceSetlId">接口id </param> | 
					
						
							|  |  |  |  |         public static void ExecuteTasksByInterFaceSetlId(string InterFaceSetlId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var InterfaceSetModel = InterFaceSetService.GetInterFaceSetById(InterFaceSetlId); | 
					
						
							|  |  |  |  |             if (InterfaceSetModel == null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                 if (InterfaceSetModel.IsSingleRequest == true) | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                     var taskData = GetSingleRequestData(InterfaceSetModel.InterFaceUrl, InterfaceSetModel.RequestJsonBody, InterfaceSetModel.UrlReqMethod); | 
					
						
							|  |  |  |  |                     bool taskSuccess = taskData.code == 1; | 
					
						
							|  |  |  |  |                     InterFaceLogService.WriteInterFaceLog(InterFaceSetlId, InterfaceSetModel.RequestJsonBody, JsonConvert.SerializeObject(taskData), InterFaceLogService.Type1, taskSuccess); | 
					
						
							|  |  |  |  |                     return; | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                 var sourseData = GetSourseData(InterfaceSetModel.InterFaceUrl, InterfaceSetModel.UrlReqMethod); | 
					
						
							|  |  |  |  |                 bool sourseisSuccess = sourseData.code == 1; | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 InterFaceLogService.WriteInterFaceLog(InterFaceSetlId, "", JsonConvert.SerializeObject(sourseData), InterFaceLogService.Type1, sourseisSuccess); | 
					
						
							|  |  |  |  |                 if (sourseData.code == 0) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     return; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 var TargetData = GetTargetData(InterfaceSetModel.InterFaceForUrl, sourseData, InterfaceSetModel.ForUrlReqMethod); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                 bool TargetisSuccess = TargetData.code == 1; | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 InterFaceLogService.WriteInterFaceLog(InterFaceSetlId, JsonConvert.SerializeObject(sourseData.data), JsonConvert.SerializeObject(TargetData), InterFaceLogService.Type2, TargetisSuccess); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (TargetData.code == 0 || InterfaceSetModel.IsCallBack == false) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     return; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 var callbackData = ExecuteCallBack(InterfaceSetModel.InterFaceCallBackUrl, sourseData, InterfaceSetModel.CallBackUrlReqMethod); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 bool CallBackisSuccess = false; | 
					
						
							|  |  |  |  |                 if (TargetData.code == 1) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     CallBackisSuccess = true; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 InterFaceLogService.WriteInterFaceLog(InterFaceSetlId, JsonConvert.SerializeObject(sourseData.data), JsonConvert.SerializeObject(callbackData), InterFaceLogService.Type3, CallBackisSuccess); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |             catch (Exception ex) | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                 Model.InterFaceLog interFaceLog = new InterFaceLog(); | 
					
						
							|  |  |  |  |                 interFaceLog.InterFaceLogId = Guid.NewGuid().ToString(); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 interFaceLog.InterFaceType = "异常"; | 
					
						
							|  |  |  |  |                 interFaceLog.LogSate = false; | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                 interFaceLog.InterFaceLogDate = DateTime.Now; | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 interFaceLog.InterFaceName = InterfaceSetModel.InterFaceName; | 
					
						
							|  |  |  |  |                 interFaceLog.InterFaceReturnData = ex.ToString(); | 
					
						
							|  |  |  |  |                 InterFaceLogService.AddInterFaceLog(interFaceLog); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |         public static Model.ReturnData GetSingleRequestData(string baseurl, string requestJsonBody, string ReqMethod) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.ReturnData returnData = new ReturnData(); | 
					
						
							|  |  |  |  |             string token = "C4A62EC0-E5D3-4EBF-A5FA-E56AA89633C0"; | 
					
						
							|  |  |  |  |             string Content = ""; | 
					
						
							|  |  |  |  |             switch (ReqMethod) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 case "Get": | 
					
						
							|  |  |  |  |                     Content = Funs.RequestGet(baseurl, token); | 
					
						
							|  |  |  |  |                     break; | 
					
						
							|  |  |  |  |                 case "Post": | 
					
						
							|  |  |  |  |                     Content = Funs.RequestPost(baseurl, token, requestJsonBody); | 
					
						
							|  |  |  |  |                     break; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             //var client = new RestClient(baseurl); | 
					
						
							|  |  |  |  |             //client.Timeout = -1; | 
					
						
							|  |  |  |  |             //var request = new RestRequest(Method.POST); | 
					
						
							|  |  |  |  |             //request.AddHeader("token", "AF17168B-87BD-4GLY-1111-F0A0A1158F9B"); | 
					
						
							|  |  |  |  |             //IRestResponse response = client.Execute(request); | 
					
						
							|  |  |  |  |             //Console.WriteLine(response.Content); | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 returnData = JsonConvert.DeserializeObject<Model.ReturnData>(Content); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 returnData.code = 0; | 
					
						
							|  |  |  |  |                 returnData.message = "获取数据失败:" + Content; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return returnData; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public static Model.ReturnData GetSourseData(string baseurl, string ReqMethod) | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.ReturnData returnData = new ReturnData(); | 
					
						
							|  |  |  |  |             string token = "C4A62EC0-E5D3-4EBF-A5FA-E56AA89633C0"; | 
					
						
							|  |  |  |  |             string Content = ""; | 
					
						
							|  |  |  |  |             switch (ReqMethod) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                 case "Get": | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                     Content = Funs.RequestGet(baseurl, token); | 
					
						
							|  |  |  |  |                     break; | 
					
						
							|  |  |  |  |                 case "Post": | 
					
						
							|  |  |  |  |                     Content = Funs.RequestPost(baseurl, token, ""); | 
					
						
							|  |  |  |  |                     break; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             //var client = new RestClient(baseurl); | 
					
						
							|  |  |  |  |             //client.Timeout = -1; | 
					
						
							|  |  |  |  |             //var request = new RestRequest(Method.POST); | 
					
						
							|  |  |  |  |             //request.AddHeader("token", "AF17168B-87BD-4GLY-1111-F0A0A1158F9B"); | 
					
						
							|  |  |  |  |             //IRestResponse response = client.Execute(request); | 
					
						
							|  |  |  |  |             //Console.WriteLine(response.Content); | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 returnData = JsonConvert.DeserializeObject<Model.ReturnData>(Content); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 returnData.code = 0; | 
					
						
							|  |  |  |  |                 returnData.message = "获取数据失败:" + Content; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return returnData; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public static Model.ResponeData GetTargetData(string baseurl, ReturnData DataInput, string ReqMethod) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.ResponeData responeData = new ResponeData(); | 
					
						
							|  |  |  |  |             if (DataInput.code == 1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 string token = DataInput.token; | 
					
						
							|  |  |  |  |                 string returnContent = ""; | 
					
						
							|  |  |  |  |                 switch (ReqMethod) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     case "Get": | 
					
						
							|  |  |  |  |                         returnContent = Funs.RequestGet(baseurl, token); | 
					
						
							|  |  |  |  |                         break; | 
					
						
							|  |  |  |  |                     case "Post": | 
					
						
							|  |  |  |  |                         returnContent = Funs.RequestPost(baseurl, token, JsonConvert.SerializeObject(DataInput.data)); | 
					
						
							|  |  |  |  |                         break; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 //var client = new RestClient(baseurl); | 
					
						
							|  |  |  |  |                 //client.Timeout = -1; | 
					
						
							|  |  |  |  |                 //if (isPost) | 
					
						
							|  |  |  |  |                 //{ | 
					
						
							|  |  |  |  |                 //    var request = new RestRequest(Method.POST); | 
					
						
							|  |  |  |  |                 //    request.AddHeader("token", DataInput.token); | 
					
						
							|  |  |  |  |                 //    request.AddJsonBody(JsonConvert.SerializeObject(DataInput.data)); | 
					
						
							|  |  |  |  |                 //    IRestResponse response = client.Execute(request); | 
					
						
							|  |  |  |  |                 //    returnContent = response.Content; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 //} | 
					
						
							|  |  |  |  |                 //else | 
					
						
							|  |  |  |  |                 //{ | 
					
						
							|  |  |  |  |                 //    var request = new RestRequest(Method.GET); | 
					
						
							|  |  |  |  |                 //    request.AddHeader("token", DataInput.token); | 
					
						
							|  |  |  |  |                 //    IRestResponse response = client.Execute(request); | 
					
						
							|  |  |  |  |                 //    returnContent = response.Content; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 //} | 
					
						
							|  |  |  |  |                 try | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     responeData = JsonConvert.DeserializeObject<Model.ResponeData>(returnContent); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 catch (Exception) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     responeData.code = 0; | 
					
						
							|  |  |  |  |                     responeData.message = "推送数据失败:" + returnContent; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 return responeData; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return responeData; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |         public static ReturnData ExecuteCallBack(string baseurl, ReturnData DataInput, string ReqMethod) | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.ReturnData returnData = new ReturnData(); | 
					
						
							|  |  |  |  |             if (DataInput.code == 1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 string token = "AF17168B-87BD-4GLY-1111-F0A0A1158F9B"; | 
					
						
							|  |  |  |  |                 string Content = ""; | 
					
						
							|  |  |  |  |                 switch (ReqMethod) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     case "Get": | 
					
						
							|  |  |  |  |                         Content = Funs.RequestGet(baseurl, token); | 
					
						
							|  |  |  |  |                         break; | 
					
						
							|  |  |  |  |                     case "Post": | 
					
						
							|  |  |  |  |                         Content = Funs.RequestPost(baseurl, token, JsonConvert.SerializeObject(DataInput.data)); | 
					
						
							|  |  |  |  |                         break; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 //var client = new RestClient(baseurl); | 
					
						
							|  |  |  |  |                 //client.Timeout = -1; | 
					
						
							|  |  |  |  |                 //var request = new RestRequest(Method.POST); | 
					
						
							|  |  |  |  |                 //request.AddHeader("token", "AF17168B-87BD-4GLY-1111-F0A0A1158F9B"); | 
					
						
							|  |  |  |  |                 //request.AddJsonBody(JsonConvert.SerializeObject(DataInput.data)); | 
					
						
							|  |  |  |  |                 //IRestResponse response = client.Execute(request); | 
					
						
							|  |  |  |  |                 //returnContent = response.Content; | 
					
						
							|  |  |  |  |                 try | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     returnData = JsonConvert.DeserializeObject<Model.ReturnData>(Content); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 catch (Exception) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     returnData.code = 0; | 
					
						
							|  |  |  |  |                     returnData.message = "回调失败:" + Content; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return returnData; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |