Example #1
0
        public static string GetFixedDrivesStatus()
        {
            try
            {
                var driveInfo = WmiController.GetSmartInformation();
                var result    = new StringBuilder();

                foreach (var drive in driveInfo)
                {
                    result.AppendLine("-----------------------------------------------------");
                    result.AppendLine($" DRIVE ({((drive.IsOK) ? "OK" : "BAD")}): {drive.Serial} - {drive.Model} - {drive.Type}");
                    result.AppendLine("-----------------------------------------------------");
                    result.AppendLine("");

                    result.AppendLine("Attribute\t\t\tCurrent  Worst  Threshold  Data  Status");
                    var maxNameLen = drive.SmartAttributes.Max(s => s.Name.Length);
                    foreach (var attr in drive.SmartAttributes)
                    {
                        if (attr.HasData)
                        {
                            result.AppendLine($"{attr.Name.PadRight(maxNameLen, ' ')} {attr.Current}\t {attr.Worst}\t {attr.Threshold}\t {attr.Data.ToString().PadRight(9, ' ')} {((attr.IsOK) ? "OK" : "BAD")}");
                        }
                    }
                    result.AppendLine();
                }


                return(result.ToString());
            }
            catch (Exception e)
            {
                Logger.Log.Error(e);
                return("Unknown");
            }
        }
Example #2
0
 public static DriveCollection GetDrives()
 {
     return(WmiController.GetSmartInformation());
 }