/
TelemetryService.cs
62 lines (56 loc) · 1.7 KB
/
TelemetryService.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
// SOLUTION : KFlearning
// PROJECT : KFlearning
// FILENAME : TelemetryService.cs
// AUTHOR : Fahmi Noor Fiqri, Kodesiana.com
// WEBSITE : https://kodesiana.com
// REPO : https://github.com/Kodesiana or https://github.com/fahminlb33
//
// This file is part of KFlearning, see LICENSE.
// See this code in repository URL above!
using KFlearning.Core.API;
using KFlearning.Core.Services;
using KFlearning.Properties;
using System;
using System.Threading.Tasks;
namespace KFlearning.Services
{
public interface ITelemetryService : IUsesPersistance
{
}
public class TelemetryService : ITelemetryService
{
private readonly ISystemInfoService _infoService;
private readonly ITelemetryClient _telemetry;
public TelemetryService(ITelemetryClient telemetry, ISystemInfoService infoService)
{
_telemetry = telemetry;
_infoService = infoService;
}
public void Load()
{
try
{
_infoService.Query();
Task.WaitAll(_telemetry.SendAppStart(Resources.AppName, _infoService.DeviceId),
_telemetry.SendIdentification(_infoService.DeviceId, _infoService.CPU, _infoService.RAM,
_infoService.OS, _infoService.Architecture));
}
catch (Exception)
{
// ignore
}
}
public void Save()
{
try
{
_infoService.Query();
Task.WaitAll(_telemetry.SendAppExit(Resources.AppName, _infoService.DeviceId));
}
catch (Exception)
{
// ignore
}
}
}
}