Hi,
i canot notify to client the method that read from a dbContext and write to another with SignalR.
If i replace a simple for loop to test all works fine
but with my method not
private async Task SyncTablesJobAsync(string jobId, ICollection<string> tables)
{
int processed = 0;
using (var scope = _scopeFactory.CreateScope())
{
var appDbCtx = scope.ServiceProvider.GetService<ApplicationDbContext>();
var companyDbCtx = scope.ServiceProvider.GetService<CompanyDbContext>();
foreach (var table in tables)
{
switch (table)
{
case "agenti":
await FillAgenti(appDbCtx, companyDbCtx);
processed++;
break;
case "rubrica":
await FillRubrica(appDbCtx, companyDbCtx);
processed++;
break;
...
}
await _hubContext.Clients.Group(jobId).SendAsync("progress", (processed / tables.Count) * 100);
}
}
}
private async Task FillAgenti(ApplicationDbContext appDbCtx, CompanyDbContext companyDbCtx)
{
var agents = await new Agent(companyDbCtx).GetAgentsAsync();
var agenteRepository = new AgenteRepository(appDbCtx, _mapper);
await agenteRepository.RemoveAllAgentiAsync();
await agenteRepository.AddAgentiAsync(
await agenteRepository.FillAgentiFromCompanyAsync(agents));
}
why can't display percentage of progress? what i wrong?