diff --git a/FunGame.Server/FunGame.Server.csproj b/FunGame.Server/FunGame.Server.csproj index 838d5d3..51ccca8 100644 --- a/FunGame.Server/FunGame.Server.csproj +++ b/FunGame.Server/FunGame.Server.csproj @@ -57,4 +57,8 @@ + + + + diff --git a/FunGame.Server/Model/ServerModel.cs b/FunGame.Server/Models/ServerModel.cs similarity index 98% rename from FunGame.Server/Model/ServerModel.cs rename to FunGame.Server/Models/ServerModel.cs index 48cf0ad..a024274 100644 --- a/FunGame.Server/Model/ServerModel.cs +++ b/FunGame.Server/Models/ServerModel.cs @@ -316,14 +316,20 @@ namespace Milimoe.FunGame.Server.Model if (RegVerify.Equals(SQLHelper.DataSet.Tables[0].Rows[0][RegVerifyCodes.Column_RegVerifyCode])) { ServerHelper.WriteLine("[" + ServerSocket.GetTypeString(type) + "] UserName: " + username + " Email: " + email); + SQLHelper.NewTransaction(); SQLHelper.Execute(UserQuery.Insert_Register(username, password, email, socket.ClientIP)); if (SQLHelper.Result == SQLResult.Success) { msg = "注册成功!请牢记您的账号与密码!"; SQLHelper.Execute(RegVerifyCodes.Delete_RegVerifyCode(username, email)); + SQLHelper.Commit(); return Send(socket, type, true, msg); } - else msg = "服务器无法处理您的注册,注册失败!"; + else + { + msg = "服务器无法处理您的注册,注册失败!"; + SQLHelper.Rollback(); + } } else msg = "验证码不正确,请重新输入!"; } diff --git a/FunGame.Server/Utility/Utility.cs b/FunGame.Server/Utilities/General.cs similarity index 100% rename from FunGame.Server/Utility/Utility.cs rename to FunGame.Server/Utilities/General.cs diff --git a/FunGame.Server/Utility/DataUtility/MySQLConnection.cs b/FunGame.Server/Utilities/MySQLConnection.cs similarity index 100% rename from FunGame.Server/Utility/DataUtility/MySQLConnection.cs rename to FunGame.Server/Utilities/MySQLConnection.cs diff --git a/FunGame.Server/Utility/DataUtility/MySQLHelper.cs b/FunGame.Server/Utilities/MySQLHelper.cs similarity index 98% rename from FunGame.Server/Utility/DataUtility/MySQLHelper.cs rename to FunGame.Server/Utilities/MySQLHelper.cs index 3965c1b..c0b9777 100644 --- a/FunGame.Server/Utility/DataUtility/MySQLHelper.cs +++ b/FunGame.Server/Utilities/MySQLHelper.cs @@ -15,10 +15,7 @@ namespace Milimoe.FunGame.Server.Utility public override string Script { get; set; } = ""; public override CommandType CommandType { get; set; } = CommandType.Text; public override SQLResult Result => _Result; - public override bool Success - { - get => Result == SQLResult.Success; - } + public override bool Success => Result == SQLResult.Success; public override SQLServerInfo ServerInfo => _ServerInfo ?? SQLServerInfo.Create(); public override int UpdateRows => _UpdateRows; public override DataSet DataSet => _DataSet; diff --git a/FunGame.Server/Utility/DataUtility/MySQLManager.cs b/FunGame.Server/Utilities/MySQLManager.cs similarity index 94% rename from FunGame.Server/Utility/DataUtility/MySQLManager.cs rename to FunGame.Server/Utilities/MySQLManager.cs index 12fe356..38469c5 100644 --- a/FunGame.Server/Utility/DataUtility/MySQLManager.cs +++ b/FunGame.Server/Utilities/MySQLManager.cs @@ -28,14 +28,12 @@ namespace Milimoe.FunGame.Server.Utility Result = SQLResult.Success; } else Result = SQLResult.NotFound; - Helper.Commit(); } catch (Exception e) { ServerHelper.Error(e); updaterow = -1; Result = SQLResult.Fail; - Helper.Rollback(); } return updaterow; @@ -85,7 +83,7 @@ namespace Milimoe.FunGame.Server.Utility /// MySQLHelper /// 执行结果 /// 插入值ID - public static object ExecuteAndGetLastInsertedID(MySQLHelper Helper, out SQLResult Result) + public static long ExecuteAndGetLastInsertedID(MySQLHelper Helper, out SQLResult Result) { MySqlCommand cmd = new(); int updaterow; @@ -101,13 +99,11 @@ namespace Milimoe.FunGame.Server.Utility Result = SQLResult.Success; } else Result = SQLResult.NotFound; - Helper.Commit(); } catch (Exception e) { ServerHelper.Error(e); Result = SQLResult.Fail; - Helper.Rollback(); } return cmd.LastInsertedId;