コード例 #1
0
ファイル: ManageClub.aspx.cs プロジェクト: kimch2/Arsenalcn
        protected void LoadPageData()
        {
            var club = ClubLogic.GetClubInfo(ClubID);

            if (club != null)
            {
                // Current User must be the manager of this club or Administrator
                if (club.ManagerUid.Value.Equals(userid) || ConfigAdmin.IsPluginAdmin(userid))
                {
                    pnlInaccessible.Visible = false;
                    phContent.Visible       = true;

                    //Init Form
                    ltrlClubName.Text        = club.FullName;
                    ltrlClubManagerName.Text = club.ManagerUserName;
                    ltrlFullName.Text        = club.FullName;
                    ltrlShortName.Text       = club.ShortName;

                    if (club.IsAppliable.Value)
                    {
                        rblAppliable.SelectedValue = "true";
                    }
                    else
                    {
                        rblAppliable.SelectedValue = "false";
                    }

                    tbManager.Text = club.ManagerUserName;

                    if (club.RankLevel == 0)
                    {
                        phExecutor.Visible = false;
                    }
                    else
                    {
                        phExecutor.Visible = true;

                        var users = ClubLogic.GetClubLeads(ClubID);
                        var sbEx  = new StringBuilder();
                        foreach (var user in users)
                        {
                            if (user.Responsibility.Value == (int)Responsibility.Executor)
                            {
                                sbEx.AppendFormat("{0}|", user.UserName);
                            }
                        }

                        if (sbEx.Length != 0)
                        {
                            sbEx.Remove(sbEx.Length - 1, 1);
                        }

                        tbExecutor.Text = sbEx.ToString();
                    }

                    tbSlogan.Text = club.Slogan;
                    tbDesc.Text   = club.Description;

                    if (club.LogoName != string.Empty)
                    {
                        ltrlLogo.Visible = true;
                        ltrlLogo.Text    =
                            string.Format(
                                "<a href=\"{0}\" target=\"_blank\" title=\"点击放大\"><img src=\"{0}\" width=\"24\" height=\"24\" alt=\"点击放大\" /></a>",
                                "UploadFiles/" + club.LogoName);
                    }
                    else
                    {
                        ltrlLogo.Visible = false;
                    }
                }
                else
                {
                    pnlInaccessible.Visible = true;
                    phContent.Visible       = false;
                }
            }
            else
            {
                pnlInaccessible.Visible = true;
                phContent.Visible       = false;
            }
        }
