//private void OnEnable() //{ // StartAction(); //} public void Setup(UserRankInfo[] rankInfos, UserRankInfo userRank) { Clear(); // BoardNum = rankInfos.Length; bool isCheckSelect = true; RankBoards = new RankBoard[rankInfos.Length]; for (int i = 0; i < RankBoards.Length; i++) { RankBoard board = Instantiate(TemplateObject, transform); RankBoards[i] = board; board.SetDisplayParam(rankInfos[i]); if (isCheckSelect && userRank.IsSame(rankInfos[i])) { board.SetSelectMode(true); isCheckSelect = false; } } SelfRankBord.SetDisplayParam(userRank); SelfRankBord.SetVisibleRank(false); SelfRankBord.gameObject.SetActive(true); State = StateStatus.Ready; }
public ActionResult Add(UserRankModel model) { if (AdminUserRanks.GetUserRidByTitle(model.UserRankTitle) > 0) { ModelState.AddModelError("UserRankTitle", "名称已经存在"); } if (ModelState.IsValid) { UserRankInfo userRankInfo = new UserRankInfo() { System = 0, Title = model.UserRankTitle, Avatar = model.Avatar ?? "", CreditsLower = model.CreditsLower, CreditsUpper = model.CreditsUpper, LimitDays = 0 }; AdminUserRanks.CreateUserRank(userRankInfo); AddMallAdminLog("添加会员等级", "添加会员等级,会员等级为:" + model.UserRankTitle); return(PromptView("会员等级添加成功")); } Load(); return(View(model)); }
public bool StoreUserScore(UserScoreParam param, ref UserRankInfo rankInfo) { using (var connection = new SQLiteConnection(ConnectionString))// 「DataSource=:memory:」にするとオンメモリのDBとして動作 { // データベースに接続 connection.Open(); using (var context = new DataContext(connection)) { User user = User.Find(context, param.Sereal); if (user == null) { connection.Close(); return(false); } UserScore score = new UserScore(user); score.Point = param.Point; bool ret = score.Commit(connection); if (rankInfo != null) { rankInfo.UserId = score.UserId; rankInfo.Name = user.Name; rankInfo.Point = score.Point; rankInfo.Rank = score.Rank(context); } connection.Close(); return(ret); } } }
public UserScoreRankData(UserRankInfo info) { Rank = info.Rank; Name = info.Name; UserId = info.UserId; Point = info.Point; }
/// <summary> /// 获得用户等级列表 /// </summary> /// <returns></returns> public static List <UserRankInfo> GetUserRankList() { List <UserRankInfo> userRankList = new List <UserRankInfo>(); IDataReader reader = BrnShop.Core.BSPData.RDBS.GetUserRankList(); while (reader.Read()) { UserRankInfo userRankInfo = new UserRankInfo(); userRankInfo.UserRid = TypeHelper.ObjectToInt(reader["userrid"]); userRankInfo.System = TypeHelper.ObjectToInt(reader["system"]); userRankInfo.Title = reader["title"].ToString(); userRankInfo.Avatar = reader["avatar"].ToString(); userRankInfo.CreditsLower = TypeHelper.ObjectToInt(reader["creditslower"]); userRankInfo.CreditsUpper = TypeHelper.ObjectToInt(reader["creditsupper"]); userRankInfo.LimitDays = TypeHelper.ObjectToInt(reader["limitdays"]); userRankList.Add(userRankInfo); } reader.Close(); return(userRankList); }
/// <summary> /// 删除用户等级 /// </summary> /// <param name="userRid">用户等级id</param> /// <returns>-2代表系统等级不能删除,-1代表此等级下还有用户未删除,0代表此用户等级不存在,1代表删除成功</returns> public static int DeleteUserRankById(int userRid) { UserRankInfo userRankInfo = GetUserRankById(userRid); if (userRankInfo != null) { if (userRankInfo.System == 1) { return(-2); } if (AdminUsers.GetUserCountByUserRid(userRid) > 0) { return(-1); } NStore.Data.UserRanks.DeleteUserRankById(userRid); BMACache.Remove(CacheKeys.MALL_USERRANK_LIST); return(1); } return(0); }
public UserRankInfo[] GetRanking(RankingRequest request) { using (var connection = new SQLiteConnection(ConnectionString))// 「DataSource=:memory:」にするとオンメモリのDBとして動作 { // データベースに接続 connection.Open(); using (var context = new DataContext(connection)) { User target = (request.Sereal != 0)? User.Find(context, request.Sereal): null; var data = UserScore.Rank(context, request.Skip, request.Take, target); UserRankInfo[] ret = new UserRankInfo[data.Length]; // foreach (var score in data) for (int i = 0; i < data.Length; i++) { var score = data[i]; UserRankInfo rankInfo = new UserRankInfo(); rankInfo.Point = score.Point; rankInfo.Rank = request.Skip + i; User user = User.FindByUserId(context, score.UserId); rankInfo.UserId = score.UserId; rankInfo.Name = user.Name; ret[i] = rankInfo; } connection.Close(); return(ret); } } }
public ActionResult Edit(int userRid = -1) { UserRankInfo userRankInfo = AdminUserRanks.GetUserRankById(userRid); if (userRankInfo == null) { return(PromptView("会员等级不存在")); } if (userRankInfo.System == 1) { return(PromptView("系统等级不能编辑")); } UserRankModel model = new UserRankModel(); model.UserRankTitle = userRankInfo.Title; model.Avatar = userRankInfo.Avatar; model.CreditsLower = userRankInfo.CreditsLower; model.CreditsUpper = userRankInfo.CreditsUpper; Load(); return(View(model)); }
public ActionResult Edit(UserRankModel model, int userRid = -1) { UserRankInfo userRankInfo = AdminUserRanks.GetUserRankById(userRid); if (userRankInfo == null) { return(PromptView("会员等级不存在")); } if (userRankInfo.System == 1) { return(PromptView("系统等级不能编辑")); } int userRid2 = AdminUserRanks.GetUserRidByTitle(model.UserRankTitle); if (userRid2 > 0 && userRid2 != userRid) { ModelState.AddModelError("UserRankTitle", "名称已经存在"); } if (ModelState.IsValid) { userRankInfo.Title = model.UserRankTitle; userRankInfo.Avatar = model.Avatar ?? ""; userRankInfo.CreditsLower = model.CreditsLower; userRankInfo.CreditsUpper = model.CreditsUpper; AdminUserRanks.UpdateUserRank(userRankInfo); AddMallAdminLog("修改会员等级", "修改会员等级,会员等级ID为:" + userRid); return(PromptView("会员等级修改成功")); } Load(); return(View(model)); }
public void SetDisplayParam(UserRankInfo info) { FindComponents(); Debug.Assert(TextComponents != null); foreach (var obj in TextComponents) { switch (obj.name) { case "Rank": obj.text = (info.Rank + 1).ToString(); TextRank = obj; break; case "Point": obj.text = info.Point.ToString(); break; case "Name": obj.text = info.Name; break; } } State = StateStatus.Ready; }
public bool RecieveMessage(MessageManager manager, MessageHeader header, byte[] data) { Debug.Assert(data != null); string text = Encoding.UTF8.GetString(data); Console.WriteLine("Recieve " + header.Name); MessageCommand param; try { param = (MessageCommand)Enum.Parse(typeof(MessageCommand), header.Name); } catch (Exception e) { Console.WriteLine(header.Name + " is unmanaged " + e); return(false); } switch (param) { case MessageCommand.Login: UserInfo userInfo = JsonConvert.DeserializeObject <UserInfo>(text); int userId = DBManager.UpdateUserData(userInfo); if (userId > 0) { UserInfoResponse userInfoRespon = new UserInfoResponse(userInfo, userId); // アップデートした情報を返す manager.SendSystemMessage(MessageCommand.ResUserInfo, userInfoRespon); lock (Server.ClientDataCollection) { foreach (var client in Server.ClientDataCollection) { if (client.Manager == manager) { client.Serieal = userInfo.Sereal; client.Name = userInfo.Name; client.UserId = userId; break; } } } } else { Console.WriteLine("Login Failed"); return(false); } break; // case "UploadScore": case MessageCommand.UploadUserScore: UserScoreParam scoreParam = JsonConvert.DeserializeObject <UserScoreParam>(text); UserRankInfo rankInfo = new UserRankInfo(); if (DBManager.StoreUserScore(scoreParam, ref rankInfo)) { // アップデートした情報を返す manager.SendSystemMessage(MessageCommand.ResUserRank, rankInfo); } else { Console.WriteLine("Login Failed"); return(false); } break; // case "ReqScoreRanking": case MessageCommand.GetScoreRanking: RankingRequest rankingReq = JsonConvert.DeserializeObject <RankingRequest>(text); UserRankInfo[] rankInfos = DBManager.GetRanking(rankingReq); if (rankInfos != null) { // アップデートした情報を返す manager.SendSystemMessage(MessageCommand.ResScoreRanking, rankInfos); Server.UserScoreRankDataCollection.Clear(); foreach (var info in rankInfos) { Server.UserScoreRankDataCollection.Add(new UserScoreRankData(info)); } } else { Console.WriteLine("Login Failed"); return(false); } break; default: Console.WriteLine(header.Name + " is unmanaged"); // break; return(false); } return(true); }
protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); this.ValidateRequest = false; WorkContext.IsHttpAjax = WebHelper.IsAjax(); WorkContext.IP = WebHelper.GetIP(); WorkContext.RegionInfo = Regions.GetRegionByIP(WorkContext.IP); WorkContext.RegionId = WorkContext.RegionInfo.RegionId; WorkContext.Url = WebHelper.GetUrl(); WorkContext.UrlReferrer = WebHelper.GetUrlReferrer(); //获得用户唯一标示符sid WorkContext.Sid = MallUtils.GetSidCookie(); if (WorkContext.Sid.Length == 0) { //生成sid WorkContext.Sid = Sessions.GenerateSid(); //将sid保存到cookie中 MallUtils.SetSidCookie(WorkContext.Sid); } PartUserInfo partUserInfo; //获得用户id int uid = MallUtils.GetUidCookie(); if (uid < 1)//当用户为游客时 { //创建游客 partUserInfo = Users.CreatePartGuest(); } else//当用户为会员时 { //获得保存在cookie中的密码 string encryptPwd = MallUtils.GetCookiePassword(); //防止用户密码被篡改为危险字符 if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd)) { //创建游客 partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } else { partUserInfo = Users.GetPartUserByUidAndPwd(uid, MallUtils.DecryptCookiePassword(encryptPwd)); if (partUserInfo != null) { //发放登陆积分 Credits.SendLoginCredits(ref partUserInfo, DateTime.Now); } else//当会员的账号或密码不正确时,将用户置为游客 { partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } } WorkContext.EncryptPwd = encryptPwd; } //设置用户等级 if (UserRanks.IsBanUserRank(partUserInfo.UserRid) && partUserInfo.LiftBanTime <= DateTime.Now) { UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits); Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid); partUserInfo.UserRid = userRankInfo.UserRid; } //当用户被禁止访问时重置用户为游客 if (partUserInfo.UserRid == 1) { partUserInfo = Users.CreatePartGuest(); WorkContext.EncryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } WorkContext.PartUserInfo = partUserInfo; WorkContext.Uid = partUserInfo.Uid; WorkContext.UserName = partUserInfo.UserName; WorkContext.UserEmail = partUserInfo.Email; WorkContext.UserMobile = partUserInfo.Mobile; WorkContext.Password = partUserInfo.Password; WorkContext.NickName = partUserInfo.NickName; WorkContext.Avatar = partUserInfo.Avatar; WorkContext.PayCreditName = Credits.PayCreditName; WorkContext.PayCreditCount = partUserInfo.PayCredits; WorkContext.RankCreditName = Credits.RankCreditName; WorkContext.RankCreditCount = partUserInfo.RankCredits; WorkContext.UserRid = partUserInfo.UserRid; WorkContext.UserRankInfo = UserRanks.GetUserRankById(partUserInfo.UserRid); WorkContext.UserRTitle = WorkContext.UserRankInfo.Title; //设置用户商城管理员组 WorkContext.MallAGid = partUserInfo.MallAGid; WorkContext.MallAdminGroupInfo = MallAdminGroups.GetMallAdminGroupById(partUserInfo.MallAGid); WorkContext.MallAGTitle = WorkContext.MallAdminGroupInfo.Title; //设置当前控制器类名 WorkContext.Controller = RouteData.Values["controller"].ToString().ToLower(); //设置当前动作方法名 WorkContext.Action = RouteData.Values["action"].ToString().ToLower(); WorkContext.PageKey = string.Format("/{0}/{1}", WorkContext.Controller, WorkContext.Action); WorkContext.ImageCDN = WorkContext.MallConfig.ImageCDN; WorkContext.CSSCDN = WorkContext.MallConfig.CSSCDN; WorkContext.ScriptCDN = WorkContext.MallConfig.ScriptCDN; //在线总人数 WorkContext.OnlineUserCount = OnlineUsers.GetOnlineUserCount(); //在线游客数 WorkContext.OnlineGuestCount = OnlineUsers.GetOnlineGuestCount(); //在线会员数 WorkContext.OnlineMemberCount = WorkContext.OnlineUserCount - WorkContext.OnlineGuestCount; //搜索词 WorkContext.SearchWord = string.Empty; //购物车中商品数量 WorkContext.CartProductCount = Carts.GetCartProductCountCookie(); //设置导航列表 WorkContext.NavList = Navs.GetNavList(); //设置友情链接列表 WorkContext.FriendLinkList = FriendLinks.GetFriendLinkList(); //设置帮助列表 WorkContext.HelpList = Helps.GetHelpList(); }
/// <summary> /// 创建用户等级 /// </summary> public static void CreateUserRank(UserRankInfo userRankInfo) { BrnMall.Data.UserRanks.CreateUserRank(userRankInfo); BMACache.Remove(CacheKeys.MALL_USERRANK_LIST); }
/// <summary> /// 创建用户等级 /// </summary> public static void CreateUserRank(UserRankInfo userRankInfo) { BrnShop.Data.UserRanks.CreateUserRank(userRankInfo); BSPCache.Remove(CacheKeys.SHOP_USERRANK_LIST); }
/// <summary> /// 更新用户解禁时间 /// </summary> /// <param name="uid">用户id</param> /// <param name="userRankInfo">用户等级</param> public static void UpdateUserLiftBanTimeByUid(int uid, UserRankInfo userRankInfo) { UpdateUserLiftBanTimeByUid(uid, DateTime.Now.AddDays(userRankInfo.LimitDays)); }
/// <summary> /// 更新用户等级 /// </summary> public static void UpdateUserRank(UserRankInfo userRankInfo) { NStore.Core.BMAData.RDBS.UpdateUserRank(userRankInfo); }
/// <summary> /// 接口方式访问没有记录cookie,通过用户账号来获取信息 /// </summary> /// <param name="account"></param> /// <returns></returns> private PartUserInfo InitUser(string account) { partUserInfo = Users.GetPartUserByMobile(account); if (partUserInfo.Uid == 0) { //创建游客 partUserInfo = Users.CreatePartGuest(); } //获得用户id int uid = partUserInfo.Uid; //设置用户等级 if (UserRanks.IsBanUserRank(partUserInfo.UserRid) && partUserInfo.LiftBanTime <= DateTime.Now) { UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits); Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid); partUserInfo.UserRid = userRankInfo.UserRid; } //当用户被禁止访问时重置用户为游客 if (partUserInfo.UserRid == 1) { partUserInfo = Users.CreatePartGuest(); WorkContext.EncryptPwd = string.Empty; ShopUtils.SetUidCookie(-1, "web"); ShopUtils.SetCookiePassword("", "web"); } WorkContext.PartUserInfo = partUserInfo; WorkContext.Uid = partUserInfo.Uid; WorkContext.UserName = partUserInfo.UserName; WorkContext.UserEmail = partUserInfo.Email; WorkContext.UserMobile = partUserInfo.Mobile; WorkContext.Password = partUserInfo.Password; WorkContext.NickName = partUserInfo.NickName; WorkContext.Avatar = partUserInfo.Avatar; WorkContext.UserRid = partUserInfo.UserRid; WorkContext.UserRankInfo = UserRanks.GetUserRankById(partUserInfo.UserRid); WorkContext.UserRTitle = WorkContext.UserRankInfo.Title; //设置用户管理员组 WorkContext.AdminGid = partUserInfo.AdminGid; WorkContext.AdminGroupInfo = AdminGroups.GetAdminGroupById(partUserInfo.AdminGid); WorkContext.AdminGTitle = WorkContext.AdminGroupInfo.Title; //设置当前控制器类名 WorkContext.Controller = RouteData.Values["controller"].ToString().ToLower(); //设置当前动作方法名 WorkContext.Action = RouteData.Values["action"].ToString().ToLower(); WorkContext.PageKey = string.Format("/{0}/{1}", WorkContext.Controller, WorkContext.Action); //当前商城主题 WorkContext.Theme = WorkContext.ShopConfig.PCTheme; //设置图片cdn WorkContext.ImageCDN = WorkContext.ShopConfig.ImageCDN; //设置csscdn WorkContext.CSSCDN = WorkContext.ShopConfig.CSSCDN; //设置脚本cdn WorkContext.ScriptCDN = WorkContext.ShopConfig.ScriptCDN; //在线总人数 WorkContext.OnlineUserCount = OnlineUsers.GetOnlineUserCount(); //在线游客数 WorkContext.OnlineGuestCount = OnlineUsers.GetOnlineGuestCount(); //在线会员数 WorkContext.OnlineMemberCount = WorkContext.OnlineUserCount - WorkContext.OnlineGuestCount; //搜索词 WorkContext.SearchWord = string.Empty; //设置导航列表 //WorkContext.NavList = Navs.GetNavList(); //设置友情链接列表 //WorkContext.FriendLinkList = FriendLinks.GetFriendLinkList(); //设置帮助列表 //WorkContext.HelpList = Helps.GetHelpList(); return(partUserInfo); }
/// <summary> /// 创建用户等级 /// </summary> public static void CreateUserRank(UserRankInfo userRankInfo) { OWZX.Core.BSPData.RDBS.CreateUserRank(userRankInfo); }
/// <summary> /// 创建用户等级 /// </summary> public static void CreateUserRank(UserRankInfo userRankInfo) { BrnMall.Core.BMAData.RDBS.CreateUserRank(userRankInfo); }
/// <summary> /// 更新用户等级 /// </summary> public static void UpdateUserRank(UserRankInfo userRankInfo) { OWZX.Data.UserRanks.UpdateUserRank(userRankInfo); BSPCache.Remove(CacheKeys.SHOP_USERRANK_LIST); }
/// <summary> /// 更新用户等级 /// </summary> public static void UpdateUserRank(UserRankInfo userRankInfo) { NStore.Data.UserRanks.UpdateUserRank(userRankInfo); BMACache.Remove(CacheKeys.MALL_USERRANK_LIST); }
/// <summary> /// 更新用户等级 /// </summary> public static void UpdateUserRank(UserRankInfo userRankInfo) { BrnShop.Core.BSPData.RDBS.UpdateUserRank(userRankInfo); }
/// <summary> /// 登录 /// </summary> public ActionResult Login() { string returnUrl = WebHelper.GetQueryString("returnUrl"); if (returnUrl.Length == 0) { returnUrl = Url.Action("index", "home"); } if (WorkContext.MallConfig.LoginType == "") { return(PromptView(returnUrl, "商城目前已经关闭登陆功能!")); } if (WorkContext.Uid > 0) { return(PromptView(returnUrl, "您已经登录,无须重复登录!")); } if (WorkContext.MallConfig.LoginFailTimes != 0 && LoginFailLogs.GetLoginFailTimesByIp(WorkContext.IP) >= WorkContext.MallConfig.LoginFailTimes) { return(PromptView(returnUrl, "您已经输入错误" + WorkContext.MallConfig.LoginFailTimes + "次密码,请15分钟后再登陆!")); } //get请求 if (WebHelper.IsGet()) { LoginModel model = new LoginModel(); model.ReturnUrl = returnUrl; model.ShadowName = WorkContext.MallConfig.ShadowName; model.IsRemember = WorkContext.MallConfig.IsRemember == 1; model.IsVerifyCode = CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.MallConfig.VerifyPages); model.OAuthPluginList = Plugins.GetOAuthPluginList(); return(View(model)); } //ajax请求 string accountName = WebHelper.GetFormString(WorkContext.MallConfig.ShadowName); string password = WebHelper.GetFormString("password"); string verifyCode = WebHelper.GetFormString("verifyCode"); int isRemember = WebHelper.GetFormInt("isRemember"); StringBuilder errorList = new StringBuilder("["); //验证账户名 if (string.IsNullOrWhiteSpace(accountName)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名不能为空", "}"); } else if (accountName.Length < 4 || accountName.Length > 50) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名必须大于3且不大于50个字符", "}"); } else if ((!SecureHelper.IsSafeSqlString(accountName, false))) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名不存在", "}"); } //验证密码 if (string.IsNullOrWhiteSpace(password)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "密码不能为空", "}"); } else if (password.Length < 4 || password.Length > 32) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "密码必须大于3且不大于32个字符", "}"); } //验证验证码 if (CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.MallConfig.VerifyPages)) { if (string.IsNullOrWhiteSpace(verifyCode)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "verifyCode", "验证码不能为空", "}"); } else if (verifyCode.ToLower() != Sessions.GetValueString(WorkContext.Sid, "verifyCode")) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "verifyCode", "验证码不正确", "}"); } } //当以上验证全部通过时 PartUserInfo partUserInfo = null; if (errorList.Length == 1) { if (BMAConfig.MallConfig.LoginType.Contains("2") && ValidateHelper.IsEmail(accountName))//邮箱登陆 { partUserInfo = Users.GetPartUserByEmail(accountName); if (partUserInfo == null) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "邮箱不存在", "}"); } } else if (BMAConfig.MallConfig.LoginType.Contains("3") && ValidateHelper.IsMobile(accountName))//手机登陆 { partUserInfo = Users.GetPartUserByMobile(accountName); if (partUserInfo == null) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "手机不存在", "}"); } } else if (BMAConfig.MallConfig.LoginType.Contains("1"))//用户名登陆 { partUserInfo = Users.GetPartUserByName(accountName); if (partUserInfo == null) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "用户名不存在", "}"); } } if (partUserInfo != null) { if (Users.CreateUserPassword(password, partUserInfo.Salt) != partUserInfo.Password) //判断密码是否正确 { LoginFailLogs.AddLoginFailTimes(WorkContext.IP, DateTime.Now); //增加登陆失败次数 errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "密码不正确", "}"); } else if (partUserInfo.UserRid == 1) //当用户等级是禁止访问等级时 { if (partUserInfo.LiftBanTime > DateTime.Now) //达到解禁时间 { UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits); Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid); partUserInfo.UserRid = userRankInfo.UserRid; } else { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "您的账号当前被锁定,不能访问", "}"); } } } } if (errorList.Length > 1)//验证失败时 { return(AjaxResult("error", errorList.Remove(errorList.Length - 1, 1).Append("]").ToString(), true)); } else//验证成功时 { //删除登陆失败日志 LoginFailLogs.DeleteLoginFailLogByIP(WorkContext.IP); //更新用户最后访问 Users.UpdateUserLastVisit(partUserInfo.Uid, DateTime.Now, WorkContext.IP, WorkContext.RegionId); //更新购物车中用户id Carts.UpdateCartUidBySid(partUserInfo.Uid, WorkContext.Sid); //将用户信息写入cookie中 MallUtils.SetUserCookie(partUserInfo, (WorkContext.MallConfig.IsRemember == 1 && isRemember == 1) ? 30 : -1); return(AjaxResult("success", "登录成功")); } }
protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); this.ValidateRequest = false; WorkContext.IsHttpAjax = WebHelper.IsAjax(); WorkContext.IP = WebHelper.GetIP(); WorkContext.RegionInfo = Regions.GetRegionByIP(WorkContext.IP); WorkContext.RegionId = WorkContext.RegionInfo.RegionId; WorkContext.Url = WebHelper.GetUrl(); WorkContext.UrlReferrer = WebHelper.GetUrlReferrer(); //获得用户唯一标示符sid WorkContext.Sid = MallUtils.GetSidCookie(); WorkContext.Openid = ""; if (WorkContext.Sid.Length == 0) { //生成sid WorkContext.Sid = Sessions.GenerateSid(); //将sid保存到cookie中 MallUtils.SetSidCookie(WorkContext.Sid); } PartUserInfo partUserInfo; //获得用户id int uid = MallUtils.GetUidCookie(); if (uid < 1)//当用户为游客时 { //创建游客 partUserInfo = Users.CreatePartGuest(); BrnMall.Core.WeiXinConfig wxconfig = BrnMall.Core.BMAConfig.WeiXinConfig; #region 获取用户openid //if (Request.QueryString["code"] == null) //{ // string host = Request.Url.Host; // string path = Request.Path; // string url = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect", wxconfig.AppID, System.Web.HttpUtility.UrlEncode("http://" + host + path)); // Response.Redirect(url); //} //else //{ // //BrnMall.Core.WeiXinConfig wxconfig = BrnMall.Core.BMAConfig.WeiXinConfig; // string code = Request.QueryString["code"];//获取授权code // // string openIdUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + wxconfig.AppID + "&secret=" + wxconfig.AppSecret + "&code=" + code + "&grant_type=authorization_code"; // string openIdUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + wxconfig.AppID + "&secret=" + wxconfig.AppSecret + "&code=" + code + "&grant_type=authorization_code"; // string content = ""; // try // { // content = BrnMall.Core.WeiXinHelp.GetPage(openIdUrl, ""); // } // catch // { // Response.Write("code:" + code + "这边错了"); // } // string openid = "";//根据授权 获取当前人的openid // try // { // openid = BrnMall.Core.WeiXinHelp.GetJsonValue(content, "openid"); // } // catch // { // Response.Write("code:" + code + "||||content" + content); // } // Senparc.Weixin.MP.AdvancedAPIs.User.UserInfoJson dic = null; // dic = Senparc.Weixin.MP.AdvancedAPIs.UserApi.Info(WeiXinHelp.IsExistAccess_Token2(), openid); // if (dic.subscribe == 1) // { // //获取用户 // //try // //{ // //BMALog.Instance.Write("openid:" + openid); // partUserInfo = Users.GetPartUserByOpenid(openid); // if (partUserInfo != null) // { // MallUtils.SetUserCookie(partUserInfo, 30); // //WorkContext.EncryptPwd= MallUtils.GetCookiePassword(); // } // else//不存在 // { // //partUserInfo = Users.CreatePartGuest(); // //WorkContext.EncryptPwd = string.Empty; // //MallUtils.SetUidCookie(-1); // //MallUtils.SetCookiePassword(""); // UserInfo userinfo = new UserInfo(); // userinfo.Pid = 3; // userinfo.Openid = dic.openid; // userinfo.NickName = dic.nickname; // userinfo.UserName = dic.nickname; // userinfo.Password = Users.CreateUserPassword("Migewan123", "1"); // userinfo.Avatar = dic.headimgurl; // userinfo.UserLevel = 0; // userinfo.PayCredits = 0; // userinfo.RankCredits = 0; // userinfo.VerifyEmail = 0; // userinfo.VerifyMobile = 0; // userinfo.Salt = Randoms.CreateRandomValue(6); // userinfo.LastVisitIP = WebHelper.GetIP(); // userinfo.MallAGid = 1;//非管理员组 // //userinfo.LastVisitRgId = Regions.GetRegionByIP(userinfo.LastVisitIP); // userinfo.LastVisitTime = DateTime.Now; // userinfo.RegisterIP = WebHelper.GetIP(); // userinfo.RegisterTime = DateTime.Now; // Users.CreateUser(userinfo); // partUserInfo = Users.GetPartUserByOpenid(openid); // MallUtils.SetUserCookie(partUserInfo, 30); // } // } //} #endregion #region 测试 ////string openid = "oD-R9wWHGhJ3rcRgX7sbU5W0s9sU"; string openid = "oD-R9wbVoaX-B-7kmk7sz1nz_-bc"; partUserInfo = Users.GetPartUserByOpenid(openid); if (partUserInfo != null) { MallUtils.SetUserCookie(partUserInfo, 30); //WorkContext.EncryptPwd= MallUtils.GetCookiePassword(); } else//不存在 { partUserInfo = Users.CreatePartGuest(); WorkContext.EncryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } #endregion } else//当用户为会员时 { //获得保存在cookie中的密码 string encryptPwd = MallUtils.GetCookiePassword(); //防止用户密码被篡改为危险字符 if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd)) { //创建游客 partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } else { partUserInfo = Users.GetPartUserByUidAndPwd(uid, MallUtils.DecryptCookiePassword(encryptPwd)); if (partUserInfo != null) { //发放登陆积分 // Credits.SendLoginCredits(ref partUserInfo, DateTime.Now); } else//当会员的账号或密码不正确时,将用户置为游客 { partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } } WorkContext.EncryptPwd = encryptPwd; } //try //{ //设置用户等级 if (UserRanks.IsBanUserRank(partUserInfo.UserRid) && partUserInfo.LiftBanTime <= DateTime.Now) { UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits); Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid); partUserInfo.UserRid = userRankInfo.UserRid; } //当用户被禁止访问时重置用户为游客 if (partUserInfo.UserRid == 1) { partUserInfo = Users.CreatePartGuest(); WorkContext.EncryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } //} //catch //{ // Response.Write("我的错"); //} //try //{ WorkContext.PartUserInfo = partUserInfo; WorkContext.Pid = partUserInfo.Pid; WorkContext.Userno = partUserInfo.Userno; WorkContext.UserLevel = partUserInfo.UserLevel; WorkContext.Openid = partUserInfo.Openid; WorkContext.Addtime = partUserInfo.Addtime; WorkContext.IsReal = partUserInfo.IsReal; WorkContext.Uid = partUserInfo.Uid; WorkContext.UserName = partUserInfo.UserName; WorkContext.UserEmail = partUserInfo.Email; WorkContext.UserMobile = partUserInfo.Mobile; WorkContext.Password = partUserInfo.Password; WorkContext.NickName = partUserInfo.NickName; WorkContext.Avatar = partUserInfo.Avatar; WorkContext.PayCreditName = Credits.PayCreditName; WorkContext.PayCreditCount = partUserInfo.PayCredits; WorkContext.RankCreditName = Credits.RankCreditName; WorkContext.RankCreditCount = partUserInfo.RankCredits; Core.BLL.SendBag bllsendbag = new Core.BLL.SendBag(); //全部红包 //WorkContext.CollarBag = bllsendbag.GetRecordSum(" Receiverid="+ partUserInfo.Uid ); //已领红包 WorkContext.NoCollarBag = bllsendbag.GetRecordSum(" Receiverid=" + partUserInfo.Uid + " and Status=0");; //未领红包 WorkContext.HaCollarBag = 0; WorkContext.UserRid = partUserInfo.UserRid; WorkContext.UserRankInfo = UserRanks.GetUserRankById(partUserInfo.UserRid); //WorkContext.UserRTitle = WorkContext.UserRankInfo.Title; switch (WorkContext.UserLevel) { case 1: WorkContext.UserRTitle = "银卡会员"; break; case 2: WorkContext.UserRTitle = "金卡会员"; break; case 3: WorkContext.UserRTitle = "钻石会员"; break; default: WorkContext.UserRTitle = "普通会员"; break; } //设置用户商城管理员组 WorkContext.MallAGid = partUserInfo.MallAGid; WorkContext.MallAdminGroupInfo = MallAdminGroups.GetMallAdminGroupById(partUserInfo.MallAGid); WorkContext.MallAGTitle = WorkContext.MallAdminGroupInfo.Title; //设置当前控制器类名 WorkContext.Controller = RouteData.Values["controller"].ToString().ToLower(); //设置当前动作方法名 WorkContext.Action = RouteData.Values["action"].ToString().ToLower(); WorkContext.PageKey = string.Format("/{0}/{1}", WorkContext.Controller, WorkContext.Action); WorkContext.ImageCDN = WorkContext.MallConfig.ImageCDN; WorkContext.CSSCDN = WorkContext.MallConfig.CSSCDN; WorkContext.ScriptCDN = WorkContext.MallConfig.ScriptCDN; //在线总人数 WorkContext.OnlineUserCount = OnlineUsers.GetOnlineUserCount(); //在线游客数 WorkContext.OnlineGuestCount = OnlineUsers.GetOnlineGuestCount(); //在线会员数 WorkContext.OnlineMemberCount = WorkContext.OnlineUserCount - WorkContext.OnlineGuestCount; //搜索词 WorkContext.SearchWord = string.Empty; //购物车中商品数量 WorkContext.CartProductCount = Carts.GetCartProductCountCookie(); //} //catch (Exception ex) //{ // Response.Write("赋值时:"+ex.ToString()); //} }
public bool AddUserRank(UserRankInfo item) { bool flag = false; try { SqlParameter[] SqlParameters = new SqlParameter[14]; SqlParameters[0] = new SqlParameter("@ID", (object)item.ID); SqlParameters[0].Direction = ParameterDirection.Output; SqlParameters[1] = new SqlParameter("@UserID", (object)item.UserID); SqlParameters[2] = new SqlParameter("@UserRank", (object)item.UserRank); SqlParameters[3] = new SqlParameter("@Attack", (object)item.Attack); SqlParameters[4] = new SqlParameter("@Defence", (object)item.Defence); SqlParameters[5] = new SqlParameter("@Luck", (object)item.Luck); SqlParameters[6] = new SqlParameter("@Agility", (object)item.Agility); SqlParameters[7] = new SqlParameter("@HP", (object)item.HP); SqlParameters[8] = new SqlParameter("@Damage", (object)item.Damage); SqlParameters[9] = new SqlParameter("@Guard", (object)item.Guard); SqlParameters[10] = new SqlParameter("@BeginDate", (object)item.BeginDate); SqlParameters[11] = new SqlParameter("@Validate", (object)item.Validate); SqlParameters[12] = new SqlParameter("@IsExit", (object)(int)(item.IsExit ? 1 : 0)); SqlParameters[13] = new SqlParameter("@Result", SqlDbType.Int); SqlParameters[13].Direction = ParameterDirection.ReturnValue; this.db.RunProcedure("SP_UserRank_Add", SqlParameters); flag = (int)SqlParameters[13].Value == 0; item.ID = (int)SqlParameters[0].Value; item.IsDirty = false; } catch (Exception ex) { if (BaseBussiness.log.IsErrorEnabled) BaseBussiness.log.Error((object)"Init", ex); } return flag; }
protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); this.ValidateRequest = false; WorkContext.IP = WebHelper.GetIP(); if (WebHelper.GetQueryString("ip") == WorkContext.IP) { WorkContext.RegionInfo = Regions.GetRegionById(WebHelper.GetQueryInt("regionid")); } else { WorkContext.RegionInfo = IPSearch.SearchRegion(WorkContext.IP); } if (WorkContext.RegionInfo == null) { WorkContext.RegionInfo = new RegionInfo() { RegionId = -1, Name = "未知区域" }; } WorkContext.RegionId = WorkContext.RegionInfo.RegionId; WorkContext.Url = WebHelper.GetUrl(); WorkContext.AppType = WebHelper.GetQueryInt("appType"); WorkContext.AppVersion = WebHelper.GetQueryString("appVersion"); WorkContext.AppOS = WebHelper.GetQueryString("appOS"); //获得用户唯一标示符sid WorkContext.Sid = WebHelper.GetQueryString("sid"); if (WorkContext.Sid.Length == 0) { //生成sid WorkContext.Sid = Sessions.GenerateSid(); } PartUserInfo partUserInfo; //获得用户id int uid = WebHelper.GetQueryInt("uid"); if (uid < 1)//当用户为游客时 { //创建游客 partUserInfo = Users.CreatePartGuest(); } else//当用户为会员时 { string encryptPwd = WebHelper.GetQueryString("encryptPwd"); //防止用户密码被篡改为危险字符 if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd)) { //创建游客 partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; } else { partUserInfo = Users.GetPartUserByUidAndPwd(uid, MallUtils.DecryptCookiePassword(encryptPwd)); if (partUserInfo != null) { //发放登陆积分 Credits.SendLoginCredits(ref partUserInfo, DateTime.Now, TypeHelper.StringToDateTime(WebHelper.GetQueryString("slctime")), out WorkContext.SLCTime); } else//当会员的账号或密码不正确时,将用户置为游客 { partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; } } WorkContext.EncryptPwd = encryptPwd; } //设置用户等级 if (UserRanks.IsBanUserRank(partUserInfo.UserRid) && partUserInfo.LiftBanTime <= DateTime.Now) { UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits); Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid); partUserInfo.UserRid = userRankInfo.UserRid; } WorkContext.PartUserInfo = partUserInfo; WorkContext.Uid = partUserInfo.Uid; WorkContext.UserName = partUserInfo.UserName; WorkContext.UserEmail = partUserInfo.Email; WorkContext.UserMobile = partUserInfo.Mobile; WorkContext.Password = partUserInfo.Password; WorkContext.NickName = partUserInfo.NickName; WorkContext.Avatar = partUserInfo.Avatar; WorkContext.PayCreditName = Credits.PayCreditName; WorkContext.PayCreditCount = partUserInfo.PayCredits; WorkContext.RankCreditName = Credits.RankCreditName; WorkContext.RankCreditCount = partUserInfo.RankCredits; WorkContext.UserRid = partUserInfo.UserRid; WorkContext.UserRankInfo = UserRanks.GetUserRankById(partUserInfo.UserRid); WorkContext.UserRTitle = WorkContext.UserRankInfo.Title; //设置用户商城管理员组 WorkContext.MallAGid = partUserInfo.MallAGid; WorkContext.MallAdminGroupInfo = MallAdminGroups.GetMallAdminGroupById(partUserInfo.MallAGid); WorkContext.MallAGTitle = WorkContext.MallAdminGroupInfo.Title; //设置当前控制器类名 WorkContext.Controller = RouteData.Values["controller"].ToString().ToLower(); //设置当前动作方法名 WorkContext.Action = RouteData.Values["action"].ToString().ToLower(); WorkContext.PageKey = string.Format("/{0}/{1}", WorkContext.Controller, WorkContext.Action); WorkContext.ImageCDN = WorkContext.MallConfig.ImageCDN; WorkContext.CSSCDN = WorkContext.MallConfig.CSSCDN; WorkContext.ScriptCDN = WorkContext.MallConfig.ScriptCDN; //在线总人数 WorkContext.OnlineUserCount = OnlineUsers.GetOnlineUserCount(); //在线游客数 WorkContext.OnlineGuestCount = OnlineUsers.GetOnlineGuestCount(); //在线会员数 WorkContext.OnlineMemberCount = WorkContext.OnlineUserCount - WorkContext.OnlineGuestCount; //购物车中商品数量 WorkContext.CartProductCount = WebHelper.GetQueryInt("cartProductCount"); }
protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); WorkContext.IsHttpAjax = WebHelper.IsAjax(); WorkContext.IP = WebHelper.GetIP(); WorkContext.RegionInfo = Regions.GetRegionByIP(WorkContext.IP); WorkContext.RegionId = WorkContext.RegionInfo.RegionId; WorkContext.Url = WebHelper.GetUrl(); WorkContext.UrlReferrer = WebHelper.GetUrlReferrer(); //获得用户唯一标示符sid WorkContext.Sid = ShopUtils.GetSidCookie(); if (WorkContext.Sid.Length == 0) { //生成sid WorkContext.Sid = Sessions.GenerateSid(); //将sid保存到cookie中 ShopUtils.SetSidCookie(WorkContext.Sid); } PartUserInfo partUserInfo; //获得用户id int uid = ShopUtils.GetUidCookie(); if (uid < 1)//当用户为游客时 { //创建游客 partUserInfo = Users.CreatePartGuest(); } else//当用户为会员时 { //获得保存在cookie中的密码 string encryptPwd = ShopUtils.GetCookiePassword(); //防止用户密码被篡改为危险字符 if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd)) { //创建游客 partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; ShopUtils.SetUidCookie(-1); ShopUtils.SetCookiePassword(""); } else { partUserInfo = Users.GetPartUserByUidAndPwd(uid, ShopUtils.DecryptCookiePassword(encryptPwd)); if (partUserInfo != null) { //发放登陆积分 Credits.SendLoginCredits(ref partUserInfo, DateTime.Now); } else//当会员的账号或密码不正确时,将用户置为游客 { partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; ShopUtils.SetUidCookie(-1); ShopUtils.SetCookiePassword(""); } } WorkContext.EncryptPwd = encryptPwd; } //设置用户等级 if (UserRanks.IsBanUserRank(partUserInfo.UserRid) && partUserInfo.LiftBanTime <= DateTime.Now) { UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits); Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid); partUserInfo.UserRid = userRankInfo.UserRid; } WorkContext.PartUserInfo = partUserInfo; WorkContext.Uid = partUserInfo.Uid; WorkContext.UserName = partUserInfo.UserName; WorkContext.UserEmail = partUserInfo.Email; WorkContext.UserMobile = partUserInfo.Mobile; WorkContext.Password = partUserInfo.Password; WorkContext.NickName = partUserInfo.NickName; WorkContext.Avatar = partUserInfo.Avatar; WorkContext.UserRid = partUserInfo.UserRid; WorkContext.UserRankInfo = UserRanks.GetUserRankById(partUserInfo.UserRid); WorkContext.UserRTitle = WorkContext.UserRankInfo.Title; //设置用户管理员组 WorkContext.AdminGid = partUserInfo.AdminGid; WorkContext.AdminGroupInfo = AdminGroups.GetAdminGroupById(partUserInfo.AdminGid); WorkContext.AdminGTitle = WorkContext.AdminGroupInfo.Title; //设置当前控制器类名 WorkContext.Controller = RouteData.Values["controller"].ToString().ToLower(); //设置当前动作方法名 WorkContext.Action = RouteData.Values["action"].ToString().ToLower(); WorkContext.PageKey = string.Format("/{0}/{1}", WorkContext.Controller, WorkContext.Action); }
public bool UpdateUserRank(UserRankInfo item) { bool flag = false; try { SqlParameter[] SqlParameters = new SqlParameter[14] { new SqlParameter("@ID", (object) item.ID), new SqlParameter("@UserID", (object) item.UserID), new SqlParameter("@UserRank", (object) item.UserRank), new SqlParameter("@Attack", (object) item.Attack), new SqlParameter("@Defence", (object) item.Defence), new SqlParameter("@Luck", (object) item.Luck), new SqlParameter("@Agility", (object) item.Agility), new SqlParameter("@HP", (object) item.HP), new SqlParameter("@Damage", (object) item.Damage), new SqlParameter("@Guard", (object) item.Guard), new SqlParameter("@BeginDate", (object) item.BeginDate), new SqlParameter("@Validate", (object) item.Validate), new SqlParameter("@IsExit", (object) (int) (item.IsExit ? 1 : 0)), new SqlParameter("@Result", SqlDbType.Int) }; SqlParameters[13].Direction = ParameterDirection.ReturnValue; this.db.RunProcedure("SP_UpdateUserRank", SqlParameters); flag = (int)SqlParameters[13].Value == 0; } catch (Exception ex) { if (BaseBussiness.log.IsErrorEnabled) BaseBussiness.log.Error((object)"SP_UpdateUserRank", ex); } return flag; }