Skip to content

Commit 402d5b0

Browse files
authored
Merge pull request #669 from immense/hotfix/agentdevicedto
Realign property name casing in DeviceClientDto.
2 parents 097e6a4 + f1e83df commit 402d5b0

File tree

8 files changed

+29
-29
lines changed

8 files changed

+29
-29
lines changed

Agent/Services/AgentHubConnection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ public async Task Connect()
109109

110110
_logger.LogInformation("Connected to server.");
111111

112-
// TODO: Move CPU sampler to background service.
113112
var device = await _deviceInfoService.CreateDevice(_connectionInfo.DeviceID, _connectionInfo.OrganizationID);
114113

115114
var result = await _hubConnection.InvokeAsync<bool>("DeviceCameOnline", device);
@@ -199,6 +198,8 @@ private async void HeartbeatTimer_Elapsed(object sender, ElapsedEventArgs e)
199198
private async Task HubConnection_Reconnected(string arg)
200199
{
201200
_logger.LogInformation("Reconnected to server.");
201+
await _updater.CheckForUpdates();
202+
202203
var device = await _deviceInfoService.CreateDevice(_connectionInfo.DeviceID, _connectionInfo.OrganizationID);
203204

204205
if (!await _hubConnection.InvokeAsync<bool>("DeviceCameOnline", device))
@@ -212,9 +213,8 @@ private async Task HubConnection_Reconnected(string arg)
212213
await Connect();
213214
return;
214215
}
215-
216-
await _updater.CheckForUpdates();
217216
}
217+
218218
private void RegisterMessageHandlers()
219219
{
220220

Agent/Services/DeviceInfoGeneratorBase.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ protected DeviceClientDto GetDeviceBase(string deviceID, string orgID)
2727

2828
return new DeviceClientDto()
2929
{
30-
Id = deviceID,
30+
ID = deviceID,
3131
DeviceName = Environment.MachineName,
3232
Platform = EnvironmentHelper.Platform.ToString(),
3333
ProcessorCount = Environment.ProcessorCount,
34-
OsArchitecture = RuntimeInformation.OSArchitecture,
35-
OsDescription = RuntimeInformation.OSDescription,
34+
OSArchitecture = RuntimeInformation.OSArchitecture,
35+
OSDescription = RuntimeInformation.OSDescription,
3636
Is64Bit = Environment.Is64BitOperatingSystem,
3737
IsOnline = true,
3838
MacAddresses = GetMacAddresses().ToArray(),
39-
OrganizationId = orgID,
39+
OrganizationID = orgID,
4040
AgentVersion = AppVersionHelper.GetAppVersion()
4141
};
4242
}

