public static Device Create(ConnectionInfo connectionInfo) { OSPlatform platform = OSUtils.GetPlatform(); DriveInfo systemDrive; if (!string.IsNullOrWhiteSpace(Environment.SystemDirectory)) { systemDrive = DriveInfo.GetDrives() .Where(x => x.IsReady) .FirstOrDefault(x => x.RootDirectory.FullName.Contains(Path.GetPathRoot(Environment.SystemDirectory ?? Environment.CurrentDirectory)) ); } else { systemDrive = DriveInfo.GetDrives().FirstOrDefault(x => x.IsReady && x.RootDirectory.FullName == Path.GetPathRoot(Environment.CurrentDirectory)); } var device = new Device() { ID = connectionInfo.DeviceID, DeviceName = Environment.MachineName, Platform = platform.ToString(), ProcessorCount = Environment.ProcessorCount, OSArchitecture = RuntimeInformation.OSArchitecture, OSDescription = RuntimeInformation.OSDescription, Is64Bit = Environment.Is64BitOperatingSystem, IsOnline = true, Drives = DriveInfo.GetDrives().Where(x => x.IsReady).Select(x => new Drive() { DriveFormat = x.DriveFormat, DriveType = x.DriveType, Name = x.Name, RootDirectory = x.RootDirectory.FullName, FreeSpace = x.TotalSize > 0 ? x.TotalFreeSpace / x.TotalSize : 0, TotalSize = x.TotalSize > 0 ? Math.Round((double)(x.TotalSize / 1024 / 1024 / 1024), 2) : 0, VolumeLabel = x.VolumeLabel }).ToList(), OrganizationID = connectionInfo.OrganizationID, CurrentUser = GetCurrentUser() }; if (systemDrive != null && systemDrive.TotalSize > 0 && systemDrive.TotalFreeSpace > 0) { device.TotalStorage = Math.Round((double)(systemDrive.TotalSize / 1024 / 1024 / 1024), 2); var freeStorage = Math.Round((double)(systemDrive.TotalFreeSpace / 1024 / 1024 / 1024), 2); device.FreeStorage = freeStorage / device.TotalStorage; } Tuple <double, double> totalMemory = new Tuple <double, double>(0, 0); if (OSUtils.IsWindows) { totalMemory = GetWinMemoryInGB(); } else if (OSUtils.IsLinux) { totalMemory = GetLinxMemoryInGB(); } if (totalMemory.Item2 > 0) { device.FreeMemory = totalMemory.Item1 / totalMemory.Item2; } else { device.FreeMemory = 0; } device.TotalMemory = totalMemory.Item2; if (File.Exists("Remotely_Agent.dll")) { device.AgentVersion = FileVersionInfo.GetVersionInfo("Remotely_Agent.dll")?.FileVersion?.ToString()?.Trim(); } return(device); }