diff --git a/GPW_Smart/App_Start/RouteConfig.cs b/GPW_Smart/App_Start/RouteConfig.cs index 852a9b0..588525e 100644 --- a/GPW_Smart/App_Start/RouteConfig.cs +++ b/GPW_Smart/App_Start/RouteConfig.cs @@ -13,6 +13,7 @@ namespace GPW_Smart var settings = new FriendlyUrlSettings(); settings.AutoRedirectMode = RedirectMode.Permanent; routes.EnableFriendlyUrls(settings); + } } } diff --git a/GPW_Smart/App_Start/WebApiConfig.cs b/GPW_Smart/App_Start/WebApiConfig.cs new file mode 100644 index 0000000..91cff53 --- /dev/null +++ b/GPW_Smart/App_Start/WebApiConfig.cs @@ -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 } + ); + } + } +} \ No newline at end of file diff --git a/GPW_Smart/Controllers/TempHistController.cs b/GPW_Smart/Controllers/TempHistController.cs new file mode 100644 index 0000000..adba048 --- /dev/null +++ b/GPW_Smart/Controllers/TempHistController.cs @@ -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/ + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET api//5 + public string Get(int id) + { + return "value"; + } + + // POST api/ + public void Post([FromBody] string value) + { + } + + // PUT api//5 + public void Put(int id, [FromBody] string value) + { + } + + // DELETE api//5 + public void Delete(int id) + { + } + } +} \ No newline at end of file diff --git a/GPW_Smart/Controllers/TempRilController.cs b/GPW_Smart/Controllers/TempRilController.cs index 3169f2a..02e86f9 100644 --- a/GPW_Smart/Controllers/TempRilController.cs +++ b/GPW_Smart/Controllers/TempRilController.cs @@ -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/ - public IEnumerable Get() + // GET api/TempRil + public string Get() { - return new string[] { "value1", "value2" }; + return "NA"; } - // GET api//5 - public string Get(int id) + // GET api/TempRil/5 + public List Get(int id) { - return "value"; + + + List answ = new List(); + + // 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 Get(int id, string date, int numRec) + { + DateTime dtRif = DateTime.Today; + DateTime.TryParse(date, out dtRif); + + List answ = new List(); + + // 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/ - public void Post([FromBody] string value) - { - } + //// POST api/TempRil + //public void Post([FromBody] string value) + //{ + //} - // PUT api//5 - public void Put(int id, [FromBody] string value) - { - } + //// PUT api/TempRil/5 + //public void Put(int id, [FromBody] string value) + //{ + //} - // DELETE api//5 - public void Delete(int id) - { - } + //// DELETE api/TempRil/5 + //public void Delete(int id) + //{ + //} } } \ No newline at end of file diff --git a/GPW_Smart/GPW_Smart.csproj b/GPW_Smart/GPW_Smart.csproj index 9f62ce0..c11d670 100644 --- a/GPW_Smart/GPW_Smart.csproj +++ b/GPW_Smart/GPW_Smart.csproj @@ -733,6 +733,7 @@ + attivitaIns.aspx ASPXCodeBehind diff --git a/GPW_Smart/Global.asax.cs b/GPW_Smart/Global.asax.cs index aa4eb9a..26dd461 100644 --- a/GPW_Smart/Global.asax.cs +++ b/GPW_Smart/Global.asax.cs @@ -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); diff --git a/GPW_Smart/WS/gateway.asmx b/GPW_Smart/WS/gateway.asmx deleted file mode 100644 index 8dbdd44..0000000 --- a/GPW_Smart/WS/gateway.asmx +++ /dev/null @@ -1 +0,0 @@ -<%@ WebService Language="C#" CodeBehind="gateway.asmx.cs" Class="GPW_Smart.WS.gateway" %> diff --git a/GPW_Smart/WS/gateway.asmx.cs b/GPW_Smart/WS/gateway.asmx.cs deleted file mode 100644 index d5e6042..0000000 --- a/GPW_Smart/WS/gateway.asmx.cs +++ /dev/null @@ -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 -{ - /// - /// Descrizione di riepilogo per gateway - /// - [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"; - } - - - /// - /// Restituisce un array di informazioni x rilievo temperature (serie dati)... - /// - TITOLO - /// - vettore valori come x,y - /// - /// - /// - /// - /// - [WebMethod] - [ScriptMethod(ResponseFormat = ResponseFormat.Json)] - public List rilTempSerie(int idxDipendente, DateTime dataRif, int maxRecords = 0) - { - // init valori.. - List allData = new List(); - List valori = new List(); - - // 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; - } - - /// - /// Restituisce un array di informazioni x rilievo temperature (istogramma freq dati)... - /// - TITOLO - /// - MaxValore - /// - vettore etichette - /// - vettore valori - /// - /// - [WebMethod] - [ScriptMethod(ResponseFormat = ResponseFormat.Json)] - public List rilTempHist(int idxUser, DateTime dataRif, int maxRecords = 0) - { - // init valori.. - List allData = new List(); - List etichette = new List(); - List valori = new List(); - -#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; - } - } -}