| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Web; | 
					
						
							|  |  |  |  | using System.Web.Security; | 
					
						
							|  |  |  |  | using System.Web.UI; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | using BLL; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.InterFace | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class InterFaceEdit : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         #region 定义项 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 接口配置主键 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public string InterFaceSetId | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["InterFaceSetId"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["InterFaceSetId"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 接口配置编辑页面 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 LoadData(); | 
					
						
							|  |  |  |  |                 ///权限 | 
					
						
							|  |  |  |  |                 this.GetButtonPower(); | 
					
						
							|  |  |  |  |                 this.InterFaceSetId = Request.Params["InterFaceSetId"]; | 
					
						
							|  |  |  |  |                 BLL.ConstValue.InitConstValueDropDownList(this.drpIsOpen, ConstValue.Group_0001, false); | 
					
						
							|  |  |  |  |                 BLL.InterFaceSetService.InitReqMethodDropDownList(this.DrpUrlReqMethod,  false); | 
					
						
							|  |  |  |  |                 BLL.InterFaceSetService.InitReqMethodDropDownList(this.DrpForUrlReqMethod,  false); | 
					
						
							|  |  |  |  |                 BLL.InterFaceSetService.InitReqMethodDropDownList(this.DrpCallBackUrlReqMethod,  false); | 
					
						
							|  |  |  |  |                 this.drpUnit.DataTextField = "UnitName"; | 
					
						
							|  |  |  |  |                 this.drpUnit.DataValueField = "UnitId"; | 
					
						
							|  |  |  |  |                 this.drpUnit.DataSource = BLL.UnitService.GetUnitDropDownList(); | 
					
						
							|  |  |  |  |                 drpUnit.DataBind(); | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                 this.drpAuthUnit.DataTextField = "UnitName"; | 
					
						
							|  |  |  |  |                 this.drpAuthUnit.DataValueField = "UnitId"; | 
					
						
							|  |  |  |  |                 this.drpAuthUnit.DataSource = BLL.UnitService.GetUnitDropDownList(); | 
					
						
							|  |  |  |  |                 drpAuthUnit.DataBind(); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                 Funs.FineUIPleaseSelect(this.drpUnit); | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(this.InterFaceSetId)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.drpUnit.SelectedValue = this.InterFaceSetId; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     var unit = BLL.CommonService.GetIsThisUnit(); | 
					
						
							|  |  |  |  |                     if (unit != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.drpUnit.SelectedValue = unit.UnitId; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                   | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(this.InterFaceSetId)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     var FaceSet = BLL.InterFaceSetService.GetInterFaceSetById(this.InterFaceSetId); | 
					
						
							|  |  |  |  |                     if (FaceSet != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                          | 
					
						
							|  |  |  |  |                         | 
					
						
							|  |  |  |  |                         if (!string.IsNullOrEmpty(FaceSet.UnitId)) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             this.drpUnit.SelectedValue = FaceSet.UnitId; | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         this.txtFaceName.Text = FaceSet.InterFaceName; | 
					
						
							|  |  |  |  |                         this.txtFaceUrl.Text = FaceSet.InterFaceUrl; | 
					
						
							|  |  |  |  |                         this.txtFaceForUrl.Text = FaceSet.InterFaceForUrl; | 
					
						
							|  |  |  |  |                         this.txtCallBackUrl.Text=FaceSet.InterFaceCallBackUrl; | 
					
						
							|  |  |  |  |                         this.IsCallBack.Checked =(bool) FaceSet.IsCallBack; | 
					
						
							|  |  |  |  |                         if (!string.IsNullOrEmpty(FaceSet.AuthUnitIds)) | 
					
						
							|  |  |  |  |                         { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                             this.drpAuthUnit.SelectedValueArray = FaceSet.AuthUnitIds.Split(','); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                         } | 
					
						
							|  |  |  |  |                         | 
					
						
							|  |  |  |  |                         this.txtRemarks.Text = FaceSet.TxtRemarks; | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                         txtRequestJsonBody.Text = FaceSet.RequestJsonBody; | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                         if (FaceSet.IsOpen.HasValue) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             this.drpIsOpen.SelectedValue = Convert.ToString(FaceSet.IsOpen); | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         if (!string.IsNullOrEmpty(FaceSet.UrlReqMethod)) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             this.DrpUrlReqMethod.SelectedValue = FaceSet.UrlReqMethod; | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         if (!string.IsNullOrEmpty(FaceSet.ForUrlReqMethod)) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             this.DrpForUrlReqMethod.SelectedValue = FaceSet.ForUrlReqMethod; | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         if (!string.IsNullOrEmpty(FaceSet.CallBackUrlReqMethod)) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             this.DrpCallBackUrlReqMethod.SelectedValue = FaceSet.CallBackUrlReqMethod; | 
					
						
							|  |  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                         if (FaceSet.IsSingleRequest != null) cbIsSingleRequest.Checked = (bool)FaceSet.IsSingleRequest; | 
					
						
							|  |  |  |  |                         cbIsSingleRequest_OnCheckedChanged(null, null); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     cbIsSingleRequest_OnCheckedChanged(null, null); | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载页面 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private void LoadData() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             btnClose.OnClientClick = ActiveWindow.GetHideReference(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 保存按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //目标单位 | 
					
						
							|  |  |  |  |             string AuthUnitId = string.Empty; | 
					
						
							|  |  |  |  |             string AuthUnitName = string.Empty; | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |             string UnitId = string.Empty;  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             AuthUnitId = string.Join(",", drpAuthUnit.SelectedValueArray); | 
					
						
							|  |  |  |  |             AuthUnitName = UnitService.getUnitNamesUnitIds(AuthUnitId); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |             if (this.drpUnit.SelectedValue != Const._Null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 UnitId = this.drpUnit.SelectedValue; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             Model.InterFaceSet newSet = new Model.InterFaceSet | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 InterFaceName = this.txtFaceName.Text.Trim(), | 
					
						
							|  |  |  |  |                 InterFaceUrl = this.txtFaceUrl.Text.Trim(), | 
					
						
							|  |  |  |  |                 InterFaceForUrl = this.txtFaceForUrl.Text.Trim(), | 
					
						
							|  |  |  |  |                 IsOpen = Convert.ToBoolean(this.drpIsOpen.SelectedValue), | 
					
						
							|  |  |  |  |                 TxtRemarks = this.txtRemarks.Text.Trim(), | 
					
						
							|  |  |  |  |                 AuthUnitIds = AuthUnitId, | 
					
						
							|  |  |  |  |                 AuthUnitName = AuthUnitName, | 
					
						
							|  |  |  |  |                 UnitId = UnitId, | 
					
						
							|  |  |  |  |                 IsCallBack = IsCallBack.Checked, | 
					
						
							|  |  |  |  |                 InterFaceCallBackUrl = txtCallBackUrl.Text, | 
					
						
							|  |  |  |  |                 UrlReqMethod=DrpUrlReqMethod.SelectedValue.Trim(), | 
					
						
							|  |  |  |  |                 ForUrlReqMethod=DrpForUrlReqMethod.SelectedValue.Trim(), | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |                 CallBackUrlReqMethod=DrpCallBackUrlReqMethod.SelectedValue.Trim(), | 
					
						
							|  |  |  |  |                 IsSingleRequest = cbIsSingleRequest.Checked, | 
					
						
							|  |  |  |  |                 RequestJsonBody = txtRequestJsonBody.Text.Trim(), | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             }; | 
					
						
							|  |  |  |  |             if (string.IsNullOrEmpty(this.InterFaceSetId)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 newSet.InterFaceSetId = SQLHelper.GetNewID(typeof(Model.InterFaceSet)); | 
					
						
							|  |  |  |  |                 BLL.InterFaceSetService.AddInterFaceSet(newSet); | 
					
						
							|  |  |  |  |                 BLL.LogService.AddLog(this.CurrUser.UserId, "添加接口设置-" + this.txtFaceName.Text.Trim()); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 newSet.InterFaceSetId = this.InterFaceSetId; | 
					
						
							|  |  |  |  |                 BLL.InterFaceSetService.UpdateInterFaceSet(newSet); | 
					
						
							|  |  |  |  |                 BLL.LogService.AddLog(this.CurrUser.UserId, "修改接口设置" + this.txtFaceName.Text.Trim()); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 获取按钮权限 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 获取按钮权限 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="button"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         private void GetButtonPower() | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  |             var buttonList = BLL.CommonService.GetAllButtonList(string.Empty, this.CurrUser.UserId, BLL.Const.UserMenuId); | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |             if (buttonList.Count() > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (buttonList.Contains(BLL.Const.BtnSave)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.btnSave.Hidden = false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void IsCallBack_CheckedChanged(object sender, CheckedEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (IsCallBack.Checked==true) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.txtCallBackUrl.Hidden = false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.txtCallBackUrl.Hidden = true; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-03-13 10:52:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void cbIsSingleRequest_OnCheckedChanged(object sender, CheckedEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (cbIsSingleRequest.Checked == true) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.rowFace.Hidden = false; | 
					
						
							|  |  |  |  |                 this.rowFaceFor.Hidden = true; | 
					
						
							|  |  |  |  |                 this.rowCallBack.Hidden = true; | 
					
						
							|  |  |  |  |                 txtRequestJsonBody.Hidden = false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.rowFace.Hidden = false; | 
					
						
							|  |  |  |  |                 this.rowFaceFor.Hidden = false; | 
					
						
							|  |  |  |  |                 this.rowCallBack.Hidden = false; | 
					
						
							|  |  |  |  |                 txtRequestJsonBody.Hidden = true; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-08-10 11:40:02 +08:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | } |