// POST: AlarmNofication public RedirectToRouteResult NewNotification() { string definition = ""; string tags = ""; List <string> tablesList = new List <string>(); string table = null; foreach (string key in Request.Form.AllKeys) { string[] values = Request.Form.GetValues(key); if (key.Contains("table")) { if (values != null) { table = values[0]; // Change table from hidden } values = null; if (tablesList.Exists(p => { return(table != null && p.Contains(table)); }) == false) { tablesList.Add(table); //Add table which is not } } if (values != null) { if (values[0].Contains("on")) { definition += " AND " + "\"" + table + "\".\"" + key + "\" "; tags += "\"" + table + "\".\"" + key + "\","; } else { definition += " " + values[0] + " "; } } } definition = definition.TrimEnd(); string tables = string.Join(",", tablesList.ToArray()); tags = tags.Substring(0, tags.Length - 1);//substring the last comma //definition = definition.Substring(3);//Substring the string from AND string projectName = Session["ProjectName"].ToString(); string userName = User.Identity.Name; int bakeryID = int.Parse(Session["id"].ToString()); int type = 2; Session["success"] = "Notification on following alarms has been set: " + definition; NotificationController.Add(definition, projectName, userName, bakeryID, type, tags, tables); return(RedirectToAction("Index", "Notification")); }
// POST: AlarmNofication public RedirectToRouteResult NewNotification() { string sIds = ""; string[] keys = Request.Form.AllKeys; foreach (string sId in keys) { //ids.Add(int.Parse(sId)); sIds += sId + " "; } sIds = sIds.Substring(0, sIds.Length - 1);//substring the last comma string projectName = Session["ProjectName"].ToString(); string userName = User.Identity.Name; int bakeryID = int.Parse(Session["id"].ToString()); int type = 1; Session["success"] = "Notification on following alarms has been set: " + sIds; NotificationController.Add(sIds, projectName, userName, bakeryID, type); return(RedirectToAction("Index", "Notification")); }