本文整理匯總了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("驗證碼已發送");
}