コード例 #2
0
ファイル: ManageClub.aspx.cs プロジェクト: kimch2/Arsenalcn
        protected void linkButtonSave_Click(object sender, EventArgs e)
        {
            if (fuLogo.PostedFile.ContentLength != 0)
            {
                var logoName = fuLogo.FileName;

                if (logoName.ToLower().LastIndexOf(".gif") != logoName.Length - 4 &&
                    logoName.ToLower().LastIndexOf(".jpg") != logoName.Length - 4 &&
                    logoName.ToLower().LastIndexOf(".png") != logoName.Length - 4)
                {
                    //invalid logo file
                    var invalidAlert = "alert('请上传扩展名为gif,jpg或png的文件!');";
                    ClientScript.RegisterClientScriptBlock(typeof(string), "invalid_logo_file", invalidAlert, true);

                    LoadPageData();

                    return;
                }

                if (fuLogo.FileBytes.LongLength > 100 * 1024)
                {
                    var fileLengthAlert = "alert('请上传小于100K的文件!');";
                    ClientScript.RegisterClientScriptBlock(typeof(string), "file_too_large", fileLengthAlert, true);

                    LoadPageData();

                    return;
                }
            }

            //validate assignment
            var club = ClubLogic.GetClubInfo(ClubID);

            //check manager
            if (tbManager.Text != club.ManagerUserName)
            {
                //check new manager existance in discuz
                if (Users.GetUserId(tbManager.Text) <= 0)
                {
                    //alert
                    var script = "alert('会长用户在系统中不存在!');";
                    ClientScript.RegisterClientScriptBlock(typeof(string), "user_not_exist", script, true);

                    LoadPageData();

                    return;
                }

                var managerID = Users.GetUserId(tbManager.Text);
                //check if the new manager is a member of the club, if not, alert
                if (ClubLogic.GetActiveUserClub(managerID, ClubID) == null)
                {
                    var script = "alert('新会长必须为该球会成员!');";
                    ClientScript.RegisterClientScriptBlock(typeof(string), "user_not_member", script, true);

                    LoadPageData();

                    return;
                }
            }

            //check executor
            if (tbExecutor.Text == string.Empty)
            {
                //change current executor to normal member
                var users = ClubLogic.GetClubLeads(ClubID);
                foreach (var userClub in users)
                {
                    if (userClub.Responsibility == (int)Responsibility.Executor)
                    {
                        //save no executor
                        UserClubLogic.ChangeResponsibility(userClub.Userid.Value, userClub.UserName, ClubID,
                                                           Responsibility.Member, username);
                    }
                }
            }
            else
            {
                //check each executor existance
                var executors = tbExecutor.Text.Split('|');

                //check club max executor count
                if (executors.Length > ClubLogic.GetClubExecutorQuota(ClubID))
                {
                    //alert
                    var script = "alert('干事数超过限额!');";
                    ClientScript.RegisterClientScriptBlock(typeof(string), "executor_count_exceed", script, true);

                    LoadPageData();

                    return;
                }

                foreach (var executor in executors)
                {
                    var executorName = executor.Trim();

                    if (executorName == club.ManagerUserName)
                    {
                        //alert
                        var script = "alert('干事不能为该球会会长!');";
                        ClientScript.RegisterClientScriptBlock(typeof(string), "user_not_manager", script, true);

                        LoadPageData();

                        return;
                    }

                    if (Users.GetUserId(executorName) <= 0)
                    {
                        //alert
                        var script = "alert('干事用户在系统中不存在!');";
                        ClientScript.RegisterClientScriptBlock(typeof(string), "user_not_exist", script, true);

                        LoadPageData();

                        return;
                    }

                    var executorID = Users.GetUserId(executorName);

                    if (ClubLogic.GetActiveUserClub(executorID, ClubID) == null)
                    {
                        var script = "alert('干事必须为该球会成员!');";
                        ClientScript.RegisterClientScriptBlock(typeof(string), "user_not_member", script, true);

                        LoadPageData();

                        return;
                    }
                }

                var leaders = ClubLogic.GetClubLeads(ClubID);

                //save executor
                foreach (var executor in executors)
                {
                    var executorName = executor.Trim();
                    var executorID   = Users.GetUserId(executorName);

                    if (leaders.Exists(delegate(UserClub uc) { return(uc.Userid == executorID); }))
                    {
                        // current executor has been an executor already
                    }
                    else
                    {
                        UserClubLogic.ChangeResponsibility(executorID, executorName, ClubID, Responsibility.Executor,
                                                           username);
                    }
                }

                foreach (var leader in leaders)
                {
                    if (leader.Responsibility.Value != (int)Responsibility.Manager)
                    {
                        if (Array.Exists(executors, delegate(string executor) { return(executor == leader.UserName); }))
                        {
                            //current leader is in the new leader list
                        }
                        else
                        {
                            UserClubLogic.ChangeResponsibility(leader.Userid.Value, leader.UserName, ClubID,
                                                               Responsibility.Member, username);
                        }
                    }
                }
            }

            //update info
            ClubLogic.UpdateClubInfo(ClubID, fuLogo.PostedFile, tbSlogan.Text, tbDesc.Text,
                                     bool.Parse(rblAppliable.SelectedValue), null);

            var scriptSaved = "alert('信息已保存');";

            ClientScript.RegisterClientScriptBlock(typeof(string), "saved", scriptSaved, true);

            LoadPageData();
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (userid == -1)
            {
                pnlFuncLink.Visible = false;

                ltrlToolBarTip.Text = "<strong>欢迎进入,请在<a href=\"/login.aspx\" target=\"_self\">登录</a>后使用全部功能</strong>";
            }
            else
            {
                pnlFuncLink.Visible = true;

                var myClubs = ClubLogic.GetActiveUserClubs(userid);

                var leftCount = ConfigGlobal.SingleUserMaxClubCount - myClubs.Count;

                if (leftCount < 0)
                {
                    leftCount = 0;
                }

                ltrlToolBarTip.Text = $"<strong>提醒:您还可以加入<em>{leftCount}</em>个球会</strong>";

                if (ConfigAdmin.IsPluginAdmin(userid))
                {
                    phAdministrator.Visible = true;
                }
                else
                {
                    phAdministrator.Visible = false;
                }
            }

            //lucky player

            if (ConfigGlobal.LuckyPlayerActive)
            {
                phLuckPlayer.Visible = true;

                ltrlBonus.Text = LuckyPlayer.CalcTotalBonus().ToString();

                var luckyPlayerID = ConfigGlobal.LuckyPlayerID;

                var player = PlayerStrip.GetPlayerInfoByPlayerID(luckyPlayerID);
                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; }));
                });

                if (DateTime.Now.Hour < ConfigGlobal.LuckyPlayerDeadline)
                {
                    IsLuckyPlayerLeader = false;
                }

                if (player != null)
                {
                    ltrlLuckyPlayerName.Text = player.UserName;

                    if ((player.UserID != userid && !IsLuckyPlayerLeader) || (userid == -1))
                    {
                        if (ConfigGlobal.LuckyPlayerBonusGot)
                        {
                            btnGetBonus.Visible = true;
                            btnGetBonus.Enabled = false;
                            btnGetBonus.Text    = "已领取";
                        }
                        else
                        {
                            btnGetBonus.Visible = false;
                        }
                    }
                    else if (!ConfigGlobal.LuckyPlayerBonusGot)
                    {
                        btnGetBonus.Visible = true;
                        if ((player.UserID != userid) && IsLuckyPlayerLeader)
                        {
                            btnGetBonus.Text = "请代领";
                        }
                    }
                    else
                    {
                        btnGetBonus.Visible = true;
                        btnGetBonus.Enabled = false;
                        btnGetBonus.Text    = "已领取";
                    }
                }
                else
                {
                    btnGetBonus.Visible = false;
                }
            }
            else
            {
                phLuckPlayer.Visible = false;
            }
        }
