182 lines
4.5 KiB
C#
182 lines
4.5 KiB
C#
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
|
|
{
|
|
// GET: IOB (è un check alive)
|
|
public string Index()
|
|
{
|
|
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/RCLEAN/100
|
|
public string RCLEAN(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);
|
|
}
|
|
answ = "OK";
|
|
}
|
|
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;
|
|
}
|
|
// 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
|
|
{
|
|
// 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("<hr/>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
|
|
{
|
|
// 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;
|
|
}
|
|
}
|
|
} |