コード例 #1
0
        /// <summary>
        /// 创建文件夹
        /// </summary>
        /// <param name="directory">文件夹</param>
        public void MakeDirectory(string directory)
        {
            FtpWebRequest  request  = null;
            FtpWebResponse response = null;

            try
            {
                request             = FtpWebRequest.Create(ftpSite + directory) as FtpWebRequest;
                request.Credentials = new NetworkCredential(ftpUser, ftpPassword);
                request.KeepAlive   = false;
                request.Method      = WebRequestMethods.Ftp.MakeDirectory;

                response = request.GetResponse() as FtpWebResponse;
            }

            catch (Exception exception)
            {
                DatabaseAssistant.ReportException(exception);
            }

            finally
            {
                if (request != null)
                {
                    request.Abort();
                }
                if (response != null)
                {
                    response.Close();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 合服按钮点击响应
        /// </summary>
        protected void mergeButton_Click(object sender, EventArgs e)
        {
            if (this.fromDropDownList.SelectedIndex == this.toDropDownList.SelectedIndex)
            {
                this.outputLabel.Text = TableManager.GetGMTText(754);
                return;
            }

            gmt.Server fromServer = gmt.Server.GetServerAt(this.fromDropDownList.SelectedIndex);
            gmt.Server toServer   = gmt.Server.GetServerAt(this.toDropDownList.SelectedIndex);

            if (DatabaseAssistant.Execute
                (
                    fromServer.DatabaseAddress,
                    fromServer.DatabasePort,
                    fromServer.DatabaseCharSet,
                    fromServer.GameDatabase,
                    fromServer.DatabaseUserId,
                    fromServer.DatabasePassword,
                    "CALL `xp_mix_data`('{0}',{1});", toServer.GameDatabase, fromServer.Id.Split('-')[1]
                ))
            {
                this.outputLabel.Text = TableManager.GetGMTText(755);
            }
            else
            {
                this.outputLabel.Text = TableManager.GetGMTText(756);
            }
        }
コード例 #3
0
        /// <summary>
        /// 执行SQL文本
        /// </summary>
        /// <param name="resultProcess">执行结果处理</param>
        /// <param name="address">地址</param>
        /// <param name="port">端口</param>
        /// <param name="charSet">字符集</param>
        /// <param name="database">数据库</param>
        /// <param name="userId">用户</param>
        /// <param name="password">密码</param>
        /// <param name="sqlText">SQL文本</param>
        /// <param name="parameter">参数</param>
        /// <returns>是否成功</returns>
        public static bool Execute(Action <MySql.Data.MySqlClient.MySqlDataReader> resultProcess, string address, string port, string charSet, string database, string userId, string password, string sqlText, params object[] parameter)
        {
            return(DatabaseAssistant.DoExecute
                   (
                       () =>
            {
                MySql.Data.MySqlClient.MySqlDataReader reader = command.ExecuteReader();
                int n = reader.FieldCount;

                try
                {
                    resultProcess(reader);
                }

                catch (Exception exception)
                {
                    DatabaseAssistant.ReportException(exception);
                }

                reader.Close();
            },
                       string.Format(DatabaseAssistant.ConnectionText, address, port, charSet, database, userId, password),
                       sqlText,
                       parameter
                   ));
        }
コード例 #4
0
        /// <summary>
        /// 更新用户数据
        /// </summary>
        /// <param name="account">账号</param>
        /// <param name="user">用户数据</param>
        /// <param name="updateType">更新类型</param>
        /// <returns></returns>
        private static bool UpdateUserDataFromDB(string account, UserInfo user, UpdateType updateType)
        {
            string sqlex = "";

            if ((updateType & UpdateType.Account) == UpdateType.Account)
            {
                sqlex = string.Format(@"{0}{1} account='{2}'", sqlex, string.IsNullOrEmpty(sqlex) ? "" : ",", user.account);
            }
            if ((updateType & UpdateType.Password) == UpdateType.Password)
            {
                sqlex = string.Format(@"{0}{1} password='******'", sqlex, string.IsNullOrEmpty(sqlex) ? "" : ",", user.password);
            }
            if ((updateType & UpdateType.Privilege) == UpdateType.Privilege)
            {
                sqlex = string.Format(@"{0}{1} privilege={2}", sqlex, string.IsNullOrEmpty(sqlex) ? "" : ",", (int)user.privilege);
            }
            if ((updateType & UpdateType.State) == UpdateType.State)
            {
                sqlex = string.Format(@"{0}{1} state={2}", sqlex, string.IsNullOrEmpty(sqlex) ? "" : ",", (int)user.state);
            }
            if ((updateType & UpdateType.Language) == UpdateType.Language)
            {
                sqlex = string.Format(@"{0}{1} language='{2}'", sqlex, string.IsNullOrEmpty(sqlex) ? "" : ",", user.language);
            }
            string sql = string.Format(@"UPDATE tb_user SET {0} WHERE account='{1}'", sqlex, account);

            if (!DatabaseAssistant.Execute(Global.GMT_DB_Address, Global.GMT_DB_Port, Global.GMT_DB_Charset, Global.GMT_DB_Name, Global.GMT_DB_User, Global.GMT_DB_Pwd, sql))
            {
                Log.AddLog(string.Format(@"Error: mysql update failed. sql: {0}", sql));
                return(false);
            }
            return(true);
        }
コード例 #5
0
 /// <summary>
 /// 执行SQL文本
 /// </summary>
 /// <param name="address">地址</param>
 /// <param name="port">端口</param>
 /// <param name="charSet">字符集</param>
 /// <param name="database">数据库</param>
 /// <param name="userId">用户</param>
 /// <param name="password">密码</param>
 /// <param name="sqlText">SQL文本</param>
 /// <param name="parameter">参数</param>
 /// <returns>是否成功</returns>
 public static bool Execute(string address, string port, string charSet, string database, string userId, string password, string sqlText, params object[] parameter)
 {
     return(DatabaseAssistant.DoExecute
            (
                () => { command.ExecuteNonQuery(); },
                string.Format(DatabaseAssistant.ConnectionText, address, port, charSet, database, userId, password),
                sqlText,
                parameter
            ));
 }
コード例 #6
0
        /// <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();
        }
コード例 #7
0
        /// <summary>
        /// 从数据库删除用户数据
        /// </summary>
        /// <param name="account">用户名</param>
        /// <returns></returns>
        private static bool DeleteUserFromDB(string account)
        {
            string sql = string.Format(@"DELETE FROM tb_user WHERE account='{0}'", account);

            if (!DatabaseAssistant.Execute(Global.GMT_DB_Address, Global.GMT_DB_Port, Global.GMT_DB_Charset, Global.GMT_DB_Name, Global.GMT_DB_User, Global.GMT_DB_Pwd, sql))
            {
                Log.AddLog(string.Format(@"Error: mysql delete failed. sql: {0}", sql));
                return(false);
            }
            return(true);
        }
コード例 #8
0
        /// <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();
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// 保存用户数据到数据库
        /// </summary>
        /// <param name="user">用户数据</param>
        /// <returns></returns>
        private static bool InsertUserDataToDB(UserInfo user)
        {
            string sql = string.Format(@"INSERT INTO tb_user (account, password, privilege, state, language) VALUES ('{0}', '{1}', {2}, {3}, '{4}')", user.account, user.password, (int)user.privilege, (int)user.state, user.language);

            if (!DatabaseAssistant.Execute(Global.GMT_DB_Address, Global.GMT_DB_Port, Global.GMT_DB_Charset, Global.GMT_DB_Name, Global.GMT_DB_User, Global.GMT_DB_Pwd, sql))
            {
                Log.AddLog(string.Format(@"Error: mysql insert failed. sql: {0}", sql));
                return(false);
            }
            return(true);
        }
コード例 #10
0
        internal static bool ExecuteGmCommand(STServerInfo server, string playerId, byte[] command, byte[] operate, bool needReturn, Action <string> reportProcess)
        {
            if (server == null)
            {
                return(false);
            }

            HttpWebRequest  request = null;
            HttpWebResponse respone = null;

            try
            {
                request                = WebRequest.Create(server.authGMHttp) as HttpWebRequest;
                request.KeepAlive      = false;
                request.Headers["svr"] = server.svrID;
                request.Headers["uid"] = playerId;
                request.Headers["cmd"] = Convert.ToBase64String(command);
                request.Headers["opt"] = Convert.ToBase64String(operate);
                request.Timeout        = 4000;

                respone = request.GetResponse() as HttpWebResponse;
                if (needReturn && reportProcess != null)
                {
                    using (StreamReader reader = new StreamReader(respone.GetResponseStream()))
                    {
                        reportProcess(reader.ReadToEnd());
                    }
                }
                return(true);
            }

            catch (Exception exception)
            {
                DatabaseAssistant.ReportException(exception);
                if (reportProcess != null)
                {
                    reportProcess(exception.Message + "\n");
                }
                return(false);
            }

            finally
            {
                if (request != null)
                {
                    request.Abort();
                }
                if (respone != null)
                {
                    respone.Close();
                }
            }
        }
コード例 #11
0
        public static string QueryTotalCost(string filter)
        {
            string sqlCondi = "";

            if (queryInfo.start_time == null || queryInfo.end_time == null)
            {
                sqlCondi = string.Format(" last_update_time between '{0}' and '{1}'"
                                         , queryInfo.start_time.ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss")
                                         , queryInfo.end_time.ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss")
                                         );
            }

            if (queryInfo.playerId != 0)
            {
                sqlCondi += " and uid = " + queryInfo.playerId;
            }

            if (!string.IsNullOrEmpty(filter))
            {
                sqlCondi += GetFilterStringByJson(filter);
            }

            string sql = string.Format("SELECT orderID FROM receipt where 1 {0}", sqlCondi);

            UInt64 totalCost = 0;

            gmt.Server server = gmt.Server.GetServerAt(0);
            DatabaseAssistant.Execute(reader =>
            {
                while (reader.Read())
                {
                    string orderInfo    = reader.GetString(0);
                    string[] orderArray = orderInfo.Split(',');

                    mw.RmbShopConfig config = null;
                    string index            = string.Format("{0}-{1}", orderArray[1], orderArray[4]);
                    TableManager.RmbShopTable.TryGetValue(index, out config);
                    int cost   = (null == config) ? config.rmb_cost : 0;
                    totalCost += (uint)cost;
                }
            },
                                      server.BillDatabaseAddress,
                                      server.BillDatabasePort,
                                      server.BillDatabaseCharSet,
                                      server.BillDatabase,
                                      server.BillDatabaseUserId,
                                      server.BillDatabasePassword,
                                      sql);

            return(string.Format(@"{{ ""totalCost"": {0} }}", totalCost));
        }
コード例 #12
0
        /// <summary>
        /// 上传
        /// </summary>
        /// <param name="file">文件名</param>
        /// <param name="buffer">缓冲区</param>
        /// <returns>是否成功</returns>
        public bool Upload(string file, byte[] buffer)
        {
            FtpWebRequest request = null;
            Stream        stream  = null;

            try
            {
                request               = FtpWebRequest.Create(ftpSite + file) as FtpWebRequest;
                request.Credentials   = new NetworkCredential(ftpUser, ftpPassword);
                request.KeepAlive     = false;
                request.Method        = WebRequestMethods.Ftp.UploadFile;
                request.UseBinary     = true;
                request.ContentLength = FTP.WriteLength;

                stream = request.GetRequestStream();

                for (int i = 0; i < buffer.Length; i += FTP.WriteLength)
                {
                    stream.Write
                    (
                        buffer,
                        i,
                        Math.Min(FTP.WriteLength, buffer.Length - i)
                    );
                }

                stream.Close();
                stream = null;

                return(true);
            }

            catch (Exception exception)
            {
                DatabaseAssistant.ReportException(exception);
                return(false);
            }

            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
                if (request != null)
                {
                    request.Abort();
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// 获取服务器开服活动时间
        /// </summary>
        public static bool GetActivityOpenTime(gmt.Server server, out STDateInfo stInfo)
        {
            mw.GS_SVR_DATE_INFO svrDateInfo = null;

            #region 从数据库读取信息
            DatabaseAssistant.Execute(
                reader =>
            {
                if (reader.Read())
                {
                    int nIdx = 0;
                    if (!reader.IsDBNull(nIdx))
                    {
                        long size = reader.GetBytes(nIdx, 0, null, 0, int.MaxValue);
                        if (0 != size)
                        {
                            byte[] dateBuffer = new byte[size];
                            reader.GetBytes(nIdx, 0, dateBuffer, 0, dateBuffer.Length);
                            using (MemoryStream stream = new MemoryStream(dateBuffer))
                            {
                                svrDateInfo = ProtoSerializer.Instance.Deserialize(stream, null, typeof(mw.GS_SVR_DATE_INFO)) as mw.GS_SVR_DATE_INFO;
                            }
                        }
                    }
                }
            },
                server.DatabaseAddress,
                server.DatabasePort,
                server.DatabaseCharSet,
                server.GameDatabase,
                server.DatabaseUserId,
                server.DatabasePassword,
                "SELECT `svr_date_data` FROM `global`;"
                );
            #endregion

            stInfo = new STDateInfo();
            if (null != svrDateInfo)
            {
                stInfo.openDate  = svrDateInfo.openDate;
                stInfo.curSDate  = svrDateInfo.signDate;
                stInfo.nextSDate = svrDateInfo.singReset;
                stInfo.rmbDate   = svrDateInfo.rmbDate;
                return(true);
            }
            return(false);
        }
コード例 #14
0
        /// <summary>
        /// 执行SQL文本
        /// </summary>
        /// <param name="executeProcess">执行处理</param>
        /// <param name="connectionText">连接文本</param>
        /// <param name="sqlText">SQL文本</param>
        /// <param name="parameter">参数</param>
        /// <returns>是否成功</returns>
        private static bool DoExecute(Action executeProcess, string connectionText, string sqlText, params object[] parameter)
        {
            lock (DatabaseAssistant.connection)
            {
                try
                {
                    if (!DatabaseAssistant.IsConnected() || DatabaseAssistant.connection.ConnectionString != connectionText)
                    {
                        if (DatabaseAssistant.IsConnected())
                        {
                            DatabaseAssistant.connection.Close();
                        }
                        DatabaseAssistant.connection.ConnectionString = connectionText;
                        DatabaseAssistant.connection.Open();
                    }

                    DatabaseAssistant.command.CommandText = parameter != null?string.Format(sqlText, parameter) : sqlText;

                    DatabaseAssistant.command.CommandTimeout = 3600;

                    executeProcess();

                    return(true);
                }

                catch (Exception exception)
                {
                    if (DatabaseAssistant.IsConnected())
                    {
                        DatabaseAssistant.ReportException(exception);
                    }

                    return(false);
                }

                finally
                {
                    if (DatabaseAssistant.IsConnected())
                    {
                        DatabaseAssistant.connection.Clone();
                    }
                }
            }
        }
コード例 #15
0
        public static string QueryPlayerCnt(string filter)
        {
            string sqlCondi = "";

            if (queryInfo.start_time == null || queryInfo.end_time == null)
            {
                sqlCondi = string.Format(" last_update_time between '{0}' and '{1}'"
                                         , queryInfo.start_time.ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss")
                                         , queryInfo.end_time.ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss")
                                         );
            }

            if (queryInfo.playerId != 0)
            {
                sqlCondi += " and uid = " + queryInfo.playerId;
            }

            if (!string.IsNullOrEmpty(filter))
            {
                sqlCondi += GetFilterStringByJson(filter);
            }

            string sql = string.Format("SELECT COUNT(DISTINCT(userID)) FROM receipt where 1 {0}", sqlCondi);

            int playerCnt = 0;

            gmt.Server server = gmt.Server.GetServerAt(0);
            DatabaseAssistant.Execute(reader =>
            {
                if (reader.Read())
                {
                    playerCnt = reader.GetInt32(0);
                }
            },
                                      server.BillDatabaseAddress,
                                      server.BillDatabasePort,
                                      server.BillDatabaseCharSet,
                                      server.BillDatabase,
                                      server.BillDatabaseUserId,
                                      server.BillDatabasePassword,
                                      sql);

            return(string.Format(@"{{ ""playerCnt"": {0} }}", playerCnt));
        }
コード例 #16
0
        /// <summary>
        /// 初始化用户字典
        /// </summary>
        private static void InitUserDictionary()
        {
            UserDictionary.Clear();
            string sql = @"SELECT account, password, privilege, state, language From tb_user";

            DatabaseAssistant.Execute(reader =>
            {
                while (reader.Read())
                {
                    UserInfo user  = new UserInfo();
                    user.account   = reader.GetString(0);
                    user.password  = reader.GetString(1);
                    user.privilege = (PrivilegeType)reader.GetInt32(2);
                    SetPrivilegeDictionary(user.privilege, out user.privilegeDic);
                    user.state    = (StateType)reader.GetInt32(3);
                    user.language = reader.GetString(4);
                    UserDictionary.Add(user.account, user);
                }
            }
                                      , Global.GMT_DB_Address
                                      , Global.GMT_DB_Port
                                      , Global.GMT_DB_Charset
                                      , Global.GMT_DB_Name
                                      , Global.GMT_DB_User
                                      , Global.GMT_DB_Pwd
                                      , sql);

            if (!UserDictionary.ContainsKey("admin"))
            {
                UserInfo admin = new UserInfo();
                admin.account  = "admin";
                admin.password = "******";
                foreach (PrivilegeType privilege in Enum.GetValues(typeof(PrivilegeType)))
                {
                    admin.privilege |= privilege;
                }
                SetPrivilegeDictionary(admin.privilege, out admin.privilegeDic);
                admin.state    = StateType.Normal;
                admin.language = "zh-CN";
                UserDictionary.Add(admin.account, admin);
                InsertUserDataToDB(admin);
            }
        }
コード例 #17
0
        /// <summary>
        /// 执行数据库
        /// </summary>
        /// <param name="server">服务器</param>
        /// <param name="fileName">SQL文件名</param>
        /// <returns>是否成功</returns>
        protected bool Execute(gmt.Server server, string fileName)
        {
            string file = HttpRuntime.AppDomainAppPath + fileName;

            if (File.Exists(file))
            {
                using (var reader = File.OpenText(file))
                {
                    return(DatabaseAssistant.Execute
                           (
                               server.DatabaseAddress,
                               server.DatabasePort,
                               server.DatabaseCharSet,
                               server.GameDatabase,
                               server.DatabaseUserId,
                               server.DatabasePassword,
                               reader.ReadToEnd()
                           ));
                }
            }

            return(false);
        }
コード例 #18
0
        protected void rechargeButton_Click(object sender, EventArgs e)
        {
            try
            {
                HttpWebRequest request = WebRequest.Create("http://192.168.1.26:8081/bill") as HttpWebRequest;

                request.Method      = "POST";
                request.ContentType = "application/x-www-form-urlencoded";

                byte[] byteArray = Encoding.UTF8.GetBytes("pushInfo=order:测试orderPushInfo&receipt=eyJhcmVhTmFtZSI6IiAiLCJjaGFubmVsSWQiOiIyMDAxIiwiZ29vZHNOdW1iZXIiOiIxIiwidXNlcmlkIjoiNjkyMDAxMTA0NDQ4NDAxIiwiZ29vZHNQcmljZSI6MjQwMCwicm9sZU5hbWUiOiIgIiwiZ29vZHNSZWdpc3RlcklkIjoiNzU2NzgwMDciLCJhcHBEYXRlIjoiMjAxNTA3MjAxMTMzMzYiLCJvcmRlcklkIjoiMTAwMDAwMDE2NDE2NzMzNiIsImFyZWFJZCI6IjEtMTUtNi0xIiwicm9sZUlkIjoiMTAwMDIifQ%3D%3D&sign=38313c03b8d6e62dc7e879543e183252");
                request.ContentLength = byteArray.Length;
                Stream newStream = request.GetRequestStream();
                newStream.Write(byteArray, 0, byteArray.Length);//写入参数
                newStream.Close();

                HttpWebResponse respone = request.GetResponse() as HttpWebResponse;
                //using (StreamReader reader = new StreamReader(respone.GetResponseStream()))
                //{
                //	string text = reader.ReadToEnd();

                //	if (text != null && text != "")
                //	{
                //		this.errorLabel.Text += text;
                //	}
                //	else
                //	{
                //		this.errorLabel.Text += "返回的是空";
                //	}
                //}
            }

            catch (Exception exception)
            {
                DatabaseAssistant.ReportException(exception);
                this.errorLabel.Text += exception.ToString();
            }
        }
コード例 #19
0
        protected void rechargeButton_Click(object sender, EventArgs e)
        {
            try
            {
                HttpWebRequest request = WebRequest.Create("http://192.168.1.26:8081/bill") as HttpWebRequest;

                request.Method      = "POST";
                request.ContentType = "application/x-www-form-urlencoded";

                byte[] byteArray = Encoding.UTF8.GetBytes("pushInfo=order:测试orderPushInfo&receipt=eyJhcmVhTmFtZSI6IiAiLCJjaGFubmVsSWQiOiIzMDUwIiwiZ29vZHNOdW1iZXIiOiI2MCIsInVzZXJpZCI6IjcxMzA1MDM5Mjg2OCIsImdvb2RzUHJpY2UiOjYsInJvbGVOYW1lIjoiICIsImdvb2RzUmVnaXN0ZXJJZCI6Ijg1Njc4MDAyIiwiYXBwRGF0ZSI6IjIwMTUwNDEzMDE1NzA2Iiwib3JkZXJJZCI6IjE1MDQxMzAxNTYzNzM0MjEyNyIsImFyZWFJZCI6IjUtMS02LTEiLCJyb2xlSWQiOiI0MzM2NiJ9&sign=31153d9089c07d739c6afe3900c93376");
                request.ContentLength = byteArray.Length;
                Stream newStream = request.GetRequestStream();
                newStream.Write(byteArray, 0, byteArray.Length);//写入参数
                newStream.Close();

                HttpWebResponse respone = request.GetResponse() as HttpWebResponse;
                using (StreamReader reader = new StreamReader(respone.GetResponseStream()))
                {
                    string text = reader.ReadToEnd();

                    if (text != null && text != "")
                    {
                        this.errorLabel.Text += text;
                    }
                    else
                    {
                        this.errorLabel.Text += TableManager.GetGMTText(391);
                    }
                }
            }

            catch (Exception exception)
            {
                DatabaseAssistant.ReportException(exception);
                this.errorLabel.Text += exception.ToString();
            }
        }
コード例 #20
0
        /// <summary>
        /// 下载
        /// </summary>
        /// <param name="file">文件名</param>
        /// <returns>缓冲区</returns>
        /// 返回数据长度
        //public int Download(string file, out byte[] buffer)
        //{
        //    buffer = null;
        //    int length = this.FileSize(file);
        //    if (length < 0) { return 0; }

        //    FtpWebRequest	request		= null;
        //    FtpWebResponse	response	= null;
        //    Stream			stream		= null;

        //    try
        //    {
        //        request = FtpWebRequest.Create(ftpSite + file) as FtpWebRequest;
        //        request.Credentials = new NetworkCredential(ftpUser, ftpPassword);
        //        request.KeepAlive = false;
        //        request.Method = WebRequestMethods.Ftp.DownloadFile;
        //        request.UseBinary = true;

        //        response = request.GetResponse() as FtpWebResponse;
        //        stream = response.GetResponseStream();

        //        buffer = new byte[length];
        //        stream.Read(buffer, 0, buffer.Length);

        //        return buffer.Length;
        //    }

        //    catch (Exception exception)
        //    {
        //        DatabaseAssistant.ReportException(exception);
        //        return 0;
        //    }

        //    finally
        //    {
        //        if (stream != null) { stream.Close(); }
        //        if (response != null) { response.Close(); }
        //        if (request != null) { request.Abort(); }
        //    }
        //}

        /// <summary>
        /// 文件尺寸
        /// </summary>
        /// <param name="file">文件名</param>
        /// <returns>尺寸</returns>
        public int FileSize(string file)
        {
            FtpWebRequest  request  = null;
            FtpWebResponse response = null;

            try
            {
                request             = FtpWebRequest.Create(ftpSite + file) as FtpWebRequest;
                request.Credentials = new NetworkCredential(ftpUser, ftpPassword);
                request.KeepAlive   = false;
                request.Method      = WebRequestMethods.Ftp.GetFileSize;
                request.UseBinary   = true;

                response = request.GetResponse() as FtpWebResponse;

                return((int)response.ContentLength);
            }

            catch (Exception exception)
            {
                DatabaseAssistant.ReportException(exception);
                return(-1);
            }

            finally
            {
                if (response != null)
                {
                    response.Close();
                }
                if (request != null)
                {
                    request.Abort();
                }
            }
        }
コード例 #21
0
 /// <summary>
 /// 出现未处理的错误
 /// </summary>
 protected void Application_Error(object sender, EventArgs e)
 {
     DatabaseAssistant.ReportException(Server.GetLastError());
     //Server.ClearError();
 }
コード例 #22
0
        /// <summary>
        /// 生成按钮点击响应
        /// </summary>
        protected void createButton_Click(object sender, EventArgs e)
        {
            this.errorLabel.Text = "";

            if (this.channelList.SelectedIndex < 0)
            {
                return;
            }

            if (this.typeTextBox.Text == null || this.typeTextBox.Text == "")
            {
                return;
            }

            if (this.giftDropDownList.Items == null)
            {
                return;
            }

            int count = 0;

            if (!int.TryParse(this.countTextBox.Text, out count) || count <= 0)
            {
                return;
            }

            //如果使用次数不填,则默认为1
            if (string.IsNullOrEmpty(this.UseTimes.Text))
            {
                this.UseTimes.Text = "1";
            }


            Channel channel = CreateKey.ChannelSet[this.channelList.SelectedIndex];

            gmt.Server keyServer = gmt.Server.GetServerAt(this.serverList.SelectedIndex);

            int selectvalue = 0;

            if (!int.TryParse(this.Mutitimes.SelectedValue, out selectvalue))
            {
                return;
            }

            if (keyServer != null)
            {
                bool error = DatabaseAssistant.Execute
                             (
                    keyServer.CodeDatabaseAddress,
                    keyServer.CodeDatabasePort,
                    keyServer.CodeDatabaseCharSet,
                    keyServer.CodeDatabase,
                    keyServer.CodeDatabaseUserId,
                    keyServer.CodeDatabasePassword,
                    "CALL xp_gift_gen({0}, {1}, {2}, '{3}', {4}, '{5}','{6}','{7}','{8}');",
                    count,
                    10,
                    channel.Id,
                    DatabaseAssistant.DetectionSql(this.typeTextBox.Text),
                    this.giftDropDownList.SelectedValue,
                    channel.GiftChar,
                    ((DateTime)ViewState["expiryDate"]).ToString("yyyy-MM-dd"), int.Parse(this.UseTimes.Text), selectvalue
                             );

                if (!error)
                {
                    this.resultLabel.Text = TableManager.GetGMTText(691);
                    return;
                }

                StringBuilder builder = new StringBuilder(TableManager.GetGMTText(692) + ":");

                DatabaseAssistant.Execute
                (
                    reader => { while (reader.Read())
                                {
                                    builder.Append("<br>").Append(reader.GetString(0));
                                }
                    },
                    keyServer.CodeDatabaseAddress,
                    keyServer.CodeDatabasePort,
                    keyServer.CodeDatabaseCharSet,
                    keyServer.CodeDatabase,
                    keyServer.CodeDatabaseUserId,
                    keyServer.CodeDatabasePassword,
                    "SELECT `gift_code` FROM `gift` ORDER BY `gen_time` DESC LIMIT {0};",
                    count
                );

                this.resultLabel.Text = builder.ToString();
            }
        }
コード例 #23
0
        /// <summary>
        /// 生成按钮点击响应
        /// </summary>
        protected void createButton_Click(object sender, EventArgs e)
        {
            if (this.channelList.SelectedIndex < 0)
            {
                return;
            }

            DateTime expiryDate = (DateTime)ViewState["expiryDate"];

            if (expiryDate <= DateTime.Today)
            {
                return;
            }

            int count = 0;

            if (!int.TryParse(this.countTextBox.Text, out count) || count <= 0)
            {
                return;
            }

            Channel channel = CreateKey.ChannelSet[this.channelList.SelectedIndex];

            gmt.Server keyServer = gmt.Server.GetServerAt(this.serverList.SelectedIndex);

            if (keyServer != null)
            {
                DatabaseAssistant.Execute
                (
                    keyServer.CodeDatabaseAddress,
                    keyServer.CodeDatabasePort,
                    keyServer.CodeDatabaseCharSet,
                    keyServer.CodeDatabase,
                    keyServer.CodeDatabaseUserId,
                    keyServer.CodeDatabasePassword,
                    "CALL xp_active_gen({0}, '{1}', {2}, {3}, {4}, {5});",
                    count,
                    channel.Prefix,
                    channel.NumberCount > 0,
                    channel.CharCount,
                    channel.Id,
                    (int)(expiryDate.Date - DateTime.Today).TotalDays
                );

                StringBuilder builder = new StringBuilder(TableManager.GetGMTText(695) + ":");

                DatabaseAssistant.Execute
                (
                    reader => { while (reader.Read())
                                {
                                    builder.Append("<br>").Append(reader.GetString(0));
                                }
                    },
                    keyServer.CodeDatabaseAddress,
                    keyServer.CodeDatabasePort,
                    keyServer.CodeDatabaseCharSet,
                    keyServer.CodeDatabase,
                    keyServer.CodeDatabaseUserId,
                    keyServer.CodeDatabasePassword,
                    "SELECT `key_code` FROM `active` ORDER BY `gen_time` DESC LIMIT {0};",
                    count
                );

                this.resultLabel.Text = builder.ToString();
            }
        }
コード例 #24
0
        /// <summary>
        /// 获取玩家编号
        /// </summary>
        /// <param name="needReport">是否需要报告</param>
        /// <returns>玩家编号</returns>
        private uint GetPlayerId(bool needReport = true)
        {
            if (this.selectListBox.Items.Count == 0)
            {
                if (needReport)
                {
                    this.errorLabel.Text = TableManager.GetGMTText(740);
                }
                return(0);
            }
            if (this.selectListBox.Items.Count != 1)
            {
                if (needReport)
                {
                    this.errorLabel.Text = TableManager.GetGMTText(748);
                }
                return(0);
            }
            gmt.Server server = gmt.Server.GetServer(this.selectListBox.Items[0].ToString());

            if (server == null)
            {
                if (needReport)
                {
                    this.errorLabel.Text = TableManager.GetGMTText(749);
                }
                return(0);
            }

            uint playerId = 0;

            string sql;

            if (!string.IsNullOrEmpty(this.playerNameTextBox.Text))
            {
                sql = string.Format("SELECT `uid` FROM `user` WHERE `uname`='{0}';", DatabaseAssistant.DetectionSql(this.playerNameTextBox.Text));
            }
            else if (!string.IsNullOrEmpty(this.uidTextBox.Text))
            {
                sql = string.Format("SELECT `uid` FROM `user` WHERE `uid`='{0}';", DatabaseAssistant.DetectionSql(this.uidTextBox.Text));
            }
            else if (!string.IsNullOrEmpty(this.cyidTextBox.Text))
            {
                sql = string.Format("SELECT `uid` FROM `user` WHERE `cyuid`='{0}';", DatabaseAssistant.DetectionSql(this.cyidTextBox.Text));
            }
            else
            {
                this.errorLabel.Text = TableManager.GetGMTText(721);
                return(0);
            }

            DatabaseAssistant.Execute(reader =>
            {
                if (reader.Read())
                {
                    playerId = reader.GetUInt32(0);
                }
            },
                                      server.DatabaseAddress,
                                      server.DatabasePort,
                                      server.DatabaseCharSet,
                                      server.GameDatabase,
                                      server.DatabaseUserId,
                                      server.DatabasePassword,
                                      sql);

            //else if (this.playerChannelIdTextBox.Text != null && this.playerChannelIdTextBox.Text != "")
            //{
            //	DatabaseAssistant.Execute(reader =>
            //	{
            //		if (reader.Read()) { playerId = reader.GetUInt32(0); }
            //	},
            //	server.DatabaseAddress,
            //	server.DatabasePort,
            //	server.DatabaseCharSet,
            //	server.GmAddress,
            //	server.DatabaseUserId,
            //	server.DatabasePassword,
            //	"SELECT `uid` FROM `user` WHERE `cyuid`='{0}';", DatabaseAssistant.DetectionSql(this.playerChannelIdTextBox.Text));
            //}

            if (playerId == 0 && needReport)
            {
                this.errorLabel.Text += TableManager.GetGMTText(737) + "\r\n";
            }

            return(playerId);
        }
コード例 #25
0
        /// <summary>
        /// 查询ID按钮点击响应
        /// </summary>
        protected void findIdButton_Click(object sender, EventArgs e)
        {
            this.idLabel.Text = "";
            if (this.selectListBox.Items.Count == 0)
            {
                this.errorLabel.Text = TableManager.GetGMTText(740);
                return;
            }

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

            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < this.selectListBox.Items.Count; ++i)
            {
                gmt.Server server = gmt.Server.GetServer(this.selectListBox.Items[i].Text);

                builder.Append("<b style='color:orange'>").Append(server.Name).Append("</b><br>");

                string sql;

                if (!string.IsNullOrEmpty(this.playerNameTextBox.Text))
                {
                    sql = string.Format("SELECT `uname`,`uid`,`cyuid` FROM `user` WHERE `uname` LIKE '%{0}%';", DatabaseAssistant.DetectionSql(this.playerNameTextBox.Text));
                }
                else if (!string.IsNullOrEmpty(this.uidTextBox.Text))
                {
                    sql = string.Format("SELECT `uname`,`uid`,`cyuid` FROM `user` WHERE `uid`='{0}';", DatabaseAssistant.DetectionSql(this.uidTextBox.Text));
                }
                else
                {
                    sql = string.Format("SELECT `uname`,`uid`,`cyuid` FROM `user` WHERE `cyuid`='{0}';", DatabaseAssistant.DetectionSql(this.cyidTextBox.Text));
                }

                DatabaseAssistant.Execute(reader =>
                {
                    bool finded = false;
                    while (reader.Read())
                    {
                        finded = true;
                        builder.Append(TableManager.GetGMTText(46) + ":").Append(reader.GetString(0));
                        builder.Append("&#09;" + TableManager.GetGMTText(722) + ":").Append(reader.GetUInt32(1));
                        builder.Append("&#09;" + TableManager.GetGMTText(48) + ":").Append(reader.GetString(2));
                        builder.Append("&#09;" + TableManager.GetGMTText(59) + ":").Append(GetPlayerStatus(reader.GetUInt32(1)));

                        builder.Append("<br>");
                    }

                    if (!finded)
                    {
                        builder.Append(TableManager.GetGMTText(674) + "<br>");
                    }
                },
                                          server.DatabaseAddress,
                                          server.DatabasePort,
                                          server.DatabaseCharSet,
                                          server.GameDatabase,
                                          server.DatabaseUserId,
                                          server.DatabasePassword,
                                          sql);
            }

            this.idLabel.Text = builder.ToString();
        }
コード例 #26
0
        private static int QueryHeroData(int server_id
                                         , int limit
                                         , int offset
                                         , string search
                                         , string sort
                                         , string order
                                         )
        {
            gmt.Server server = gmt.Server.GetServerAt(server_id);

            #region 查询总数
            string sqlCnt = "select count(uid) from heroinfo_ where 1 " + search;

            DatabaseAssistant.Execute(reader =>
            {
                if (reader.Read())
                {
                    queryInfo.resTotal = reader.GetInt32(0);
                }
            },
                                      server.LogDatabaseAddress,
                                      server.LogDatabasePort,
                                      server.LogDatabaseCharSet,
                                      server.LogDatabase,
                                      server.LogDatabaseUserId,
                                      server.LogDatabasePassword,
                                      sqlCnt
                                      );
            #endregion

            if (queryInfo.resTotal != 0)
            {
                string orderSql = "";
                #region 排序
                if (!string.IsNullOrEmpty(sort))
                {
                    if (!string.IsNullOrEmpty(sort))
                    {
                        if (sort == "type_name")
                        {
                            sort = "type";
                        }
                        orderSql = string.Format("order by {0} {1}", sort, order);
                    }
                }
                #endregion

                #region 查找id集合
                string sql = string.Format("SELECT id FROM heroinfo_ where 1 {0} {1} limit {2}, {3}"
                                           , search
                                           , orderSql
                                           , offset
                                           , limit
                                           );

                StringBuilder sbIds = new StringBuilder();
                DatabaseAssistant.Execute(reader =>
                {
                    while (reader.Read())
                    {
                        sbIds.Append(reader.GetString(0));
                        sbIds.Append(",");
                    }

                    if (sbIds.Length != 0)
                    {
                        sbIds.Remove(sbIds.Length - 1, 1);
                    }
                },
                                          server.LogDatabaseAddress,
                                          server.LogDatabasePort,
                                          server.LogDatabaseCharSet,
                                          server.LogDatabase,
                                          server.LogDatabaseUserId,
                                          server.LogDatabasePassword,
                                          sql
                                          );
                #endregion

                #region 根据id集合查找数据
                sql = string.Format("select date, uid, cyuid, channel_id, team_level, type, hero_id, target_id, value_bf, value_af, zdl_bf, zdl_af, team_zdl_bf, team_zdl_af, vip from heroinfo_ where id in ({0}) {1}", sbIds.ToString(), orderSql);
                DatabaseAssistant.Execute(reader =>
                {
                    while (reader.Read())
                    {
                        try
                        {
                            HeroInfoData hero = new HeroInfoData();
                            hero.date         = reader.GetDateTime(0).ToString("yyyy-MM-dd HH:mm:ss");
                            hero.uid          = reader.GetUInt32(1);
                            hero.channel_id   = reader.GetString(3);
                            hero.team_level   = reader.GetInt32(4);
                            hero.type         = reader.GetInt32(5);

                            if (-1 != hero.type)
                            {
                                if (HeroInfoTypeDic.ContainsKey(hero.type))
                                {
                                    hero.type_name = HeroInfoTypeDic[hero.type];
                                }
                                else
                                {
                                    hero.type_name = string.Format("Unknown(type: {0})", hero.type);
                                }
                            }

                            hero.hero_id = reader.GetInt32(6);

                            if (-1 != hero.hero_id)
                            {
                                if (itemNameDic.ContainsKey(hero.hero_id))
                                {
                                    hero.hero_name = itemNameDic[hero.hero_id];
                                }
                                else
                                {
                                    hero.hero_name = string.Format("Unknown(id: {0})", hero.hero_id);
                                }
                            }

                            hero.target_id = reader.GetInt32(7);
                            //if (itemNameDic.ContainsKey(hero.target_id))
                            //{
                            //    hero.target_name = itemNameDic[hero.target_id];
                            //}
                            //else
                            //{
                            //    hero.target_name = string.Format("Unknown(id: {0})", hero.target_id);
                            //}

                            hero.value_bf = reader.GetInt32(8);
                            hero.value_af = reader.GetInt32(9);

                            hero.zdl_bf = reader.GetInt32(10);
                            hero.zdl_af = reader.GetInt32(11);

                            hero.team_zdl_bf = reader.GetInt32(12);
                            hero.team_zdl_af = reader.GetInt32(13);

                            hero.vip = reader.GetInt32(14);

                            heroInfoList.Add(hero);
                        }
                        catch (Exception e)
                        {
                            Log.AddLog(e.ToString());
                        }
                    }
                },
                                          server.LogDatabaseAddress,
                                          server.LogDatabasePort,
                                          server.LogDatabaseCharSet,
                                          server.LogDatabase,
                                          server.LogDatabaseUserId,
                                          server.LogDatabasePassword,
                                          sql);
                #endregion
            }

            return(queryInfo.resTotal);
        }
コード例 #27
0
        private static int QueryItemData(int server_id
                                         , int limit
                                         , int offset
                                         , string search
                                         , string sort
                                         , string order
                                         )
        {
            gmt.Server server = gmt.Server.GetServerAt(server_id);

            #region 查询总数
            string sqlCnt = "select count(uid) from item_ where 1 " + search;

            DatabaseAssistant.Execute(reader =>
            {
                if (reader.Read())
                {
                    queryInfo.resTotal = reader.GetInt32(0);
                }
            },
                                      server.LogDatabaseAddress,
                                      server.LogDatabasePort,
                                      server.LogDatabaseCharSet,
                                      server.LogDatabase,
                                      server.LogDatabaseUserId,
                                      server.LogDatabasePassword,
                                      sqlCnt
                                      );
            #endregion

            if (queryInfo.resTotal != 0)
            {
                string orderSql = "";
                #region 排序
                if (!string.IsNullOrEmpty(sort))
                {
                    if (sort == "item_type_name")
                    {
                        sort = "item_type";
                    }
                    else if (sort == "item_name")
                    {
                        sort = "item_id";
                    }
                    else if (sort == "cause_name")
                    {
                        sort = "causeid";
                    }
                    else if (sort == "total")
                    {
                        sort = "";
                    }

                    if (!string.IsNullOrEmpty(sort))
                    {
                        orderSql = string.Format("order by {0} {1}", sort, order);
                    }
                }
                #endregion

                #region 查找id集合
                string sql = string.Format("SELECT id FROM item_ where 1 {0} {1} limit {2}, {3}"
                                           , search
                                           , orderSql
                                           , offset
                                           , limit
                                           );

                StringBuilder sbIds = new StringBuilder();
                DatabaseAssistant.Execute(reader =>
                {
                    while (reader.Read())
                    {
                        sbIds.Append(reader.GetString(0));
                        sbIds.Append(",");
                    }

                    if (sbIds.Length != 0)
                    {
                        sbIds.Remove(sbIds.Length - 1, 1);
                    }
                },
                                          server.LogDatabaseAddress,
                                          server.LogDatabasePort,
                                          server.LogDatabaseCharSet,
                                          server.LogDatabase,
                                          server.LogDatabaseUserId,
                                          server.LogDatabasePassword,
                                          sql
                                          );
                #endregion

                #region 根据id集合查找数据
                sql = string.Format("select date, uid, cyuid, channel_id, team_level, item_type, item_id, causeid, quantity, vip, action from item_ where id in ({0}) {1}", sbIds.ToString(), orderSql);
                DatabaseAssistant.Execute(reader =>
                {
                    while (reader.Read())
                    {
                        try
                        {
                            ItemData item   = new ItemData();
                            item.date       = reader.GetDateTime(0).ToString("yyyy-MM-dd HH:mm:ss");
                            item.uid        = reader.GetUInt32(1);
                            item.channel_id = reader.GetString(3);
                            item.team_level = reader.GetInt32(4);
                            item.item_type  = reader.GetInt32(5);

                            if (typeNameDic.ContainsKey(item.item_type))
                            {
                                item.item_type_name = typeNameDic[item.item_type];
                            }
                            else
                            {
                                item.item_type_name = string.Format("Unknown(type: {0})", item.item_type);
                            }

                            item.item_id = reader.GetInt32(6);

                            if (itemNameDic.ContainsKey(item.item_id))
                            {
                                item.item_name = itemNameDic[item.item_id];
                            }
                            else
                            {
                                item.item_name = string.Format("Unknown(id: {0})", item.item_id);
                            }

                            item.causeid = reader.GetInt32(7);

                            item.total = -1;

                            if (item.causeid < causeNameList.Count)
                            {
                                item.cause_name = causeNameList[item.causeid];
                            }
                            else
                            {
                                item.cause_name = string.Format("Unknown(id: {0})", item.causeid);
                            }

                            item.quantity = reader.GetInt32(8);
                            item.vip      = reader.GetInt32(9);
                            item.action   = reader.GetInt32(10);
                            itemList.Add(item);
                        }
                        catch (Exception e)
                        {
                            Log.AddLog(e.ToString());
                        }
                    }
                },
                                          server.LogDatabaseAddress,
                                          server.LogDatabasePort,
                                          server.LogDatabaseCharSet,
                                          server.LogDatabase,
                                          server.LogDatabaseUserId,
                                          server.LogDatabasePassword,
                                          sql);
                #endregion
            }
            return(queryInfo.resTotal);
        }
コード例 #28
0
        protected void btn_swap_openid_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;
            }

            uint uid_1 = 0;

            uint.TryParse(Request.Form["input_swap_uid_1"].ToString(), out uid_1);
            uint uid_2 = 0;

            uint.TryParse(Request.Form["input_swap_uid_2"].ToString(), out uid_2);

            if (0 == uid_1)
            {
                this.errorLabel.Text = "uid_1 Cannot be null or 0";
            }

            if (0 == uid_2)
            {
                this.errorLabel.Text = "uid_2 Cannot be null or 0";
            }

            string device_id_1 = "", device_id_2 = "";
            string open_id_1 = "", open_id_2 = "";
            string cyuid_1 = "", cyuid_2 = "";

            gmt.Server server = gmt.Server.GetServer(this.selectListBox.Items[0].Value);
            string     sql    = string.Format("SELECT t.uid, device_id, open_id, t.cyuid FROM sglogindb_kr.`tb_user_info` a RIGHT JOIN (SELECT uid, cyuid FROM USER WHERE uid IN ({0}, {1}))t ON a.cyuid = t.cyuid;", uid_1, uid_2);

            DatabaseAssistant.Execute(reader =>
            {
                while (reader.Read())
                {
                    if (reader.GetInt32(0) == uid_1)
                    {
                        device_id_1 = reader.GetString(1);
                        open_id_1   = reader.GetString(2);
                        cyuid_1     = reader.GetString(3);
                    }

                    if (reader.GetInt32(0) == uid_2)
                    {
                        device_id_2 = reader.GetString(1);
                        open_id_2   = reader.GetString(2);
                        cyuid_2     = reader.GetString(3);
                    }
                }
            },
                                      server.DatabaseAddress,
                                      server.DatabasePort,
                                      server.DatabaseCharSet,
                                      server.GameDatabase,
                                      server.DatabaseUserId,
                                      server.DatabasePassword,
                                      sql);

            if (string.IsNullOrEmpty(device_id_1))
            {
                this.errorLabel.Text = "cannot find player! uid: " + uid_1;
                return;
            }

            if (string.IsNullOrEmpty(device_id_2))
            {
                this.errorLabel.Text = "cannot find player! uid: " + uid_2;
                return;
            }

            //if (device_id_1 != device_id_2)
            //{
            //    this.errorLabel.Text = "device id is not the same!";
            //    return;
            //}

            sql = string.Format("update sglogindb_kr.tb_user_info set open_id = '{0}' where cyuid = '{1}'", open_id_2, cyuid_1);
            DatabaseAssistant.Execute(reader =>
            {
            },
                                      server.DatabaseAddress,
                                      server.DatabasePort,
                                      server.DatabaseCharSet,
                                      server.GameDatabase,
                                      server.DatabaseUserId,
                                      server.DatabasePassword,
                                      sql);

            sql = string.Format("update sglogindb_kr.tb_user_info set open_id = '{0}' where cyuid = '{1}'", open_id_1, cyuid_2);
            DatabaseAssistant.Execute(reader =>
            {
            },
                                      server.DatabaseAddress,
                                      server.DatabasePort,
                                      server.DatabaseCharSet,
                                      server.GameDatabase,
                                      server.DatabaseUserId,
                                      server.DatabasePassword,
                                      sql);

            this.errorLabel.Text = "SWAP SUCCESS!";
        }
コード例 #29
0
        public static string UpdatePlayerRechargeTableData(int limit
                                                           , int offset
                                                           , string sort
                                                           , string order
                                                           , string filter
                                                           )
        {
            #region 数据库查询语句拼接
            string sqlCondi = "";

            if (queryInfo.start_time != new DateTime(0))
            {
                sqlCondi = string.Format(" last_update_time >= '{0}'", queryInfo.start_time.ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss"));
            }

            if (queryInfo.end_time != new DateTime(0))
            {
                sqlCondi = string.Format(" and last_update_time <= '{0}'", queryInfo.end_time.ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss"));
            }

            if (queryInfo.playerId != 0)
            {
                sqlCondi += " and userID = " + queryInfo.playerId;
            }

            if (!string.IsNullOrEmpty(filter))
            {
                sqlCondi += GetFilterStringByJson(filter);
            }
            #endregion

            int totalRows = 0;
            List <PlayerRechargeInfo> rechargeList = new List <PlayerRechargeInfo>();

            #region 查询目标总数
            gmt.Server server = gmt.Server.GetServerAt(0);
            string     sql    = string.Format("SELECT COUNT(state) FROM receipt where 1 {0}", sqlCondi);
            DatabaseAssistant.Execute(reader =>
            {
                if (reader.Read())
                {
                    totalRows = reader.GetInt32(0);
                }
            },
                                      server.BillDatabaseAddress,
                                      server.BillDatabasePort,
                                      server.BillDatabaseCharSet,
                                      server.BillDatabase,
                                      server.BillDatabaseUserId,
                                      server.BillDatabasePassword,
                                      sql);
            #endregion

            if (totalRows != 0)
            {
                string sql_order = "";
                #region 排序
                if (!string.IsNullOrEmpty(sort))
                {
                    sql_order = string.Format("ORDER BY {0} {1}", sort, order);
                }

                #endregion

                StringBuilder sbIds = new StringBuilder();
                #region 查询id集合
                sql = string.Format("select id from receipt where 1 {0} {1} limit {2}, {3}"
                                    , sqlCondi
                                    , sql_order
                                    , offset
                                    , limit
                                    );

                DatabaseAssistant.Execute(reader =>
                {
                    while (reader.Read())
                    {
                        sbIds.Append(reader.GetString(0));
                        sbIds.Append(",");
                    }

                    if (sbIds.Length != 0)
                    {
                        sbIds.Remove(sbIds.Length - 1, 1);
                    }
                },
                                          server.BillDatabaseAddress,
                                          server.BillDatabasePort,
                                          server.BillDatabaseCharSet,
                                          server.BillDatabase,
                                          server.BillDatabaseUserId,
                                          server.BillDatabasePassword,
                                          sql
                                          );

                #endregion

                #region 根据id集合查询结果

                sql = string.Format("SELECT orderID, state, plat_order_id, raw_type, last_update_time FROM receipt where id in ({0}) {1}"
                                    , sbIds.ToString()
                                    , sql_order);

                DatabaseAssistant.Execute(reader =>
                {
                    while (reader.Read())
                    {
                        PlayerRechargeInfo prInfo = new PlayerRechargeInfo();

                        string orderInfo    = reader.GetString(0);
                        string[] orderArray = orderInfo.Split(',');

                        int.TryParse(orderArray[0], out prInfo.userID);
                        prInfo.cyUid = orderArray[2];
                        int.TryParse(orderArray[3], out prInfo.serverId);
                        prInfo.serverIdStr = IntToBytes(prInfo.serverId);

                        mw.RmbShopConfig config = null;
                        string index            = string.Format("{0}-{1}", orderArray[1], orderArray[4]);
                        TableManager.RmbShopTable.TryGetValue(index, out config);
                        if (null == config)
                        {
                            prInfo.goodsName = config.goods_name;
                            prInfo.goodsCost = config.rmb_cost;
                        }
                        else
                        {
                            prInfo.goodsName = TableManager.GetGMTText(719) + "(" + orderArray[4] + ")";
                            prInfo.goodsCost = 0;
                        }

                        int.TryParse(orderArray[5], out prInfo.goodsNum);

                        int nState = reader.GetInt32(1);
                        if (ReceiptStateTable.ContainsKey((EReceiptState)nState))
                        {
                            prInfo.state = ReceiptStateTable[(EReceiptState)nState];
                        }
                        else
                        {
                            prInfo.state = TableManager.GetGMTText(719) + "(" + nState + ")";
                        }

                        prInfo.plat_order_id    = reader.IsDBNull(2) ? "" : reader.GetString(2);
                        prInfo.raw_type         = m_rawType[reader.GetInt16(3)];
                        prInfo.last_update_time = reader.GetDateTime(4).ToString("yyyy-MM-dd HH:mm:ss");

                        rechargeList.Add(prInfo);
                    }
                },
                                          server.BillDatabaseAddress,
                                          server.BillDatabasePort,
                                          server.BillDatabaseCharSet,
                                          server.BillDatabase,
                                          server.BillDatabaseUserId,
                                          server.BillDatabasePassword,
                                          sql);
                #endregion
            }

            string rechargeData = JsonConvert.SerializeObject(rechargeList);
            return(string.Format(@"{{""error"":0, ""data"": {{""total"":{0}, ""rows"":{1} }} }}", totalRows, rechargeData));
        }
コード例 #30
0
        /// <summary>
        /// 显示信息按钮点击响应
        /// </summary>
        protected void informationButton_Click(object sender, EventArgs e)
        {
            this.idLabel.Text = "";
            uint playerId = this.GetPlayerId();

            if (playerId != 0)
            {
                gmt.Server    server  = gmt.Server.GetServer(this.selectListBox.Items[0].ToString());
                StringBuilder builder = new StringBuilder();
                if (string.IsNullOrEmpty(server.GameDatabase))
                {
                    return;
                }

                //记录各项信息的字符串
                string vipLevel = ""
                , teamLevel     = ""
                , yuanbao_all   = ""
                , yuanbao       = ""
                , money         = ""
                , energy        = ""
                , lingyu        = ""
                , registerTime  = ""
                , heroCount     = ""
                , fuben         = ""
                , guildName     = ""
                , onlinetime    = ""
                , smallMonth    = ""
                , bigMonth      = ""
                , lastSaveTime  = "";

                #region VIP等级、金钱、元宝、体力、在线时长、充值元宝总数、灵玉、最后登录时间
                DatabaseAssistant.Execute(
                    reader =>
                {
                    if (reader.Read())
                    {
                        vipLevel = reader.GetInt32(0).ToString();
                        money    = reader.GetInt32(1).ToString();
                        yuanbao  = reader.GetInt32(2).ToString();
                        energy   = reader.GetInt32(3).ToString();

                        onlinetime  = reader.GetInt32(4) / 3600 + TableManager.GetGMTText(741);
                        onlinetime += (reader.GetInt32(4) % 3600) / 60 + TableManager.GetGMTText(742);
                        onlinetime += reader.GetInt32(4) % 60 + TableManager.GetGMTText(94);

                        yuanbao_all = reader.GetInt32(5).ToString();
                        lingyu      = reader.GetInt32(6).ToString();

                        lastSaveTime = reader.GetDateTime(7).ToString();
                    }
                },
                    server.DatabaseAddress,
                    server.DatabasePort,
                    server.DatabaseCharSet,
                    server.GameDatabase,
                    server.DatabaseUserId,
                    server.DatabasePassword,
                    "SELECT `vip_level`,`money`,`yuanbao`,`energy`,`online_time`,`yuanbao_all`,`hero_soul_ex`,`last_save_time` FROM `user_info` WHERE `uid`={0};",
                    playerId);
                #endregion

                #region 副本进度、帮派名称
                DatabaseAssistant.Execute(
                    reader =>
                {
                    if (reader.Read())
                    {
                        byte[] buffer = new byte[reader.GetBytes(0, 0, null, 0, int.MaxValue)];
                        reader.GetBytes(0, 0, buffer, 0, buffer.Length);
                        using (MemoryStream stream = new MemoryStream(buffer))
                        {
                            mw.OtherInfo othern = ProtoSerializer.Instance.Deserialize(stream, null, typeof(mw.OtherInfo)) as mw.OtherInfo;
                            fuben     = othern.instanceInfo.comm_instance.ToString();
                            guildName = othern.guildInfo.name;
                            if (string.IsNullOrEmpty(guildName))
                            {
                                guildName = TableManager.GetGMTText(743);
                            }
                        }
                    }
                },
                    server.DatabaseAddress,
                    server.DatabasePort,
                    server.DatabaseCharSet,
                    server.GameDatabase,
                    server.DatabaseUserId,
                    server.DatabasePassword,
                    "SELECT `other_data` FROM `other_info` WHERE `uid`={0};",
                    playerId);
                #endregion

                #region 创建时间
                int      dayidx       = 0; //记录创建时间是一年中的第几天
                DateTime registertime = DateTime.Now;
                //角色创建时间
                DatabaseAssistant.Execute(reader =>
                {
                    registerTime = TableManager.GetGMTText(719);
                    if (reader.Read())
                    {
                        DateTime datetime = reader.GetDateTime(0);
                        registerTime      = datetime.ToString();
                        dayidx            = reader.GetDateTime(0).DayOfYear;
                        registertime      = reader.GetDateTime(0);
                    }
                },
                                          server.DatabaseAddress,
                                          server.DatabasePort,
                                          server.DatabaseCharSet,
                                          server.GameDatabase,
                                          server.DatabaseUserId,
                                          server.DatabasePassword,
                                          "SELECT `register_time` FROM `user` WHERE `uid`={0};",
                                          playerId);
                #endregion

                #region 团队等级、武将数量
                DatabaseAssistant.Execute(
                    reader =>
                {
                    if (reader.Read())
                    {
                        byte[] buffer = new byte[reader.GetBytes(0, 0, null, 0, int.MaxValue)];
                        reader.GetBytes(0, 0, buffer, 0, buffer.Length);
                        using (MemoryStream stream = new MemoryStream(buffer))
                        {
                            mw.HeroPackage heroPackage = ProtoSerializer.Instance.Deserialize(stream, null, typeof(mw.HeroPackage)) as mw.HeroPackage;
                            teamLevel = heroPackage.level.ToString();
                            heroCount = heroPackage.heroInfos.Count.ToString();
                        }
                    }
                },
                    server.DatabaseAddress,
                    server.DatabasePort,
                    server.DatabaseCharSet,
                    server.GameDatabase,
                    server.DatabaseUserId,
                    server.DatabasePassword,
                    "SELECT `card_data` FROM `card_package` WHERE `uid`={0};",
                    playerId);
                #endregion

                #region 月卡
                //小月卡=超值月卡
                DatabaseAssistant.Execute(
                    reader =>
                {
                    smallMonth = TableManager.GetGMTText(743);
                    if (reader.Read())
                    {
                        DateTime datetime = reader.GetDateTime(0);
                        smallMonth        = datetime.ToString();
                    }
                },
                    server.DatabaseAddress,
                    server.DatabasePort,
                    server.DatabaseCharSet,
                    server.GameDatabase,
                    server.DatabaseUserId,
                    server.DatabasePassword,
                    "SELECT `s_month_time` FROM `user_info` WHERE `uid`={0};",
                    playerId);

                //大月卡=至尊卡
                DatabaseAssistant.Execute(
                    reader =>
                {
                    bigMonth = TableManager.GetGMTText(744);
                    if (reader.Read())
                    {
                        if (reader.GetInt32(0) == 1)
                        {
                            bigMonth = TableManager.GetGMTText(745);
                        }
                    }
                },
                    server.DatabaseAddress,
                    server.DatabasePort,
                    server.DatabaseCharSet,
                    server.GameDatabase,
                    server.DatabaseUserId,
                    server.DatabasePassword,
                    "SELECT `ex_month_time` FROM `user_info` WHERE `uid`={0};",
                    playerId);
                #endregion

                #region 显示

                if (vipLevel == "")
                {
                    vipLevel = "0";
                }
                if (teamLevel == "")
                {
                    teamLevel = "0";
                }
                if (yuanbao_all == "")
                {
                    yuanbao_all = "0";
                }
                if (yuanbao == "")
                {
                    yuanbao = "0";
                }
                if (money == "")
                {
                    money = "0";
                }
                if (energy == "")
                {
                    energy = "0";
                }
                if (lingyu == "")
                {
                    lingyu = "0";
                }
                if (heroCount == "")
                {
                    heroCount = "0";
                }
                if (fuben == "")
                {
                    fuben = TableManager.GetGMTText(743);
                }
                if (guildName == "")
                {
                    guildName = TableManager.GetGMTText(743);
                }
                if (onlinetime == "")
                {
                    onlinetime = "0";
                }

                builder.Append("<table><tr><td colspan='8'>" + TableManager.GetGMTText(57) + "</td></tr>");
                builder.Append("<tr><td colspan='2'>" + TableManager.GetGMTText(58) + ":").Append(playerId);
                builder.Append("</td><td colspan='2'>" + TableManager.GetGMTText(59) + ":").Append(GetPlayerStatus(playerId));
                builder.Append("</td><td colspan='2'>" + TableManager.GetGMTText(60) + ":").Append(vipLevel);
                builder.Append("</td><td colspan='2'>" + TableManager.GetGMTText(61) + ":").Append(teamLevel);
                builder.Append("</td></tr><tr><td colspan='2'>" + TableManager.GetGMTText(62) + ":").Append(yuanbao_all);
                builder.Append("</td><td colspan='2'>" + TableManager.GetGMTText(63) + ":").Append(yuanbao);
                builder.Append("</td><td colspan='2'>" + TableManager.GetGMTText(64) + ":").Append(money);
                builder.Append("</td><td colspan='2'>" + TableManager.GetGMTText(65) + ":").Append(energy);
                builder.Append("</td></tr><tr><td colspan='2'>" + TableManager.GetGMTText(66) + ":").Append(lingyu);
                builder.Append("</td><td colspan='2'>" + TableManager.GetGMTText(67) + ":").Append(heroCount);
                builder.Append("</td><td colspan='2'>" + TableManager.GetGMTText(68) + ":").Append(fuben);
                builder.Append("</td><td colspan='2'>" + TableManager.GetGMTText(69) + ":").Append(guildName);
                builder.Append("</td></tr><tr><td colspan='4'>" + TableManager.GetGMTText(70) + ":").Append(registerTime);
                builder.Append("</td><td colspan='4'>" + TableManager.GetGMTText(71) + ":").Append(lastSaveTime);
                builder.Append("</td></tr><tr><td colspan='2'>" + TableManager.GetGMTText(72) + ":").Append(onlinetime);
                builder.Append("</td><td colspan='4'>" + TableManager.GetGMTText(746) + ":").Append(smallMonth);
                builder.Append("</td></tr><tr><td colspan='2'>" + TableManager.GetGMTText(74) + ":").Append(bigMonth);
                builder.Append("</td></tr></table>");

                this.idLabel.Text = builder.ToString();

                #endregion
            }
        }