You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
5.0 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. using Business.Account;
  2. using Business.Configuration;
  3. using Common.Helper;
  4. using Common.Model.Account;
  5. using Newtonsoft.Json;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Web;
  10. namespace JMEAgentSystem.WebPages.Account
  11. {
  12. public partial class Login : System.Web.UI.Page
  13. {
  14. private readonly IAccountServices _accountServices = AutoFacContainer.Resolve<IAccountServices>();
  15. protected string _agentPlatform;
  16. protected string _agentPlatformId;
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. _agentPlatform = HttpContext.Current.Request.Headers.Get("Agent-Platform");
  20. _agentPlatformId = HttpContext.Current.Request.Headers.Get("Agent-Platform-Id");
  21. var methodName = GetStatic.ReadFormData("MethodName", "");
  22. var isLogout = Convert.ToBoolean(GetStatic.ReadQueryString("isLogout", "false"));
  23. if (methodName.Equals("login"))
  24. SystemLogin();
  25. if (isLogout == true)
  26. {
  27. Logout();
  28. }
  29. CheckRememberMe();
  30. }
  31. private void CheckRememberMe()
  32. {
  33. string dt = DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Year.ToString();
  34. var userData = GetStatic.ReadCookie("JME_Agent_System_UserData_" + dt, "");
  35. if (!string.IsNullOrEmpty(userData))
  36. {
  37. string[] userDatas = userData.Split('|');
  38. referralCode.Text = userDatas[0];
  39. password.Attributes.Add("value", userDatas[1]);
  40. checkbox_signup.Checked = true;
  41. }
  42. }
  43. protected void SystemLogin()
  44. {
  45. var agentPlatform = HttpContext.Current.Request.Headers.Get("Agent-Platform");
  46. var agentPlatformId = HttpContext.Current.Request.Headers.Get("Agent-Platform-Id");
  47. LoginModel loginModel = new LoginModel()
  48. {
  49. Password = GetStatic.ReadFormData("Password", ""),
  50. ReferralCode = GetStatic.ReadFormData("ReferralCode", ""),
  51. IpAddress = GetStatic.GetIpAddress(Request),
  52. UserDetails = GetStatic.GetUserInfo(Request),
  53. AgentPlatform = agentPlatform,
  54. AgentPlatformId = agentPlatformId
  55. };
  56. bool RememberMe = Convert.ToBoolean(GetStatic.ReadFormData("RememberMe", "false"));
  57. DataSet ds = _accountServices.LoginSystem(loginModel);
  58. var result = GetStatic.ParseDbResult(ds.Tables[0]);
  59. if (result.ResponseCode == "0")
  60. {
  61. GetStatic.WriteSession("admin", ds.Tables[1].Rows[0]["REFERRAL_CODE"].ToString());
  62. GetStatic.WriteSession("agentName", ds.Tables[1].Rows[0]["REFERRAL_NAME"].ToString());
  63. GetStatic.WriteSession("agentAddress", ds.Tables[1].Rows[0]["REFERRAL_ADDRESS"].ToString());
  64. GetStatic.WriteSession("agentMobile", ds.Tables[1].Rows[0]["REFERRAL_MOBILE"].ToString());
  65. GetStatic.WriteSession("agentEmail", ds.Tables[1].Rows[0]["REFERRAL_EMAIL"].ToString());
  66. GetStatic.WriteSession("agentAssignedBranch", ds.Tables[1].Rows[0]["AGENTNAME"].ToString());
  67. GetStatic.WriteSession("agentType", ds.Tables[1].Rows[0]["REFERRAL_TYPE_CODE"].ToString());
  68. GetStatic.WriteSession("agentLimit", ds.Tables[1].Rows[0]["REFERRAL_LIMIT"].ToString());
  69. GetStatic.WriteSession("agentId", ds.Tables[1].Rows[0]["BRANCH_ID"].ToString());
  70. GetStatic.WriteSession("isForceChangePassword", ds.Tables[1].Rows[0]["FORCE_CHANGE_PWD"].ToString());
  71. GetStatic.WriteSession("countryId","113");
  72. if (!string.IsNullOrEmpty(GetStatic.ReadCookie("JME_Agent_System_UserData_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.AddDays(-1).Day.ToString() + "_" + DateTime.Now.Year.ToString(), "")))
  73. {
  74. GetStatic.DeleteCookie("JME_Agent_System_UserData_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.AddDays(-1).Day.ToString() + "_" + DateTime.Now.Year.ToString());
  75. }
  76. string dt = DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Year.ToString();
  77. if (RememberMe)
  78. GetStatic.WriteCookie("JME_Agent_System_UserData_" + dt, loginModel.ReferralCode + "|" + loginModel.Password);
  79. else
  80. GetStatic.DeleteCookie("JME_Agent_System_UserData_" + dt);
  81. }
  82. Response.ContentType = "text/plain";
  83. string json = JsonConvert.SerializeObject(result);
  84. Response.Write(json);
  85. Response.End();
  86. }
  87. private void Logout()
  88. {
  89. Session.Clear();
  90. Session.Abandon();
  91. Response.Redirect("/Webpages/Account/Login");
  92. }
  93. }
  94. }