public string Explain(string JSON) { if (JSON == null) { return("SMART Data: no data"); } try { ReportingSMART rd = JsonConvert.DeserializeObject <ReportingSMART>(JSON); if (rd.UpdatedAttribs == null) { rd.UpdatedAttribs = new List <int>(); } string res = "--- ERROR - FAILURE IMMINENT ---\r\n"; res += rd.App.Model + "\r\n"; res += "SN: " + rd.App.SerialNumber + "\r\n"; res += "Firmware: " + rd.App.FirmwareRevision + "\r\n"; res += "Size: " + CommonUtilities.NiceSize(rd.App.Size) + "\r\n\r\n"; if (rd.App.Attributes == null) { rd.App.Attributes = new Dictionary <int, VulpesSMARTAttribute>(); } if (rd.App.Attributes.Count > 0) { res += "Attrib|Name|Ideal|Fail|Value|Threshold|Worst|Raw\r\n"; } foreach (KeyValuePair <int, VulpesSMARTAttribute> kvp in rd.App.Attributes) { string Name = "???"; string AttribIdeal = ""; if (SMARTDescription.Descriptions.ContainsKey(kvp.Key) == true) { Name = SMARTDescription.Descriptions[kvp.Key].Description; switch (SMARTDescription.Descriptions[kvp.Key].Ideal) { case SMARTDescriptionEnum.Critical: AttribIdeal = "‼"; break; case SMARTDescriptionEnum.LowIdeal: AttribIdeal = "↓"; break; case SMARTDescriptionEnum.HighIdeal: AttribIdeal = "↑"; break; } } res += "0x" + kvp.Value.ID.ToString("X") + "|" + Name + "|" + AttribIdeal + "|" + (kvp.Value.FailureImminent == true ? "!true!" : "false") + "|" + kvp.Value.Value + "|" + kvp.Value.Threshold + "|" + kvp.Value.Worst + "|" + kvp.Value.Vendordata + (SMARTDescription.IsAttribInError(kvp.Value) == true ? " ◄ ◄ ◄ ◄ ◄" : "") + (rd.UpdatedAttribs.Contains(kvp.Key) == true ? "←←" : "") + "\r\n"; } return(res); } catch { return("SMART Report Data faulty: " + JSON); } }
private void lstDisks_SelectedIndexChanged(object sender, EventArgs e) { lstSmartAttr.Items.Clear(); if (lstDisks.SelectedItems.Count == 0) { return; } VulpesSMARTInfo i = (VulpesSMARTInfo)lstDisks.SelectedItems[0].Tag; if (i.Attributes == null) { return; } foreach (KeyValuePair <int, VulpesSMARTAttribute> kvp in i.Attributes) { ListViewItem l = new ListViewItem("0x" + kvp.Key.ToString("X")); l.Tag = kvp.Value; string Name = "???"; string AttribIdeal = ""; if (SMARTDescription.Descriptions.ContainsKey(kvp.Key) == true) { Name = SMARTDescription.Descriptions[kvp.Key].Description; switch (SMARTDescription.Descriptions[kvp.Key].Ideal) { case SMARTDescriptionEnum.Critical: AttribIdeal = "‼"; break; case SMARTDescriptionEnum.LowIdeal: AttribIdeal = "↓"; break; case SMARTDescriptionEnum.HighIdeal: AttribIdeal = "↑"; break; } } l.SubItems.Add(Name); l.SubItems.Add(AttribIdeal); l.SubItems.Add(kvp.Value.FailureImminent == true ? "!true!" : "false"); l.SubItems.Add(kvp.Value.Value.ToString()); l.SubItems.Add(kvp.Value.Threshold.ToString()); l.SubItems.Add(kvp.Value.Worst.ToString()); l.SubItems.Add(kvp.Value.Vendordata.ToString()); if (SMARTDescription.IsAttribInError(kvp.Value) == true) { l.ForeColor = Color.Red; l.UseItemStyleForSubItems = true; } lstSmartAttr.Items.Add(l); } }