83 lines
2.2 KiB
C#
83 lines
2.2 KiB
C#
using MP_MON.Models;
|
|
using Newtonsoft.Json;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
|
|
namespace MP_MON.Controllers
|
|
{
|
|
public class MSEController : Controller
|
|
{
|
|
private MoonProEntities db = new MoonProEntities();
|
|
|
|
// GET: StatusMap
|
|
public ActionResult StatusMap(string baseCss)
|
|
{
|
|
return SingleStatus(baseCss, "");
|
|
}
|
|
|
|
// GET: StatusMap
|
|
public ActionResult SingleStatus(string baseCss, string IdxMacchina)
|
|
{
|
|
int dataRefresh = 2000;
|
|
// salvo idxMacc in sessione se c'è...
|
|
if (IdxMacchina != "" && IdxMacchina != null)
|
|
{
|
|
memLayer.ML.setSessionVal("IdxMacchina", IdxMacchina);
|
|
}
|
|
else
|
|
{
|
|
IdxMacchina = memLayer.ML.StringSessionObj("IdxMacchina");
|
|
}
|
|
try
|
|
{
|
|
dataRefresh = Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["dataRefreshMs"]);
|
|
}
|
|
catch
|
|
{ }
|
|
// cerco su REDIS...
|
|
string hMSE = MapoDb.DataLayer.hMSE();
|
|
string dataSer = memLayer.ML.getRSV(hMSE);
|
|
List<MappaStatoExpl> dati = new List<MappaStatoExpl>();
|
|
if (dataSer != "" && dataSer != null)
|
|
{
|
|
try
|
|
{
|
|
dati = JsonConvert.DeserializeObject<List<MappaStatoExpl>>(dataSer);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
dati = db.stp_MSE_getData(dataRefresh).ToList();
|
|
logger.lg.scriviLog(string.Format("Recuperata MSE da DB{0}{1}", Environment.NewLine, exc));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// se non c'è rileggo...
|
|
dati = db.stp_MSE_getData(dataRefresh).ToList();
|
|
// serializzo
|
|
dataSer = JsonConvert.SerializeObject(dati);
|
|
// metto in redis
|
|
memLayer.ML.setRSV(hMSE, dataSer, memLayer.ML.CRI("MSE_cacheDuration"));
|
|
}
|
|
// filtro dati SOLO PER la macchina che mi interessa...
|
|
dati = dati.Where(e => e.IdxMacchina == IdxMacchina).ToList();
|
|
ViewBag.baseCss = baseCss;
|
|
ViewBag.IdxMacchina = IdxMacchina;
|
|
return PartialView("_StatusMapSingle", dati);
|
|
}
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
db.Dispose();
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
}
|
|
}
|