Ejemplo n.º 1
0
        public ActionResult FromCurrent()
        {
            List <int> alarms = (List <int>)Session["alarmIDs"];

            if (alarms != null)
            {
                Session["alarmIDs"] = null;
                if (Session["AlarmDB"].ToString() == "")
                {
                    string DB = string.Empty;
                    foreach (string key in Session.Keys)
                    {
                        if (key.Contains("dbName" + Request.QueryString["name"] + Request.QueryString["plc"]))
                        {
                            DB = Session[key].ToString();
                        }
                    }
                    Session["AlarmDB"] = DB;
                }
                ViewBag.Alarms = AlarmNotificationHandler.SelectAlarmsTexts(Session["AlarmDB"].ToString(), alarms);
                return(View("All"));
            }
            Session["tempforview"] = "Problem with accesing current alarms";
            return(RedirectToAction("Index", "Alarm"));
        }
        /// <summary>
        /// get notifications
        /// </summary>
        /// <param name="ActiveNotifications"></param>
        /// <returns></returns>
        public async Task <JsonResult> getNotifications(List <Notification> ActiveNotifications = null)
        {
            List <Notification>     resultNotifications = new List <Notification>();
            NotificationDataContext db = new NotificationDataContext();

            if (ActiveNotifications == null)
            {
                ActiveNotifications = db.Notifications.Where(p => p.Owner == User.Identity.Name).ToList();
            }
            // TOMAS
            if (false)
            {
                foreach (Notification notification in ActiveNotifications)
                {
                    if (notification.Active == true)
                    {
                        switch (notification.Type)
                        { //In the future here will come next type for other type of notifications
                        case 1:
                            AlarmNotificationController ANC = new AlarmNotificationController();
                            Notification Anotif             = new Notification();
                            Anotif = await AlarmNotificationHandler.getNotifcations(notification);

                            if (Anotif.Status == null)
                            {
                                break;
                            }
                            if (Anotif.Status == 1)
                            {
                                resultNotifications.Add(Anotif);
                            }
                            break;

                        case 2:
                            GraphNotificationController GNC = new GraphNotificationController();
                            Notification Gnotif             = new Notification();
                            Gnotif = await GraphNotificationHandler.getNotifcations(notification);

                            if (Gnotif == null)
                            {
                                break;
                            }
                            if (Gnotif.Status == 1)
                            {
                                resultNotifications.Add(Gnotif);
                            }
                            break;
                        }
                    }
                }
            }
            return(Json(resultNotifications, "application/json", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        // GET: AlarmNofication
        public ActionResult All()
        {
            string DB = null;

            foreach (string key in Session.Keys)
            {
                if (key.Contains("dbName" + Request.QueryString["name"] + Request.QueryString["plc"]))
                {
                    DB = Session[key].ToString();
                }
            }
            ViewBag.Alarms = AlarmNotificationHandler.SelectAlarmsTexts(DB);
            return(View());
        }