Exemplo n.º 1
0
        private void updateMysql(Dictionary <String, String> data, DbObject dbObject)
        {
            string serverStr = String.Format("Database={0};Data Source={1};User Id={2};Password={3};pooling=false;CharSet=utf8;port={4}", dbObject.Name, dbObject.Host, dbObject.User, dbObject.Password, dbObject.Port);

            if (mysqlHelper == null)
            {
                //SetTextMesssage("数据库连接字符串:" + serverStr);
                mysqlHelper = new MysqlHelper(serverStr);
            }
            //检测数据库连接
            if (!mysqlHelper.CheckConnectStatus())
            {
                Error("数据库连接失败,请检查网关数据库配置是否正确");
                return;
            }
            //执行充值SQL语句
            string txtSql = this.txtSql.Text.Trim();
            //账号
            string account = data["account"];
            //金额
            double money = Convert.ToDouble(data["money"]);
            //充值比例
            double scale = Convert.ToDouble(data["scale"]);
            //游戏币
            double gold = money * scale;
            //分区
            string quname = data["quname"];
            //游戏币别名
            string alias = data["alias"];
            //订单编号
            string ordernumber = data["ordernumber"];

            //替换SQL的字符
            txtSql = txtSql.Replace("{account}", account);
            txtSql = txtSql.Replace("{money}", money.ToString());
            txtSql = txtSql.Replace("{gold}", gold.ToString());
            txtSql = txtSql.Replace("{order_no}", ordernumber.ToString());
            //执行SQL
            //SetTextMesssage("充值sql语句:" + txtSql);
            int res = mysqlHelper.commonExecute(txtSql);

            if (res > 0)
            {
                //充值成功返回
                string yxb = gold >= 10000 ? (gold / 10000).ToString() + '万' : gold.ToString();
                string msg = String.Format("{0} 玩家“{1}”成功充值{2}元,获得{3}{4}个。", quname, account, money, alias, yxb);
                SetTextMesssage(msg);
                sendMsgBySocket(msg);
            }
            else
            {
                //充值失败返回
                string msg = String.Format("{0} 玩家“{1}”充值失败,充值金额{2}元,订单编号:{3}", quname, account, money, ordernumber);
                SetTextMesssage(msg);
                sendMsgBySocket(msg);
            }
        }
Exemplo n.º 2
0
        private void Socket_getSocketText(Session sesson, string text)
        {
            //算法密钥
            string key = this.txtKey.Text.Trim();
            //DES解密
            string decode = Des.decrypt(text, key);

            if (decode == string.Empty)
            {
                Error("算法密钥不正确");
                return;
            }
            Dictionary <String, String> data = Tool.getFormData(decode);

            if (data.Count <= 0)
            {
                return;
            }
            string appkey = this.txtAppkey.Text.Trim();

            if (!appkey.Equals(data["appkey"]))
            {
                Error("商户密钥不正确");
                return;
            }
            //创建数据库连接
            DbObject dbObject = new DbObject();

            dbObject.Host = this.txtDbHost.Text.Trim();
            if (dbtype.Equals("mysql"))
            {
                dbObject.Port = this.txtDbPort.Text.Trim();
            }
            dbObject.User     = this.txtDbUser.Text.Trim();
            dbObject.Password = this.txtDbPassword.Text.Trim();
            dbObject.Name     = data["database"];
            if (dbObject.Name == string.Empty)
            {
                Error("分区数据库不能为空,请前往平台修改分区设置");
                return;
            }
            if (dbtype.Equals("mysql"))
            {
                updateMysql(data, dbObject);
            }
            else
            {
                updateSQLServer(data, dbObject);
            }
        }
Exemplo n.º 3
0
        private void updateSQLServer(Dictionary <String, String> data, DbObject dbObject)
        {
            string serverStr = String.Format("server={0};Database={1};User ID={2};Password={3};Integrated Security=sspi;Persist Security Info=True;pooling=true;", dbObject.Host, dbObject.Name, dbObject.User, dbObject.Password);

            if (sqlDbHelper == null)
            {
                //SetTextMesssage("数据库连接字符串:" + serverStr);
                sqlDbHelper = new SqlDbHelper(serverStr);
            }
            //检测数据库连接
            if (!sqlDbHelper.CheckConnectStatus())
            {
                Error("数据库连接失败,请检查网关数据库配置是否正确");
                return;
            }
            //执行充值SQL语句
            string txtSql = this.txtSql.Text.Trim();
            //账号
            string account = data["account"];
            //金额
            double money = Convert.ToDouble(data["money"]);
            //充值比例
            double scale = Convert.ToDouble(data["scale"]);
            //游戏币
            double gold = money * scale;
            //分区
            string quname = data["quname"];
            //游戏币别名
            string alias = data["alias"];
            //订单编号
            string ordernumber = data["ordernumber"];

            //替换SQL的字符
            txtSql = txtSql.Replace("{account}", account);
            txtSql = txtSql.Replace("{money}", money.ToString());
            txtSql = txtSql.Replace("{gold}", gold.ToString());
            txtSql = txtSql.Replace("{order_no}", ordernumber.ToString());
            //SetTextMesssage("充值sql语句:" + txtSql);
            //执行SQL
            int res = sqlDbHelper.ExecuteSql(txtSql);

            if (res > 0)
            {
                //充值成功返回
                string yxb = gold >= 10000 ? (gold / 10000).ToString() + '万' : gold.ToString();
                string msg = String.Format("{0} 玩家“{1}”成功充值{2}元,获得{3}{4}个。", quname, account, money, alias, yxb);
                SetTextMesssage(msg);
                if (socketClient != null)
                {
                    String paramString = Tool.toJson(1, msg);
                    socketClient.Send(System.Text.Encoding.Default.GetBytes(paramString));
                }
            }
            else
            {
                //充值失败返回
                string msg = String.Format("{0} 玩家“{1}”充值失败,充值金额{2}元,订单编号:{3}", quname, account, money, ordernumber);
                SetTextMesssage(msg);
                sendMsgBySocket(msg);
            }
        }