Skip to content

Commit 757086b

Browse files
committed
Use AppVersionHelper in DeviceInfoGeneratorBase.
1 parent 3cf0de4 commit 757086b

File tree

5 files changed

+6
-34
lines changed

5 files changed

+6
-34
lines changed

Agent/Interfaces/IDeviceInformationService.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,5 @@ namespace Remotely.Agent.Interfaces
1010
public interface IDeviceInformationService
1111
{
1212
Task<Device> CreateDevice(string deviceId, string orgId);
13-
Device GetDeviceBase(string deviceID, string orgID);
14-
(double usedStorage, double totalStorage) GetSystemDriveInfo();
15-
(double usedGB, double totalGB) GetMemoryInGB();
16-
string GetAgentVersion();
17-
List<Drive> GetAllDrives();
1813
}
1914
}

Agent/Services/DeviceInfoGeneratorBase.cs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
using Microsoft.Extensions.Logging;
22
using Remotely.Shared.Models;
3-
using Remotely.Shared.Services;
43
using Remotely.Shared.Utilities;
54
using System;
65
using System.Collections.Generic;
7-
using System.Diagnostics;
86
using System.IO;
97
using System.Linq;
108
using System.Runtime.InteropServices;
11-
using System.Text;
12-
using System.Threading.Tasks;
139

1410
namespace Remotely.Agent.Services
1511
{
@@ -22,7 +18,7 @@ public DeviceInfoGeneratorBase(ILogger<DeviceInfoGeneratorBase> logger)
2218
_logger = logger;
2319
}
2420

25-
public Device GetDeviceBase(string deviceID, string orgID)
21+
protected Device GetDeviceBase(string deviceID, string orgID)
2622
{
2723

2824
return new Device()
@@ -35,11 +31,12 @@ public Device GetDeviceBase(string deviceID, string orgID)
3531
OSDescription = RuntimeInformation.OSDescription,
3632
Is64Bit = Environment.Is64BitOperatingSystem,
3733
IsOnline = true,
38-
OrganizationID = orgID
39-
};
34+
OrganizationID = orgID,
35+
AgentVersion = AppVersionHelper.GetAppVersion()
36+
};
4037
}
4138

42-
public (double usedStorage, double totalStorage) GetSystemDriveInfo()
39+
protected (double usedStorage, double totalStorage) GetSystemDriveInfo()
4340
{
4441
try
4542
{
@@ -77,24 +74,7 @@ public Device GetDeviceBase(string deviceID, string orgID)
7774
return (0, 0);
7875
}
7976

80-
public string GetAgentVersion()
81-
{
82-
try
83-
{
84-
if (File.Exists("Remotely_Agent.dll"))
85-
{
86-
return FileVersionInfo.GetVersionInfo("Remotely_Agent.dll").FileVersion.ToString().Trim();
87-
}
88-
}
89-
catch (Exception ex)
90-
{
91-
_logger.LogError(ex, "Error getting agent version.");
92-
}
93-
94-
return "0.0.0.0";
95-
}
96-
97-
public List<Drive> GetAllDrives()
77+
protected List<Drive> GetAllDrives()
9878
{
9979
try
10080
{

Agent/Services/Linux/DeviceInfoGeneratorLinux.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public Task<Device> CreateDevice(string deviceId, string orgId)
4343
device.UsedMemory = usedMemory;
4444
device.TotalMemory = totalMemory;
4545
device.CpuUtilization = _cpuUtilSampler.CurrentUtilization;
46-
device.AgentVersion = GetAgentVersion();
4746
}
4847
catch (Exception ex)
4948
{

Agent/Services/MacOS/DeviceInfoGeneratorMac.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public async Task<Device> CreateDevice(string deviceId, string orgId)
3838
device.UsedMemory = usedMemory;
3939
device.TotalMemory = totalMemory;
4040
device.CpuUtilization = await GetCpuUtilization();
41-
device.AgentVersion = GetAgentVersion();
4241
}
4342
catch (Exception ex)
4443
{

Agent/Services/Windows/DeviceInfoGeneratorWin.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public Task<Device> CreateDevice(string deviceId, string orgId)
3939
device.UsedMemory = usedMemory;
4040
device.TotalMemory = totalMemory;
4141
device.CpuUtilization = _cpuUtilSampler.CurrentUtilization;
42-
device.AgentVersion = GetAgentVersion();
4342
}
4443
catch (Exception ex)
4544
{

0 commit comments

Comments
 (0)