コード例 #1
0
 public static void SetLoginUserCookie(Base_Users user)
 {
     HttpContext.Current.Session["UserID"]   = user.UserID;
     HttpContext.Current.Session["Username"] = user.Username;
     HttpContext.Current.Session["RoleID"]   = user.RoleID;
     HttpContext.Current.Session["IsBand"]   = user.IsBand;
     HttpContext.Current.Session["AgentID"]  = user.AgentID;
     HttpContext.Current.Session["VipID"]    = user.VipID;
     HttpContext.Current.Session.Timeout     = Convert.ToInt32(ConfigHelper.GetAppSetting("SessionExpire"));
 }
コード例 #2
0
        public Message UserLogon(Base_Users user)
        {
            List <DbParameter> list = new List <DbParameter>();

            list.Add(base.Database.MakeInParam("strUserName", user.Username));
            list.Add(base.Database.MakeInParam("strPassword", user.Password));
            list.Add(base.Database.MakeInParam("strClientIP", user.LastLoginIP));
            list.Add(base.Database.MakeOutParam("strErrorDescribe", typeof(string), 127));
            return(MessageHelper.GetMessageForObject <Base_Users>(base.Database, "NET_PM_UserLogon", list));
        }
コード例 #3
0
        public static void SetUserCookie(Base_Users user)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary.Add("UserID", user.UserID);
            dictionary.Add("Username", user.Username);
            dictionary.Add("RoleID", user.RoleID);
            dictionary.Add("IsBand", user.IsBand);
            Add(dictionary, 30);
        }
コード例 #4
0
        /// <summary>
        /// 管理员注销
        /// </summary>
        public void UserLogout( )
        {
            Base_Users userExt = GetUserInfoFromCookie( );

            if (userExt == null)
            {
                return;
            }
            AdminCookie.ClearUserCookie( );
        }
コード例 #5
0
ファイル: AdminCookie.cs プロジェクト: generalSun/HappyWebWH
        /// <summary>
        /// 设置用户 Cookie
        /// </summary>
        /// <param name="user"></param>
        public static void SetUserCookie(Base_Users user)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>( );

            dic.Add(Base_Users._UserID, user.UserID);
            dic.Add(Base_Users._Username, user.Username);
            dic.Add(Base_Users._RoleID, user.RoleID);
            dic.Add(Base_Users._IsBand, user.IsBand);
            Add(dic, 30);
        }
コード例 #6
0
        public static bool CheckedUserLogon()
        {
            Base_Users userFromCookie = GetUserFromCookie();

            if (userFromCookie == null || userFromCookie.UserID <= 0 || userFromCookie.RoleID <= 0)
            {
                return(false);
            }
            SetUserCookie(userFromCookie);
            return(true);
        }
コード例 #7
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="user"></param>
        /// <param name="newLogonPass"></param>
        public void ModifyUserLogonPass(Base_Users user, string newLogonPass)
        {
            string sqlQuery = "UPDATE Base_Users SET Password = @Password WHERE UserID= @UserID";

            var prams = new List <DbParameter>();

            prams.Add(Database.MakeInParam("UserID", user.UserID));
            prams.Add(Database.MakeInParam("Password", newLogonPass));

            Database.ExecuteNonQuery(CommandType.Text, sqlQuery, prams.ToArray());
        }
コード例 #8
0
        public Message UserLogonApp(Base_Users user, string machineID)
        {
            List <DbParameter> list = new List <DbParameter>();

            list.Add(base.Database.MakeInParam("strAccounts", user.Username));
            list.Add(base.Database.MakeInParam("strPassword", user.Password));
            list.Add(base.Database.MakeInParam("strClientIP", user.LastLoginIP));
            list.Add(base.Database.MakeInParam("strMachineSerial", machineID));
            list.Add(base.Database.MakeOutParam("strErrorDescribe", typeof(string), 127));
            return(MessageHelper.GetMessageForObject <Base_Users>(base.Database, "APP_PM_UserLogon", list));
        }
