mirror of
https://github.com/project-redbud/FunGame-Server.git
synced 2025-04-22 03:59:36 +08:00
Update Server Architecture and SQLHelper Transaction (#18)
This commit is contained in:
parent
955fff82d5
commit
ac2cf9ee67
@ -57,4 +57,8 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -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 = "验证码不正确,请重新输入!";
|
||||
}
|
@ -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;
|
@ -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
|
||||
/// <param name="Helper">MySQLHelper</param>
|
||||
/// <param name="Result">执行结果</param>
|
||||
/// <returns>插入值ID</returns>
|
||||
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;
|
Loading…
x
Reference in New Issue
Block a user