/// <summary> /// 页面载入响应 /// </summary> protected override void OnGmPageLoad() { if (!this.IsPostBack) { this.versionTextBox.Text = GmNormal.Version; this.statusDropDownList.Items.Add(TableManager.GetGMTText(341)); this.statusDropDownList.Items.Add(TableManager.GetGMTText(342)); this.statusDropDownList.Items.Add(TableManager.GetGMTText(343)); this.statusDropDownList.Items.Add(TableManager.GetGMTText(344)); for (int i = 0; i < ServerListConfig.DataList.Count; ++i) { string name = ServerListConfig.DataList[i].Name; this.channelListBox.Items.Add(new ListItem(name, name)); } if (this.channelListBox.Items.Count > 0) { this.channelListBox.SelectedIndex = 0; } this.UpdateServerList(); } this.outputLabel.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> public static void itemGiveOptionDisplay(ref DropDownList typeDropList, ref DropDownList dropList, ref TextBox txtBox) { dropList.Items.Clear(); txtBox.Enabled = true; int type = int.Parse(typeDropList.SelectedValue); switch (type) { // 0 经济类型 case 0: // 1 物品 case 1: // 2 武魂 case 2: // 3 饰品 case 3: // 4 晶石 case 4: // 5 坐骑碎片 case 5: itemDelOptionDisplay(ref typeDropList, ref dropList, ref txtBox); break; // 6 武将 case 6: { itemDelOptionDisplay(ref typeDropList, ref dropList, ref txtBox); txtBox.Text = "1"; txtBox.Enabled = false; } break; // 7 经验 case 7: { dropList.Items.Add(TableManager.GetGMTText(338)); dropList.Items.Add(TableManager.GetGMTText(339)); } break; // 8 宠物 case 8: { foreach (var pair in TableManager.PetTable) { string text = TextManager.GetText(pair.Value.name) + "[" + pair.Value.petstar + " STAR]" + "(" + pair.Value.idx + ")"; dropList.Items.Add(new ListItem(text, pair.Value.idx.ToString())); } } break; // 9 坐骑 case 9: { itemDelOptionDisplay(ref typeDropList, ref dropList, ref txtBox); txtBox.Text = "1"; txtBox.Enabled = false; } break; } }
//移除白名单 protected void WhiteNameRemoveButton_Click(object sender, EventArgs e) { if (this.WhiteNameListBox.SelectedIndex < 0) { this.reportLabel.Text = TableManager.GetGMTText(878); return; } this.WhiteNameListBox.Items.RemoveAt(this.WhiteNameListBox.SelectedIndex); this.reportLabel.Text = TableManager.GetGMTText(879); }
/// <summary> /// 玩家移除按钮点击响应 /// </summary> protected void playerRemoveButton_Click(object sender, EventArgs e) { if (this.playerListBox.SelectedIndex < 0) { this.reportLabel.Text = TableManager.GetGMTText(661); return; } this.playerListBox.Items.RemoveAt(this.playerListBox.SelectedIndex); }
protected void gmButton_Click(object sender, EventArgs e) { List <string> uidList = new List <string>(this.playerListBox.Items.Count); foreach (var item in this.playerListBox.Items) { uidList.Add(item.ToString()); } if (uidList.Count == 0) { this.reportLabel.Text = TableManager.GetGMTText(667); return; } this.reportLabel.Text = ""; //转大写 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; string[] uidArr = uidList.ToArray(); if (uidList.Count != 0) { StringBuilder uidBuilder = new StringBuilder(); for (int i = 0; i < uidArr.Length; i += 100) { int end = Math.Min(i + 100, uidArr.Length); for (int j = i; j < end; ++j) { if (j != i) { uidBuilder.Append(","); } uidBuilder.Append(uidArr[j]); } } string[] uidSet = uidBuilder.ToString().Split(','); HashSet <string> uidCheck = new HashSet <string>(); foreach (var uid in uidSet) { if (!string.IsNullOrEmpty(uid) && !uidCheck.Contains(uid)) { this.ExecuteGmCommand(uid, commond, "", true, text => this.reportLabel.Text += text); uidCheck.Add(uid); } } } }
/// <summary> /// 确认玩家按钮点击响应 /// </summary> protected void ensureButton_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; } StringBuilder builder = new StringBuilder(); gmt.Server server = gmt.Server.GetServer(this.selectListBox.Items[0].Value); builder.Append(server.Name).Append("<br>"); string sql = ""; if (!string.IsNullOrEmpty(this.uidTextBox.Text)) { sql = string.Format("SELECT `uname`,`uid`,`cyuid` FROM `user` WHERE `uid`='{0}';", DatabaseAssistant.DetectionSql(this.uidTextBox.Text)); } DatabaseAssistant.Execute(reader => { bool finded = false; while (reader.Read()) { finded = true; builder.Append(TableManager.GetGMTText(9) + "(").Append(reader.GetString(0)); this.playerNameLabel.Text = reader.GetString(0); builder.Append(") " + TableManager.GetGMTText(722) + "(").Append(reader.GetUInt32(1)); builder.Append(") " + TableManager.GetGMTText(48) + "(").Append(reader.GetString(2)).Append(")<br>"); } if (!finded) { builder.Append(TableManager.GetGMTText(674) + "<br>"); } }, server.DatabaseAddress, server.DatabasePort, server.DatabaseCharSet, server.GameDatabase, server.DatabaseUserId, server.DatabasePassword, sql); //显示玩家信息 //this.playerNameLabel.Text = builder.ToString(); }
/// <summary> /// 发送走马灯 /// </summary> /// <param name="user">用户</param> /// <param name="server">服务器</param> /// <param name="content">走马灯内容</param> /// <param name="reportProcess">报告处理</param> /// <returns>是否成功</returns> public static bool SendCommand(string user, Server server, string content, Action <string> reportProcess) { HttpWebRequest request = null; HttpWebResponse respone = null; try { request = WebRequest.Create(server.GmAddress) as HttpWebRequest; request.Headers["svr"] = server.Id; request.Headers["uid"] = "0"; request.Headers["cmd"] = Convert.ToBase64String(Encoding.UTF8.GetBytes(content)); request.Timeout = 1000; respone = request.GetResponse() as HttpWebResponse; if (reportProcess != null) { using (StreamReader reader = new StreamReader(respone.GetResponseStream())) { string text = reader.ReadToEnd(); if (text != null && text != "") { reportProcess(text); } else { reportProcess(TableManager.GetGMTText(391)); } } } Log.AddRecord(user, string.Format("{0}\r\n{1}\r\n成功", server.Name, content)); return(true); } catch (Exception exception) { DatabaseAssistant.ReportException(exception); Log.AddRecord(user, string.Format("{0}\r\n{1}\r\n失败", server.Name, content)); return(false); } finally { if (request != null) { request.Abort(); } if (respone != null) { respone.Close(); } } }
//是否全服 protected void AllServerCheckBox_CheckedChanged1(object sender, EventArgs e) { if (this.AllServerCheckBox.Checked == true) { this.reportLabel.Text = TableManager.GetGMTText(880); } if (this.AllServerCheckBox.Checked == false) { this.reportLabel.Text = TableManager.GetGMTText(881); } }
/// <summary> /// 发送按钮点击响应 /// </summary> protected void sendButton_Click(object sender, EventArgs e) { if (GiftTable.GiftListEx == null) { this.outputLabel.Text = TableManager.GetGMTText(701); return; } this.outputLabel.Text = TableManager.Send(GiftTable.GiftListEx); this.outputLabel.Text += TableManager.Send(TextManager.GetConfigList()); }
//是否强制单选按钮 protected void ForceUpdateCheckBox_CheckedChanged(object sender, EventArgs e) { if (this.CheckBox1.Checked == true) { this.reportLabel.Text = TableManager.GetGMTText(869); } if (this.CheckBox1.Checked == false) { this.reportLabel.Text = TableManager.GetGMTText(874); } //this.ExecuteGmCommand("0", string.Format("NC({0})", 5040), "", false, text => this.reportLabel .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); } }
/// <summary> /// 保存 /// </summary> public void Save() { string noticestring = this.Noticetxt.Text; string filePath = HttpRuntime.AppDomainAppPath + "NoticeList.txt"; FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite); StreamWriter sw = new StreamWriter(fs); fs.SetLength(0); sw.Write(noticestring); sw.Close(); this.OutputLable.Text = TableManager.GetGMTText(823); }
protected void sendtableButton_Click(object sender, EventArgs e) { GiftManager.addgiftconfig = GiftTable.GiftListEx; if (TableManager.SendTable(VersionIDText.Text)) { this.outputLabel.Text = TableManager.GetGMTText(658); } else { this.outputLabel.Text = TableManager.GetLastError(); } }
/// <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> /// 添加按钮点击响应 /// </summary> protected void addButton_Click(object sender, EventArgs e) { if (this.CurrentServerList != null) { string config = this.GetConfig(); this.CurrentServerList.Add(config, this.visibleCheckBox.Checked); if (!this.visibleCheckBox.Checked) { config += ("," + TableManager.GetGMTText(400) + ""); } ServerListConfig.Save(); this.serverListBox.Items.Add(new ListItem(config, this.idTextBox.Text)); } }
/// <summary> /// 发送按钮点击响应 /// </summary> protected void sendButton_Click(object sender, EventArgs e) { /*if (string.IsNullOrEmpty(FTP.Site)) * { * this.outputLabel.Text = "FTP还没有配置"; * return; * } * * FTP ftp = new FTP(); * * string version; * if (string.IsNullOrEmpty(this.versionTextBox.Text)) * { * version = ""; * } * else * { * version = this.versionTextBox.Text + "/"; * ftp.MakeDirectory(this.versionTextBox.Text); * } * * StringBuilder builder = new StringBuilder(); * foreach (var data in ServerListConfig.DataList) * { * foreach (var channel in data.ChannelList) * { * builder.Append("channel:"); * string text = "#编号 #服务器名 #IP # 端口 #状态 #是否推荐 #大区ID #服务器名称ID;\r\n" + data.ServerList.GetText(); * if (ftp.Upload(version + "ServerList." + channel + ".txt", Encoding.UTF8.GetBytes(text))) * { * builder.Append("成功<br>"); * } * else * { * builder.Append("失败<br>"); * } * } * } * * this.outputLabel.Text = builder.ToString();*/ if (FTPManager.Upload("ServerList_" + ServerListConfig.DataList[0].Name + ".zip", CdnZip.PackServerList(this.versionTextBox.Text))) { this.outputLabel.Text = TableManager.GetGMTText(405); } else { this.outputLabel.Text = TableManager.GetGMTText(404); } }
/// <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); }
/// <summary> /// 礼包添加按钮点击响应 /// </summary> protected void giftAddButton_Click(object sender, EventArgs e) { if (this.giftDropDownList.Items == null) { this.reportLabel.Text = TableManager.GetGMTText(662); return; } if (this.giftListBox.Items.Count >= 5) { this.reportLabel.Text = "Only support 5 mails"; return; } this.giftListBox.Items.Add(this.giftDropDownList.SelectedItem); }
/// <summary> /// 打包服务器列表 /// </summary> /// <param name="version">版本</param> /// <returns>Zip包缓冲区</returns> public static byte[] PackServerList(string version) { using (MemoryStream memory = new MemoryStream()) { using (ZipOutputStream stream = new ZipOutputStream(memory)) { byte[] buffer = null; // 服务器列表 if (!string.IsNullOrEmpty(version) && version[version.Length - 1] != '/') { version = version + '/'; } foreach (var data in ServerListConfig.DataList) { foreach (var channel in data.ChannelList) { string text = string.Format("#{0} #{1} #{2} #{3} #{4} #{5} #{6} #{7} #{8};\r\n" , TableManager.GetGMTText(203) , TableManager.GetGMTText(204) , TableManager.GetGMTText(205) , TableManager.GetGMTText(206) , TableManager.GetGMTText(207) , TableManager.GetGMTText(401) , TableManager.GetGMTText(402) , TableManager.GetGMTText(403) , TableManager.GetGMTText(910)) + data.ServerList.GetText() + data.Name; ZipEntry entry = new ZipEntry("android/ServerList/" + version + "ServerList." + channel + ".txt"); stream.PutNextEntry(entry); buffer = Encoding.UTF8.GetBytes(text); stream.Write(buffer, 0, buffer.Length); } } stream.CloseEntry(); stream.Finish(); byte[] zipBuffer = new byte[memory.Length]; Array.Copy(memory.GetBuffer(), zipBuffer, zipBuffer.Length); return(zipBuffer); } } }
/// <summary> /// 页面载入响应 /// </summary> protected override void OnGmPageLoad() { string path = HttpRuntime.AppDomainAppPath + "log"; if (!Directory.Exists(path)) { this.Response.Write(TableManager.GetGMTText(700)); return; } string[] files = Directory.GetFileSystemEntries(path); using (var memory = new MemoryStream()) { using (ZipOutputStream stream = new ZipOutputStream(memory)) { foreach (var file in files) { if (File.Exists(file)) { using (var fileStream = File.OpenRead(file)) { byte[] buffer = new byte[fileStream.Length]; fileStream.Read(buffer, 0, buffer.Length); string fileText = file.Replace('\\', '/'); fileText = fileText.Substring(fileText.LastIndexOf('/') + 1); stream.PutNextEntry(new ZipEntry(fileText)); stream.Write(buffer, 0, buffer.Length); } } } stream.CloseEntry(); stream.Finish(); byte[] zipBuffer = new byte[memory.Length]; Array.Copy(memory.GetBuffer(), zipBuffer, zipBuffer.Length); Response.ContentType = "application/x-msdownload"; string filename = "attachment; filename=" + "log.zip"; Response.AddHeader("Content-Disposition", filename); Response.BinaryWrite(zipBuffer); } } }
/// <summary> /// 修改按钮点击响应 /// </summary> protected void modifyButton_Click(object sender, EventArgs e) { if (this.serverListBox.SelectedIndex < 0) { return; } if (this.CurrentServerList != null) { string config = this.GetConfig(); this.CurrentServerList.Modify(config, this.visibleCheckBox.Checked, this.serverListBox.SelectedIndex); if (!this.visibleCheckBox.Checked) { config += ("," + TableManager.GetGMTText(400) + ""); } this.serverListBox.Items[this.serverListBox.SelectedIndex].Text = config; } }
/// <summary> /// 确认设置按钮点击响应 /// </summary> protected void ActivityOpenButton_Click(object sender, EventArgs e) { gmt.Server keyServer = gmt.Server.GetServerAt(this.OpentimeserverList.SelectedIndex); string[] date = this.expiryDateTextBox.Text.Split('/'); if (keyServer != null) { if (this.ExecuteGmCommand("0", string.Format("ODATE({0},{1},{2})", date[0], date[1], date[2]), "", true, text => { this.reportLabel.Text = text; })) { UpdateActivityOpenTimeListBox(); } } else { this.reportLabel.Text = TableManager.GetGMTText(423); } }
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> private string GetPlayerStatus(uint playerId) { for (int i = 0; i < Ban.banList.Count; i++) { if (playerId == Ban.banList[i]) { return("<b style='color:red'>" + TableManager.GetGMTText(53) + "</b>"); } } for (int i = 0; i < ShutUp.shutupList.Count; i++) { if (playerId == ShutUp.shutupList[i]) { return("<b style='color:orange'>" + TableManager.GetGMTText(51) + "</b>"); } } return("<b style='color:green'>" + TableManager.GetGMTText(747) + "</b>"); }
/// <summary> /// 更新服务器列表 /// </summary> private void UpdateServerList() { ServerList list = this.CurrentServerList; this.serverListBox.Items.Clear(); if (list != null) { for (int i = 0; i < list.Count; ++i) { ServerConfig config = list.GetServerConfig(i); string text = config.Text; if (!config.Visible) { text += ("," + TableManager.GetGMTText(400) + ""); } this.serverListBox.Items.Add(text); } } }
/// <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); } }
private void showServerStatus() { if (gmt.ServerListConfig.DataList != null && this.selectListBox.Items.Count == 1 ) { string serverText = gmt.ServerListConfig.DataList[int.Parse(selectListBox.Items[0].Value)].ServerList.GetText(); string[] serverValue = serverText.Split(','); int index; if (serverValue != null && serverValue.Length >= 4) { if (int.TryParse(serverValue[4], out index) && index >= 0 && index < serverStatus.Count) { this.serverStatusLabel.Text = serverStatus[index]; return; } } } this.serverStatusLabel.Text = TableManager.GetGMTText(719); }
/// <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); } }