コード例 #9
0
        /// <summary>
        /// 获取管理员帐号
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public string GetAccountsByUserID(int userID)
        {
            Base_Users user = GetUserByUserID(userID);

            if (user != null)
            {
                return(user.Username);
            }

            return("");
        }
コード例 #10
0
        /// <summary>
        /// 管理员注销
        /// </summary>
        public void UserLogout()
        {
            Base_Users userExt = WHCache.Default.Get <SessionCache>(AppConfig.UserCacheKey) as Base_Users;

            if (userExt == null)
            {
                return;
            }
            WHCache.Default.Delete <SessionCache>(AppConfig.UserCacheKey);
            WHCache.Default.Delete <CookiesCache>(AppConfig.UserCacheKey);
        }
コード例 #11
0
        /// <summary>
        /// 验证用户密码
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="logonPass"></param>
        /// <returns></returns>
        public Message ValidUserLogonPass(int userID, string logonPass)
        {
            Base_Users userExt = aidePlatformManagerData.GetUserByUserID(userID);

            if (userExt == null || userExt.UserID <= 0 ||
                !userExt.Password.Equals(logonPass, StringComparison.InvariantCultureIgnoreCase))
            {
                return(new Message(false, "帐号不存在或密码输入错误。"));
            }

            return(new Message(true));
        }
コード例 #12
0
        /// <summary>
        /// 管理员登录
        /// </summary>
        /// <param name="user">管理员信息</param>
        /// <returns></returns>
        public Message UserLogon(Base_Users user)
        {
            var prams = new List <DbParameter>
            {
                Database.MakeInParam("strUserName", user.Username),
                Database.MakeInParam("strPassword", user.Password),
                Database.MakeInParam("strClientIP", user.LastLoginIP),
                Database.MakeOutParam("strErrorDescribe", typeof(string), 127)
            };

            return(MessageHelper.GetMessageForObject <LoginUser>(Database, "NET_PM_UserLogon", prams));
        }
コード例 #13
0
        public override string New(HttpRequest req)
        {
            string json   = "";
            string module = GetModuleName(Convert.ToInt32(req["moduleType"] ?? "0"));


            try
            {
                Base_Users user = new Base_Users();
                user.Username = req.Form["UserName"];
                user.Password = Utility.MD5(req.Form["Password"]);
                bool oIsBand = (req.Form["IsBand"] == "on" ? true : false);
                byte IsBand  = Convert.ToByte(oIsBand);
                user.BandIP      = req.Form["BandIP"];
                user.RoleID      = Convert.ToInt32(string.IsNullOrEmpty(req.Form["RoleID"]) ? "0" : req.Form["RoleID"]);
                user.LastLoginIP = Utility.UserIP;
                string sNullity = req.Form["Nullity"];
                user.Nullity = Convert.ToByte(sNullity == "on" ? 1 : 0);
                if (string.IsNullOrEmpty(user.Username))
                {
                    json = JsonResultHelper.GetSuccessJson("用户名不能为空");
                }
                else
                {
                    Base_Users getuser = aidePlatformManagerFacade.GetUserByAccounts(user.Username);
                    if (getuser != null)
                    {
                        json = JsonResultHelper.GetSuccessJson("用户名已经存在!");
                        LogHelper2.SaveErrLog("新增账号[" + req.Form["UserName"] + "]", "保存失败!用户名已经存在!", userExt.UserID, (int)LogOperationEnum.AddAdmin, GameRequest.GetUserIP(), module);
                    }
                    else
                    {
                        int id = aidePlatformManagerFacade.AddUser(user);
                        if (id == -1)
                        {
                            json = JsonResultHelper.GetSuccessJson("保存失败!");
                        }
                        else
                        {
                            json = JsonResultHelper.GetSuccessJson("保存成功!");
                        }

                        LogHelper2.SaveSuccessLog("新增账号[" + req.Form["UserName"] + "]", userExt.UserID, (int)LogOperationEnum.AddAdmin, GameRequest.GetUserIP(), module);
                    }
                }
            }
            catch (Exception ex)
            {
                json = JsonResultHelper.GetErrorJson(ex.Message);
                LogHelper2.SaveErrLog("新增账号[" + req.Form["UserName"] + "]", ex.Message, userExt.UserID, (int)LogOperationEnum.AddAdmin, GameRequest.GetUserIP(), module);
            }
            return(json);
        }
