Gestioner WebApi x REST call
This commit is contained in:
@@ -13,6 +13,7 @@ namespace GPW_Smart
|
||||
var settings = new FriendlyUrlSettings();
|
||||
settings.AutoRedirectMode = RedirectMode.Permanent;
|
||||
routes.EnableFriendlyUrls(settings);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Web.Http;
|
||||
|
||||
namespace GPW_Smart
|
||||
{
|
||||
public static class WebApiConfig
|
||||
{
|
||||
public static void Register(HttpConfiguration config)
|
||||
{
|
||||
// Servizi e configurazione dell'API Web
|
||||
|
||||
// Route dell'API Web
|
||||
config.MapHttpAttributeRoutes();
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "DefaultApi",
|
||||
routeTemplate: "api/{controller}/{id}",
|
||||
defaults: new { id = RouteParameter.Optional }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace GPW_Smart.Controllers
|
||||
{
|
||||
public class TempHistController : ApiController
|
||||
{
|
||||
// GET api/<controller>
|
||||
public IEnumerable<string> Get()
|
||||
{
|
||||
return new string[] { "value1", "value2" };
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
public string Get(int id)
|
||||
{
|
||||
return "value";
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using GPW_data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@@ -9,31 +10,63 @@ namespace GPW_Smart.Controllers
|
||||
{
|
||||
public class TempRilController : ApiController
|
||||
{
|
||||
// GET api/<controller>
|
||||
public IEnumerable<string> Get()
|
||||
// GET api/TempRil
|
||||
public string Get()
|
||||
{
|
||||
return new string[] { "value1", "value2" };
|
||||
return "NA";
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
public string Get(int id)
|
||||
// GET api/TempRil/5
|
||||
public List<chartJsTimeSerie> Get(int id)
|
||||
{
|
||||
return "value";
|
||||
|
||||
|
||||
List<chartJsTimeSerie> answ = new List<chartJsTimeSerie>();
|
||||
|
||||
// recupero dati
|
||||
var tabDati = DataProxy.DP.taRT.getByUserPeriod(id, DateTime.Today, 0);
|
||||
|
||||
foreach (var item in tabDati)
|
||||
{
|
||||
answ.Add(new chartJsTimeSerie() { x = item.dtRilievo, y = item.tempRil });
|
||||
}
|
||||
|
||||
// restituisco oggetto!
|
||||
return answ;
|
||||
}
|
||||
// GET api/TempRil/5?date=2020-09-01&numRec=10
|
||||
public List<chartJsTimeSerie> Get(int id, string date, int numRec)
|
||||
{
|
||||
DateTime dtRif = DateTime.Today;
|
||||
DateTime.TryParse(date, out dtRif);
|
||||
|
||||
List<chartJsTimeSerie> answ = new List<chartJsTimeSerie>();
|
||||
|
||||
// recupero dati
|
||||
var tabDati = DataProxy.DP.taRT.getByUserPeriod(id, dtRif, numRec);
|
||||
|
||||
foreach (var item in tabDati)
|
||||
{
|
||||
answ.Add(new chartJsTimeSerie() { x = item.dtRilievo, y = item.tempRil });
|
||||
}
|
||||
|
||||
// restituisco oggetto!
|
||||
return answ;
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
//// POST api/TempRil
|
||||
//public void Post([FromBody] string value)
|
||||
//{
|
||||
//}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
//// PUT api/TempRil/5
|
||||
//public void Put(int id, [FromBody] string value)
|
||||
//{
|
||||
//}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
//// DELETE api/TempRil/5
|
||||
//public void Delete(int id)
|
||||
//{
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -733,6 +733,7 @@
|
||||
</Compile>
|
||||
<Compile Include="App_Start\BundleConfig.cs" />
|
||||
<Compile Include="App_Start\RouteConfig.cs" />
|
||||
<Compile Include="App_Start\WebApiConfig.cs" />
|
||||
<Compile Include="attivitaIns.aspx.cs">
|
||||
<DependentUpon>attivitaIns.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using System.Web.Optimization;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
@@ -13,6 +14,7 @@ namespace GPW_Smart
|
||||
{
|
||||
void Application_Start(object sender, EventArgs e)
|
||||
{
|
||||
GlobalConfiguration.Configure(WebApiConfig.Register);
|
||||
// Code that runs on application startup
|
||||
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
||||
BundleConfig.RegisterBundles(BundleTable.Bundles);
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<%@ WebService Language="C#" CodeBehind="gateway.asmx.cs" Class="GPW_Smart.WS.gateway" %>
|
||||
@@ -1,119 +0,0 @@
|
||||
using GPW_data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Script.Services;
|
||||
using System.Web.Services;
|
||||
|
||||
namespace GPW_Smart.WS
|
||||
{
|
||||
/// <summary>
|
||||
/// Descrizione di riepilogo per gateway
|
||||
/// </summary>
|
||||
[WebService(Namespace = "http://www.steamware.net/")]
|
||||
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||
[System.ComponentModel.ToolboxItem(false)]
|
||||
// Per consentire la chiamata di questo servizio Web dallo script utilizzando ASP.NET AJAX, rimuovere il commento dalla riga seguente.
|
||||
[System.Web.Script.Services.ScriptService]
|
||||
public class gateway : System.Web.Services.WebService
|
||||
{
|
||||
|
||||
[WebMethod]
|
||||
public string HelloWorld()
|
||||
{
|
||||
return "Hello World";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce un array di informazioni x rilievo temperature (serie dati)...
|
||||
/// - TITOLO
|
||||
/// - vettore valori come x,y
|
||||
/// </summary>
|
||||
/// <param name="idxDipendente"></param>
|
||||
/// <param name="dataRif"></param>
|
||||
/// <param name="maxRecords"></param>
|
||||
/// <returns></returns>
|
||||
[WebMethod]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
||||
public List<object> rilTempSerie(int idxDipendente, DateTime dataRif, int maxRecords = 0)
|
||||
{
|
||||
// init valori..
|
||||
List<object> allData = new List<object>();
|
||||
List<chartJsTimeSerie> valori = new List<chartJsTimeSerie>();
|
||||
|
||||
// aggiungo TITOLO della serie dati...
|
||||
allData.Add("Temperatura Rilevata");
|
||||
|
||||
// recupero dati
|
||||
var tabDati = DataProxy.DP.taRT.getByUserPeriod(idxDipendente, dataRif, maxRecords);
|
||||
|
||||
foreach (var item in tabDati)
|
||||
{
|
||||
valori.Add(new chartJsTimeSerie() { x = item.dtRilievo, y = item.tempRil });
|
||||
}
|
||||
|
||||
allData.Add(valori);
|
||||
// restituisco oggetto!
|
||||
return allData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce un array di informazioni x rilievo temperature (istogramma freq dati)...
|
||||
/// - TITOLO
|
||||
/// - MaxValore
|
||||
/// - vettore etichette
|
||||
/// - vettore valori
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[WebMethod]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
||||
public List<object> rilTempHist(int idxUser, DateTime dataRif, int maxRecords = 0)
|
||||
{
|
||||
// init valori..
|
||||
List<object> allData = new List<object>();
|
||||
List<string> etichette = new List<string>();
|
||||
List<int> valori = new List<int>();
|
||||
|
||||
#if false
|
||||
// aggiungo TITOLO della serie dati...
|
||||
string titolo = string.Format("VMD - {0:yyyy-MM-dd}", dataRif);
|
||||
allData.Add(titolo);
|
||||
int maxVal = 4;
|
||||
allData.Add(maxVal);
|
||||
// leggo info...
|
||||
DS_Applicazione.VisVMDDataTable tab = DtProxy.man.taVVMD.getByPaziente(idxUser, dataRif);
|
||||
// se contiene valori...
|
||||
if (tab.Rows.Count > 0)
|
||||
{
|
||||
// recupero SOLO i PENALTY... e sono 8...
|
||||
int valore = 0;
|
||||
for (int i = 0; i < tab.Columns.Count; i++)
|
||||
{
|
||||
// recupero nome colonna, se è "_" inserisco...
|
||||
if (tab.Columns[i].ToString().IndexOf("_p") >= 0)
|
||||
{
|
||||
etichette.Add(tab.Columns[i].ToString().Replace("_p", ""));
|
||||
Int32.TryParse(tab[0][i].ToString(), out valore);
|
||||
valori.Add(valore);
|
||||
}
|
||||
}
|
||||
}
|
||||
// altrimenti valori vuoti...
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
etichette.Add(i.ToString());
|
||||
valori.Add(0);
|
||||
}
|
||||
}
|
||||
allData.Add(etichette);
|
||||
allData.Add(valori);
|
||||
#endif
|
||||
// restituisco oggetto!
|
||||
return allData;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user