public MachineStatusResult(SystemStatus status) { Cpu = new CpuResult(status.CpuInfo); Drives = status.DrivesInfo.ToDictionary(x => x.VolumeName.Replace(":", string.Empty), x => new DriveResult(x)); if (Drives.ContainsKey("total") == false && status.DrivesInfo.Any()) { var totalSpace = status.DrivesInfo.Sum(x => x.TotalSpace); var freeSpace = status.DrivesInfo.Sum(x => x.FreeSpace); var total = new DriveInfo("total", totalSpace, freeSpace); Drives.Add(total.VolumeName, new DriveResult(total)); } Ram = new MemoryResult(status.MemoryInfo); Environment = new EnvResult(status.EnvInfo); }
public void AddDriveExpressionUNC(string Drive, string Expression, string UNC) { string driveLetterContainingUNC = DrivesContainUNC(UNC); if (!string.IsNullOrEmpty(driveLetterContainingUNC)) { log.Warn($"Skip: \"{UNC}\" - already in \"{driveLetterContainingUNC}\" drive mapping"); return; } if (Drives.ContainsKey(Drive)) { Drives[Drive].Add(new Tuple <string, string>(Expression, UNC)); } else { Drives.Add(Drive, new List <Tuple <string, string> >() { new Tuple <string, string>(Expression, UNC) }); } }
public void MoveFirstUNCConflict(string FromDrive, string ToDrive) { if (!Drives.ContainsKey(FromDrive)) { log.Error($"{FromDrive} doesn't exist!"); return; } if (Drives.ContainsKey(ToDrive)) { log.Error($"{ToDrive} is already in use!"); return; } List <Tuple <string, string> > uncs = Drives[FromDrive]; Tuple <string, string> unc = uncs[1]; Drives.Add(ToDrive, new List <Tuple <string, string> >() { unc }); uncs.RemoveAt(1); log.Debug($"Moved \"{FromDrive}\" [{unc.Item1} = {unc.Item2}] to \"{ToDrive}\""); }