-
Notifications
You must be signed in to change notification settings - Fork 0
/
Worker.cs
75 lines (65 loc) · 2.71 KB
/
Worker.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using PullTelax.Services.Interfaces;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace PullTelax
{
public class Worker : BackgroundService
{
private readonly IGetAgents _agentService;
private readonly IGetAgentSessions _agentSession;
private readonly IGetAgentStatus _agentStatus;
private readonly IGetQueues _agentQueue;
private readonly IGetCallsMade _callsMade;
private readonly IGetCallsReceived _callsReceived;
private readonly ILogger<Worker> _logger;
public Worker(
IGetAgents agentService,
IGetAgentSessions agentSession,
IGetAgentStatus agentStatus,
IGetQueues agentQueue,
IGetCallsMade callsMade,
IGetCallsReceived callsReceived,
ILogger<Worker> logger)
{
_agentService = agentService;
_agentSession = agentSession;
_agentStatus = agentStatus;
_agentQueue = agentQueue;
_callsMade = callsMade;
_callsReceived = callsReceived;
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
try
{
string agent = await _agentService.GetAgentAsync();
_logger.LogWarning(agent);
string queue = await _agentQueue.GetQueuesAsync();
_logger.LogWarning(queue);
string agentSession = await _agentSession.GetAgentSessionsAsync();
_logger.LogWarning(agentSession);
string agentStatus = await _agentStatus.GetAgentStatusAsync();
_logger.LogWarning(agentStatus);
string incommingCalls = await _callsReceived.GetCallsReceivedAsync();
_logger.LogWarning(incommingCalls);
string outgoingCalls = await _callsMade.GetCallsMadeAsync();
_logger.LogWarning(outgoingCalls);
//await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);
await Task.Delay(TimeSpan.FromHours(1), stoppingToken);
// await Task.Delay(3000, stoppingToken);
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
}
catch (OperationCanceledException)
{
break;
}
}
}
}
}