DZKJInterface.aspx.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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.DZKJ
  9. {
  10. public partial class DZKJInterface : System.Web.UI.Page
  11. {
  12. string Account = "";
  13. string Password = "";
  14. string HardwareCode = "";
  15. string ip = "";
  16. int type = -1;
  17. string VerificationCode = "";
  18. LYFZ.WeixinServiceDate.Model.Model_DZKJ_CustomerAccount dzkjModel = new WeixinServiceDate.Model.Model_DZKJ_CustomerAccount();
  19. LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount DZKJ_Dal = new WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount();
  20. string sVersion = "";
  21. protected void Page_Load(object sender, EventArgs e)
  22. {
  23. var retJosnObj = GetReturnJson(-1,"","参数错误");
  24. // if (!IsPostBack)
  25. {
  26. //type= 0 为登录 1 验证 2 为退出登录
  27. //type = Login , verification
  28. if (Request.QueryString["Account"] != null)
  29. {
  30. Account = Request.QueryString["Account"].ToString();
  31. }
  32. if (Request.Form["Account"] != null)
  33. {
  34. Account = Request.Form["Account"].ToString();
  35. }
  36. if (Request.QueryString["type"] != null && !string.IsNullOrEmpty(Request.QueryString["type"].ToString().Trim()))
  37. {
  38. type =Convert.ToInt32(Request.QueryString["type"].ToString().Trim());
  39. }
  40. if (type == 0 || type == 1 || type == 2)
  41. {
  42. if (Request.QueryString["v"] != null)
  43. {
  44. sVersion = Request.QueryString["v"].ToString();
  45. }
  46. if (Request.Form["v"] != null)
  47. {
  48. sVersion = Request.Form["v"].ToString();
  49. }
  50. if (Request.QueryString["Password"] != null)
  51. {
  52. Password = Request.QueryString["Password"].ToString();
  53. }
  54. if (Request.QueryString["HardwareCode"] != null)
  55. {
  56. HardwareCode = Request.QueryString["HardwareCode"].ToString();
  57. }
  58. if (Request.QueryString["VerificationCode"] != null)
  59. {
  60. VerificationCode = Request.QueryString["VerificationCode"].ToString();
  61. }
  62. if (Request.Form["ip"] != null)
  63. {
  64. ip = Request.Form["ip"].ToString();
  65. }
  66. if (Request.Form["Password"] != null)
  67. {
  68. Password = Request.Form["Password"].ToString();
  69. }
  70. if (Request.Form["HardwareCode"] != null)
  71. {
  72. HardwareCode = Request.Form["HardwareCode"].ToString();
  73. }
  74. if (Request.Form["VerificationCode"] != null)
  75. {
  76. VerificationCode = Request.Form["VerificationCode"].ToString();
  77. }
  78. DataRow dzkjRow = Global.DZKJ_CustomerAccountDataTable.Rows.Find(Account);
  79. if (dzkjRow != null)
  80. {
  81. dzkjModel = DZKJ_Dal.DataRowToModel(dzkjRow);
  82. }
  83. //DZKJ_Dal.GetModelObject("Account='" + Account + "' and Password='" + Password + "'");
  84. if (dzkjRow!=null&&dzkjModel.ID > 1)
  85. {
  86. if (dzkjModel.IsEnabled == 1)
  87. {
  88. if (dzkjModel.PeriodOfValidity > DateTime.Now.AddDays(-1))
  89. {
  90. if (type == 1)
  91. {
  92. //开始验证
  93. if (VerificationCode.ToLower().Trim() == LYFZ.WinAPI.SDKSecurity.MD5Encrypt(dzkjModel.Password + dzkjModel.LatestLoginTime.ToString("yyyy-MM-dd HH:mm:ss")).ToLower().Trim())
  94. {
  95. var DZKJ_CustomerInfo = new
  96. {
  97. Account = Account,
  98. PeriodOfValidity = dzkjModel.PeriodOfValidity.ToString("yyyy-MM-dd"),
  99. StartSimulatorCount = dzkjModel.StartSimulatorCount,
  100. RegistrationTime = dzkjModel.RegistrationTime.ToString("yyyy-MM-dd HH:mm:ss"),
  101. LatestLoginTime = dzkjModel.LatestLoginTime.ToString("yyyy-MM-dd HH:mm:ss"),
  102. NewVerificationCode = LYFZ.WinAPI.SDKSecurity.MD5Encrypt(VerificationCode.Substring(0, 16) + "lyfz_dzkj" + Account)
  103. };
  104. retJosnObj = GetReturnJson(0, DZKJ_CustomerInfo, "验证成功");
  105. Global.UpdateCustomerAccountDataTableSmallEifVersion(Account, sVersion);
  106. }
  107. else
  108. {
  109. retJosnObj = GetReturnJson(-6, "", "验证失败,验证码不正确");
  110. }
  111. }
  112. else
  113. {
  114. if (dzkjModel.Password.Trim() == Password.Trim() && !string.IsNullOrEmpty(Password.Trim()))
  115. {
  116. if (type == 0 && dzkjModel.HardwareCode.ToLower().Trim() != HardwareCode.ToLower().Trim())
  117. {
  118. retJosnObj = GetReturnJson(-2, "", "申请码不正确");
  119. }
  120. else
  121. {
  122. ///开始登录
  123. if (type == 0)
  124. {
  125. dzkjModel.LatestLoginTime = DateTime.Now;
  126. Global.UpdateCustomerAccountDataTableLatestLoginTime(Account, ip, dzkjModel.LatestLoginTime,sVersion);
  127. var DZKJ_CustomerInfo = new
  128. {
  129. Account = Account,
  130. PeriodOfValidity = dzkjModel.PeriodOfValidity.ToString("yyyy-MM-dd"),
  131. StartSimulatorCount = dzkjModel.StartSimulatorCount,
  132. RegistrationTime = dzkjModel.RegistrationTime.ToString("yyyy-MM-dd HH:mm:ss"),
  133. LatestLoginTime = dzkjModel.LatestLoginTime.ToString("yyyy-MM-dd HH:mm:ss"),
  134. VerificationCode = LYFZ.WinAPI.SDKSecurity.MD5Encrypt(Password + dzkjModel.LatestLoginTime.ToString("yyyy-MM-dd HH:mm:ss"))
  135. };
  136. retJosnObj = GetReturnJson(0, DZKJ_CustomerInfo, "登录成功");
  137. }
  138. else if (type == 2)
  139. {
  140. dzkjModel.LatestLoginTime = DateTime.Now;
  141. Global.UpdateCustomerAccountDataTableLatestLoginTime(Account, ip, dzkjModel.LatestLoginTime, sVersion);
  142. retJosnObj = GetReturnJson(0, "", "退出登录成功");
  143. }
  144. }
  145. }
  146. else
  147. {
  148. retJosnObj = GetReturnJson(-3, "", "验证失败,密码不正确");
  149. }
  150. }
  151. }
  152. else
  153. {
  154. retJosnObj = GetReturnJson(-5, "", "验证失败,该帐号已过有效期");
  155. }
  156. }
  157. else {
  158. retJosnObj = GetReturnJson(-4, "", "验证失败,该帐号已被禁用");
  159. }
  160. }
  161. else
  162. {
  163. retJosnObj = GetReturnJson(-3, "", "验证失败,帐号不正确");
  164. }
  165. }
  166. }
  167. string iniConfigInfo = Newtonsoft.Json.JsonConvert.SerializeObject(retJosnObj);
  168. Response.Write(iniConfigInfo);
  169. }
  170. public static object GetReturnJson(int code, object data, string msg)
  171. {
  172. var retJosnObj = new
  173. {
  174. code=code,
  175. data = data,
  176. msg=msg
  177. };
  178. return retJosnObj;
  179. }
  180. /* public LYFZ.WeixinServiceDate.Model.Model_DZKJ_CustomerAccount GetDzkjModelLogin(string Account, string Password, string HardwareCode)
  181. {
  182. LYFZ.WeixinServiceDate.Model.Model_DZKJ_CustomerAccount ret_dzkj_model=null;
  183. lock (dzkjModelLoginList)
  184. {
  185. foreach (LYFZ.WeixinServiceDate.Model.Model_DZKJ_CustomerAccount _dzkj_model in dzkjModelLoginList)
  186. {
  187. if (_dzkj_model.Account.Trim().ToLower() == Account.Trim().ToLower())
  188. {
  189. ret_dzkj_model = _dzkj_model;
  190. }
  191. }
  192. }
  193. return ret_dzkj_model;
  194. }
  195. public void AddDzkjModelLoginList(LYFZ.WeixinServiceDate.Model.Model_DZKJ_CustomerAccount _dzkj_model)
  196. {
  197. lock (dzkjModelLoginList)
  198. {
  199. dzkjModelLoginList.Add(_dzkj_model);
  200. }
  201. }
  202. public void RemoveDzkjModelLoginList(LYFZ.WeixinServiceDate.Model.Model_DZKJ_CustomerAccount _dzkj_model)
  203. {
  204. lock (dzkjModelLoginList)
  205. {
  206. dzkjModelLoginList.Remove(_dzkj_model);
  207. }
  208. }*/
  209. }
  210. }