Пример #1
0
        /// <summary>从门户后台管理自动登录</summary>
        private bool AutoLogin(string returnUrl)
        {
            var token = this.Request.QueryString["token"];

            if (token.IsNullOrEmpty())
            {
                return(false);
            }
            var userId = this.Context.GetPortalMgmtUserId(token);

            if (userId.IsNullOrEmpty())
            {
                return(false);
            }
            var nUserId = 0;

            if (!int.TryParse(userId, out nUserId))
            {
                return(false);
            }
            var user = this.Context.GetPortalMgmtUser(nUserId);

            if (user == null)
            {
                return(false);
            }
            var admin   = Users.GetUserInfo(user.USERNAME);
            var context = this.Context.GetHttpContextWrapper();
            var config  = GeneralConfigs.GetConfig();

            if (admin == null)
            {
                var principal = new PKSPrincipal();
                var identity  = new PKSIdentity();
                identity.Name        = user.USERNAME;
                identity.Email       = user.EMAIL;
                identity.PhoneNumber = user.PHONENUMBER;
                principal.Identity   = identity;
                admin = context.CreateUser(config, principal, true);
            }
            else if (admin.Adminid != 1 || admin.Groupid != 1)
            {
                admin.Adminid  = 1;
                admin.Groupid  = 1;
                admin.Authtime = Utils.GetDateTime();
                AdminUsers.UpdateUserAllInfo(admin);
                //移除该用户的在线信息,使之重建在线表信息
                OnlineUsers.DeleteUserByUid(admin.Uid);
            }
            var adminGroup = AdminUserGroups.AdminGetUserGroupInfo(admin.Groupid);

            ForumUtils.WriteUserCookie(admin.Uid, ForumExtension.ExpireMinutes, config.Passwordkey);
            this.Context.AddAdminCookie(config, admin.Uid, admin.Password, admin.Secques, ForumExtension.ExpireMinutes);
            SoftInfo.LoadSoftInfo();
            AdminVistLogs.InsertLog(admin.Uid, admin.Username, admin.Groupid, adminGroup.Grouptitle, DNTRequest.GetIP(), "后台管理员登陆", "");
            return(true);
        }
        private void SaveUserInfo_Click(object sender, EventArgs e)
        {
            #region 保存用户信息

            if (this.CheckCookie())
            {
                int    uid       = DNTRequest.GetInt("uid", -1);
                string errorInfo = "";

                if (!AllowEditUserInfo(uid, true))
                {
                    return;
                }

                if (userName.Text != ViewState["username"].ToString())
                {
                    if (AdminUsers.GetUserId(userName.Text) > 0)
                    {
                        base.RegisterStartupScript("", "<script>alert('您所输入的用户名已被使用过, 请输入其他的用户名!');</script>");
                        return;
                    }
                }

                if (userName.Text == "")
                {
                    base.RegisterStartupScript("", "<script>alert('用户名不能为空!');</script>");
                    return;
                }

                if (groupid.SelectedValue == "0")
                {
                    base.RegisterStartupScript("", "<script>alert('您未选中任何用户组!');</script>");
                    return;
                }

                userInfo             = AdminUsers.GetUserInfo(uid);
                userInfo.Username    = userName.Text;
                userInfo.Nickname    = nickname.Text;
                userInfo.Accessmasks = Convert.ToInt32(accessmasks.SelectedValue);

                //当用户组发生变化时则相应更新用户的管理组字段
                if (userInfo.Groupid.ToString() != groupid.SelectedValue)
                {
                    userInfo.Adminid = UserGroups.GetUserGroupInfo(int.Parse(groupid.SelectedValue)).Radminid;
                }

                //userInfo.Avatarshowid = 0;

                if ((bday.Text == "0000-00-00") || (bday.Text == "0000-0-0") | (bday.Text.Trim() == ""))
                {
                    userInfo.Bday = "";
                }
                else
                {
                    if (!Utils.IsDateString(bday.Text.Trim()))
                    {
                        base.RegisterStartupScript("", "<script>alert('用户生日不是有效的日期型数据!');</script>");
                        return;
                    }
                    else
                    {
                        userInfo.Bday = bday.Text;
                    }
                }


                if (!Users.ValidateEmail(email.Text, uid))
                {
                    base.RegisterStartupScript("", "<script>alert('当前用户的邮箱地址已被使用过, 请输入其他的邮箱!');</script>");
                    return;
                }

                userInfo.Email  = email.Text;
                userInfo.Gender = Convert.ToInt32(gender.SelectedValue);
                //userInfo.Groupexpiry = Convert.ToInt32(groupexpiry.Text);后台操作为永久禁言和永久禁访

                userInfo.Groupexpiry = 0;
                userInfo.Extgroupids = extgroupids.GetSelectString(",");

                if ((groupid.SelectedValue != "1") && (userInfo.Uid == BaseConfigs.GetFounderUid))
                {
                    base.RegisterStartupScript("", "<script>alert('创始人的所属用户组不能被修改为其它组!');window.location.href='global_edituser.aspx?uid=" + DNTRequest.GetString("uid") + "';</script>");
                    return;
                }

                userInfo.Groupid      = Convert.ToInt32(groupid.SelectedValue);
                userInfo.Invisible    = Convert.ToInt32(invisible.SelectedValue);
                userInfo.Joindate     = joindate.Text;
                userInfo.Lastactivity = lastactivity.Text;
                userInfo.Lastip       = lastip.Text;
                userInfo.Lastpost     = lastpost.Text;
                userInfo.Lastvisit    = lastvisit.Text;
                userInfo.Newpm        = Convert.ToInt32(newpm.SelectedValue);
                userInfo.Newsletter   = (ReceivePMSettingType)GetNewsLetter();
                userInfo.Oltime       = Convert.ToInt32(oltime.Text);
                userInfo.Pageviews    = Convert.ToInt32(pageviews.Text);
                userInfo.Pmsound      = Convert.ToInt32(pmsound.Text);
                userInfo.Posts        = Convert.ToInt32(posts.Text);
                userInfo.Ppp          = Convert.ToInt32(ppp.Text);
                userInfo.Regip        = regip.Text;
                userInfo.Digestposts  = Convert.ToInt32(digestposts.Text);

                if (secques.SelectedValue == "1")
                {
                    userInfo.Secques = "";                               //清空安全码
                }
                userInfo.Showemail  = Convert.ToInt32(showemail.SelectedValue);
                userInfo.Sigstatus  = Convert.ToInt32(sigstatus.SelectedValue);
                userInfo.Templateid = Convert.ToInt32(templateid.SelectedValue);
                userInfo.Tpp        = Convert.ToInt32(tpp.Text);


                if (Utils.IsNumeric(extcredits1.Text.Replace("-", "")))
                {
                    userInfo.Extcredits1 = float.Parse(extcredits1.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits2.Text.Replace("-", "")))
                {
                    userInfo.Extcredits2 = float.Parse(extcredits2.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits3.Text.Replace("-", "")))
                {
                    userInfo.Extcredits3 = float.Parse(extcredits3.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits4.Text.Replace("-", "")))
                {
                    userInfo.Extcredits4 = float.Parse(extcredits4.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits5.Text.Replace("-", "")))
                {
                    userInfo.Extcredits5 = float.Parse(extcredits5.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits6.Text.Replace("-", "")))
                {
                    userInfo.Extcredits6 = float.Parse(extcredits6.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits7.Text.Replace("-", "")))
                {
                    userInfo.Extcredits7 = float.Parse(extcredits7.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits8.Text.Replace("-", "")))
                {
                    userInfo.Extcredits8 = float.Parse(extcredits8.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }


                //根据公式计算用户的总积分,并更新
                userInfo.Credits = CreditsFacade.GetUserCreditsByUserInfo(userInfo);
                //判断用户组是否为积分用户组。如果是的话,就用当前积分更新。
                if (UserGroups.IsCreditUserGroup(userInfo.Groupid))
                {
                    userInfo.Groupid = CreditsFacade.GetCreditsUserGroupId(userInfo.Credits).Groupid;
                }
                //用户扩展信息
                userInfo.Website      = website.Text;
                userInfo.Icq          = icq.Text;
                userInfo.Qq           = qq.Text;
                userInfo.Yahoo        = yahoo.Text;
                userInfo.Msn          = msn.Text;
                userInfo.Skype        = skype.Text;
                userInfo.Location     = location.Text;
                userInfo.Customstatus = customstatus.Text;
                //userInfo.Avatar = avatar.Text;
                //userInfo.Avatarheight = Convert.ToInt32(avatarheight.Text);
                //userInfo.Avatarwidth = Convert.ToInt32(avatarwidth.Text);
                userInfo.Bio = bio.Text;
                if (signature.Text.Length > UserGroups.GetUserGroupInfo(userInfo.Groupid).Maxsigsize)
                {
                    errorInfo = "更新的签名长度超过 " + UserGroups.GetUserGroupInfo(userInfo.Groupid).Maxsigsize + " 字符的限制,未能更新。";
                }
                else
                {
                    userInfo.Signature = signature.Text;
                    //签名UBB转换HTML
                    PostpramsInfo _postpramsinfo = new PostpramsInfo();
                    _postpramsinfo.Showimages = UserGroups.GetUserGroupInfo(userInfo.Groupid).Allowsigimgcode;
                    _postpramsinfo.Sdetail    = signature.Text;
                    userInfo.Sightml          = UBB.UBBToHTML(_postpramsinfo);
                }

                userInfo.Realname = realname.Text;
                userInfo.Idcard   = idcard.Text;
                userInfo.Mobile   = mobile.Text;
                userInfo.Phone    = phone.Text;
                userInfo.Medals   = DNTRequest.GetString("medalid");

                if (IsEditUserName.Checked && userName.Text != ViewState["username"].ToString())
                {
                    AdminUsers.UserNameChange(userInfo, ViewState["username"].ToString());
                    //用户重命名同步
                    Discuz.Forum.Sync.RenameUser(userInfo.Uid, ViewState["username"].ToString(), userInfo.Username, "");
                }

                if (AdminUsers.UpdateUserAllInfo(userInfo))
                {
                    OnlineUsers.DeleteUserByUid(userInfo.Uid);    //移除该用户的在线信息,使之重建在线表信息
                    if (ViewState["Groupid"].ToString() != userInfo.Groupid.ToString())
                    {
                        if (userInfo.Groupid == 4)
                        {
                            if (AlbumPluginProvider.GetInstance() != null)
                            {
                                AlbumPluginProvider.GetInstance().Ban(userInfo.Uid);
                            }
                            if (SpacePluginProvider.GetInstance() != null)
                            {
                                SpacePluginProvider.GetInstance().Ban(userInfo.Uid);
                            }
                        }
                        else
                        {
                            if (AlbumPluginProvider.GetInstance() != null)
                            {
                                AlbumPluginProvider.GetInstance().UnBan(userInfo.Uid);
                            }
                            if (SpacePluginProvider.GetInstance() != null)
                            {
                                SpacePluginProvider.GetInstance().UnBan(userInfo.Uid);
                            }
                        }
                    }
                    //if (userName.Text != ViewState["username"].ToString())
                    //{
                    //    AdminUsers.UserNameChange(userInfo, ViewState["username"].ToString());
                    //}
                    //删除头像
                    if (delavart.Checked)
                    {
                        Avatars.DeleteAvatar(userInfo.Uid.ToString());
                    }
                    AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台编辑用户", "用户名:" + userName.Text);
                    if (errorInfo == "")
                    {
                        base.RegisterStartupScript("PAGE", "window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';");
                    }
                    else
                    {
                        base.RegisterStartupScript("PAGE", "alert('" + errorInfo + "');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';");
                    }
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';</script>");
                }
            }

            #endregion
        }
Пример #3
0
        private void SaveUserInfo_Click(object sender, EventArgs e)
        {
            #region 保存用户信息

            if (this.CheckCookie())
            {
                int    uid       = DNTRequest.GetInt("uid", -1);
                string errorInfo = "";

                if (!AllowEditUserInfo(uid, true))
                {
                    return;
                }

                if (userName.Text != ViewState["username"].ToString())
                {
                    if (AdminUsers.GetUserID(userName.Text) != -1)
                    {
                        base.RegisterStartupScript("", "<script>alert('您所输入的用户名已被使用过, 请输入其他的用户名!');</script>");
                        return;
                    }
                }

                if (userName.Text == "")
                {
                    base.RegisterStartupScript("", "<script>alert('用户名不能为空!');</script>");
                    return;
                }

                if (groupid.SelectedValue == "0")
                {
                    base.RegisterStartupScript("", "<script>alert('您未选中任何用户组!');</script>");
                    return;
                }

                __userinfo             = AdminUsers.GetUserInfo(uid);
                __userinfo.Username    = userName.Text;
                __userinfo.Nickname    = nickname.Text;
                __userinfo.Accessmasks = Convert.ToInt32(accessmasks.SelectedValue);

                //当用户组发生变化时则相应更新用户的管理组字段
                if (__userinfo.Groupid.ToString() != groupid.SelectedValue)
                {
                    __userinfo.Adminid = DatabaseProvider.GetInstance().GetRadminidByGroupid(int.Parse(groupid.SelectedValue));
                }

                __userinfo.Avatarshowid = 0;

                if ((bday.Text == "0000-00-00") || (bday.Text == "0000-0-0") | (bday.Text.Trim() == ""))
                {
                    __userinfo.Bday = "";
                }
                else
                {
                    if (!Utils.IsDateString(bday.Text.Trim()))
                    {
                        base.RegisterStartupScript("", "<script>alert('用户生日不是有效的日期型数据!');</script>");
                        return;
                    }
                    else
                    {
                        __userinfo.Bday = bday.Text;
                    }
                }

                if (Utils.IsNumeric(credits.Text.Replace("-", "")))
                {
                    __userinfo.Credits = Convert.ToInt32(credits.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户的金币不能为空或大于9位 !');</script>");
                    return;
                }

                GeneralConfigInfo __configinfo = GeneralConfigs.Deserialize(Server.MapPath("../../config/general.config"));
                if (__configinfo.Doublee == 0)
                {
                    int currentuid = AdminUsers.FindUserEmail(email.Text);
                    if ((currentuid != -1) && (currentuid != uid))
                    {
                        base.RegisterStartupScript("", "<script>alert('当前用户的邮箱地址已被使用过, 请输入其他的邮箱!');</script>");
                        return;
                    }
                }

                __userinfo.Email       = email.Text;
                __userinfo.Gender      = Convert.ToInt32(gender.SelectedValue);
                __userinfo.Groupexpiry = Convert.ToInt32(groupexpiry.Text);
                __userinfo.Extgroupids = extgroupids.GetSelectString(",");

                if ((groupid.SelectedValue != "1") && (__userinfo.Uid == 1))
                {
                    base.RegisterStartupScript("", "<script>alert('初始化系统管理员的所属用户组设置不能修改为其它组!');window.location.href='global_edituser.aspx?uid=" + DNTRequest.GetString("uid") + "';</script>");
                    return;
                }

                __userinfo.Groupid      = Convert.ToInt32(groupid.SelectedValue);
                __userinfo.Invisible    = Convert.ToInt32(invisible.SelectedValue);
                __userinfo.Joindate     = joindate.Text;
                __userinfo.Lastactivity = lastactivity.Text;
                __userinfo.Lastip       = lastip.Text;
                __userinfo.Lastpost     = lastpost.Text;
                __userinfo.Lastvisit    = lastvisit.Text;
                __userinfo.Newpm        = Convert.ToInt32(newpm.SelectedValue);
                __userinfo.Newsletter   = (ReceivePMSettingType)GetNewsLetter();
                __userinfo.Oltime       = Convert.ToInt32(oltime.Text);
                __userinfo.Pageviews    = Convert.ToInt32(pageviews.Text);
                __userinfo.Pmsound      = Convert.ToInt32(pmsound.Text);
                __userinfo.Posts        = Convert.ToInt32(posts.Text);
                __userinfo.Ppp          = Convert.ToInt32(ppp.Text);
                __userinfo.Regip        = regip.Text;
                __userinfo.Digestposts  = Convert.ToInt32(digestposts.Text);

                if (secques.SelectedValue == "1")
                {
                    __userinfo.Secques = "";                               //清空安全码
                }
                __userinfo.Showemail  = Convert.ToInt32(showemail.SelectedValue);
                __userinfo.Sigstatus  = Convert.ToInt32(sigstatus.SelectedValue);
                __userinfo.Templateid = Convert.ToInt32(templateid.SelectedValue);
                __userinfo.Tpp        = Convert.ToInt32(tpp.Text);


                if (Utils.IsNumeric(extcredits1.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits1 = float.Parse(extcredits1.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits2.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits2 = float.Parse(extcredits2.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits3.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits3 = float.Parse(extcredits3.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits4.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits4 = float.Parse(extcredits4.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits5.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits5 = float.Parse(extcredits5.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits6.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits6 = float.Parse(extcredits6.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits7.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits7 = float.Parse(extcredits7.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits8.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits8 = float.Parse(extcredits8.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }


                //用户扩展信息
                __userinfo.Website      = website.Text;
                __userinfo.Icq          = icq.Text;
                __userinfo.Qq           = qq.Text;
                __userinfo.Yahoo        = yahoo.Text;
                __userinfo.Msn          = msn.Text;
                __userinfo.Skype        = skype.Text;
                __userinfo.Location     = location.Text;
                __userinfo.Customstatus = customstatus.Text;
                __userinfo.Avatar       = avatar.Text;
                __userinfo.Avatarheight = Convert.ToInt32(avatarheight.Text);
                __userinfo.Avatarwidth  = Convert.ToInt32(avatarwidth.Text);
                __userinfo.Bio          = bio.Text;
                if (signature.Text.Length > UserGroups.GetUserGroupInfo(__userinfo.Groupid).Maxsigsize)
                {
                    errorInfo = "更新的签名长度超过 " + UserGroups.GetUserGroupInfo(__userinfo.Groupid).Maxsigsize + " 字符的限制,未能更新。";
                }
                else
                {
                    __userinfo.Signature = signature.Text;
                    //签名UBB转换HTML
                    PostpramsInfo _postpramsinfo = new PostpramsInfo();
                    _postpramsinfo.Showimages = UserGroups.GetUserGroupInfo(__userinfo.Groupid).Allowsigimgcode;
                    _postpramsinfo.Sdetail    = signature.Text;
                    __userinfo.Sightml        = UBB.UBBToHTML(_postpramsinfo);
                }

                __userinfo.Realname = realname.Text;
                __userinfo.Idcard   = idcard.Text;
                __userinfo.Mobile   = mobile.Text;
                __userinfo.Phone    = phone.Text;
                __userinfo.Medals   = DNTRequest.GetString("medalid");

                if (IsEditUserName.Checked)
                {
                    AdminUsers.UserNameChange(__userinfo, ViewState["username"].ToString());
                }

                if (AdminUsers.UpdateUserAllInfo(__userinfo))
                {
                    if (userName.Text != ViewState["username"].ToString())
                    {
                        AdminUsers.UserNameChange(__userinfo, ViewState["username"].ToString());
                    }
                    AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台编辑用户", "用户名:" + userName.Text);
                    if (errorInfo == "")
                    {
                        base.RegisterStartupScript("PAGE", "window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';");
                    }
                    else
                    {
                        base.RegisterStartupScript("PAGE", "alert('" + errorInfo + "');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';");
                    }
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';</script>");
                }
            }

            #endregion
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var responseMessage = "-1";
            var userMoney       = "0";
            var bingoHistoryID  = 0;
            var isGoogleAdv     = false;

            try
            {
                if (userid != -1)
                {
                    if (Request.Form["StripResult"] != null)
                    {
                        if (Request.Form["StripResult"] == "start")
                        {
                            bool.TryParse(Request.Form["IsGoogleAdv"], out isGoogleAdv);

                            #region StartGetStrip

                            var clubs = ClubLogic.GetActiveUserClubs(userid);

                            if (clubs.Count != 0)
                            {
                                var clubID = clubs[0].ID.Value;

                                //check the user last time play
                                //TimeSpan ts = PlayerStrip.GetUserBingoTimeSpan(userid);

                                var count = PlayerStrip.GetUserBingoPlayCountThisHour(userid);
                                var info  = Users.GetUserInfo(userid);

                                userMoney = ((int)info.Extcredits2).ToString();

                                if ((ConfigGlobal.BingoPlayCountPerHour > count) &&
                                    (PlayerStrip.GetClubRemainingEquipment(clubID) > 0))
                                {
                                    if (isGoogleAdv && ConfigGlobal.GoogleAdvActive)
                                    {
                                        bingoHistoryID = PlayerStrip.InsertBingoStart(userid, username, clubID);

                                        responseMessage = (ConfigGlobal.BingoPlayCountPerHour - count).ToString();
                                    }
                                    else
                                    {
                                        //play cost
                                        var bingoCost = ConfigGlobal.BingoCost;

                                        if (info.Extcredits2 >= bingoCost)
                                        {
                                            info.Extcredits2 = info.Extcredits2 - bingoCost;

                                            if (AdminUsers.UpdateUserAllInfo(info))
                                            {
                                                bingoHistoryID = PlayerStrip.InsertBingoStart(userid, username, clubID);

                                                //return a rate based on user fortune

                                                //responseResult = PlayerStrip.CalcFlashRate(userid);

                                                //return userFortune

                                                responseMessage =
                                                    (ConfigGlobal.BingoPlayCountPerHour - count).ToString();
                                            }
                                        }
                                        else
                                        {
                                            responseMessage = "-2";
                                        }
                                    }
                                }
                                else
                                {
                                    responseMessage = "0";
                                }
                            }

                            #endregion
                        }
                        else if (Request.Form["StripResult"] == "result")
                        {
                            var finalResult = Request.Form["FinalResult"];
                            var resultType  = Request.Form["ResultType"];

                            var authKey = Request.Form["AuthKey"];
                            bingoHistoryID = int.Parse(Request.Form["ID"]);
                            bool.TryParse(Request.Form["IsGoogleAdv"], out isGoogleAdv);

                            var info = Users.GetUserInfo(userid);

                            if (PlayerStrip.ValidateAuthKey(bingoHistoryID.ToString(), userid.ToString(), authKey))
                            {
                                if (PlayerStrip.ValidateBingoResult(bingoHistoryID, userid))
                                {
                                    if (isGoogleAdv && ConfigGlobal.GoogleAdvActive)
                                    {
                                        #region GetStripResult

                                        var br = BingoUtil.AnalyzeFlashResult(userid, finalResult, resultType);
                                        responseMessage = PlayerStrip.UpdateBingoResult(userid, username, br, resultType);
                                        userMoney       = ((int)info.Extcredits2).ToString("f0");

                                        #endregion
                                    }
                                    else
                                    {
                                        var bingoGetCost = ConfigGlobal.BingoGetCost;
                                        if (info.Extcredits2 >= bingoGetCost)
                                        {
                                            info.Extcredits2 = info.Extcredits2 - bingoGetCost;
                                            if (AdminUsers.UpdateUserAllInfo(info))
                                            {
                                                #region GetStripResult

                                                var br = BingoUtil.AnalyzeFlashResult(userid, finalResult, resultType);
                                                responseMessage = PlayerStrip.UpdateBingoResult(userid, username, br,
                                                                                                resultType);
                                                userMoney = ((int)info.Extcredits2).ToString("f0");

                                                #endregion
                                            }
                                        }
                                        else
                                        {
                                            responseMessage = "-2";
                                        }
                                    }
                                }
                            }
                            else
                            {
                                responseMessage = "-1";
                            }
                        }
                    }
                }
            }
            catch
            {
                responseMessage = "-1";
            }
            var responseText =
                $"ServerMessage={responseMessage}&UserMoney={userMoney}&ID={bingoHistoryID}&UserID={userid}";
            Response.Write(responseText);
        }
Пример #5
0
        protected void btnGetBonus_Click(object sender, EventArgs e)
        {
            var luckyPlayerID = ConfigGlobal.LuckyPlayerID;

            var player  = PlayerStrip.GetPlayerInfoByPlayerID(luckyPlayerID);
            var gPlayer = PlayerStrip.GetPlayerInfo(userid);

            var clubs = ClubLogic.GetActiveUserClubs(player.UserID);
            var isLuckyPlayerLeader =
                clubs.Exists(
                    delegate(Club club)
            {
                return
                (ClubLogic.GetClubLeads(club.ID.Value)
                 .Exists(delegate(UserClub uc) { return uc.Userid == this.userid; }));
            });

            var script = string.Empty;
            var CanGetLuckyPlayerBonus = false;

            if ((gPlayer.UserID == player.UserID) || isLuckyPlayerLeader)
            {
                CanGetLuckyPlayerBonus = true;
            }

            if (player != null && gPlayer != null && !ConfigGlobal.LuckyPlayerBonusGot && CanGetLuckyPlayerBonus)
            {
                var totalBonus = LuckyPlayer.CalcTotalBonus();

                var bonusToUser = (int)(totalBonus * ConfigGlobal.LuckyPlayerBonusPercentage);
                var bonusToClub = totalBonus - bonusToUser;

                var userInfo = Users.GetUserInfo(userid);
                userInfo.Extcredits2 += bonusToUser;

                AdminUsers.UpdateUserAllInfo(userInfo);

                //club update
                //List<Club> clubs = ClubLogic.GetActiveUserClubs(userid);
                var clubID = -1;

                if (clubs.Count == 0)
                {
                    bonusToClub = 0;
                }
                else
                {
                    var club = clubs[0];
                    clubID = club.ID.Value;

                    club.Fortune += bonusToClub;

                    ClubLogic.SaveClub(club);
                }

                LuckyPlayer.SetBonusGot(gPlayer.ID, bonusToClub, clubID, player.ID);

                Config.Cache.RefreshCache();

                script = $"alert('您已获得幸运球员奖金{bonusToUser}枪手币,球会获得{bonusToClub}枪手币');";

                btnGetBonus.Visible = true;
                btnGetBonus.Enabled = false;
                btnGetBonus.Text    = "已领取";
            }
            else
            {
                script = "alert('您无法领取今日的幸运球员奖金');";
            }

            Page.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", script, true);
        }
Пример #6
0
        public static string UpdateBingoResult(int userID, string userName, BingoResult result, string resultType)
        {
            if (result.Result != BingoResultType.Null)
            {
                var sql = string.Empty;
                if ((resultType == "card") && (result.Result == BingoResultType.Card) &&
                    (result.ResultDetail.Length == 36))
                {
                    try
                    {
                        var guid = result.ResultDetail;
                        sql =
                            "INSERT INTO dbo.AcnClub_Card (UserID, UserName, IsActive, IsInUse, GainDate, ActiveDate, ArsenalPlayerGuid) VALUES (@userID, @userName, 0, 0, getdate(), null, @guid)";

                        using (var con = SQLConn.GetConnection())
                        {
                            var com = new SqlCommand(sql, con);

                            com.Parameters.Add(new SqlParameter("@userID", userID));
                            com.Parameters.Add(new SqlParameter("@userName", userName));
                            com.Parameters.Add(new SqlParameter("@guid", new Guid(guid)));

                            con.Open();

                            com.ExecuteNonQuery();

                            //con.Close();
                        }

                        UpdateBingoResultLog(userID, result);

                        return("a card of " + Player.Cache.Load(new Guid(guid)).DisplayName);
                    }
                    catch
                    {
                        //throw new Exception("Invalid Arsenal Player Guid.");
                        return("-1");
                    }
                }
                if ((resultType == "card") && (result.Result == BingoResultType.Card) &&
                    (result.ResultDetail == "legend"))
                {
                    try
                    {
                        sql =
                            "INSERT INTO dbo.AcnClub_Card (UserID, UserName, IsActive, IsInUse, GainDate, ActiveDate, ArsenalPlayerGuid) VALUES (@userID, @userName, 0, 0, getdate(), null, null)";

                        using (var con = SQLConn.GetConnection())
                        {
                            var com = new SqlCommand(sql, con);

                            com.Parameters.Add(new SqlParameter("@userID", userID));
                            com.Parameters.Add(new SqlParameter("@userName", userName));

                            con.Open();

                            com.ExecuteNonQuery();

                            //con.Close();
                        }

                        UpdateBingoResultLog(userID, result);

                        return("a legend card");
                    }
                    catch
                    {
                        return("-1");
                    }
                }
                if (result.Result == BingoResultType.Cash)
                {
                    try
                    {
                        var bonusCash   = Convert.ToSingle(result.ResultDetail);
                        var finalResult = string.Empty;

                        var info = Users.GetUserInfo(userID);
                        info.Extcredits2 += bonusCash;

                        if (AdminUsers.UpdateUserAllInfo(info))
                        {
                            finalResult = ("Cash(QSB):" + bonusCash);

                            UpdateBingoResultLog(userID, result);

                            return(finalResult);
                        }
                        return("-1");
                    }
                    catch
                    {
                        return("-1");
                    }
                }
                try
                {
                    // Strip Bonus
                    var shirt     = 0;
                    var shorts    = 0;
                    var sock      = 0;
                    var bonusCash = 0f;
                    var bonusRate = ConfigGlobal.BingoBonusRate;

                    var finalResult = string.Empty;

                    var player = GetPlayerInfo(userID);

                    if ((result.Result == BingoResultType.Strip) || (result.Result == BingoResultType.Both))
                    {
                        if (result.ResultDetail == "shirt")
                        {
                            shirt++;
                        }
                        else if (result.ResultDetail == "shorts")
                        {
                            shorts++;
                        }
                        else if (result.ResultDetail == "sock")
                        {
                            sock++;
                        }
                        else if (result.ResultDetail == "strips")
                        {
                            shirt  += 5;
                            shorts += 5;
                            sock   += 5;
                        }

                        if (player == null)
                        {
                            sql =
                                "INSERT INTO dbo.AcnClub_Player VALUES (@userID, @userName, @shirt, @shorts, @sock, null, 1, null)";
                        }
                        else
                        {
                            shirt  = player.Shirt + shirt;
                            shorts = player.Shorts + shorts;
                            sock   = player.Sock + sock;

                            sql =
                                "UPDATE dbo.AcnClub_Player SET Shirt = @shirt, Shorts = @shorts, Sock = @sock WHERE UserID = @userID AND UserName = @userName";
                        }
                        using (var con = SQLConn.GetConnection())
                        {
                            var com = new SqlCommand(sql, con);

                            com.Parameters.Add(new SqlParameter("@userID", userID));
                            com.Parameters.Add(new SqlParameter("@userName", userName));
                            com.Parameters.Add(new SqlParameter("@shirt", shirt));
                            com.Parameters.Add(new SqlParameter("@shorts", shorts));
                            com.Parameters.Add(new SqlParameter("@sock", sock));

                            con.Open();

                            com.ExecuteNonQuery();

                            //con.Close();
                        }

                        if (result.ResultDetail == "strips")
                        {
                            finalResult += ("5 " + result.ResultDetail);
                        }
                        else
                        {
                            finalResult += ("a " + result.ResultDetail);
                        }
                    }


                    //Cash Bonus
                    if (result.Result == BingoResultType.Both)
                    {
                        if (player != null)
                        {
                            if (result.ResultDetail == "shirt")
                            {
                                bonusCash =
                                    Convert.ToSingle(Math.Floor(Math.Sqrt(Convert.ToDouble(player.Shirt)) * bonusRate));
                            }
                            else if (result.ResultDetail == "shorts")
                            {
                                bonusCash =
                                    Convert.ToSingle(Math.Floor(Math.Sqrt(Convert.ToDouble(player.Shorts)) * bonusRate));
                            }
                            else if (result.ResultDetail == "sock")
                            {
                                bonusCash =
                                    Convert.ToSingle(Math.Floor(Math.Sqrt(Convert.ToDouble(player.Sock)) * bonusRate));
                            }
                        }
                        else
                        {
                            bonusCash = 0f;
                        }

                        bonusCash += Convert.ToSingle(ConfigGlobal.BingoGetCost) +
                                     Convert.ToSingle(ConfigGlobal.BingoCost);

                        var info = Users.GetUserInfo(userID);
                        info.Extcredits2 += bonusCash;
                        if (AdminUsers.UpdateUserAllInfo(info))
                        {
                            finalResult += (" and Cash(QSB):" + bonusCash);
                        }

                        result.ResultDetail += string.Format("+({0})", bonusCash);
                    }

                    UpdateBingoResultLog(userID, result);
                    return(finalResult);
                }
                catch
                {
                    return("-1");
                }
            }
            return("-1");
        }