From 52ab3cb1b99b76b16caa41f435c7d37f3b7c3947 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 3 Sep 2020 14:06:49 +0200 Subject: [PATCH] bozza gestione webapi --- GPW_Smart/Controllers/TempRilController.cs | 39 +++++++++++++++++++++ GPW_Smart/GPW_Smart.csproj | 11 ++++++ GPW_Smart/WS/gateway.asmx.cs | 40 ++++++++++++++++++++-- GPW_Smart/Web.config | 12 ++++--- GPW_Smart/WebUserControls/cmp_chart.ascx | 2 +- GPW_Smart/packages.config | 7 ++++ GPW_data/GPW_data.csproj | 2 ++ 7 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 GPW_Smart/Controllers/TempRilController.cs diff --git a/GPW_Smart/Controllers/TempRilController.cs b/GPW_Smart/Controllers/TempRilController.cs new file mode 100644 index 0000000..3169f2a --- /dev/null +++ b/GPW_Smart/Controllers/TempRilController.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 TempRilController : 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/GPW_Smart.csproj b/GPW_Smart/GPW_Smart.csproj index 0f1412e..9f62ce0 100644 --- a/GPW_Smart/GPW_Smart.csproj +++ b/GPW_Smart/GPW_Smart.csproj @@ -140,6 +140,10 @@ ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll @@ -165,6 +169,12 @@ + + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll + + + ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.7\lib\net45\System.Web.Http.WebHost.dll + @@ -733,6 +743,7 @@ ASPXCodeBehind + Default.aspx ASPXCodeBehind diff --git a/GPW_Smart/WS/gateway.asmx.cs b/GPW_Smart/WS/gateway.asmx.cs index 6950ff6..d5e6042 100644 --- a/GPW_Smart/WS/gateway.asmx.cs +++ b/GPW_Smart/WS/gateway.asmx.cs @@ -1,4 +1,5 @@ -using System; +using GPW_data; +using System; using System.Collections.Generic; using System.Linq; using System.Web; @@ -26,7 +27,40 @@ namespace GPW_Smart.WS /// - /// Restituisce un array di informazioni... + /// 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 @@ -35,7 +69,7 @@ namespace GPW_Smart.WS /// [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] - public List userScoreData(int idxUser, DateTime dataRif) + public List rilTempHist(int idxUser, DateTime dataRif, int maxRecords = 0) { // init valori.. List allData = new List(); diff --git a/GPW_Smart/Web.config b/GPW_Smart/Web.config index 304ac9c..63175f8 100644 --- a/GPW_Smart/Web.config +++ b/GPW_Smart/Web.config @@ -136,8 +136,7 @@ - + @@ -431,9 +430,14 @@ - + + + + + + - + diff --git a/GPW_Smart/WebUserControls/cmp_chart.ascx b/GPW_Smart/WebUserControls/cmp_chart.ascx index 7fa939f..4365743 100644 --- a/GPW_Smart/WebUserControls/cmp_chart.ascx +++ b/GPW_Smart/WebUserControls/cmp_chart.ascx @@ -1,7 +1,7 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_chart.ascx.cs" Inherits="GPW_Smart.WebUserControls.cmp_chart" %> - + diff --git a/GPW_Smart/packages.config b/GPW_Smart/packages.config index 948df9c..9ce3d3e 100644 --- a/GPW_Smart/packages.config +++ b/GPW_Smart/packages.config @@ -21,6 +21,13 @@ + + + + + + + diff --git a/GPW_data/GPW_data.csproj b/GPW_data/GPW_data.csproj index bc11023..22ef46b 100644 --- a/GPW_data/GPW_data.csproj +++ b/GPW_data/GPW_data.csproj @@ -161,7 +161,9 @@ True DS_Utility.xsd + + True