コード例 #1
0
        /// <summary>
        /// 封停用户
        /// </summary>
        public static int ACCOUNT_CLOSE(string serverIP, int usersn, string userNick, string userName, int userbyid, string Reason, ref string strDesc)
        {
            int    result = -1;
            string sql    = null;

            try
            {
                serverIP = CommonInfo.JW2_FindDBIP(serverIP, 8);
                sql      = "select sql_statement from sqlexpress where sql_type='JW2_ACCOUNT_CLOSE' and sql_condition = 'JW2_ACCOUNT_CLOSE'";
                System.Data.DataSet ds = SqlHelper.ExecuteDataset(sql);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    sql    = ds.Tables[0].Rows[0].ItemArray[0].ToString();
                    sql    = string.Format(sql, usersn);
                    result = MySqlHelper.ExecuteNonQuery(SqlHelper.JW2GetConnectionString(serverIP, SqlHelper.jw2User, SqlHelper.jw2UserPwd, SqlHelper.jw2loginDB), sql);
                }
                if (result > 0)
                {
                    strDesc = lg.JW2API_ACCOUNTCLOSE + userName.ToString() + lg.JW2API_PlayerSN + userNick.ToString() + lg.JW2API_Success;
                    result  = CommonInfo.JW2_BanUser(serverIP, userbyid, usersn, userName, userNick, Reason);
                    SqlHelper.insertGMtoolsLog(userbyid, "JW2", serverIP, "JW2_ACCOUNT_CLOSE", lg.JW2API_ACCOUNTCLOSE + userName.ToString() + lg.JW2API_Success);
                }
                else
                {
                    strDesc = lg.JW2API_ACCOUNTCLOSE + userName.ToString() + lg.JW2API_PlayerSN + userNick.ToString() + lg.JW2API_Failure;
                    result  = CommonInfo.JW2_BanUser(serverIP, userbyid, usersn, userName, userNick, Reason);
                    SqlHelper.insertGMtoolsLog(userbyid, "JW2", serverIP, "JW2_ACCOUNT_CLOSE", lg.JW2API_ACCOUNTCLOSE + userName.ToString() + lg.JW2API_Failure);
                }
            }
            catch (MySqlException ex)
            {
                strDesc = lg.JW2API_DatebaseConnectError;
                SqlHelper.errLog.WriteLog("ServerIP" + serverIP + ex.Message);
                if (ex.Message == "Duplicate entry '" + usersn + "' for key 1")
                {
                    result = 2;
                }
            }
            return(result);
        }