コード例 #14
0
        private void ProcessData()
        {
            Base_Users user = new Base_Users();

            user.Username = CtrlHelper.GetText(txtAccounts);
            user.IsBand   = 1;//未绑定IP
            user.IsAssist = byte.Parse(rblIsAssist.SelectedValue);
            user.Nullity  = byte.Parse(rbtnNullity.SelectedValue);
            if (hidfLogonPass.Value.Trim() == "********")
            {
                user.Password = Utility.MD5(txtLogonPass.Text.Trim());
            }
            else
            {
                user.Password = hidfLogonPass.Value.Trim();
            }
            user.RoleID = Convert.ToInt32(ddlRole.SelectedValue.Trim());


            Message msg = new Message();

            if (StrCmd == "add")
            {
                //判断权限
                AuthUserOperationPermission(Permission.Add);
                user.LastLoginIP = Utility.UserIP;
                msg = FacadeManage.aidePlatformManagerFacade.Register(user);
            }
            else
            {
                //判断权限
                AuthUserOperationPermission(Permission.Edit);
                user.UserID = IntParam;
                msg         = FacadeManage.aidePlatformManagerFacade.ModifyUserInfo(user);
            }

            if (msg.Success)
            {
                if (StrCmd == "add")
                {
                    ShowInfo("用户信息增加成功", "BaseUserList.aspx", 1200);
                }
                else
                {
                    ShowInfo("用户信息修改成功", "BaseUserList.aspx", 1200);
                }
            }
            else
            {
                ShowError(msg.Content);
            }
        }
コード例 #15
0
        //加载菜单
        private void LoadNavmenu( )
        {
            Base_Users userExt = aidePlatformManagerFacade.GetUserInfoFromCookie( );

            if (userExt == null || userExt.UserID < 0)
            {
                Fetch.Redirect("Login.aspx");
                return;
            }

            ds = aidePlatformManagerFacade.GetMenuByUserID(userExt.UserID);
            BindMenu( );
        }
コード例 #16
0
        public void BindIP(Base_Users user)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("UPDATE Base_Users SET ").Append("IsBand=@IsBand, ").Append("BandIP=@BandIP ")
            .Append("WHERE UserID=@UserID");
            List <DbParameter> list = new List <DbParameter>();

            list.Add(base.Database.MakeInParam("IsBand", user.IsBand));
            list.Add(base.Database.MakeInParam("BandIP", user.BandIP));
            list.Add(base.Database.MakeInParam("UserID", user.UserID));
            base.Database.ExecuteNonQuery(CommandType.Text, stringBuilder.ToString(), list.ToArray());
        }
コード例 #17
0
        /// <summary>
        /// 管理员帐号是否存在
        /// </summary>
        /// <param name="accounts"></param>
        /// <returns></returns>
        public Message ExistUserAccounts(string accounts)
        {
            Base_Users user = aidePlatformManagerData.GetUserByAccounts(accounts);

            if (user != null && user.UserID > 0)
            {
                return(new Message(true, ResMessage.Error_ExistsUser));
            }
            else
            {
                return(new Message(false));
            }
        }
コード例 #18
0
 protected override void Initialize(RequestContext requestContext)
 {
     base.Initialize(requestContext);
     user = FacadeManage.aidePlatformManagerFacade.GetUserInfoFromCache();
     if (user != null && user.UserID > 0 && (user.UserID == 1 || user.RoleID > 0))
     {
         if (TypeUtil.ObjectToInt(base.Request["ModuleID"]) > 0)
         {
             user.MoudleID = TypeUtil.ObjectToInt(base.Request["ModuleID"]);
         }
         FacadeManage.aidePlatformManagerFacade.SaveUserCache(user);
     }
 }
