/// <summary> /// 用户登录验证 /// </summary> /// <param name="context"></param> /// <returns></returns> private string GetUserLogin(HttpContext context) { string wrong = string.Empty; string code = "0"; try { string loginName = context.Request["ln"] as string; string password = context.Request["ps"] as string; string _Ver = string.Empty; try { _Ver = context.Request["Ver"] as string; } catch { } string _Server = string.Empty; try { _Server = context.Request["Server"] as string; } catch { } string _EquipmentNO = string.Empty; try { _EquipmentNO = context.Request["EqNo"] as string; } catch { } string _DeviceName = string.Empty; try { _DeviceName = context.Request["EqNm"] as string; } catch { } MD5 md = new MD5CryptoServiceProvider(); byte[] bytes = Encoding.Unicode.GetBytes(password); string md5Pass = BitConverter.ToString(md.ComputeHash(bytes)).Replace("-", ""); LSFW_EMPLOYEE model = dal.GetUserLogin(loginName, md5Pass); if (string.IsNullOrEmpty(model.LOGINNAME)) { wrong = "用户登录失败!"; code = "1"; } else { bytes = Encoding.Unicode.GetBytes(loginName); string _token = new ComUtilDal().GenerateToKen(); model.Token = _token; context.Session["UserToken"] = _token; new T_MOBILE_LOGONLOGDal().Insert(model.LOGINNAME, model.NAME, model.DEPNAM, _Ver, _Server, _EquipmentNO, _DeviceName.ToUpper()); } return(JsonHelper <Messaging <LSFW_EMPLOYEE> > .EntityToJson(new Messaging <LSFW_EMPLOYEE>(code, wrong, model))); } catch (Exception ex) { SystemErrorPlug.ErrorRecord(ex.ToString()); wrong = ex.Message.ToString().Trim().Replace("\r\n", ""); code = "500"; return(JsonHelper <Messaging <string> > .EntityToJson(new Messaging <string>(code, wrong))); } }
private string CheckPassword(HttpContext context) { try { string loginName = context.Request["LOGINNAM"] as string; string password = context.Request["Password"] as string; MD5 md = new MD5CryptoServiceProvider(); byte[] bytes = Encoding.Unicode.GetBytes(password); string md5Pass = BitConverter.ToString(md.ComputeHash(bytes)).Replace("-", ""); LSFW_EMPLOYEE model = dal.GetUserLogin(loginName, md5Pass); if (!string.IsNullOrEmpty(model.LOGINNAME)) { return(JsonHelper <Messaging <string> > .EntityToJson(new Messaging <string>("0", xml.ReadLandXml("0")))); } else { return(JsonHelper <Messaging <string> > .EntityToJson(new Messaging <string>("1", xml.ReadLandXml("1")))); } } catch (Exception ex) { SystemErrorPlug.ErrorRecord(ex.ToString()); return(JsonHelper <Messaging <string> > .EntityToJson(new Messaging <string>("500", ex.Message))); } }
/// <summary> /// 验证用户登录信息获取信息 /// </summary> /// <param name="loginName"></param> /// <param name="password"></param> /// <returns></returns> public LSFW_EMPLOYEE GetUserLogin(string loginName, string password) { try { string strSql = string.Format(@" SELECT PASSWORD,ID,FAC,DEPNAM,NAME,LOGINNAME,[PASSWORD],POSNAM,PHONE,MAIL,LEAYN,ISLOGIN,HPIC,LCCID,ENAM,ETIM FROM LSFW_EMPLOYEE (NOLOCK) WHERE LOGINNAME = '{0}' AND PASSWORD = '******' AND LEAYN = 'N'", loginName, password); LSFW_EMPLOYEE model = new LSFW_EMPLOYEE(); using (SqlDataReader read = db.ExecuteReader(strSql)) { if (read.Read()) { model.ID = read["ID"].ToString(); model.FAC = read["FAC"].ToString(); model.ENAM = read["ENAM"].ToString(); model.DEPNAM = read["DEPNAM"].ToString(); model.NAME = read["NAME"].ToString(); model.LOGINNAME = read["LOGINNAME"].ToString(); model.POSNAM = read["POSNAM"].ToString(); model.PHONE = read["PHONE"].ToString(); model.MAIL = read["MAIL"].ToString(); model.LEAYN = read["LEAYN"].ToString(); model.ISLOGIN = read["ISLOGIN"].ToString(); model.PASSWORD = read["PASSWORD"].ToString(); } read.Dispose(); } return(model); } catch { throw; } }