AuthorizationInfoLis.aspx.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. namespace LYFZ.WeixinServers.WeiXinAPP
  9. {
  10. public partial class AuthorizationInfoLis : System.Web.UI.Page
  11. {
  12. protected void Page_Load(object sender, EventArgs e)
  13. {
  14. CommonHandler.CheckLoginJump(this);
  15. if (!IsPostBack)
  16. {
  17. if (Request.QueryString["Keyword"] != null)
  18. {
  19. Keyword = Request.QueryString["Keyword"].ToString().Trim();
  20. }
  21. if (Request.QueryString["type"] != null)
  22. {
  23. if (Request.QueryString["type"].ToString().Trim() == "refresh")
  24. {
  25. Global.RefreshLoadAuthorizationInfoDaTable();
  26. }
  27. }
  28. if (Request.QueryString["del"] != null && Request.QueryString["del"].ToString().Length>0)
  29. {
  30. try
  31. {
  32. if (CommonHandler.CheckAdmin(this))
  33. {
  34. int delID = Convert.ToInt32(Request.QueryString["del"].ToString());
  35. deleteAuthorization_info(delID);
  36. }
  37. }
  38. catch (Exception ex){
  39. showMsegesBox("删除失败,请重试.错误原因:"+ex.Message);
  40. }
  41. }
  42. }
  43. bindUserList();
  44. }
  45. string Keyword = "";
  46. public string PagingInfoHtml = "";
  47. void deleteAuthorization_info(int id)
  48. {
  49. if (Authorization_infoDal.Delete(id))
  50. {
  51. this.Response.Redirect("AuthorizationInfoLis.aspx");
  52. }
  53. else {
  54. showMsegesBox("删除失败,请重试.");
  55. }
  56. }
  57. void showMsegesBox(string msg)
  58. {
  59. Response.Write("<script>alert('" + msg + "');document.location='AuthorizationInfoLis.aspx';</script>"); return;
  60. }
  61. LYFZ.WeixinServiceDate.DAL.DAL_Authorization_info Authorization_infoDal = new WeixinServiceDate.DAL.DAL_Authorization_info();
  62. public System.Text.StringBuilder Authorization_infoListHtmlTb = new System.Text.StringBuilder();
  63. void bindUserList()
  64. {
  65. string whereStr = "";
  66. if (Keyword.Length > 0)
  67. {
  68. whereStr = " [JMGDomainName] like '%" + Keyword + "%' or [CompanyName] like '%" + Keyword + "%' or [authorizer_appid] like '%" + Keyword + "%' ";
  69. }
  70. DataRow[] cacheRows = Global.AuthorizationInfoDaTable.Select(whereStr.Trim(), "id desc");
  71. int sumCount = cacheRows.Length;
  72. string countInfo = "当前缓存共" + sumCount.ToString() + "条记录";
  73. PagingInfoHtml = LYFZ.WXLibrary.PageTabList.GetPagingInfo_Web(1, 1, countInfo);
  74. DataTable authorizationInfoDaTable = Global.AuthorizationInfoDaTable;// Authorization_infoDal.GetList("1=1");
  75. for (int i = 0; i < cacheRows.Length; i++)
  76. {
  77. DataRow row = cacheRows[i];//authorizationInfoDaTable.Rows[i];
  78. string AuthorizeStatus = row["AuthorizeStatus"].ToString() == "0" ? "已取消授权" : "已授权";
  79. Authorization_infoListHtmlTb.Append("<tr>"
  80. + " <td>" + row["id"].ToString() + "</td>"
  81. + " <td>" + row["CompanyName"].ToString() + "<br />" + row["JMGDomainName"].ToString() + "</td>"
  82. + " <td>" + row["authorizer_appid"].ToString() + "</td>"
  83. + " <td>" + AuthorizeStatus + "</td>"
  84. + " <td><b>授权令牌(Access_token):</b>" + row["authorizer_access_token"].ToString() + "<br /><b>令牌有效时间(Expires_in):</b>" + row["expires_in"].ToString() + "<br /><b>授权刷新令牌(Access_refresh_token):</b>" + row["authorizer_refresh_token"].ToString() + "<br /><b>最新刷新令牌的时间:</b>" + Convert.ToDateTime(row["RefreshTokenTime"]).ToString("yyyy-MM-dd HH:mm") + "</td>"
  85. + "<td>" + Convert.ToDateTime(row["CreateTime"]).ToString("yyyy-MM-dd HH:mm") + "</td>"
  86. + "<td>" + Convert.ToDateTime(row["UpdateTime"]).ToString("yyyy-MM-dd HH:mm") + "</td>"
  87. + " <td>"
  88. + "<a href=\"AuthorizationInfoLis.aspx?eid=" + row["id"].ToString() + "&authorizer_appid=" + row["authorizer_appid"].ToString() + "\" style=\"margin-right:10px;\"><i class=\"icon-pencil\"></i></a>"
  89. + "<a href=\"#myModal\" role=\"button\" onclick=\"setModalValue(" + row["id"].ToString() + ")\" data-toggle=\"modal\"><i class=\"icon-remove\"></i></a>"
  90. + "</td>"
  91. + " </tr>");
  92. }
  93. }
  94. }
  95. }