コード例 #19
0
 public void ModifyUserInfo(Base_Users user)
 {
     System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
     stringBuilder.Append("UPDATE Base_Users SET ").Append("Password=@Password, ").Append("RoleID=@RoleID, ").Append("Nullity=@Nullity, ").Append("IsAssist=@IsAssist, ").Append("MobilePhone=@MobilePhone ").Append("WHERE UserID=@UserID");
     System.Collections.Generic.List <System.Data.Common.DbParameter> list = new System.Collections.Generic.List <System.Data.Common.DbParameter>();
     list.Add(base.Database.MakeInParam("Password", user.Password));
     list.Add(base.Database.MakeInParam("RoleID", user.RoleID));
     list.Add(base.Database.MakeInParam("Nullity", user.Nullity));
     list.Add(base.Database.MakeInParam("UserID", user.UserID));
     list.Add(base.Database.MakeInParam("IsAssist", user.IsAssist));
     list.Add(base.Database.MakeInParam("MobilePhone", user.MobilePhone));
     base.Database.ExecuteNonQuery(System.Data.CommandType.Text, stringBuilder.ToString(), list.ToArray());
 }
コード例 #20
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLogin_Click(object sender, ImageClickEventArgs e)
        {
            string verifyCode = CtrlHelper.GetText(txtVerifyCode);
            string accounts   = TextFilter.FilterScript(CtrlHelper.GetText(txtLoginName));
            string passwd     = Utility.MD5(CtrlHelper.GetText(txtLoginPass));

            if (!Fetch.ValidVerifyCodeVer2(verifyCode))
            {
                Fetch.Redirect("Login.aspx?errtype=verifycode");
            }

            Base_Users user = new Base_Users( );

            user.Username    = accounts;
            user.Password    = passwd;
            user.LastLoginIP = GameRequest.GetUserIP( );

            Message msg = aidePlatformManagerFacade.UserLogon(user);

            if (!msg.Success)
            {
                string errtype = "errorUnknown";
                switch (msg.MessageID)
                {
                case 100:
                    errtype = "errorNamePassowrd";
                    break;

                case 101:
                    errtype = "errorBindIP";
                    break;

                case 102:
                    errtype = "errorNullity";
                    break;

                default:
                    errtype = "errorUnknown";
                    break;
                }
                Fetch.Redirect(string.Format("Login.aspx?errtype={0}", errtype));
            }
            user = msg.EntityList[0] as Base_Users;
            if (user == null || (user.UserID != ApplicationConfig.SUPER_ADMINISTRATOR_ID && user.RoleID < 0))
            {
                Fetch.Redirect("Login.aspx?errtype=errorUserRole");
            }

            //转向
            Fetch.Redirect("Index.aspx");
        }
コード例 #21
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            //验证登陆
            if (!FacadeManage.aidePlatformManagerFacade.CheckedUserLogon())
            {
                ajv.msg = "无操作权限";
                context.Response.Write(ajv.SerializeToJson());
                return;
            }
            userExt = FacadeManage.aidePlatformManagerFacade.GetUserInfoFromCache();

            //执行操作
            string action = GameRequest.GetQueryString("action").ToLower();

            switch (action)
            {
            case "updatelevelconfig":
                UpdateLevelConfig(context);
                break;

            case "updatelotteryitem":
                UpdateLotteryItem(context);
                break;

            case "getusergamerecord":
                GetUserGameRecord(context);
                break;

            case "cleartabledata":
                ClearTableData(context);
                break;

            case "getnewmessageandneworder":
                GetNewMessageAndNewOrder(context);
                break;

            case "getuserinfo":
                GetUserInfo(context);
                break;

            case "updatetransferreturnconfig":
                UpdateTransferReturnConfig(context);
                break;

            default:
                break;
            }
        }
