示例#1
0
        /// <summary>
        /// 执行GM命令
        /// </summary>
        /// <param name="playerId">玩家编号</param>
        /// <param name="commandText">命令文本</param>
        /// <param name="operateText">操作文本</param>
        /// <param name="needReturn">是否需要返回</param>
        /// <param name="reportProcess">报告处理</param>
        /// <returns>是否成功</returns>
        protected virtual bool ExecuteGmCommand(string playerId, string commandText, string operateText, bool needReturn, Action <string> reportProcess)
        {
            Server server  = Session["Server"] as Server;
            string account = Session["user"] as string;

            return(AGmPage.ExecuteGmCommand(account, server, playerId, commandText, operateText, needReturn, reportProcess));
        }
        /// <summary>
        /// GM命令按钮点击响应
        /// </summary>
        protected void gmButton_Click(object sender, EventArgs e)
        {
            if (this.selectListBox.Items.Count != 1 ||
                string.IsNullOrEmpty(this.selectListBox.Items[0].Value))
            {
                this.errorLabel.Text = TableManager.GetGMTText(720);
                return;
            }

            if (string.IsNullOrEmpty(this.uidTextBox.Text))
            {
                this.errorLabel.Text = TableManager.GetGMTText(721);
                return;
            }

            string account = Session["user"] as string;

            gmt.Server server = gmt.Server.GetServer(this.selectListBox.Items[0].Value);

            uint playerId = this.GetPlayerId(false);

            if (playerId != 0)
            {
                //转大写
                int    starIdx = this.gmTextBox.Text.IndexOfAny("(".ToCharArray());
                string textA   = this.gmTextBox.Text.Substring(0, starIdx);
                string textB   = this.gmTextBox.Text.Substring(starIdx);
                string commond = textA.ToUpper() + textB;

                AGmPage.ExecuteGmCommand(account, server, playerId.ToString(), commond, "", this.needReturn, text => this.errorLabel.Text += text);
            }
        }
        /// <summary>
        /// 跳过新手按钮点击响应
        /// </summary>
        protected void skipNewbieButton_Click(object sender, EventArgs e)
        {
            if (this.selectListBox.Items.Count != 1 ||
                string.IsNullOrEmpty(this.selectListBox.Items[0].Value))
            {
                this.errorLabel.Text = TableManager.GetGMTText(720);
                return;
            }

            if (string.IsNullOrEmpty(this.uidTextBox.Text))
            {
                this.errorLabel.Text = TableManager.GetGMTText(721);
                return;
            }

            string account = Session["user"] as string;

            gmt.Server server = gmt.Server.GetServer(this.selectListBox.Items[0].Value);

            uint playerId = this.GetPlayerId();

            if (playerId != 0)
            {
                AGmPage.ExecuteGmCommand(account, server, playerId.ToString(), string.Format("CO({0},1)", playerId), "", true, text => this.errorLabel.Text += text);
            }
        }
        /// <summary>
        /// 发放单人礼包按钮点击响应
        /// </summary>
        protected void singleGiftButton_Click(object sender, EventArgs e)
        {
            if (this.selectListBox.Items.Count != 1 ||
                string.IsNullOrEmpty(this.selectListBox.Items[0].Value))
            {
                this.errorLabel.Text = TableManager.GetGMTText(720);
                return;
            }

            if (string.IsNullOrEmpty(this.uidTextBox.Text))
            {
                this.errorLabel.Text = TableManager.GetGMTText(721);
                return;
            }

            string account = Session["user"] as string;

            gmt.Server server = gmt.Server.GetServer(this.selectListBox.Items[0].Value);

            int giftId = 0;

            if (!int.TryParse(this.giftOptionDropDownList.SelectedValue, out giftId))
            {
                return;
            }

            uint playerId = this.GetPlayerId();

            if (playerId == 0)
            {
                return;
            }

            string gmcmd = string.Format("GIFT({0},{1})", playerId, giftId);

            bool   isGiftTimeOn = (Request.Form["gift_timer_checker"] == "on") ? true : false;
            string give_time    = this.datetimepicker_1.Value;

            if (isGiftTimeOn)
            {
                STTimedMail stMailInfo = new STTimedMail();
                stMailInfo.uid        = playerId;
                stMailInfo.mailId     = giftId;
                stMailInfo.serverName = this.selectListBox.Items[0].Value;
                stMailInfo.sendTime   = CUtils.GetTimestamp(Convert.ToDateTime(give_time));
                stMailInfo.cmd        = gmcmd;
                TimedMailSender.AddTimedMail(stMailInfo);
            }
            else
            {
                AGmPage.ExecuteGmCommand(account, server, playerId.ToString(), gmcmd, "", true, text => this.errorLabel.Text += text);
            }
        }
