public string GetToken(string userName, string password) { try { List <MyParameter> sqlParameters = new List <MyParameter>(); MyParameter userPara = new MyParameter("@User_Name", userName, (int)DbType.String, null); sqlParameters.Add(userPara); MyParameter userPass = new MyParameter("@User_Password", password, (int)DbType.String, null); sqlParameters.Add(userPass); string ReadSql = @"SELECT * FROM Sys_User Where User_Name = @User_Name AND User_Password = @User_Password"; DataTable rdt = db.ExecuteDataTable(ReadSql, PreparParameters(sqlParameters)); sys_User = EntityHelper.GetEntity <Sys_User>(rdt); if (sys_User != null) { string token = Guid.NewGuid().ToString(); sys_User.User_Password = token; //System.Web.HttpContext.Current.Session["SysUser"] = sys_User; return(sys_User.ToJson()); } throw new Exception("账号或密码不正确!"); } catch (FaultException ex) { throw ex; } }