inserita modalità test REDIS x salvataggio hash e recupero (X MP/IO e checkStato)
This commit is contained in:
+158
-61
@@ -1,71 +1,168 @@
|
||||
using MapoDb;
|
||||
using SteamWare;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace MP_IO.Controllers
|
||||
{
|
||||
public class BENCHController : Controller
|
||||
public class BENCHController : Controller
|
||||
{
|
||||
// GET: IOB (è un check alive)
|
||||
public string Index()
|
||||
{
|
||||
// GET: IOB (è un check alive)
|
||||
public string Index()
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
|
||||
// disabilitato: non vale la pena
|
||||
//// GET: IOB/enabled/5 - tenuta in cache per 5 sec...
|
||||
//[OutputCache(Duration = 5, VaryByParam = "id")]
|
||||
|
||||
// GET: BENCH/DB/1000
|
||||
public string DB(int? id)
|
||||
{
|
||||
string answ = "ND";
|
||||
// se id nullo --> KO!
|
||||
if (id == null)
|
||||
{
|
||||
answ = "KO";
|
||||
}
|
||||
else
|
||||
{
|
||||
int numRep = 0;
|
||||
Int32.TryParse(id.ToString(), out numRep);
|
||||
try
|
||||
{
|
||||
answ = MapoDb.MapoDb.obj.benchReadTI("DB", numRep);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore in BENCH/DB{0}{1}", Environment.NewLine, exc));
|
||||
answ = "NO";
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
// GET: BENCH/RED/1000
|
||||
public string RED(int? id)
|
||||
{
|
||||
string answ = "ND";
|
||||
// se id nullo --> KO!
|
||||
if (id == null)
|
||||
{
|
||||
answ = "KO";
|
||||
}
|
||||
else
|
||||
{
|
||||
int numRep = 0;
|
||||
Int32.TryParse(id.ToString(), out numRep);
|
||||
try
|
||||
{
|
||||
answ = MapoDb.MapoDb.obj.benchReadTI("RED", numRep);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore in BENCH/RED{0}{1}", Environment.NewLine, exc));
|
||||
answ = "NO";
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
// GET: BENCH/DB/1000
|
||||
public string DB(int? id)
|
||||
{
|
||||
string answ = "ND";
|
||||
// se id nullo --> KO!
|
||||
if (id == null)
|
||||
{
|
||||
answ = "KO";
|
||||
}
|
||||
else
|
||||
{
|
||||
int numRep = 0;
|
||||
Int32.TryParse(id.ToString(), out numRep);
|
||||
try
|
||||
{
|
||||
answ = MapoDb.MapoDb.obj.benchReadTI("DB", numRep);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore in BENCH/DB{0}{1}", Environment.NewLine, exc));
|
||||
answ = "NO";
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
// GET: BENCH/RED/1000
|
||||
public string RED(int? id)
|
||||
{
|
||||
string answ = "ND";
|
||||
// se id nullo --> KO!
|
||||
if (id == null)
|
||||
{
|
||||
answ = "KO";
|
||||
}
|
||||
else
|
||||
{
|
||||
int numRep = 0;
|
||||
Int32.TryParse(id.ToString(), out numRep);
|
||||
try
|
||||
{
|
||||
answ = MapoDb.MapoDb.obj.benchReadTI("RED", numRep);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore in BENCH/RED{0}{1}", Environment.NewLine, exc));
|
||||
answ = "NO";
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
// GET BENCH/RSETUP/100
|
||||
public string RSETUP(int? id)
|
||||
{
|
||||
string answ = "ND";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
// se id nullo --> KO!
|
||||
if (id == null)
|
||||
{
|
||||
answ = "KO";
|
||||
}
|
||||
else
|
||||
{
|
||||
string chiave;
|
||||
KeyValuePair<string, string>[] valori = new KeyValuePair<string, string>[2];
|
||||
try
|
||||
{
|
||||
// svuoto i precedenti hash... CICLO!
|
||||
for (int i = 0; i < id; i++)
|
||||
{
|
||||
chiave = string.Format("test:{0}", i);
|
||||
memLayer.ML.redDelKey(chiave);
|
||||
}
|
||||
// recupero tutti i record della tabella
|
||||
|
||||
// salvo il datasetet come insieme di hash in redis...
|
||||
for (int i = 0; i < id; i++)
|
||||
{
|
||||
chiave = string.Format("test:{0}", i);
|
||||
valori[0] = new KeyValuePair<string, string>("numero", i.ToString());
|
||||
valori[1] = new KeyValuePair<string, string>("doppio", (i * 2).ToString());
|
||||
memLayer.ML.redSaveHash(chiave, valori);
|
||||
}
|
||||
answ = "OK";
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
stopWatch.Stop();
|
||||
// Get the elapsed time as a TimeSpan value.
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
// accodo tempo!
|
||||
answ = string.Format("Elapsed: {0}ms", ts.TotalMilliseconds);
|
||||
// ritorno
|
||||
return answ;
|
||||
}
|
||||
// GET BENCH/RSH/100
|
||||
public string RSH(int? id)
|
||||
{
|
||||
string answ = "ND";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
// se id nullo --> KO!
|
||||
if (id == null)
|
||||
{
|
||||
answ = "KO";
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = "";
|
||||
string chiave;
|
||||
KeyValuePair<string, string>[] valori = new KeyValuePair<string, string>[2];
|
||||
try
|
||||
{
|
||||
//// svuoto i precedenti hash... CICLO!
|
||||
//for (int i = 0; i < 1000; i++)
|
||||
//{
|
||||
// chiave = string.Format("test:{0}", i);
|
||||
// memLayer.ML.redDelKey(chiave);
|
||||
//}
|
||||
//// recupero tutti i record della tabella
|
||||
|
||||
//// salvo il datasetet come insieme di hash in redis...
|
||||
//for (int i = 0; i < 1000; i++)
|
||||
//{
|
||||
// chiave = string.Format("test:{0}", i);
|
||||
// valori[0] = new KeyValuePair<string, string>("numero", i.ToString());
|
||||
// valori[1] = new KeyValuePair<string, string>("doppio", (i * 2).ToString());
|
||||
// memLayer.ML.redSaveHash(chiave, valori);
|
||||
//}
|
||||
// ora restituisco record completo dell'hash con ID indicato
|
||||
chiave = string.Format("test:{0}", id);
|
||||
valori = memLayer.ML.redGetHash(chiave);
|
||||
foreach (var item in valori)
|
||||
{
|
||||
answ += string.Format("{0}|{1}<br/>", item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
stopWatch.Stop();
|
||||
// Get the elapsed time as a TimeSpan value.
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
// accodo tempo!
|
||||
answ += string.Format("<hr/>Elapsed: {0}ms", ts.TotalMilliseconds);
|
||||
// ritorno
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user