因为AStart低代码平台支持远端事务管理,所以override onSave即可,将returnTransaction设为true,则会返回事务id,但是这个事务就需要人手关闭。 比如在此次加班申请单修改数据递交后,再希望在同一个事务中调用远端的加班单检测api,如果检测失败,则此次的加班申请单修改数据的更新回滚。
protected override async Task<String> onSave(bool returnTransaction = false)
{
DataRow mRow = GetCurrentRow(mainGrid.MainView.Tag as BindingSource);
string lastTrxId = await base.onSave(true);
if (lastTrxId == null) return null;
try
{
await RpcService.GetAsync<bool>(RpcService.SrvPrefix + "/hrOt/checkOtBill", new { trxId = lastTrxId, billId = GetStringVal(mRow["id"], null) });
await RpcService.Commit(lastTrxId);
}
catch
{
await RpcService.Rollback(lastTrxId);
throw;
}
finally
{
await RpcService.Release(lastTrxId);
}
return null;
}