コード例 #4
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);
        }
コード例 #5
0
        //#region ICallbackEventHandler Members

        //public string GetCallbackResult()
        //{
        //    if (_clubID > 0 && _clientStatus >= 0)
        //    {
        //        UserClubStatus uct = (UserClubStatus)_clientStatus;
        //        UserClubStatus resultStatus = UserClubStatus.No;

        //        if ((int)ClubLogic.GetUserClubStatus(this.userid, _clubID) == _clientStatus)
        //        {
        //            //action = apply, check if club appliable flag
        //            if (uct == UserClubStatus.No)
        //            {
        //                Arsenalcn.ClubSys.Entity.Club club = ClubLogic.GetClubInfo(_clubID);
        //                if (club != null)
        //                {
        //                    if (!club.IsAppliable.Value)
        //                    {
        //                        return "Not Appliable";
        //                    }
        //                }
        //                else
        //                {
        //                    return string.Empty;
        //                }
        //            }

        //            if (UserClubLogic.UserClubAction(this.userid, this.username, _clubID, uct))
        //            {
        //                switch (uct)
        //                {
        //                    case UserClubStatus.Applied:
        //                        resultStatus = UserClubStatus.No;
        //                        break;
        //                    case UserClubStatus.Member:
        //                        resultStatus = UserClubStatus.No;
        //                        break;
        //                    case UserClubStatus.No:
        //                        resultStatus = UserClubStatus.Applied;
        //                        break;
        //                    default:
        //                        break;
        //                }

        //                return string.Format("{0};{1}", _clubID, (int)resultStatus);
        //            }
        //            else
        //                return string.Empty;
        //        }
        //        else
        //            return string.Empty;
        //    }
        //    else
        //        return string.Empty;
        //}

        //private int _clubID = -1;
        //private int _clientStatus = -1;
        //public void RaiseCallbackEvent(string eventArgument)
        //{
        //    string[] param = eventArgument.Split(';');

        //    if (param.Length == 2)
        //    {
        //        _clubID = int.Parse(param[0]);
        //        _clientStatus = int.Parse(param[1]);
        //    }
        //}

        //#endregion

        protected void gvClubList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var club = (Club)e.Row.DataItem;

                var count = ClubLogic.GetClubMembers(club.ID.Value).Count;

                var ltrlMemberCount = e.Row.FindControl("ltrlMemberCount") as Literal;
                ltrlMemberCount.Text = count.ToString();

                var ltrlClubLogo = e.Row.FindControl("ltrlClubLogo") as Literal;
                var ltrlClubName = e.Row.FindControl("ltrlClubName") as Literal;
                var ltrlClubRank = e.Row.FindControl("ltrlClubRank") as Literal;

                var ltrlActionText = e.Row.FindControl("ltrlActionText") as Literal;
                var ltrlStatus     = e.Row.FindControl("ltrlStatus") as Literal;
                //Literal ltrlButtonDisplay = e.Row.FindControl("ltrlButtonDisplay") as Literal;
                var ltrlIsAppliable = e.Row.FindControl("ltrlIsAppliable") as Literal;

                var ltrlEquipmentCount = e.Row.FindControl("ltrlEquipmentCount") as Literal;

                ltrlClubLogo.Text =
                    string.Format(
                        "<a href=\"ClubView.aspx?ClubID={0}\" title=\"{2}\"><img src=\"UploadFiles/{1}\" alt=\"{2}\" width=\"80\" height=\"80\" /></a>",
                        club.ID, club.LogoName, club.FullName);
                ltrlClubName.Text =
                    $"<a href=\"ClubView.aspx?ClubID={club.ID}\" class=\"StrongLink\" title=\"{HttpUtility.HtmlEncode(club.Slogan).Replace("'", "\"")}\">{club.FullName}</a>";
                ltrlClubRank.Text =
                    $"<a href=\"ClubRank.aspx?ClubID={club.ID}\" class=\"StrongLink\">RPos:{club.RankScore}</a><div class=\"ClubSys_Rank\" style=\"width: {(club.RankLevel*20)}px;\"></div>";

                ltrlEquipmentCount.Text =
                    $"<em title=\"卡片数C|视频数V(今日库存)\">{PlayerStrip.GetClubMemberCardCount(club.ID.Value)}|{PlayerStrip.GetClubMemberVideoCount(club.ID.Value)}({PlayerStrip.GetClubRemainingEquipment(club.ID.Value)})</em>";

                if (!club.IsAppliable.Value)
                {
                    ltrlIsAppliable.Visible = true;
                }
                else
                {
                    ltrlIsAppliable.Visible = false;
                }

                if (ConfigGlobal.ChampionsClubID > 0 && club.ID == ConfigGlobal.ChampionsClubID)
                {
                    ltrlClubName.Text =
                        $"<div class=\"ClubSys_Crown\" title=\"{ConfigGlobal.ChampionsTitle}\"></div><div>{ltrlClubName.Text}</div>";
                }

                //if (userid == -1 || club.ManagerUid == userid)
                //{
                //    ltrlButtonDisplay.Text = "none";
                //}
                //else
                //{
                //    ltrlButtonDisplay.Text = "inline";
                //}

                // the count of clubs which current user has joined exceed max quota, hide join action
                //if (ClubLogic.GetActiveUserClubs(userid).Count >= Config.SingleUserMaxClubCount && uct != UserClubStatus.Member)
                //{
                //    ltrlButtonDisplay.Text = "none";
                //}

                //hide join btn if club is set to not appliable to join
                //if (uct == UserClubStatus.No && (!club.IsAppliable.Value || count >= ClubLogic.GetClubMemberQuota(club.ID.Value)))
                //{
                //    ltrlButtonDisplay.Text = "none";
                //}

                //ltrlStatus.Text = ((int)uct).ToString();

                //switch (uct)
                //{
                //    case UserClubStatus.Applied:
                //        ltrlActionText.Text = "取消申请";
                //        break;
                //    case UserClubStatus.Member:
                //        ltrlActionText.Text = "退出球会";
                //        break;
                //    case UserClubStatus.No:
                //        ltrlActionText.Text = "申请加入";
                //        break;
                //    default:
                //        ltrlActionText.Text = "申请加入";
                //        break;
                //}

                var rptLeader = e.Row.FindControl("rptClubLeads") as Repeater;
                if (rptLeader != null)
                {
                    var uc = ClubLogic.GetClubLeads(club.ID.Value);

                    foreach (var userClub in uc)
                    {
                        userClub.AdditionalData = ClubLogic.TranslateResponsibility(userClub.Responsibility.Value);

                        //temp usage of username for li class
                        if (userClub.Responsibility.Value == (int)Responsibility.Manager)
                        {
                            userClub.AdditionalData2 = " class=\"Manager\"";
                        }
                        else
                        {
                            userClub.AdditionalData2 = string.Empty;
                        }
                    }

                    rptLeader.DataSource = uc;
                    rptLeader.DataBind();
                }
            }
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region SetControlProperty

            ctrlLeftPanel.UserID   = userid;
            ctrlLeftPanel.UserName = username;
            ctrlLeftPanel.UserKey  = userkey;

            ctrlFieldToolBar.UserID   = userid;
            ctrlFieldToolBar.UserName = username;

            ctrlMenuTabBar.CurrentMenu = ClubMenuItem.ClubInfo;
            ctrlMenuTabBar.ClubID      = ClubID;

            ctrlClubSysHeader.UserID   = userid;
            ctrlClubSysHeader.ClubID   = ClubID;
            ctrlClubSysHeader.UserName = username;

            #endregion

            var currentClub = ClubLogic.GetClubInfo(ClubID);

            if (currentClub != null && Title.IndexOf("{0}", StringComparison.Ordinal) >= 0)
            {
                Title = string.Format(Title, currentClub.FullName);
            }

            if (currentClub != null)
            {
                ltrlShortName.Text   = currentClub.ShortName;
                ltrlCreatorName.Text =
                    $"<a href=\"MyPlayerProfile.aspx?userid={currentClub.CreatorUid.Value}\" target = \"_blank\" >{currentClub.CreatorUserName}</ a >";
                //ltrlCreatorUid.Text = currentClub.CreatorUid.Value.ToString();

                ltrlSlogan.Text        = HttpUtility.HtmlEncode(currentClub.Slogan);
                ltrlFortune.Text       = Convert.ToInt32(currentClub.Fortune).ToString("N0");
                ltrlMemberCredit.Text  = Convert.ToInt32(currentClub.MemberCredit).ToString("N0");
                ltrlMemberFortune.Text = Convert.ToInt32(currentClub.MemberFortune).ToString("N0");
                //ltrlEquipmentCount.Text = Convert.ToInt32(PlayerStrip.GetClubMemberEquipmentCount(currentClub.ID.Value)).ToString("N0");
                ltrlEquipmentCount.Text =
                    $"C:{PlayerStrip.GetClubMemberCardCount(currentClub.ID.Value)} | V:{PlayerStrip.GetClubMemberVideoCount(currentClub.ID.Value)}";
                ltrlCreateDate.Text   = currentClub.CreateDate.ToString("yyyy年MM月dd日");
                ltrlDays.Text         = (DateTime.Now - currentClub.CreateDate).Days.ToString();
                ltrlMemeberCount.Text = ClubLogic.GetClubMemberCount(ClubID).ToString();
                ltrlMemberQuota.Text  = ClubLogic.GetClubMemberQuota(ClubID).ToString();

                if (currentClub.IsAppliable.Value)
                {
                    ltrlAppliable.Text = "开放中";
                }
                else
                {
                    ltrlAppliable.Text = "已关闭";
                }

                var uc = ClubLogic.GetClubLeads(ClubID);

                foreach (var userClub in uc)
                {
                    userClub.AdditionalData = ClubLogic.TranslateResponsibility(userClub.Responsibility.Value);

                    //temp usage of username for li class
                    if (userClub.Responsibility.Value == (int)Responsibility.Manager)
                    {
                        userClub.AdditionalData2 = " class=\"Manager\"";
                    }
                    else
                    {
                        userClub.AdditionalData2 = string.Empty;
                    }
                }

                rptClubLeads.DataSource = uc;
                rptClubLeads.DataBind();
            }
        }