Skip to content

Commit

Permalink
Use AppVersionHelper in DeviceInfoGeneratorBase.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed May 3, 2023
1 parent 3cf0de4 commit 757086b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 34 deletions.
5 changes: 0 additions & 5 deletions Agent/Interfaces/IDeviceInformationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,5 @@ namespace Remotely.Agent.Interfaces
public interface IDeviceInformationService
{
Task<Device> CreateDevice(string deviceId, string orgId);
Device GetDeviceBase(string deviceID, string orgID);
(double usedStorage, double totalStorage) GetSystemDriveInfo();
(double usedGB, double totalGB) GetMemoryInGB();
string GetAgentVersion();
List<Drive> GetAllDrives();
}
}
32 changes: 6 additions & 26 deletions Agent/Services/DeviceInfoGeneratorBase.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using Microsoft.Extensions.Logging;
using Remotely.Shared.Models;
using Remotely.Shared.Services;
using Remotely.Shared.Utilities;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace Remotely.Agent.Services
{
Expand All @@ -22,7 +18,7 @@ public DeviceInfoGeneratorBase(ILogger<DeviceInfoGeneratorBase> logger)
_logger = logger;
}

public Device GetDeviceBase(string deviceID, string orgID)
protected Device GetDeviceBase(string deviceID, string orgID)
{

return new Device()
Expand All @@ -35,11 +31,12 @@ public Device GetDeviceBase(string deviceID, string orgID)
OSDescription = RuntimeInformation.OSDescription,
Is64Bit = Environment.Is64BitOperatingSystem,
IsOnline = true,
OrganizationID = orgID
};
OrganizationID = orgID,
AgentVersion = AppVersionHelper.GetAppVersion()
};
}

public (double usedStorage, double totalStorage) GetSystemDriveInfo()
protected (double usedStorage, double totalStorage) GetSystemDriveInfo()
{
try
{
Expand Down Expand Up @@ -77,24 +74,7 @@ public Device GetDeviceBase(string deviceID, string orgID)
return (0, 0);
}

public string GetAgentVersion()
{
try
{
if (File.Exists("Remotely_Agent.dll"))
{
return FileVersionInfo.GetVersionInfo("Remotely_Agent.dll").FileVersion.ToString().Trim();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error getting agent version.");
}

return "0.0.0.0";
}

public List<Drive> GetAllDrives()
protected List<Drive> GetAllDrives()
{
try
{
Expand Down
1 change: 0 additions & 1 deletion Agent/Services/Linux/DeviceInfoGeneratorLinux.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public Task<Device> CreateDevice(string deviceId, string orgId)
device.UsedMemory = usedMemory;
device.TotalMemory = totalMemory;
device.CpuUtilization = _cpuUtilSampler.CurrentUtilization;
device.AgentVersion = GetAgentVersion();
}
catch (Exception ex)
{
Expand Down
1 change: 0 additions & 1 deletion Agent/Services/MacOS/DeviceInfoGeneratorMac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public async Task<Device> CreateDevice(string deviceId, string orgId)
device.UsedMemory = usedMemory;
device.TotalMemory = totalMemory;
device.CpuUtilization = await GetCpuUtilization();
device.AgentVersion = GetAgentVersion();
}
catch (Exception ex)
{
Expand Down
1 change: 0 additions & 1 deletion Agent/Services/Windows/DeviceInfoGeneratorWin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public Task<Device> CreateDevice(string deviceId, string orgId)
device.UsedMemory = usedMemory;
device.TotalMemory = totalMemory;
device.CpuUtilization = _cpuUtilSampler.CurrentUtilization;
device.AgentVersion = GetAgentVersion();
}
catch (Exception ex)
{
Expand Down

0 comments on commit 757086b

Please sign in to comment.