Files
MoonPro.net/MP-Tablet/windowSize.ashx.cs
T
2018-03-07 17:42:10 +01:00

57 lines
2.0 KiB
C#

using SteamWare;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MoonProTablet
{
/// <summary>
/// Descrizione di riepilogo per windowSize
/// vedere https://techbrij.com/browser-height-width-server-responsive-design-asp-net
/// </summary>
public class windowSize : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
/// <summary>
/// Processa la richeista andando a recuperare width-height del browser
/// </summary>
/// <param name="context"></param>
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
var json = new System.Web.Script.Serialization.JavaScriptSerializer();
var output = json.Serialize(new { isFirst = context.Session["BrowserWidth"] == null });
context.Response.Write(output);
string Width = context.Request.QueryString["Width"];
string Height = context.Request.QueryString["Height"];
string scrWidth = context.Request.QueryString["scrWidth"];
string scrHeight = context.Request.QueryString["scrHeight"];
string PixRat = context.Request.QueryString["PixRat"];
context.Session["BrowserWidth"] = Width;
context.Session["BrowserHeight"] = Height;
// salva in REDIS come conteggio INCREMENTALE...
if (memLayer.ML.CRB("RedEnab"))
{
string memName = string.Format("COUNT:wh:{0}x{1}", Width, Height);
// conto +1 x la size nel contatore REDIS
long nCall = memLayer.ML.setRCntI(memLayer.ML.redHash(memName));
// conto anche SCHERMO...
memName = string.Format("COUNT:scr:{0}x{1}", scrWidth, scrHeight);
nCall = memLayer.ML.setRCntI(memLayer.ML.redHash(memName));
// salvo la PIXEL RATIO con WINDOWS...
memName = string.Format("COUNT:wpr:[{2}] {0}x{1}", Width, Height, PixRat);
nCall = memLayer.ML.setRCntI(memLayer.ML.redHash(memName));
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}