本文整理汇总了C#中BLL.users.GetRandomName方法的典型用法代码示例。如果您正苦于以下问题:C# BLL.users.GetRandomName方法的具体用法?C# BLL.users.GetRandomName怎么用?C# BLL.users.GetRandomName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BLL.users
的用法示例。
在下文中一共展示了BLL.users.GetRandomName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: user_oauth_register
private void user_oauth_register(HttpContext context)
{
//检查URL参数
if (context.Session["oauth_name"] == null)
{
context.Response.Write("{\"msg\": 0, \"msgbox\": \"错误提示:授权参数不正确!\"}");
return;
}
//获取授权信息
string result = Utils.UrlExecute(siteConfig.webpath + "api/oauth/" + context.Session["oauth_name"].ToString() + "/result_json.aspx");
if (result.Contains("error"))
{
context.Response.Write("{\"msg\": 0, \"msgbox\": \"错误提示:请检查URL是否正确!\"}");
return;
}
//反序列化JSON
Dictionary<string, object> dic = JsonMapper.ToObject<Dictionary<string, object>>(result);
if (dic["ret"].ToString() != "0")
{
context.Response.Write("{\"msg\": 0, \"msgbox\": \"错误代码:" + dic["ret"] + "," + dic["msg"] + "\"}");
return;
}
string password = DTRequest.GetFormString("txtPassword").Trim();
string email = DTRequest.GetFormString("txtEmail").Trim();
string userip = DTRequest.GetIP();
//检查用户名
BLL.users bll = new BLL.users();
Model.users model = new Model.users();
//检查默认组别是否存在
Model.user_groups modelGroup = new BLL.user_groups().GetDefault();
if (modelGroup == null)
{
context.Response.Write("{\"msg\":0, \"msgbox\":\"系统尚未分组,请联系管理员设置会员分组!\"}");
return;
}
//保存注册信息
model.group_id = modelGroup.id;
model.user_name = bll.GetRandomName(10);
model.password = DESEncrypt.Encrypt(password);
model.email = email;
if (!string.IsNullOrEmpty(dic["nick"].ToString()))
{
model.nick_name = dic["nick"].ToString();
}
if (dic["avatar"].ToString().StartsWith("http://"))
{
model.avatar = dic["avatar"].ToString();
}
if (!string.IsNullOrEmpty(dic["sex"].ToString()))
{
model.sex = dic["sex"].ToString();
}
if (!string.IsNullOrEmpty(dic["birthday"].ToString()))
{
model.birthday = DateTime.Parse(dic["birthday"].ToString());
}
model.reg_ip = userip;
model.reg_time = DateTime.Now;
model.is_lock = 0; //设置为对应状态
int newId = bll.Add(model);
if (newId < 1)
{
context.Response.Write("{\"msg\":0, \"msgbox\":\"系统故障,注册失败,请联系网站管理员!\"}");
return;
}
model = bll.GetModel(newId);
//赠送积分金额
if (modelGroup.point > 0)
{
new BLL.point_log().Add(model.id, model.user_name, modelGroup.point, "注册赠送积分");
}
if (modelGroup.amount > 0)
{
new BLL.amount_log().Add(model.id, model.user_name, DTEnums.AmountTypeEnum.SysGive.ToString(), modelGroup.amount, "注册赠送金额", 1);
}
//判断是否发送站内短消息
if (userConfig.regmsgstatus == 1)
{
new BLL.user_message().Add(1, "", model.user_name, "欢迎您成为本站会员", userConfig.regmsgtxt);
}
//绑定到对应的授权类型
Model.user_oauth oauthModel = new Model.user_oauth();
oauthModel.oauth_name = dic["oauth_name"].ToString();
oauthModel.user_id = model.id;
oauthModel.user_name = model.user_name;
oauthModel.oauth_access_token = dic["oauth_access_token"].ToString();
oauthModel.oauth_openid = dic["oauth_openid"].ToString();
new BLL.user_oauth().Add(oauthModel);
context.Session[DTKeys.SESSION_USER_INFO] = model;
context.Session.Timeout = 45;
//记住登录状态,防止Session提前过期
Utils.WriteCookie(DTKeys.COOKIE_USER_NAME_REMEMBER, "DTcms", model.user_name);
Utils.WriteCookie(DTKeys.COOKIE_USER_PWD_REMEMBER, "DTcms", model.password);
//写入登录日志
new BLL.user_login_log().Add(model.id, model.user_name, "会员登录", DTRequest.GetIP());
//返回URL
context.Response.Write("{\"msg\":1, \"msgbox\":\"会员登录成功!\"}");
return;
//.........这里部分代码省略.........
示例2: user_oauth_register
private void user_oauth_register(HttpContext context)
{
//检查URL参数
if (context.Session["oauth_name"] == null)
{
context.Response.Write("{\"status\": 0, \"msg\": \"错误提示:授权参数不正确!\"}");
return;
}
//获取授权信息
string result = Utils.UrlExecute(siteConfig.webpath + "api/oauth/" + context.Session["oauth_name"].ToString() + "/result_json.aspx");
if (result.Contains("error"))
{
context.Response.Write("{\"status\": 0, \"msg\": \"错误提示:请检查URL是否正确!\"}");
return;
}
string password = DTRequest.GetFormString("txtPassword").Trim();
string email = Utils.ToHtml(DTRequest.GetFormString("txtEmail").Trim());
string mobile = Utils.ToHtml(DTRequest.GetFormString("txtMobile").Trim());
string userip = DTRequest.GetIP();
//反序列化JSON
Dictionary<string, object> dic = JsonHelper.DataRowFromJSON(result);
if (dic["ret"].ToString() != "0")
{
context.Response.Write("{\"status\": 0, \"msg\": \"错误代码:" + dic["ret"] + "," + dic["msg"] + "\"}");
return;
}
BLL.users bll = new BLL.users();
Model.users model = new Model.users();
//如果开启手机登录要验证手机
if (userConfig.mobilelogin == 1 && !string.IsNullOrEmpty(mobile))
{
if (bll.ExistsMobile(mobile))
{
context.Response.Write("{\"status\":0, \"msg\":\"对不起,该手机号码已被使用!\"}");
return;
}
}
//如果开启邮箱登录要验证邮箱
if (userConfig.emaillogin == 1 && !string.IsNullOrEmpty(email))
{
if (bll.ExistsEmail(email))
{
context.Response.Write("{\"status\":0, \"msg\":\"对不起,该电子邮箱已被使用!\"}");
return;
}
}
//检查默认组别是否存在
Model.user_groups modelGroup = new BLL.user_groups().GetDefault();
if (modelGroup == null)
{
context.Response.Write("{\"status\":0, \"msg\":\"用户尚未分组,请联系管理员!\"}");
return;
}
//保存注册信息
model.group_id = modelGroup.id;
model.user_name = bll.GetRandomName(10); //随机用户名
model.salt = Utils.GetCheckCode(6); //获得6位的salt加密字符串
model.password = DESEncrypt.Encrypt(password, model.salt);
model.email = email;
model.mobile = mobile;
if (!string.IsNullOrEmpty(dic["nick"].ToString()))
{
model.nick_name = dic["nick"].ToString();
}
if (dic["avatar"].ToString().StartsWith("http://"))
{
model.avatar = dic["avatar"].ToString();
}
if (!string.IsNullOrEmpty(dic["sex"].ToString()))
{
model.sex = dic["sex"].ToString();
}
if (!string.IsNullOrEmpty(dic["birthday"].ToString()))
{
model.birthday = Utils.StrToDateTime(dic["birthday"].ToString());
}
model.reg_ip = userip;
model.reg_time = DateTime.Now;
model.status = 0; //设置为正常状态
model.id = bll.Add(model); //保存数据
if (model.id < 1)
{
context.Response.Write("{\"status\":0, \"msg\":\"注册失败,请联系网站管理员!\"}");
return;
}
//赠送积分金额
if (modelGroup.point > 0)
{
new BLL.user_point_log().Add(model.id, model.user_name, modelGroup.point, "注册赠送积分", false);
}
if (modelGroup.amount > 0)
{
new BLL.user_amount_log().Add(model.id, model.user_name, modelGroup.amount, "注册赠送金额");
}
//判断是否发送欢迎消息
if (userConfig.regmsgstatus == 1) //站内短消息
{
new BLL.user_message().Add(1, "", model.user_name, "欢迎您成为本站会员", userConfig.regmsgtxt);
}
else if (userConfig.regmsgstatus == 2) //发送邮件
//.........这里部分代码省略.........