Example #1
0
        public ActionResult Index()
        {
            HealthEventViewModel model = null;

            using (StreamReader file = System.IO.File.OpenText(string.Format(@"{0}\App_Data\{1}", Server.MapPath("~"), Definitions.HEALTH_EVENT_JSON_FILE)))
            {
                var serializer = new JsonSerializer();
                model = (HealthEventViewModel)serializer.Deserialize(file, typeof(HealthEventViewModel));
            }
            Session[Definitions.HEALTH_EVENT_MODEL_KEY] = model;
            return(View(model));
        }
Example #2
0
        //[Ignore("skip DeserializeTest")]
        public void DeserializeTest()
        {
            _healthEventViewModel = new HealthEventViewModel
            {
                eventType     = "Intel® ME Firmware Health Event",
                responsedatas = new response[] {
                    new response {
                        description = "Byte 5 – Event Data 1",
                        dependence  = "",
                        hex         = false,
                        positions   = new position[] {
                            new position {
                                pos    = "[6:7]",
                                values = new valueData[] {
                                    new valueData {
                                        value       = "10b",
                                        description = "OEM code in byte 2"
                                    }
                                }
                            },
                        }
                    },
                    new response {
                        description = "Byte 6 – Event Data 2",
                        dependence  = "",
                        hex         = true,
                        positions   = new position[] {
                            new position {
                                pos    = "[0:7]",
                                values = new valueData[] {
                                    new valueData {
                                        value       = "00",
                                        description = "Recovery GPIO forced. Recovery Image loaded due to recovery MGPIO pin asserted. Pin number is configurable in factory presets, Default recovery pin is MGPIO1. Repair action: Deassert MGPIO1 and reset the Intel® ME"
                                    },
                                    new valueData {
                                        value       = "01",
                                        description = "Image execution failed. Recovery Image or backup operational image loaded because operational image is corrupted. This may be either caused by Flash device corruption or failed upgrade procedure. Repair action: Either the Flash device must be replaced (if error is persistent) or the upgrade procedure must be started again."
                                    },
                                    new valueData {
                                        value       = "02",
                                        description = "Flash erase error. Error during Flash erasure procedure probably due to Flash part corruption. Repair action: The Flash device must be replaced."
                                    },
                                    new valueData {
                                        value       = "03",
                                        description = "Flash state information. Repair action: Check extended info byte in Event Data 3 (byte 7) whether this is wear-out protection causing this event. If so just wait until wear-out protection expires, otherwise probably the flash device must be replaced (if error is persistent)."
                                    },
                                    new valueData {
                                        value       = "04",
                                        description = "Internal error. Error during firmware execution – Repair action: Firmware should automatically recover from error state. If error is persistent then operational image shall be updated or hardware board repair is needed."
                                    },
                                    new valueData {
                                        value       = "05",
                                        description = "BMC did not respond correctly to Chassis Control - Power Down command triggered by Intel® Node Manager policy failure action and Intel® ME forced shutdown. Repair action: Verify the Intel® Node Manager policy configuration."
                                    },
                                    new valueData {
                                        value       = "06",
                                        description = "Direct Flash update requested by the BIOS. Intel® ME Firmware will switch to recovery mode to perform full update from BIOS. Repair action: This is transient state. Intel® ME Firmware should return to operational mode after successful image update performed by the BIOS."
                                    },
                                }
                            },
                        }
                    },
                }
            };
            var json = new JsonFormatter(JsonConvert.SerializeObject(_healthEventViewModel)).Format();

            Assert.True(!string.IsNullOrEmpty(json));
            //File.WriteAllText(JSON_FILE, json);
        }
Example #3
0
        public static string[] DecodeFromJson(string data, HealthEventViewModel decodingConfig, string itemformat)
        {
            if (string.IsNullOrEmpty(data) || decodingConfig == null || string.IsNullOrEmpty(itemformat))
            {
                return(null);
            }

            var results       = new List <string>();
            var dependencyDic = new Dictionary <string, string>();
            var response      = Hex2BinConverter(data, " ").Split(' ');
            var idxH          = 0;
            var idxL          = 2;

            foreach (var d in decodingConfig.responsedatas)
            {
                var dependenceValue = string.Empty;
                var dependenceKey   = d.dependence.Trim();
                var buffer          = new List <string>();
                var values          = new List <valueData>();
                var ishex           = d.hex;
                for (var i = idxH; i < idxL; ++i)
                {
                    buffer.Add(response[i]);
                }
                if (!ishex)
                {
                    buffer.Reverse();
                }
                foreach (var p in d.positions)
                {
                    if (!string.IsNullOrEmpty(dependenceKey) && dependencyDic.ContainsKey(dependenceKey))
                    {
                        dependenceValue = dependencyDic[dependenceKey];
                        foreach (var px in p.values)
                        {
                            if (px.value == dependenceValue)
                            {
                                values.AddRange(px.values);
                                break;
                            }
                        }
                    }
                    else
                    {
                        values.AddRange(p.values);
                    }

                    if (values.Count == 0)
                    {
                        continue;
                    }

                    foreach (var x in values)
                    {
                        var lookup = Hex2BinConverter(x.value);
                        var match  = false;
                        if (ishex)
                        {
                            match = buffer[0] + buffer[1] == lookup;
                        }
                        else
                        {
                            var position = p.pos.Trim().TrimStart('[').TrimEnd(']').Split(':');
                            var s        = string.Join(string.Empty, buffer.ToArray());
                            var val      = new StringBuilder();
                            for (var i = int.Parse(position[0]); i < int.Parse(position[1]) + 1; ++i)
                            {
                                val.Append(s[i].ToString());
                            }
                            match = val.ToString() == lookup;
                        }
                        if (match)
                        {
                            var v = x.value;
                            if (!string.IsNullOrEmpty(dependenceValue))
                            {
                                v = string.Format("{0} - {1}[{2}]", dependenceValue, d.description, v);
                            }
                            var s = string.Format(itemformat, v, x.description);
                            if (!results.Contains(s))
                            {
                                results.Add(s);
                            }
                            if (!dependencyDic.ContainsKey(d.description))
                            {
                                dependencyDic[d.description] = v;
                            }
                        }
                    }
                }

                idxH += 2;
                idxL += 2;
            }
            return(results.ToArray());
        }