From 8c966c53ed0c4ff6329a7b093a7962efc661dfaf Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Sat, 2 Jun 2018 10:56:23 +0200 Subject: [PATCH] Aggiunta classe x recuperare dati json --- MP-Site/TestMVC.cshtml | 57 ++++++++++++++++++++ MP-Site/WS/AutoCompletamento.asmx.cs | 61 +++++++++++----------- MP-Site/WS/MPData.asmx | 1 + MP-Site/WS/MPData.asmx.cs | 77 ++++++++++++++++++++++++++++ MapoDb/resoconti.cs | 33 +++++++++++- 5 files changed, 197 insertions(+), 32 deletions(-) create mode 100644 MP-Site/TestMVC.cshtml create mode 100644 MP-Site/WS/MPData.asmx create mode 100644 MP-Site/WS/MPData.asmx.cs diff --git a/MP-Site/TestMVC.cshtml b/MP-Site/TestMVC.cshtml new file mode 100644 index 00000000..c493e820 --- /dev/null +++ b/MP-Site/TestMVC.cshtml @@ -0,0 +1,57 @@ +@{ + Layout = null; +} + + + + + + + + + + + +
+ + +
+
+ + diff --git a/MP-Site/WS/AutoCompletamento.asmx.cs b/MP-Site/WS/AutoCompletamento.asmx.cs index 7d816ed4..d894d61d 100644 --- a/MP-Site/WS/AutoCompletamento.asmx.cs +++ b/MP-Site/WS/AutoCompletamento.asmx.cs @@ -4,39 +4,38 @@ using System.Web.Services; namespace MoonPro.WS { - /// - /// servizi per AutoCompletamento oggetti - /// - [WebService(Namespace = "http://www.steamware.net/")] - [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] - [System.ComponentModel.ToolboxItem(false)] - // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. - [System.Web.Script.Services.ScriptService] - public class AutoCompletamento : System.Web.Services.WebService - { + /// + /// servizi per AutoCompletamento oggetti + /// + [WebService(Namespace = "http://www.steamware.net/")] + [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] + [System.ComponentModel.ToolboxItem(false)] + // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. + [System.Web.Script.Services.ScriptService] + public class AutoCompletamento : System.Web.Services.WebService + { - /// - /// elenco articoli per ricerca interattiva - /// - /// - [WebMethod(Description = "elenco articoli per ricerca interattiva")] - public string[] elencoArticoli(string prefixText, int count) + /// + /// elenco articoli per ricerca interattiva + /// + /// + [WebMethod(Description = "elenco articoli per ricerca interattiva")] + public string[] elencoArticoli(string prefixText, int count) + { + // inizializzo risposta + List suggerimenti = new List(); + // proseguo SOLO SE min "MinCharAutocomplete" char... + if (count >= memLayer.ML.confReadInt("MinCharAutocomplete")) + { + // elenco candidati + MapoDb.DS_Utility.v_selArticoliDataTable tabDati = MapoDb.DataLayer.obj.taSelArt.getByConditio(prefixText); + // aggiungo ogni riga... + foreach (MapoDb.DS_Utility.v_selArticoliRow riga in tabDati) { - // inizializzo risposta - List suggerimenti = new List(); - // proseguo SOLO SE min "MinCharAutocomplete" char... - if (count >= memLayer.ML.confReadInt("MinCharAutocomplete")) - { - // elenco candidati - MapoDb.DS_Utility.v_selArticoliDataTable tabDati = MapoDb.DataLayer.obj.taSelArt.getByConditio(prefixText); - // aggiungo ogni riga... - foreach (MapoDb.DS_Utility.v_selArticoliRow riga in tabDati) - { - suggerimenti.Add(riga.value); - } - } - return suggerimenti.ToArray(); + suggerimenti.Add(riga.value); } - + } + return suggerimenti.ToArray(); } + } } diff --git a/MP-Site/WS/MPData.asmx b/MP-Site/WS/MPData.asmx new file mode 100644 index 00000000..192817ee --- /dev/null +++ b/MP-Site/WS/MPData.asmx @@ -0,0 +1 @@ +<%@ WebService Language="C#" CodeBehind="MPData.asmx.cs" Class="MoonPro.WS.MPData" %> diff --git a/MP-Site/WS/MPData.asmx.cs b/MP-Site/WS/MPData.asmx.cs new file mode 100644 index 00000000..c3db74b6 --- /dev/null +++ b/MP-Site/WS/MPData.asmx.cs @@ -0,0 +1,77 @@ +using System; +using System.Web.Script.Serialization; +using System.Web.Script.Services; +using System.Web.Services; + +namespace MoonPro.WS +{ + /// + /// Descrizione di riepilogo per MPData + /// + [WebService(Namespace = "http://tempuri.org/")] + [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. + [ScriptService] + public class MPData : System.Web.Services.WebService + { + + [WebMethod] + public string HelloWorld() + { + return "Hello World"; + } + + [WebMethod] + [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] + public void randomData() + { + JavaScriptSerializer js = new JavaScriptSerializer(); + Context.Response.Clear(); + Context.Response.ContentType = "application/json"; + // genero numVal valori random inizio/fine... + int numVal = 10; + int maxMinutes = 60; + Random random = new Random(); + visjsDsItem[] items = new visjsDsItem[numVal]; + DateTime lastDate = DateTime.Now.AddDays(-7); + for (int i = 0; i < numVal; i++) + { + items[i] = new visjsDsItem() + { + id = i, + content = string.Format("Random data {0}", i), + start = lastDate, + end = lastDate.AddHours(random.Next(maxMinutes)), + group = "1", + className = "" + }; + } + Context.Response.Write(js.Serialize(items)); + } + + [WebMethod] + [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] + public void getData() + { + JavaScriptSerializer js = new JavaScriptSerializer(); + Context.Response.Clear(); + Context.Response.ContentType = "application/json"; + Random random = new Random(); + int i = 1; + DateTime lastDate = DateTime.Now; + int maxMinutes = 60; + visjsDsItem item = new visjsDsItem() + { + id = i, + content = string.Format("Random data {0}", i), + start = lastDate, + end = lastDate.AddHours(random.Next(maxMinutes)), + group = "1", + className = "" + }; + Context.Response.Write(js.Serialize(item)); + } + } +} + diff --git a/MapoDb/resoconti.cs b/MapoDb/resoconti.cs index dc43c3c8..a1123460 100644 --- a/MapoDb/resoconti.cs +++ b/MapoDb/resoconti.cs @@ -300,7 +300,7 @@ public class resoconti if (answ == 0) { MapoDb.DS_ProdTempi.stp_repDonati_getLastStatoDurataMacchinaRow riga = (MapoDb.DS_ProdTempi.stp_repDonati_getLastStatoDurataMacchinaRow)(MapoDb.DataLayer.obj.taDatiStatoMacch.GetData(idx, 0)[0]); - answ = riga.idxStato; + answ = riga.idxStato; } } catch @@ -606,3 +606,34 @@ public class resoconti #endregion } + +/// +/// Item Dataset di vis.js +/// +public class visjsDsItem +{ + /// + /// identificativo univoco + /// + public int id; + /// + /// Testo descrittivo + /// + public string content; + /// + /// Inizio dell'evento + /// + public DateTime start; + /// + /// Fine dell'evento + /// + public DateTime end; + /// + /// Gruppo dell'item + /// + public string group; + /// + /// Classe css + /// + public string className; +}