本文整理汇总了C#中UserRepository.GetUserInfoByAccount方法的典型用法代码示例。如果您正苦于以下问题:C# UserRepository.GetUserInfoByAccount方法的具体用法?C# UserRepository.GetUserInfoByAccount怎么用?C# UserRepository.GetUserInfoByAccount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRepository
的用法示例。
在下文中一共展示了UserRepository.GetUserInfoByAccount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostValidationCode
public async Task<HttpResponseMessage> PostValidationCode([FromBody]RegisterParameter registerParam)
{
string sNewAccount = registerParam.account;
string validationCode = (new Random()).Next(1000, 9999).ToString();
string openid = registerParam.openID;
//对应openid从redis取出验证码 若没有 生成验证码 存入redis **20分钟有效
var userinfoRedis = await UserInfoControllerHelper.GetUserInfoRedisByOpenid(openid);
//注册测试用的白名单
if(string.IsNullOrEmpty(userinfoRedis.PreRegisterValidationCode) || await CommonLib.Weixin.User.WXAuthHelper.IsTester(openid))
{
await UserInfoControllerHelper.SaveUserPreRegisterToRedis(openid, preRegisterValidationCode: validationCode);
}
else
{
validationCode = userinfoRedis.PreRegisterValidationCode;
}
if(string.IsNullOrEmpty(sNewAccount) || string.IsNullOrEmpty(openid))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
if(!sNewAccount.Contains("@"))
sNewAccount += "@phone.51science.cn";
using(UserRepository userRepository = new UserRepository())
{
userinfo = await userRepository.GetUserInfoByAccount(sNewAccount);
//注册测试用的白名单
if(userinfo != null && !await CommonLib.Weixin.User.WXAuthHelper.IsTester(openid))
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.AccountExist);
else
{
WebApiHelper.SendValidStringSMS(validationCode, sNewAccount.Substring(0, 11));
//向redis里存入手机号 防止故意验证失败后又改其他手机号注册 向redis里存入验证次数
await UserInfoControllerHelper.SaveUserPreRegisterToRedis(openid, preRegisterAccount: sNewAccount, preRegisterTryTimes: "10");
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Success);
}
}
}
示例2: PostUserLoginAccountPassword
public async Task<HttpResponseMessage> PostUserLoginAccountPassword([FromBody]LoginParameter userlogin)
{
string account = userlogin.account;
string password = userlogin.password;
string openid = userlogin.openID;
if (string.IsNullOrEmpty(account) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(openid))
return WebApiHelper.HttpRMtoJson(userlogin.jsonpCallback, null, HttpStatusCode.OK, customStatus.InvalidArguments);
//[email protected]
if (!account.Contains("@"))
account += "@phone.51science.cn";
password = Encryption.EncryptMD5(userlogin.password);
using (UserRepository userRepository = new UserRepository())
{
userinfo = await userRepository.GetUserInfoByAccountPassword(account, password);
if (userinfo != null)
{
if (userinfo.Status == 1)
return WebApiHelper.HttpRMtoJson(userlogin.jsonpCallback, userinfo, HttpStatusCode.OK, customStatus.Forbidden);
else
{
if (userinfo.IsLogin == 0)
{
userinfo.IsLogin = 1;
userinfo.LastLogin = DateTime.MinValue;
}
var userinfoRedis = await UserInfoControllerHelper.GetUserInfoRedisByOpenid(openid);
if (await UserInfoControllerHelper.CheckUserInfoPhoto(userinfo, userinfoRedis))
{
//photo已更新为微信头像
}
int clIsBusiness = userinfo.IsBusiness ?? 0;
//性别取自微信
int clGender = string.IsNullOrEmpty(userinfoRedis.Sex) ? 0 : int.Parse(userinfoRedis.Sex);
long clResearchFieldID = userinfo.ResearchFieldId ?? 0;
if (await ComplexLocationManager.UpdateComplexLocationAsync(openid, clIsBusiness, clGender, clResearchFieldID))
{
//位置索引添加供筛选字段
try
{
BKLogger.LogInfoAsync(typeof(LoginController), "记录位置信息:"
+ userinfo.Name
+ userinfo.uuid.ToString()
+ userinfo.IsBusiness
+ userinfo.Gender
+ userinfo.ResearchFieldId + " | "
+ clIsBusiness + clGender + clResearchFieldID);
}
catch (Exception ex)
{
}
}
if (await userRepository.SaveUserOpenid(userinfo.uuid, openid, userinfoRedis.Unionid))
{
userinfo.Gender = userinfoRedis.Sex;
return WebApiHelper.HttpRMtoJson(userlogin.jsonpCallback, userinfo, HttpStatusCode.OK, customStatus.Success);
}
else
return WebApiHelper.HttpRMtoJson(userlogin.jsonpCallback, userinfo, HttpStatusCode.OK, customStatus.Fail);
}
}
else
{
userinfo = await userRepository.GetUserInfoByAccount(account);
if (userinfo != null)
return WebApiHelper.HttpRMtoJson(userlogin.jsonpCallback, null, HttpStatusCode.OK, customStatus.WrongPassowrd);
else
return WebApiHelper.HttpRMtoJson(userlogin.jsonpCallback, null, HttpStatusCode.OK, customStatus.NotFound);
}
}
}
示例3: PostUserLoginResetPassword
public async Task<HttpResponseMessage> PostUserLoginResetPassword([FromBody]RegisterParameter registerParam)
{
string sNewAccount = registerParam.account;
string validationCode = registerParam.validationCode;
string password = Encryption.EncryptMD5(registerParam.password);
string openid = registerParam.openID;
if (string.IsNullOrEmpty(sNewAccount) || string.IsNullOrEmpty(openid) || string.IsNullOrEmpty(validationCode) || password == Encryption.EncryptMD5(""))
{
return WebApiHelper.HttpRMtoJson(registerParam.jsonpCallback, null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
if (!sNewAccount.Contains("@"))
sNewAccount += "@phone.51science.cn";
using (UserRepository userRepository = new UserRepository())
{
userinfo = await userRepository.GetUserInfoByAccount(sNewAccount);
}
if (userinfo == null)
return WebApiHelper.HttpRMtoJson(registerParam.jsonpCallback, null, HttpStatusCode.OK, customStatus.NotFound);
else
{
var preRegisterRedis = await UserInfoControllerHelper.GetUserInfoRedisByOpenid(openid);
string preRegisterAccount = preRegisterRedis.PreRegisterAccount;
string preRegisterValidationCode = preRegisterRedis.PreRegisterValidationCode;
int preRegisterTryTimes = 0;
int.TryParse(preRegisterRedis.PreRegisterTryTimes, out preRegisterTryTimes);
if (string.IsNullOrEmpty(preRegisterAccount) || sNewAccount != preRegisterAccount)
{
await UserInfoControllerHelper.SaveUserPreRegisterToRedis(openid, preRegisterValidationCode: "");
preRegisterValidationCode = "";
}
if (!string.IsNullOrEmpty(preRegisterValidationCode))
{
if (preRegisterTryTimes > 0)
{
await UserInfoControllerHelper.SaveUserPreRegisterToRedis(openid, preRegisterTryTimes: (preRegisterTryTimes - 1).ToString());
}
else
{
await UserInfoControllerHelper.SaveUserPreRegisterToRedis(openid, "", "", "");
return WebApiHelper.HttpRMtoJson(registerParam.jsonpCallback, null, HttpStatusCode.OK, customStatus.Forbidden);
}
if (validationCode != preRegisterValidationCode)
{
return WebApiHelper.HttpRMtoJson(registerParam.jsonpCallback, null, HttpStatusCode.OK, customStatus.ErrorValidationCode);
}
}
else
{
return WebApiHelper.HttpRMtoJson(registerParam.jsonpCallback, null, HttpStatusCode.OK, customStatus.NoValidationCode);
}
bool result = false;
using (UserRepository userRepository = new UserRepository())
{
result = await userRepository.UpdateUserinfoPassword(sNewAccount, password);
}
if (result)
return WebApiHelper.HttpRMtoJson(registerParam.jsonpCallback, null, HttpStatusCode.OK, customStatus.Success);
else
return WebApiHelper.HttpRMtoJson(registerParam.jsonpCallback, null, HttpStatusCode.OK, customStatus.Fail);
}
}
示例4: PostRegister
public async Task<HttpResponseMessage> PostRegister([FromBody]RegisterParameter registerParam)
{
string sNewAccount = registerParam.account;
string validationCode = registerParam.validationCode;
string name = registerParam.name;
string password = Encryption.EncryptMD5(registerParam.password);
string openid = registerParam.openID;
if(string.IsNullOrEmpty(sNewAccount) || string.IsNullOrEmpty(openid) || string.IsNullOrEmpty(validationCode) || string.IsNullOrEmpty(name) || password == Encryption.EncryptMD5(""))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
if(!sNewAccount.Contains("@"))
sNewAccount += "@phone.51science.cn";
using(UserRepository userRepository = new UserRepository())
{
userinfo = await userRepository.GetUserInfoByAccount(sNewAccount);
//注册测试用的白名单
if(userinfo != null && !await CommonLib.Weixin.User.WXAuthHelper.IsTester(openid))
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.AccountExist);
else
{
// 从redis里取出手机号、验证码 防止故意验证失败后又改其他手机号注册 从redis里取出验证次数
var preRegisterRedis = await UserInfoControllerHelper.GetUserInfoRedisByOpenid(openid);
string preRegisterAccount = preRegisterRedis.PreRegisterAccount;
string preRegisterValidationCode = preRegisterRedis.PreRegisterValidationCode;
int preRegisterTryTimes = 0;
int.TryParse(preRegisterRedis.PreRegisterTryTimes, out preRegisterTryTimes);
if(string.IsNullOrEmpty(preRegisterAccount) || sNewAccount != preRegisterAccount)
{
await UserInfoControllerHelper.SaveUserPreRegisterToRedis(openid, preRegisterValidationCode: "");
preRegisterValidationCode = "";
}
if(!string.IsNullOrEmpty(preRegisterValidationCode))
{
if(preRegisterTryTimes > 0)
{
await UserInfoControllerHelper.SaveUserPreRegisterToRedis(openid, preRegisterTryTimes: (preRegisterTryTimes - 1).ToString());
}
else
{
await UserInfoControllerHelper.SaveUserPreRegisterToRedis(openid, "", "", "");
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Forbidden);
}
if(validationCode != preRegisterValidationCode)
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Fail);
}
}
else
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.NotFound);
}
await userRepository.SavePreRegister(sNewAccount, name, password,2, openid);
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Success);
}
}
}
示例5: PostComplement
public async Task<HttpResponseMessage> PostComplement([FromBody]ComplementParameter registerParam, [FromUri]string type)
{
string openid = registerParam.openID;
string university = registerParam.university;
string faculty = registerParam.faculty;
int researchFieldId = registerParam.researchFieldId;
short degree = registerParam.degree;
short enrollment = registerParam.enrollment;
string gender = registerParam.Gender;
string name = registerParam.name;
string position = registerParam.position;
short isBusiness = registerParam.isBusiness;
if (string.IsNullOrEmpty(openid) || string.IsNullOrEmpty(university) || string.IsNullOrEmpty(faculty) || researchFieldId == 0 || string.IsNullOrEmpty(gender) || string.IsNullOrEmpty(name))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
if (string.IsNullOrEmpty(position) && isBusiness == 0)
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
if (isBusiness == 2 && enrollment == 0)
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
var preRegisterRedis = await UserInfoControllerHelper.GetUserInfoRedisByOpenid(openid);
string preRegisterAccount = preRegisterRedis.PreRegisterAccount;
pre_register preRegister = null;
if (type != "update")
{
using (UserRepository userRepository = new UserRepository())
{
userinfo = await userRepository.GetUserInfoByAccount(preRegisterAccount);
preRegister = await userRepository.GetPreRegisterByOpenid(openid);
}
if (userinfo != null)
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.AccountExist);
if (preRegister == null)
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.NotFound);
}
//更新数据库的userinfo
bool result = await UserInfoControllerHelper.SaveUserInfo(registerParam, preRegister);
if (result)
{
//更新redis的性别
UserInfoRedis redisUser = new UserInfoRedis();
redisUser.Openid = openid;
redisUser.Sex = gender;
await RedisManager.SaveObjectAsync(redisUser);
using (UserRepository userRepository = new UserRepository())
{
userinfo = await userRepository.GetUserInfoByOpenid(openid);
}
if (await ComplexLocationManager.UpdateComplexLocationAsync(openid, userinfo.IsBusiness ?? 0, int.Parse(userinfo.Gender), userinfo.ResearchFieldId ?? 0))
{
//位置索引添加供筛选字段
}
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Success);
}
else
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Fail);
}
}