コード例 #22
0
        public static Base_Users GetUserFromCookieOld()
        {
            HttpContext context = HttpContext.Current;

            if (context == null)
            {
                return(null);
            }

            Base_Users user       = new Base_Users();
            object     objUserID  = GetValue(Base_Users._UserID);
            object     objAccount = GetValue(Base_Users._Username);
            object     objRoleID  = GetValue(Base_Users._RoleID);
            object     objIsBand  = GetValue(Base_Users._IsBand);
            object     objAgentID = GetValue(Base_Users._AgentID);
            object     objVipID   = GetValue(Base_Users._VipID);


            if (objUserID == null || objAccount == null || objRoleID == null || objIsBand == null || objAgentID == null || objVipID == null)
            {
                return(null);
            }
            user.UserID   = int.Parse(objUserID.ToString());
            user.Username = objAccount.ToString();
            user.RoleID   = int.Parse(objRoleID.ToString());
            user.IsBand   = int.Parse(objIsBand.ToString());
            user.AgentID  = int.Parse(objAgentID.ToString());
            user.VipID    = int.Parse(objVipID.ToString());
            return(user);

            /*
             * string cookie = Utility.GetCookie( Fetch.GetCookieName );
             * if ( TextUtility.EmptyTrimOrNull( cookie ) )
             *  return null;
             *
             * Base_Users user = new Base_Users( );
             * user.UserID = TypeParse.StrToInt( GetCookie( Base_Users._UserID ), 0 );
             * user.Accounts = GetCookie( Base_Users._Accounts );
             * user.LogonPass = GetCookie( Base_Users._LogonPass );
             * user.RoleID = TypeParse.StrToInt( GetCookie( Base_Users._RoleID ), 0 );
             * user.RoleName = GetCookie( Base_Users._RoleName );
             * user.Nullity = Convert.ToByte( GetCookie( Base_Users._Nullity ) );
             * user.RealName = GetCookie( Base_Users._RealName );
             * user.LinkEmail = GetCookie( Base_Users._LinkEmail );
             * user.LastLogonDate = Convert.ToDateTime( GetCookie( Base_Users._LastLogonDate ) );
             * user.OwnStation = GetCookie( Base_Users._OwnStation );
             *
             * return user;*/
        }
コード例 #23
0
        /// <summary>
        /// 资料修改
        /// </summary>
        /// <param name="userExt">可根据用户可修改的项在此增加用户更改的字段</param>
        /// <returns></returns>
        public static Message CheckedUserToModify(ref Base_Users user)
        {
            Message msg = new Message(false);

            //邮件地址

            /*  msg = GameWebRules.CheckedEmail(user.LinkEmail);
             * if (!msg.Success)
             *    return msg;
             *
             * user.RealName = Utility.HtmlEncode(Utils.TextFilter.FilterScript(user.RealName));
             * user.LinkEmail = Utility.HtmlEncode(Utils.TextFilter.FilterScript(user.LinkEmail));
             */
            return(new Message(true));
        }
コード例 #24
0
ファイル: AdminCookie.cs プロジェクト: generalSun/HappyWebWH
        /// <summary>
        /// 检查用户登录状态
        /// </summary>
        /// <returns></returns>
        public static bool CheckedUserLogon( )
        {
            Base_Users user = AdminCookie.GetUserFromCookie( );

            if (user == null || user.UserID <= 0 || user.RoleID <= 0)
            {
                return(false);
            }
            else
            {
                AdminCookie.SetUserCookie(user);
            }

            return(true);
        }
