I used AbpHub(SignalRHub) and after injecting the repository and writing the data, the data could not be committed to the database.
I directly used the demo in abp-samples and was able to write data successfully.
But I made a new project myself, and after imitating it, I failed to write to the database (it did not prompt an error, but there was no data in the database).
I suspected that the unit of work was not in effect, so I manually enabled the unit of work. This time the data was written successfully, but I kept displaying an error: Volo.Abp.AbpException: Complete is called before!
public async Task<SignalRTestDto> GetOrCreateAsync(string targetUserName)
{
var result = await _signalRTestRepository.FindAsync(s => s.Name == targetUserName);
using(var uow = UnitOfWorkManager.Begin())
{
Logger.LogDebug("CurrentUnitOfWork.Id:{0}", CurrentUnitOfWork.Id);
if (result == null)
{
result = new SignalRTest(targetUserName);
await _signalRTestRepository.InsertAsync(result, true);
await CurrentUnitOfWork.CompleteAsync();
}
}
return ObjectMapper.Map<SignalRTest, SignalRTestDto>(result);
}
This is the project I tested: https://github.com/zhangzw218/AbpSignalRDemo/tree/feature/2023070801_zzw_SignalR_Test
I compare the differences between the two Web, but can't find the problem.
Can someone take a look at this for me? I've integrated two projects into one solution: ..\AbpSignalRDemo\SignalRDemo2\SignalRDemo2.sln