OfficialAccountList.aspx.cs 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using LYFZ.WeixinServiceDate.DAL;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. namespace LYFZ.WeixinServers.WxAuthorize
  9. {
  10. public partial class OfficialAccountList : System.Web.UI.Page
  11. {
  12. public string table = "";
  13. DAL_CustomerInterfaces officialAccountDal = new DAL_CustomerInterfaces();
  14. public string eid = "";
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. if (Request.QueryString["eid"] != null)
  18. {
  19. eid = Request.QueryString["eid"];
  20. }
  21. if (Request.QueryString["delid"] == null)
  22. {
  23. string strWhere = String.Format("Token='{0}'", eid);
  24. System.Data.DataTable officialAccountTb = officialAccountDal.GetOfficialAccountList(eid);
  25. if (officialAccountTb != null)
  26. {
  27. foreach (System.Data.DataRow dr in officialAccountTb.Rows)
  28. {
  29. string AuthorizeStatus = "未授权";
  30. if (dr["AuthorizeStatus"] != null)
  31. {
  32. AuthorizeStatus = (dr["AuthorizeStatus"].ToString() == "1" ? "已授权" : "未授权");
  33. }
  34. table += "<tr>";
  35. table += " <td>" + dr["OfficialAccountName"] + "</td>";
  36. table += " <td>" + dr["AppSecret"] + "</td>";
  37. table += " <td>" + dr["AppID"] + "</td>";
  38. table += " <td><span id=\"#foo\">http://wx.lyfz.net/WxInterface.aspx?eid=" + eid + "&appid=" + dr["AppID"] + "</span> "+
  39. " <button class=\"layui-icon\" data-clipboard-text=\"http://wx.lyfz.net/WxInterface.aspx?eid=" + eid + "&appid=" + dr["AppID"] + "\">&#xe621;</button></td>";
  40. table += " <td>" + AuthorizeStatus + "</td>";
  41. table += " <td>"
  42. + " <a class=\"layui-btn\" href=\"AddOfficialAccount.aspx?id=" + dr["id"] + "&eid=" + eid + "\">编辑</a>"
  43. + " <a class=\"layui-btn\" target=\"_blank\" href=\"" + GetAuthorizationAndBindUrl(dr["AppID"].ToString(), String.Format("{0}{1}",eid, dr["AppID"])) + "\">授权</a>"
  44. + " <a class=\"layui-btn\" href=\"OfficialAccountList.aspx?delid=" + dr["id"] + "&eid=" + eid + "\">删除</a>"
  45. + "</td>";
  46. table += "</tr>";
  47. }
  48. }
  49. }
  50. else {
  51. delOfficialAccount(eid);
  52. }
  53. }
  54. void delOfficialAccount(string eid)
  55. {
  56. try
  57. {
  58. int delid = -1;
  59. if (Request.QueryString["delid"] != null)
  60. {
  61. if (!String.IsNullOrEmpty(Request.QueryString["delid"]))
  62. {
  63. delid = Convert.ToInt32(Request.QueryString["delid"]);
  64. }
  65. }
  66. if (delid > 0)
  67. {
  68. officialAccountDal.Delete(delid);
  69. }
  70. Response.Redirect(String.Format("OfficialAccountList.aspx?eid={0}", eid));
  71. }
  72. catch { }
  73. }
  74. /// <summary>
  75. /// 获取微信接口授权并绑定URL
  76. /// </summary>
  77. /// <param name="appid"></param>
  78. /// <param name="yuname"></param>
  79. /// <returns></returns>
  80. public static string GetAuthorizationAndBindUrl(string appid, string yuname)
  81. {
  82. return "http://wx.lyfz.net/Authorize.aspx?appid=" + appid + "&yuname=" + LYFZ.WinAPI.SDKSecurity.Encode(yuname);
  83. }
  84. }
  85. }