本文整理汇总了C#中System.Random.To方法的典型用法代码示例。如果您正苦于以下问题:C# Random.To方法的具体用法?C# Random.To怎么用?C# Random.To使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Random
的用法示例。
在下文中一共展示了Random.To方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendUnBindingCode
/// <summary>
/// 发送解绑手机验证码
/// <para>@mobile:手机号</para>
/// <para>@rv:验证码</para>
/// </summary>
private ActionResult SendUnBindingCode(NxpDictionary<string, object> nxpDictionary)
{
var mobile = nxpDictionary.GetString("mobile", string.Empty);
var userid = nxpDictionary.GetInt32("userid", 0);
var member = _memberService.GetById(userid);
if (member.Mobile != mobile)
{
return LogError("请输入正确的手机号");
}
if (string.IsNullOrWhiteSpace(member.Mobile))
{
return LogError("手机号已解除绑定");
}
var code = new Random().Next(1000, 9999);
var res = _memberService.SendSmsUnbindingMobileMessage(mobile, code.To<string>());
if (!res)
{
return LogError("发送失败或使用次数已满");
}
//验证码写入Session
Session["UNBINDING_CODE_" + WebHelper.Md5(mobile)] = code;
Session["UNBINDING_CODE_COUNT_" + WebHelper.Md5(mobile)] = 0;
return ShowResult("验证码已发送");
}
示例2: SendFindPasswordCode
/// <summary>
/// 发送找回密码验证码
/// <para>@username:用户名</para>
/// <para>@rv:验证码</para>
/// </summary>
private ActionResult SendFindPasswordCode(NxpDictionary<string, object> nxpDictionary)
{
var userName = nxpDictionary.GetString("username", string.Empty);
var rv = nxpDictionary.GetString("rv", string.Empty);
if (string.IsNullOrEmpty(rv) || rv != Session["VALIDATE_CODE"].To<string>(string.Empty))
{
return LogError("输入的答案不正确");
}
var member = _memberService.GetByName(userName);
if (member == null)
{
return LogError("用户名不存在");
}
if (member.IsBindingMobile != 1)
{
return LogError("用户未绑定手机号");
}
if (member.Status != 0)
{
return LogError("用户账号被冻结");
}
var code = new Random().Next(1000, 9999);
var res = _memberService.SendSmsRegisterMessage(member.Mobile, code.To<string>());
if (!res)
{
return LogError("发送失败或使用次数已满");
}
//验证码写入Session
Session["FINDPASSWORD_CODE_" + WebHelper.Md5(userName)] = code;
Session["FINDPASSWORD_CODE_COUNT_" + WebHelper.Md5(userName)] = 0;
return ShowResult("验证码已发送");
}
示例3: SendRegisterCode
/// <summary>
/// 发送注册验证码
/// <para>@mobile:手机</para>
/// <para>@rv:验证码</para>
/// </summary>
private ActionResult SendRegisterCode(NxpDictionary<string, object> nxpDictionary)
{
var mobile = nxpDictionary.GetString("mobile", string.Empty);;
var rv = nxpDictionary.GetString("rv", string.Empty);
if (string.IsNullOrEmpty(rv) || rv != Session["VALIDATE_CODE"].To<string>(string.Empty))
{
return LogError("输入的答案不正确");
}
if (!Regex.IsMatch(mobile, "\\d{11}"))
{
return LogError("非法手机号");
}
var member = _memberService.GetByName(mobile);
if (member != null && member.Id > 0)
{
return LogError("手机号已存在");
}
var tempMember = _memberService.GetByMobile(mobile);
if (tempMember != null && tempMember.Id > 0)
{
return LogError("该手机号已被其他账号绑定");
}
var code = new Random().Next(1000, 9999);
var res = _memberService.SendSmsRegisterMessage(mobile, code.To<string>());
if (!res)
{
return LogError("发送失败或使用次数已满");
}
//验证码写入Session
Session["REGISTER_CODE_" + WebHelper.Md5(mobile)] = code;
Session["REGISTER_CODE_COUNT_" + WebHelper.Md5(mobile)] = 0;
return ShowResult("成功发送了验证码");
}
示例4: SendBindingCode
/// <summary>
/// 发送绑定手机验证码
/// <para>@mobile:手机号</para>
/// <para>@rv:验证码</para>
/// </summary>
private ActionResult SendBindingCode(NxpDictionary<string, object> nxpDictionary)
{
var mobile = nxpDictionary.GetString("mobile", string.Empty);
var rv = nxpDictionary.GetString("rv", string.Empty);
if (string.IsNullOrEmpty(rv) || rv != Session["VALIDATE_CODE"].To<string>(string.Empty))
{
return LogError("输入的答案不正确");
}
if (!Regex.IsMatch(mobile, "\\d{11}"))
{
return LogError("非法手机号");
}
if (_memberService.GetByMobile(mobile) != null)
{
return LogError("手机号已被绑定");
}
var code = new Random().Next(1000, 9999);
var res = _memberService.SendSmsBindingMobileMessage(mobile, code.To<string>());
if (!res)
{
return LogError("发送失败或使用次数已满");
}
//验证码写入Session
Session["BINDING_CODE_" + WebHelper.Md5(mobile)] = code;
Session["BINDING_CODE_COUNT_" + WebHelper.Md5(mobile)] = 0;
return ShowResult("验证码已发送");
}