public CustomJsonResult HistoryDataForOID(string id, string oid, int count) { int agentId; HistoryMonitorDataModel history = null; try { SNMPController controller = new SNMPController(Properties.Settings.Default.ProdDatabaseConnectionString); if (int.TryParse(id, out agentId)) { List <MonitorData> businessLayerHistory = controller.GetHistoryOfOIDForAgent(agentId, oid, count); businessLayerHistory.Sort((item1, item2) => item1.Timestamp.CompareTo(item2.Timestamp)); history = new HistoryMonitorDataModel(businessLayerHistory); } else { BusinessLayer.ExceptionHandling.ExceptionCore.HandleException(BusinessLayer.ExceptionHandling.ExceptionCategory.Normal, new FormatException("HistoryDataForOID: id not Integer")); } } catch (Exception exc) { BusinessLayer.ExceptionHandling.ExceptionCore.HandleException(BusinessLayer.ExceptionHandling.ExceptionCategory.Normal, exc); } return(new CustomJsonResult { Data = history, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public void GetHistoryOfOIDForAgentTest() { List <MonitorData> list = controller.GetHistoryOfOIDForAgent(1, "1.3.6.1.2.1.1.5.0", 10); Assert.IsTrue(list.Count <= 10); }