Server/Hubs/AgentHub.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public async Task<bool> DeviceCameOnline(DeviceClientDto device)
9292
{
9393
try
9494
{
95-
if (CheckForDeviceBan(device.Id, device.DeviceName))
95+
if (CheckForDeviceBan(device.ID, device.DeviceName))
9696
{
9797
return false;
9898
}
@@ -147,7 +147,7 @@ public async Task<bool> DeviceCameOnline(DeviceClientDto device)
147147

148148
public async Task DeviceHeartbeat(DeviceClientDto device)
149149
{
150-
if (CheckForDeviceBan(device.Id, device.DeviceName))
150+
if (CheckForDeviceBan(device.ID, device.DeviceName))
151151
{
152152
return;
153153
}

Server/Services/DataService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,14 @@ public async Task<Result<Device>> AddOrUpdateDevice(DeviceClientDto deviceDto)
360360
{
361361
using var dbContext = _appDbFactory.GetContext();
362362

363-
var device = await dbContext.Devices.FindAsync(deviceDto.Id);
363+
var device = await dbContext.Devices.FindAsync(deviceDto.ID);
364364

365365
if (device is null)
366366
{
367367
device = new Device
368368
{
369-
OrganizationID = deviceDto.OrganizationId,
370-
ID = deviceDto.Id,
369+
OrganizationID = deviceDto.OrganizationID,
370+
ID = deviceDto.ID,
371371
};
372372
await dbContext.Devices.AddAsync(device);
373373
}
@@ -380,8 +380,8 @@ public async Task<Result<Device>> AddOrUpdateDevice(DeviceClientDto deviceDto)
380380
device.UsedStorage = deviceDto.UsedStorage;
381381
device.Is64Bit = deviceDto.Is64Bit;
382382
device.IsOnline = true;
383-
device.OSArchitecture = deviceDto.OsArchitecture;
384-
device.OSDescription = deviceDto.OsDescription;
383+
device.OSArchitecture = deviceDto.OSArchitecture;
384+
device.OSDescription = deviceDto.OSDescription;
385385
device.Platform = deviceDto.Platform;
386386
device.ProcessorCount = deviceDto.ProcessorCount;
387387
device.PublicIP = deviceDto.PublicIP;

Shared/Dtos/DeviceClientDto.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class DeviceClientDto
2929
public List<Drive> Drives { get; set; } = new();
3030

3131
[DataMember]
32-
public string Id { get; set; } = string.Empty;
32+
public string ID { get; set; } = string.Empty;
3333

3434
[DataMember]
3535
public bool Is64Bit { get; set; }
@@ -41,13 +41,13 @@ public class DeviceClientDto
4141
public string[] MacAddresses { get; set; } = Array.Empty<string>();
4242

4343
[DataMember]
44-
public string OrganizationId { get; set; } = string.Empty;
44+
public string OrganizationID { get; set; } = string.Empty;
4545

4646
[DataMember]
47-
public Architecture OsArchitecture { get; set; }
47+
public Architecture OSArchitecture { get; set; }
4848

4949
[DataMember]
50-
public string OsDescription { get; set; } = string.Empty;
50+
public string OSDescription { get; set; } = string.Empty;
5151

5252
[DataMember]
5353
public string Platform { get; set; } = string.Empty;

Tests/LoadTester/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private static async Task StartAgent(int i)
116116
{
117117
try
118118
{
119-
var currentInfo = await _deviceInfo.CreateDevice(device.Id, _organizationId);
119+
var currentInfo = await _deviceInfo.CreateDevice(device.ID, _organizationId);
120120
currentInfo.DeviceName = device.DeviceName;
121121
await hubConnection.SendAsync("DeviceHeartbeat", currentInfo);
122122
}

Tests/Server.Tests/DataServiceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public async Task AddOrUpdateDevice()
3838

3939
var newDevice = new DeviceClientDto()
4040
{
41-
Id = _newDeviceID,
42-
OrganizationId = _testData.Org1Id,
41+
ID = _newDeviceID,
42+
OrganizationID = _testData.Org1Id,
4343
DeviceName = Environment.MachineName,
4444
Is64Bit = Environment.Is64BitOperatingSystem
4545
};

Tests/Server.Tests/TestData.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ public async Task Init()
116116

117117
var device1 = new DeviceClientDto()
118118
{
119-
Id = "Org1Device1",
119+
ID = "Org1Device1",
120120
DeviceName = "Org1Device1Name",
121-
OrganizationId = Org1Id
121+
OrganizationID = Org1Id
122122
};
123123
var device2 = new DeviceClientDto()
124124
{
125-
Id = "Org1Device2",
125+
ID = "Org1Device2",
126126
DeviceName = "Org1Device2Name",
127-
OrganizationId = Org1Id
127+
OrganizationID = Org1Id
128128
};
129129
Org1Device1 = (await dataService.AddOrUpdateDevice(device1)).Value;
130130
Org1Device2 = (await dataService.AddOrUpdateDevice(device2)).Value;
@@ -150,15 +150,15 @@ public async Task Init()
150150

151151
var device3 = new DeviceClientDto()
152152
{
153-
Id = "Org2Device1",
153+
ID = "Org2Device1",
154154
DeviceName = "Org2Device1Name",
155-
OrganizationId = Org2Id
155+
OrganizationID = Org2Id
156156
};
157157
var device4 = new DeviceClientDto()
158158
{
159-
Id = "Org2Device2",
159+
ID = "Org2Device2",
160160
DeviceName = "Org2Device2Name",
161-
OrganizationId = Org2Id
161+
OrganizationID = Org2Id
162162
};
163163
Org2Device1 = (await dataService.AddOrUpdateDevice(device3)).Value;
164164
Org2Device2 = (await dataService.AddOrUpdateDevice(device4)).Value;

0 commit comments

Comments
 (0)