/// <param name="id">Id is page </param>s public async Task <ActionResult> Page(int page = 0, int count = 30) { List <int> alarms = new List <int>(); string lang = "en"; if (Session["filteredAlarms"] != null) { alarms = (List <int>)Session["filteredAlarms"]; } else { alarms = null; } int offsetPage = page * count; if (page < 0) { Session["tempforview"] = "You have reached the minimum alarm page"; return(RedirectToAction("Index")); } List <AlarmHelper.alarm> model = new List <AlarmHelper.alarm>(); AlarmHelper AH = new AlarmHelper(); int plcID = 1; if (int.Parse(Session["AlarmPlcID"].ToString()) != 0) { plcID = int.Parse(Session["AlarmPlcID"].ToString()); } if (Session["AlarmLang"] != null) { if (Session["AlarmLang"].ToString().Length >= 2) { lang = Session["AlarmLang"].ToString(); } } model = await AH.SelectAlarms(Session["AlarmDB"].ToString(), page, 30, alarms, plcID, lang); if (model.Count == 0) { Session["tempforview"] = "No alarms has been found"; return(RedirectToAction("Index")); } ViewBag.page = page; ViewBag.legend = "Notification from current alarms means only from the unique ones \n Other occurence of the alarm would not viewed"; return(View("Index", model)); }
public async Task <JsonResult> getAlarmsData() { try { StreamReader stream = new StreamReader(Request.InputStream); string json = stream.ReadToEnd(); DataRequest dataRequest = new JavaScriptSerializer().Deserialize <DataRequest>(json); string DB = string.Empty; string table = string.Empty; int plcID = 1; foreach (string key in Session.Keys) { if (key.Contains("plcID") && key.Contains(Request.QueryString["plc"].ToString())) { plcID = (int)Session[key]; } if (key.Contains("dbName") && key.Contains(Request.QueryString["plc"].ToString())) { DB = Session[key].ToString(); } if (key.Contains("tableName") && key.Contains(Request.QueryString["plc"].ToString())) { table = Session[key].ToString(); } } List <AlarmGraphData> data = new List <AlarmGraphData>(); AlarmHelper AH = new AlarmHelper(); data = await AH.SelectAlarms(DB, dataRequest.beginTime, dataRequest.beginTime + dataRequest.timeAxisLength, plcID); return(Json(data)); } catch (Exception e) { List <AlarmGraphData> data = new List <AlarmGraphData>(); AlarmGraphData mesData = new AlarmGraphData(); mesData.title = e.Message.ToString(); data.Add(mesData); AlarmGraphData source = new AlarmGraphData(); source.title = e.Source.ToString(); data.Add(source); return(Json(data)); } }
// GET: Alarm public async Task <ActionResult> Index() { DBConnnection(); int plcID = 1; string lang = "en"; if (Session["AlarmPlcID"] != null) { plcID = int.Parse(Session["AlarmPlcID"].ToString()); } if (Session["AlarmLang"] != null) { if (Session["AlarmLang"].ToString().Length >= 2) { lang = Session["AlarmLang"].ToString(); } } List <int> alarms = new List <int>(); if (Session["filteredAlarms"] != null) { alarms = (List <int>)Session["filteredAlarms"]; } else { alarms = null; } List <AlarmHelper.alarm> model = new List <AlarmHelper.alarm>(); AlarmHelper AH = new AlarmHelper(); model = await AH.SelectAlarms(Session["AlarmDB"].ToString(), 0, 30, alarms, plcID, lang); ViewBag.page = 0; ViewBag.legend = "Notification from current alarms means only from the unique ones \n Other occurence of the alarm would not viewed"; return(View(model)); }