コード例 #25
0
ファイル: BaseUserInfo.aspx.cs プロジェクト: yuk320/WHJHWeb
 /// <summary>
 /// 数据绑定
 /// </summary>
 private void GameUserDataBind()
 {
     if (IntParam > 0)
     {
         Base_Users user = FacadeManage.aidePlatformManagerFacade.GetUserByUserId(IntParam);
         if (user != null)
         {
             CtrlHelper.SetText(txtAccounts, user.Username);
             txtLogonPass.Attributes.Add("value", "********");
             txtConfirmPass.Attributes.Add("value", "********");
             CtrlHelper.SetText(hidfLogonPass, user.Password);
             ddlRole.SelectedValue = user.RoleID.ToString().Trim();
         }
     }
 }
コード例 #26
0
        public JsonResult SendCode()
        {
            string     accounts       = TypeUtil.ObjectToString(base.Request["userName"]);
            Base_Users userByAccounts = FacadeManage.aidePlatformManagerFacade.GetUserByAccounts(accounts);

            if (userByAccounts == null)
            {
                return(Json(new
                {
                    IsOk = false,
                    Msg = "账号不存在"
                }));
            }
            if (!userByAccounts.IsMobileNeed)
            {
                return(Json(new
                {
                    IsOk = false,
                    Msg = "该账号不需要手机验证"
                }));
            }
            if (string.IsNullOrEmpty(userByAccounts.MobilePhone))
            {
                return(Json(new
                {
                    IsOk = false,
                    Msg = "请先设置管理员手机号码"
                }));
            }
            string content = ApplicationSettings.Get("phoneContent");
            string text    = TextUtility.CreateAuthStr(6, true);
            string text2   = CodeHelper.SendCode(userByAccounts.MobilePhone, text, content);

            if (text2 == "发送成功")
            {
                base.Session["code"] = text;
                return(Json(new
                {
                    IsOk = true,
                    Msg = "发送成功"
                }));
            }
            return(Json(new
            {
                IsOk = false,
                Msg = text2
            }));
        }
コード例 #27
0
ファイル: PlatformManagerFacade.cs プロジェクト: toowind/QY
        /// <summary>
        /// 管理员登录
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public Message UserLogon(Base_Users user)
        {
            Message msg = GameWebRules.CheckedUserLogon(user);

            if (!msg.Success)
            {
                return(msg);
            }
            msg = aidePlatformManagerData.UserLogon(user);
            if (msg.Success)
            {
                Base_Users logonUser = msg.EntityList[0] as Base_Users;
                AdminCookie.SetLoginUserCookie(logonUser);
            }
            return(msg);
        }
コード例 #28
0
        public Message ModifyPowerUserLogonPass(Base_Users admin, Base_Users powerUser, string newPasswd)
        {
            if (admin.UserID != 1 || admin.RoleID != 1)
            {
                return(new Message(false, "您没有修改用户密码的权限。"));
            }
            Message message = GameWebRules.CheckedPassword(newPasswd);

            if (!message.Success)
            {
                return(message);
            }
            newPasswd = TextEncrypt.EncryptPassword(newPasswd);
            aidePlatformManagerData.ModifyUserLogonPass(powerUser, newPasswd);
            return(new Message(true));
        }
コード例 #29
0
        public Message ModifyUserLogonPass(Base_Users userExt, string oldPasswd, string newPasswd)
        {
            Message message = GameWebRules.CheckUserPasswordForModify(ref oldPasswd, ref newPasswd);

            if (!message.Success)
            {
                return(message);
            }
            message = ValidUserLogonPass(userExt.UserID, oldPasswd);
            if (!message.Success)
            {
                return(message);
            }
            aidePlatformManagerData.ModifyUserLogonPass(userExt, Utility.MD5(newPasswd));
            return(new Message(true));
        }
コード例 #30
0
        public Message Register(Base_Users user)
        {
            Message message = GameWebRules.CheckedUserToRegister(ref user);

            if (!message.Success)
            {
                return(message);
            }
            message = ExistUserAccounts(user.Username);
            if (message.Success)
            {
                message.Success = false;
                return(message);
            }
            aidePlatformManagerData.Register(user);
            return(new Message(true));
        }