示例#5
0
 /// <summary>
 /// 执行GM命令
 /// </summary>
 /// <param name="user">用户</param>
 /// <param name="server">服务器</param>
 /// <param name="commandText">命令文本</param>
 /// <param name="operateText">操作文本</param>
 /// <param name="needReturn">是否需要返回</param>
 /// <param name="reportProcess">报告处理</param>
 /// <returns>是否成功</returns>
 internal static bool ExecuteGmCommand(string user, Server server, string playerId, string commandText, string operateText, bool needReturn, Action <string> reportProcess)
 {
     if (AGmPage.ExecuteGmCommand(server, playerId, Encoding.UTF8.GetBytes(commandText), Encoding.UTF8.GetBytes(operateText), needReturn, reportProcess))
     {
         Log.AddRecord(user, string.Format("{0}\r\n{1}\r\n" + TableManager.GetGMTText(755), server.Name, commandText));
         return(true);
     }
     else
     {
         Log.AddRecord(user, string.Format("{0}\r\n{1}\r\n" + TableManager.GetGMTText(756), server.Name, commandText));
         return(false);
     }
 }
        /// <summary>
        /// 执行GM命令
        /// </summary>
        /// <param name="playerId"></param>
        /// <param name="commandText"></param>
        /// <param name="operateText"></param>
        /// <param name="needReturn"></param>
        /// <param name="reportProcess"></param>
        /// <returns></returns>
        protected override bool ExecuteGmCommand(string playerId, string commandText, string operateText, bool needReturn, Action <string> reportProcess)
        {
            bool   success = true;
            string account = Session["user"] as string;

            gmt.Server keyServer = gmt.Server.GetServerAt(this.OpentimeserverList.SelectedIndex);
            if (keyServer != null)
            {
                success &= AGmPage.ExecuteGmCommand(account, keyServer, "0", commandText, operateText, needReturn, reportProcess);
            }

            return(success);
        }
        /// <summary>
        /// 发送给服务器
        /// </summary>
        /// <param name="output">输出文本</param>
        /// <param name="server">服务器</param>
        /// <param name="sendBuffer">缓冲区</param>
        /// <returns>输出文本</returns>
        private static string Send2Server(string output, gmt.Server server, byte[] sendBuffer)
        {
            output += string.Format(TableManager.GetGMTText(235) + "{0}:", server.Name);
            if (AGmPage.ExecuteGmCommand(server, "0", Encoding.UTF8.GetBytes("3"), sendBuffer, false, null))
            {
                output += TableManager.GetGMTText(755) + "<br />";
            }
            else
            {
                output += TableManager.GetGMTText(756) + "<br />";
            }

            return(output);
        }
        protected void firstChargeResetButton_Click(object sender, EventArgs e)
        {
            if (this.selectListBox.Items.Count == 0)
            {
                this.errorLabel.Text = TableManager.GetGMTText(734);
                return;
            }

            foreach (var item in this.selectListBox.Items)
            {
                gmt.Server server = gmt.Server.GetServer(item.ToString());
                if (server != null)
                {
                    string gmcmd = "RDATE()";
                    AGmPage.ExecuteGmCommand("SYSTEM", server, "0", gmcmd, "", true, null);
                }
            }
        }
        /// <summary>
        /// 发放全员礼包按钮点击响应
        /// </summary>
        protected void wholeGiftButton_Click(object sender, EventArgs e)
        {
            int giftId = 0;

            if (!int.TryParse(this.giftOptionDropDownList.SelectedValue, out giftId))
            {
                return;
            }

            uint playerId = 0;

            bool   isGiftTimeOn = (Request.Form["gift_timer_checker"] == "on") ? true : false;
            string give_time    = this.datetimepicker_1.Value;
            string gmcmd        = string.Format("GIFT({0},{1})", playerId, giftId);

            string account = Session["user"] as string;

            for (int i = 0; i < selectListBox.Items.Count; ++i)
            {
                gmt.Server server = gmt.Server.GetServer(selectListBox.Items[i].Text);
                if (server == null)
                {
                    this.errorLabel.Text += TableManager.GetGMTText(733) + ":" + selectListBox.Items[i].Text;
                    continue;
                }

                if (isGiftTimeOn)
                {
                    STTimedMail stMailInfo = new STTimedMail();
                    stMailInfo.uid        = playerId;
                    stMailInfo.mailId     = giftId;
                    stMailInfo.serverName = selectListBox.Items[i].Text;
                    stMailInfo.sendTime   = CUtils.GetTimestamp(Convert.ToDateTime(give_time));
                    stMailInfo.cmd        = gmcmd;
                    TimedMailSender.AddTimedMail(stMailInfo);
                }
                else
                {
                    AGmPage.ExecuteGmCommand(account, server, playerId.ToString(), gmcmd, "", true, text => this.errorLabel.Text += text);
                }
            }
        }
        protected void delItemButton_Click(object sender, EventArgs e)
        {
            if (this.selectListBox.Items.Count != 1 ||
                string.IsNullOrEmpty(this.selectListBox.Items[0].Value))
            {
                this.errorLabel.Text = TableManager.GetGMTText(720);
                return;
            }

            if (string.IsNullOrEmpty(this.uidTextBox.Text))
            {
                this.errorLabel.Text = TableManager.GetGMTText(721);
                return;
            }

            gmt.Server server = gmt.Server.GetServer(this.selectListBox.Items[0].Value);

            uint playerId = this.GetPlayerId();
            int  count    = 0;

            string gmCommand = string.Empty;

            if (!int.TryParse(this.itemDelCountTextBox.Text, out count) || count == 0)
            {
                this.errorLabel.Text = TableManager.GetGMTText(732);
                return;
            }

            if (playerId != 0)
            {
                this.needReturn = true;
                int type = GetRwdID4DelItemIdx(this.itemDelTypeDropDownList.SelectedIndex);
                if (type == -1)
                {
                    return;
                }
                gmCommand = string.Format("DI({0},{1},{2})", type, this.itemDelOptionDropDownList.SelectedItem.Value, count);
                string account = Session["user"] as string;
                AGmPage.ExecuteGmCommand(account, server, playerId.ToString(), gmCommand, "", true, text => this.errorLabel.Text += text);
            }
        }
        /// <summary>
        /// 关服按钮点击响应
        /// </summary>
        protected void shutdownButton_Click(object sender, EventArgs e)
        {
            if (selectListBox.Items.Count == 0)
            {
                this.errorLabel.Text = TableManager.GetGMTText(720);
            }

            string account = Session["user"] as string;

            for (int i = 0; i < selectListBox.Items.Count; ++i)
            {
                gmt.Server server = gmt.Server.GetServer(selectListBox.Items[i].Text);
                if (server == null)
                {
                    this.errorLabel.Text += TableManager.GetGMTText(733) + ":" + selectListBox.Items[i].Text;
                    continue;
                }

                AGmPage.ExecuteGmCommand(account, server, "0", "SDN()", "", true, text => this.errorLabel.Text += text);
            }
        }
        /// <summary>
        /// 执行GM命令
        /// </summary>
        /// <param name="playerId">玩家编号</param>
        /// <param name="commandText">命令文本</param>
        /// <param name="operateText">操作文本</param>
        /// <param name="needReturn">是否需要返回</param>
        /// <param name="reportProcess">报告处理</param>
        /// <returns>是否成功</returns>
        protected override bool ExecuteGmCommand(string playerId, string commandText, string operateText, bool needReturn, Action <string> reportProcess)
        {
            if (this.selectListBox.Items.Count == 0)
            {
                this.errorLabel.Text = TableManager.GetGMTText(740);
                return(false);
            }

            bool   success = true;
            string account = Session["user"] as string;

            foreach (var item in this.selectListBox.Items)
            {
                gmt.Server server = gmt.Server.GetServer(item.ToString());

                if (server != null)
                {
                    success &= AGmPage.ExecuteGmCommand(account, server, playerId, commandText, operateText, needReturn, reportProcess);
                }
            }

            return(success);
        }
        private static bool _SendMail(STTimedMail stMail)
        {
            Server server = Server.GetServer(stMail.serverName);

            return(AGmPage.ExecuteGmCommand("SYSTEM", server, "0", stMail.cmd, "", true, null));
        }
        /// <summary>
        /// 确认发放按钮点击响应
        /// </summary>
        protected void givePropButton_Click(object sender, EventArgs e)
        {
            if (this.selectListBox.Items.Count != 1 ||
                string.IsNullOrEmpty(this.selectListBox.Items[0].Value))
            {
                this.errorLabel.Text = TableManager.GetGMTText(720);
                return;
            }

            if (string.IsNullOrEmpty(this.uidTextBox.Text))
            {
                this.errorLabel.Text = TableManager.GetGMTText(721);
                return;
            }

            gmt.Server server = gmt.Server.GetServer(this.selectListBox.Items[0].Value);

            uint playerId = this.GetPlayerId();
            int  count    = 0;

            string gmCommand = string.Empty;

            if (!int.TryParse(this.itemGiveCountTextBox.Text, out count) || count == 0)
            {
                this.errorLabel.Text = TableManager.GetGMTText(732);
                return;
            }

            if (playerId != 0)
            {
                this.needReturn = true;
                switch (this.itemGiveTypeDropDownList.SelectedIndex)
                {
                // 0 经济类型
                case 0:
                    gmCommand = string.Format("AM({0},{1})", this.itemGiveOptionDropDownList.SelectedItem.Value, count);
                    break;

                // 1 物品
                case 1:
                    gmCommand = string.Format("NI({0},{1})", this.itemGiveOptionDropDownList.SelectedItem.Value, count);
                    break;

                // 2 武魂
                case 2:
                    gmCommand = string.Format("NHS({0},{1})", this.itemGiveOptionDropDownList.SelectedItem.Value, count);
                    break;

                // 3 饰品
                case 3:
                    gmCommand = string.Format("NS({0})", this.itemGiveOptionDropDownList.SelectedItem.Value);
                    break;

                // 4 晶石
                case 4:
                    gmCommand = string.Format("NPS({0},{1})", this.itemGiveOptionDropDownList.SelectedItem.Value, count);
                    break;

                // 5 坐骑碎片
                case 5:
                    gmCommand = string.Format("NMC({0},{1})", this.itemGiveOptionDropDownList.SelectedItem.Value, count);
                    break;

                // 6 武将
                case 6:
                    gmCommand = string.Format("NH({0})", this.itemGiveOptionDropDownList.SelectedItem.Value);
                    break;

                // 7 经验
                case 7:
                {
                    int nTeamExp = 0, nHeroExp = 0;
                    if (this.itemGiveOptionDropDownList.SelectedIndex == 0)
                    {
                        nTeamExp = count;
                    }
                    else
                    {
                        nHeroExp = count;
                    }

                    gmCommand = string.Format("ATE({0},{1})", nTeamExp, nHeroExp);
                }
                break;

                // 8 宠物
                case 8:
                    gmCommand = string.Format("NP({0})", this.itemGiveOptionDropDownList.SelectedItem.Value);
                    break;

                // 9 坐骑
                case 9:
                    gmCommand = string.Format("NM({0})", this.itemGiveOptionDropDownList.SelectedItem.Value);
                    break;
                }

                string account = Session["user"] as string;
                AGmPage.ExecuteGmCommand(account, server, playerId.ToString(), gmCommand, "", true, text => this.errorLabel.Text += text);
            }
        }