using MP_MON.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Configuration; using System.Web.Mvc; namespace MP_MON.Controllers { public class HomeController : Controller { private MoonProEntities db = new MoonProEntities(); public ActionResult Index() { // ricarico ogni minuto COMUNQUE tutto... string pageRefreshSec = "60"; // refresh std ogni sec int pageRefreshMs = 1000; ViewBag.cssSemBase = "sem"; try { pageRefreshSec = WebConfigurationManager.AppSettings["pageRefreshSec"]; } catch { } if (pageRefreshSec == "") pageRefreshSec = "60"; ViewBag.pageRefreshMs = pageRefreshMs; Response.AddHeader("Refresh", pageRefreshSec); return View(); } public ActionResult Blink() { // ricarico ogni minuto COMUNQUE tutto... string pageRefreshSec = "60"; // se ho animazione refresh è ogni 2 sec... int pageRefreshMs = 2000; ViewBag.cssSemBase = "semBlink"; try { pageRefreshSec = WebConfigurationManager.AppSettings["pageRefreshSec"]; } catch { } if (pageRefreshSec == "") pageRefreshSec = "60"; ViewBag.pageRefreshMs = pageRefreshMs; Response.AddHeader("Refresh", pageRefreshSec); return View("Index"); } public ActionResult GetClock() { return PartialView("_mmClock"); } public ActionResult checkIOB() { string esito = "ND"; // verifico TUTTE le macchine x il keepAlive e se almeno 1 è offline da oltre "keepAliveMin" minuti --> invio email!!! int keepAliveMin = 1; try { keepAliveMin = Convert.ToInt32(WebConfigurationManager.AppSettings["keepAliveMin"]); } catch { } // recupero elenco macchine offline e mostro! var MappaStato = db.stp_MSE_getOffline(keepAliveMin); List risultato = MappaStato.ToList(); int numKO = risultato.Count; // invio email SE ne ho trovate > 0... !!!FARE!!! if (numKO > 0) { // scrivo esito esito = string.Format("Trovate {0} schede offline", numKO); } else { esito = "OK"; } ViewBag.EsitoVerifica = esito; // inserisco elenco macchine offline x rendering in aprtialView return PartialView("_checkIOB", risultato); } } }