mirror of
https://github.com/project-redbud/FunGame-Server.git
synced 2025-04-23 04:29:38 +08:00
Update Server Architecture and SQLHelper Transaction (#18)
This commit is contained in:
parent
955fff82d5
commit
ac2cf9ee67
@ -57,4 +57,8 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Controllers\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -316,14 +316,20 @@ namespace Milimoe.FunGame.Server.Model
|
|||||||
if (RegVerify.Equals(SQLHelper.DataSet.Tables[0].Rows[0][RegVerifyCodes.Column_RegVerifyCode]))
|
if (RegVerify.Equals(SQLHelper.DataSet.Tables[0].Rows[0][RegVerifyCodes.Column_RegVerifyCode]))
|
||||||
{
|
{
|
||||||
ServerHelper.WriteLine("[" + ServerSocket.GetTypeString(type) + "] UserName: " + username + " Email: " + email);
|
ServerHelper.WriteLine("[" + ServerSocket.GetTypeString(type) + "] UserName: " + username + " Email: " + email);
|
||||||
|
SQLHelper.NewTransaction();
|
||||||
SQLHelper.Execute(UserQuery.Insert_Register(username, password, email, socket.ClientIP));
|
SQLHelper.Execute(UserQuery.Insert_Register(username, password, email, socket.ClientIP));
|
||||||
if (SQLHelper.Result == SQLResult.Success)
|
if (SQLHelper.Result == SQLResult.Success)
|
||||||
{
|
{
|
||||||
msg = "注册成功!请牢记您的账号与密码!";
|
msg = "注册成功!请牢记您的账号与密码!";
|
||||||
SQLHelper.Execute(RegVerifyCodes.Delete_RegVerifyCode(username, email));
|
SQLHelper.Execute(RegVerifyCodes.Delete_RegVerifyCode(username, email));
|
||||||
|
SQLHelper.Commit();
|
||||||
return Send(socket, type, true, msg);
|
return Send(socket, type, true, msg);
|
||||||
}
|
}
|
||||||
else msg = "服务器无法处理您的注册,注册失败!";
|
else
|
||||||
|
{
|
||||||
|
msg = "服务器无法处理您的注册,注册失败!";
|
||||||
|
SQLHelper.Rollback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else msg = "验证码不正确,请重新输入!";
|
else msg = "验证码不正确,请重新输入!";
|
||||||
}
|
}
|
@ -15,10 +15,7 @@ namespace Milimoe.FunGame.Server.Utility
|
|||||||
public override string Script { get; set; } = "";
|
public override string Script { get; set; } = "";
|
||||||
public override CommandType CommandType { get; set; } = CommandType.Text;
|
public override CommandType CommandType { get; set; } = CommandType.Text;
|
||||||
public override SQLResult Result => _Result;
|
public override SQLResult Result => _Result;
|
||||||
public override bool Success
|
public override bool Success => Result == SQLResult.Success;
|
||||||
{
|
|
||||||
get => Result == SQLResult.Success;
|
|
||||||
}
|
|
||||||
public override SQLServerInfo ServerInfo => _ServerInfo ?? SQLServerInfo.Create();
|
public override SQLServerInfo ServerInfo => _ServerInfo ?? SQLServerInfo.Create();
|
||||||
public override int UpdateRows => _UpdateRows;
|
public override int UpdateRows => _UpdateRows;
|
||||||
public override DataSet DataSet => _DataSet;
|
public override DataSet DataSet => _DataSet;
|
@ -28,14 +28,12 @@ namespace Milimoe.FunGame.Server.Utility
|
|||||||
Result = SQLResult.Success;
|
Result = SQLResult.Success;
|
||||||
}
|
}
|
||||||
else Result = SQLResult.NotFound;
|
else Result = SQLResult.NotFound;
|
||||||
Helper.Commit();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ServerHelper.Error(e);
|
ServerHelper.Error(e);
|
||||||
updaterow = -1;
|
updaterow = -1;
|
||||||
Result = SQLResult.Fail;
|
Result = SQLResult.Fail;
|
||||||
Helper.Rollback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return updaterow;
|
return updaterow;
|
||||||
@ -85,7 +83,7 @@ namespace Milimoe.FunGame.Server.Utility
|
|||||||
/// <param name="Helper">MySQLHelper</param>
|
/// <param name="Helper">MySQLHelper</param>
|
||||||
/// <param name="Result">执行结果</param>
|
/// <param name="Result">执行结果</param>
|
||||||
/// <returns>插入值ID</returns>
|
/// <returns>插入值ID</returns>
|
||||||
public static object ExecuteAndGetLastInsertedID(MySQLHelper Helper, out SQLResult Result)
|
public static long ExecuteAndGetLastInsertedID(MySQLHelper Helper, out SQLResult Result)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new();
|
MySqlCommand cmd = new();
|
||||||
int updaterow;
|
int updaterow;
|
||||||
@ -101,13 +99,11 @@ namespace Milimoe.FunGame.Server.Utility
|
|||||||
Result = SQLResult.Success;
|
Result = SQLResult.Success;
|
||||||
}
|
}
|
||||||
else Result = SQLResult.NotFound;
|
else Result = SQLResult.NotFound;
|
||||||
Helper.Commit();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ServerHelper.Error(e);
|
ServerHelper.Error(e);
|
||||||
Result = SQLResult.Fail;
|
Result = SQLResult.Fail;
|
||||||
Helper.Rollback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd.LastInsertedId;
|
return cmd.LastInsertedId;
|
Loading…
x
Reference in New Issue
Block a user