| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using Model; | 
					
						
							|  |  |  |  | using Newtonsoft.Json.Linq; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Web; | 
					
						
							|  |  |  |  | using System.Web.UI; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.InterFace | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class InterFaceTaskEdit : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         public string InterFaceTaskId | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["InterFaceTaskId"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["InterFaceTaskId"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) { | 
					
						
							|  |  |  |  |                 this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); | 
					
						
							|  |  |  |  |                 InterFaceTaskId = Request.Params["InterFaceTaskId"]; | 
					
						
							|  |  |  |  |                 InterFaceSetService.InitInterFaceDropDownList(DropInterFaceSet, false); | 
					
						
							|  |  |  |  |                 BindGrid(); | 
					
						
							|  |  |  |  |                 #region Grid1 | 
					
						
							|  |  |  |  |                 // 删除选中单元格的客户端脚本 | 
					
						
							|  |  |  |  |                 string deleteScript = GetDeleteScript(); | 
					
						
							|  |  |  |  |                 JObject defaultObj = new JObject(); | 
					
						
							|  |  |  |  |                 defaultObj.Add("InterFaceSetId", ""); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 // 在第一行新增一条数据 | 
					
						
							|  |  |  |  |                 btnNew.OnClientClick = Grid1.GetAddNewRecordReference(defaultObj, true); | 
					
						
							|  |  |  |  |                 // 删除选中行按钮 | 
					
						
							|  |  |  |  |                 btnDelete.OnClientClick = Grid1.GetNoSelectionAlertReference("请选择一条记录!") + deleteScript; | 
					
						
							|  |  |  |  |                 #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private void BindGrid() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(InterFaceTaskId)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var model = BLL.InterFaceTaskService.GetInterFaceTaskById(InterFaceTaskId); | 
					
						
							|  |  |  |  |                 txtFrequency.Text= model.Frequency; | 
					
						
							|  |  |  |  |                 txtInterFaceName.Text= model.InterFaceName; | 
					
						
							|  |  |  |  |                 IsEnable.Checked = (bool)model.Enable; | 
					
						
							|  |  |  |  |                 var a =  model.InterFaceSetLists.Split(','); | 
					
						
							|  |  |  |  |                 var q = (from x in a select new { id = Guid.NewGuid().ToString(), InterFaceSetId = x.ToString() }).ToList(); | 
					
						
							|  |  |  |  |                 Grid1.DataSource= q; | 
					
						
							|  |  |  |  |                 Grid1.DataBind();    | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             List<string> list = new List<string>(); | 
					
						
							|  |  |  |  |             JArray EditorArr = Grid1.GetMergedData(); | 
					
						
							|  |  |  |  |             if (EditorArr.Count > 0) | 
					
						
							|  |  |  |  |             {  | 
					
						
							|  |  |  |  |                 for (int i = 0; i < EditorArr.Count; i++) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     JObject objects = (JObject)EditorArr[i]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     list.Add(objects["values"]["InterFaceSetId"].ToString()); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(InterFaceTaskId)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var model=BLL.InterFaceTaskService.GetInterFaceTaskById(InterFaceTaskId);    | 
					
						
							|  |  |  |  |                 model.InterFaceName=txtInterFaceName.Text; | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                 model.Frequency = txtFrequency.Text.Trim(); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 model.InterFaceSetLists=string .Join(",", list); | 
					
						
							|  |  |  |  |                 model.CreateTime = DateTime.Now; | 
					
						
							|  |  |  |  |                 model.Enable = IsEnable.Checked; | 
					
						
							|  |  |  |  |                 InterFaceTaskService.UpdateInterFaceTask(model); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.InterFaceTask model =new Model.InterFaceTask(); | 
					
						
							|  |  |  |  |                 model.InterFaceTaskId = SQLHelper.GetNewID(typeof(Model.InterFaceTask)); | 
					
						
							|  |  |  |  |                 InterFaceTaskId = model.InterFaceTaskId; | 
					
						
							|  |  |  |  |                 model.InterFaceName = txtInterFaceName.Text; | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                 model.Frequency = txtFrequency.Text.Trim(); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 model.InterFaceSetLists = string.Join(",", list); | 
					
						
							|  |  |  |  |                 model.CreateTime = DateTime.Now; | 
					
						
							|  |  |  |  |                 model.Enable = IsEnable.Checked; | 
					
						
							|  |  |  |  |                 InterFaceTaskService.AddInterFaceTask(model); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             QuartzServices.SyncISchedulerById(InterFaceTaskId); | 
					
						
							|  |  |  |  |             ShowNotify("保存成功!", MessageBoxIcon.Success); | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); | 
					
						
							|  |  |  |  |   | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private string GetDeleteScript() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return Confirm.GetShowReference("确定删除当前数据吗?", String.Empty, MessageBoxIcon.Question, Grid1.GetDeleteSelectedRowsReference(), String.Empty); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | } |