DataAPI.aspx.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using LYFZ.WeixinServiceDate.DAL;
  8. using LYFZ.WeixinServiceDate.Model;
  9. using LYFZ.WXLibrary;
  10. namespace LYFZ.WeixinServers.WxAuthorize
  11. {
  12. public partial class DataAPI : System.Web.UI.Page
  13. {
  14. 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["type"] != null)
  22. {
  23. string type = Request.QueryString["type"];
  24. switch (type)
  25. {
  26. case "edit":
  27. EditOfficialAccount(eid);
  28. break;
  29. }
  30. }
  31. }
  32. public Model_CustomerInterfaces cusModel = new Model_CustomerInterfaces();
  33. DAL_CustomerInterfaces cusDal = new DAL_CustomerInterfaces();
  34. string postinfoddomaine = "post";
  35. string retMsg = "";
  36. void EditOfficialAccount(string eid)
  37. {
  38. if (!String.IsNullOrEmpty(eid))
  39. {
  40. string OfficialAccountName = "";
  41. string OfficialAccount = "";
  42. string APPID = "";
  43. int id = -1;
  44. if (Request.QueryString["id"] != null)
  45. {
  46. id = Convert.ToInt32(Request.QueryString["id"]);
  47. }
  48. if (Request["OfficialAccountName"] != null)
  49. {
  50. OfficialAccountName = Request["OfficialAccountName"];
  51. }
  52. if (Request["OfficialAccount"] != null)
  53. {
  54. OfficialAccount = Request["OfficialAccount"];
  55. }
  56. if (Request["APPID"] != null)
  57. {
  58. APPID = Request["APPID"];
  59. }
  60. if (String.IsNullOrEmpty(APPID))
  61. {
  62. Response.Write("{\"code\":-100,\"info\":\"请求失败\",\"data\":\"APPID不能为空!\"}");
  63. }
  64. else
  65. {
  66. if (id > 0)
  67. {
  68. cusModel = cusDal.GetModel(id);
  69. }
  70. string JMGDomainName = String.Format("{0}{1}", eid, APPID);
  71. if (cusModel != null && cusModel.ID > 0)
  72. {
  73. try
  74. {
  75. cusModel.JMGDomainName = JMGDomainName;
  76. cusModel.CompanyName = OfficialAccountName;
  77. cusModel.RefreshTime = DateTime.Now;
  78. cusModel.Token = eid;
  79. cusModel.AppID = APPID;
  80. cusModel.AppSecret = OfficialAccount;
  81. cusModel.EncodingAESKey = "";
  82. cusModel.OfficialAccount = OfficialAccount;
  83. cusModel.OfficialAccountName = OfficialAccountName;
  84. cusModel.ISEnabled = 1;
  85. if (cusDal.Update(cusModel))
  86. {
  87. // cusModel = (LYFZ.WeixinServiceDate.Model.Model_CustomerInterfaces)cusDal.GetModelObject("JMGDomainName", JMGDomainName);
  88. Global.UpdateCustInfo(JMGDomainName, cusModel);
  89. try
  90. {
  91. Global.UpdateAuthorizedAPPIDHandleJMGDomainName(cusModel.AppID, cusModel.JMGDomainName, cusModel.CompanyName);
  92. }
  93. catch (Exception ex)
  94. {
  95. CommonHandleClass.WriteLog("域名为:" + JMGDomainName + " 的的客户更新授权处理对象加密锁域名时出错:" + ex.Message, postinfoddomaine, Global.LogsDongleDomainList);
  96. }
  97. CommonHandleClass.WriteLog("域名为:" + JMGDomainName + " 的信息更新提交成功", postinfoddomaine, Global.LogsDongleDomainList);
  98. }
  99. else
  100. {
  101. retMsg = "Exception:Refresh Failed";
  102. CommonHandleClass.WriteLog("域名为:" + JMGDomainName + " 的信息更新提交失败,数据库更新记录时失败", postinfoddomaine, Global.LogsDongleDomainList);
  103. }
  104. }
  105. catch (Exception ex)
  106. {
  107. retMsg = "Exception:" + ex.Message;
  108. CommonHandleClass.WriteLog("域名为:" + JMGDomainName + " 的信息更新提交失败,错误信息为:" + ex.Message, postinfoddomaine, Global.LogsDongleDomainList);
  109. Global.RefreshLoadCustDaTable();
  110. }
  111. }
  112. else
  113. {
  114. try
  115. {
  116. cusModel.JMGDomainName = JMGDomainName;
  117. cusModel.ShellDomainName = "http://p.lyfz.net";
  118. cusModel.IPAddress = "0.0.0.0";
  119. cusModel.PortNumber = 0;
  120. cusModel.UseType = 0;
  121. cusModel.CompanyName = OfficialAccountName;
  122. cusModel.CallFrequency = 0;
  123. cusModel.RefreshTime = DateTime.Now;
  124. cusModel.ThirdPartyPlatformURL = "";
  125. cusModel.Token = eid;
  126. cusModel.AppID = APPID;
  127. cusModel.AppSecret = OfficialAccount;
  128. cusModel.EncodingAESKey = "";
  129. cusModel.OfficialAccount = OfficialAccount;
  130. cusModel.OfficialAccountName = OfficialAccountName;
  131. cusModel.ISEnabled = 1;
  132. if (cusDal.Add(cusModel))
  133. {
  134. cusModel = (LYFZ.WeixinServiceDate.Model.Model_CustomerInterfaces)cusDal.GetModelObject("JMGDomainName", JMGDomainName);
  135. Global.UpdateCustInfo(JMGDomainName, cusModel);
  136. // retMsg += ":" + IPAddress;
  137. CommonHandleClass.WriteLog("域名为:" + JMGDomainName + " 的信息提交成功", postinfoddomaine, Global.LogsDongleDomainList);
  138. }
  139. else
  140. {
  141. retMsg = "Exception:Add Failed";
  142. CommonHandleClass.WriteLog("域名为:" + JMGDomainName + " 的信息提交失败,数据库添加记录时失败", postinfoddomaine, Global.LogsDongleDomainList);
  143. }
  144. }
  145. catch (Exception ex)
  146. {
  147. retMsg = "Exception:" + ex.Message;
  148. CommonHandleClass.WriteLog("域名为:" + JMGDomainName + " 的信息提交失败,错误信息为:" + ex.Message, postinfoddomaine, Global.LogsDongleDomainList);
  149. Global.RefreshLoadCustDaTable();
  150. }
  151. }
  152. }
  153. }
  154. else
  155. {
  156. retMsg = "企业ID不能为空";
  157. }
  158. if (String.IsNullOrEmpty(retMsg))
  159. {
  160. Response.Write("{\"code\":200,\"info\":\"请求成功\",\"data\":\"数据提交成功!\"}");
  161. }
  162. else
  163. {
  164. Response.Write("{\"code\":-100,\"info\":\"请求失败\",\"data\":\"" + retMsg + "\"}");
  165. }
  166. }
  167. }
  168. }