123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace LYFZ.WeixinServers.DZKJ
- {
- public partial class DZKJInterface : System.Web.UI.Page
- {
- string Account = "";
- string Password = "";
- string HardwareCode = "";
- string ip = "";
- int type = -1;
- string VerificationCode = "";
- LYFZ.WeixinServiceDate.Model.Model_DZKJ_CustomerAccount dzkjModel = new WeixinServiceDate.Model.Model_DZKJ_CustomerAccount();
- LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount DZKJ_Dal = new WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount();
- string sVersion = "";
- protected void Page_Load(object sender, EventArgs e)
- {
- var retJosnObj = GetReturnJson(-1,"","参数错误");
- // if (!IsPostBack)
- {
- //type= 0 为登录 1 验证 2 为退出登录
- //type = Login , verification
- if (Request.QueryString["Account"] != null)
- {
- Account = Request.QueryString["Account"].ToString();
- }
- if (Request.Form["Account"] != null)
- {
- Account = Request.Form["Account"].ToString();
- }
- if (Request.QueryString["type"] != null && !string.IsNullOrEmpty(Request.QueryString["type"].ToString().Trim()))
- {
- type =Convert.ToInt32(Request.QueryString["type"].ToString().Trim());
- }
- if (type == 0 || type == 1 || type == 2)
- {
- if (Request.QueryString["v"] != null)
- {
- sVersion = Request.QueryString["v"].ToString();
- }
- if (Request.Form["v"] != null)
- {
- sVersion = Request.Form["v"].ToString();
- }
-
- if (Request.QueryString["Password"] != null)
- {
- Password = Request.QueryString["Password"].ToString();
- }
- if (Request.QueryString["HardwareCode"] != null)
- {
- HardwareCode = Request.QueryString["HardwareCode"].ToString();
- }
- if (Request.QueryString["VerificationCode"] != null)
- {
- VerificationCode = Request.QueryString["VerificationCode"].ToString();
- }
- if (Request.Form["ip"] != null)
- {
- ip = Request.Form["ip"].ToString();
- }
-
- if (Request.Form["Password"] != null)
- {
- Password = Request.Form["Password"].ToString();
- }
- if (Request.Form["HardwareCode"] != null)
- {
- HardwareCode = Request.Form["HardwareCode"].ToString();
- }
- if (Request.Form["VerificationCode"] != null)
- {
- VerificationCode = Request.Form["VerificationCode"].ToString();
- }
- DataRow dzkjRow = Global.DZKJ_CustomerAccountDataTable.Rows.Find(Account);
- if (dzkjRow != null)
- {
- dzkjModel = DZKJ_Dal.DataRowToModel(dzkjRow);
- }
- //DZKJ_Dal.GetModelObject("Account='" + Account + "' and Password='" + Password + "'");
- if (dzkjRow!=null&&dzkjModel.ID > 1)
- {
- if (dzkjModel.IsEnabled == 1)
- {
- if (dzkjModel.PeriodOfValidity > DateTime.Now.AddDays(-1))
- {
- if (type == 1)
- {
- //开始验证
- if (VerificationCode.ToLower().Trim() == LYFZ.WinAPI.SDKSecurity.MD5Encrypt(dzkjModel.Password + dzkjModel.LatestLoginTime.ToString("yyyy-MM-dd HH:mm:ss")).ToLower().Trim())
- {
- var DZKJ_CustomerInfo = new
- {
- Account = Account,
- PeriodOfValidity = dzkjModel.PeriodOfValidity.ToString("yyyy-MM-dd"),
- StartSimulatorCount = dzkjModel.StartSimulatorCount,
- RegistrationTime = dzkjModel.RegistrationTime.ToString("yyyy-MM-dd HH:mm:ss"),
- LatestLoginTime = dzkjModel.LatestLoginTime.ToString("yyyy-MM-dd HH:mm:ss"),
- NewVerificationCode = LYFZ.WinAPI.SDKSecurity.MD5Encrypt(VerificationCode.Substring(0, 16) + "lyfz_dzkj" + Account)
- };
- retJosnObj = GetReturnJson(0, DZKJ_CustomerInfo, "验证成功");
- Global.UpdateCustomerAccountDataTableSmallEifVersion(Account, sVersion);
- }
- else
- {
- retJosnObj = GetReturnJson(-6, "", "验证失败,验证码不正确");
- }
- }
- else
- {
- if (dzkjModel.Password.Trim() == Password.Trim() && !string.IsNullOrEmpty(Password.Trim()))
- {
- if (type == 0 && dzkjModel.HardwareCode.ToLower().Trim() != HardwareCode.ToLower().Trim())
- {
- retJosnObj = GetReturnJson(-2, "", "申请码不正确");
- }
- else
- {
- ///开始登录
- if (type == 0)
- {
- dzkjModel.LatestLoginTime = DateTime.Now;
- Global.UpdateCustomerAccountDataTableLatestLoginTime(Account, ip, dzkjModel.LatestLoginTime,sVersion);
- var DZKJ_CustomerInfo = new
- {
- Account = Account,
- PeriodOfValidity = dzkjModel.PeriodOfValidity.ToString("yyyy-MM-dd"),
- StartSimulatorCount = dzkjModel.StartSimulatorCount,
- RegistrationTime = dzkjModel.RegistrationTime.ToString("yyyy-MM-dd HH:mm:ss"),
- LatestLoginTime = dzkjModel.LatestLoginTime.ToString("yyyy-MM-dd HH:mm:ss"),
- VerificationCode = LYFZ.WinAPI.SDKSecurity.MD5Encrypt(Password + dzkjModel.LatestLoginTime.ToString("yyyy-MM-dd HH:mm:ss"))
- };
- retJosnObj = GetReturnJson(0, DZKJ_CustomerInfo, "登录成功");
- }
- else if (type == 2)
- {
- dzkjModel.LatestLoginTime = DateTime.Now;
- Global.UpdateCustomerAccountDataTableLatestLoginTime(Account, ip, dzkjModel.LatestLoginTime, sVersion);
- retJosnObj = GetReturnJson(0, "", "退出登录成功");
- }
-
- }
- }
- else
- {
- retJosnObj = GetReturnJson(-3, "", "验证失败,密码不正确");
- }
- }
- }
- else
- {
- retJosnObj = GetReturnJson(-5, "", "验证失败,该帐号已过有效期");
- }
- }
- else {
- retJosnObj = GetReturnJson(-4, "", "验证失败,该帐号已被禁用");
- }
- }
- else
- {
- retJosnObj = GetReturnJson(-3, "", "验证失败,帐号不正确");
- }
- }
-
- }
- string iniConfigInfo = Newtonsoft.Json.JsonConvert.SerializeObject(retJosnObj);
- Response.Write(iniConfigInfo);
- }
- public static object GetReturnJson(int code, object data, string msg)
- {
- var retJosnObj = new
- {
- code=code,
- data = data,
- msg=msg
- };
- return retJosnObj;
- }
- /* public LYFZ.WeixinServiceDate.Model.Model_DZKJ_CustomerAccount GetDzkjModelLogin(string Account, string Password, string HardwareCode)
- {
- LYFZ.WeixinServiceDate.Model.Model_DZKJ_CustomerAccount ret_dzkj_model=null;
- lock (dzkjModelLoginList)
- {
- foreach (LYFZ.WeixinServiceDate.Model.Model_DZKJ_CustomerAccount _dzkj_model in dzkjModelLoginList)
- {
- if (_dzkj_model.Account.Trim().ToLower() == Account.Trim().ToLower())
- {
- ret_dzkj_model = _dzkj_model;
- }
- }
- }
- return ret_dzkj_model;
- }
- public void AddDzkjModelLoginList(LYFZ.WeixinServiceDate.Model.Model_DZKJ_CustomerAccount _dzkj_model)
- {
- lock (dzkjModelLoginList)
- {
- dzkjModelLoginList.Add(_dzkj_model);
- }
- }
- public void RemoveDzkjModelLoginList(LYFZ.WeixinServiceDate.Model.Model_DZKJ_CustomerAccount _dzkj_model)
- {
- lock (dzkjModelLoginList)
- {
- dzkjModelLoginList.Remove(_dzkj_model);
- }
- }*/
- }
- }
|