test autocomplete (parziale)

This commit is contained in:
Samuele Locatelli
2014-03-10 13:25:54 +01:00
parent c5768d5b2a
commit 20cfff3acb
6 changed files with 111 additions and 92 deletions
+22
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using SteamWare;
using GMW_data;
@@ -93,5 +94,26 @@ namespace GMW.WS
return suggerimenti.ToArray();
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string[] celle(string prefixText, int count)
{
// inizializzo risposta
List<string> suggerimenti = new List<string>();
// proseguo SOLO SE min "MinCharAutocomplete" char...
if (count >= memLayer.ML.confReadInt("MinCharAutocomplete"))
{
// elenco candidati
DS_magazzino.CelleDataTable tabCelle = MagClass.magazzino.taCelle.getByCodCellaLike(prefixText, memLayer.ML.confReadString("CodCS"));
// aggiungo ogni riga...
foreach (DS_magazzino.CelleRow riga in tabCelle)
{
suggerimenti.Add(string.Format("{0}#{1}", riga.CodCella, riga.CodCella));
}
}
return suggerimenti.ToArray();
}
}
}
+1
View File
@@ -0,0 +1 @@
<%@ WebService Language="C#" CodeBehind="DataFeed.asmx.cs" Class="GMW.WS.DataFeed" %>
+75
View File
@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using SteamWare;
using GMW_data;
namespace GMW.WS
{
/// <summary>
/// Summary description for WS_Data
/// </summary>
[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 DataFeed : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string[] test(string prefixText)
{
//TODO: implement real search here!
// dummy implementation
List<string> output = new List<string>();
for (int i = 0; i < 100; i++)
{
output.Add(string.Format("{0}{1}#{1}", prefixText, i));
}
return output.ToArray();
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string[] celle(string prefixText, int count)
{
// inizializzo risposta
List<string> suggerimenti = new List<string>();
// proseguo SOLO SE min "MinCharAutocomplete" char...
if (count >= memLayer.ML.confReadInt("MinCharAutocomplete"))
{
// elenco candidati
DS_magazzino.CelleDataTable tabCelle = MagClass.magazzino.taCelle.getByCodCellaLike(prefixText, memLayer.ML.confReadString("CodCS"));
// aggiungo ogni riga...
foreach (DS_magazzino.CelleRow riga in tabCelle)
{
suggerimenti.Add(string.Format("{0}#{1}", riga.CodCella, riga.CodCella));
}
}
return suggerimenti.ToArray();
}
//[WebMethod]
//[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
//public string[] Fornitori(string keywordStartsWith)
//{
// // inizializzo risposta
// List<string> suggerimenti = new List<string>();
// // elenco candidati
// DS_utilsProjEts.v_selFornitoriClaDataTable tabella = DataProxy_ProjEts.DP.taSelForn.getBySearchLike(keywordStartsWith);
// // aggiungo ogni riga...
// foreach (DS_utilsProjEts.v_selFornitoriClaRow riga in tabella)
// {
// //suggerimenti.Add(riga.label);
// suggerimenti.Add(string.Format("{0}#{1}", riga.label, riga.value));
// }
// return suggerimenti.ToArray();
//}
}
}
+10 -38
View File
@@ -1,48 +1,20 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/FullPage.master" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="GMW.test" %>
<%@ Register src="WebUserControls/mod_autocomplete.ascx" tagname="mod_autocomplete" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<br />
<br />
<div class="navbar navbar-inverse navbar-collapse collapse">
<ul id="itemPlaceholderContainer" runat="server" class="nav navbar-nav navbar-right">
<asp:Repeater ID="menu" runat="server" DataSourceID="XmlDataSource1">
<ItemTemplate>
<li class="dropdown">
<a href='<%# XPath("@url")%>' class="dropdown-toggle" data-toggle="dropdown">
<i class='<%# XPath("@description")%>'></i>
<%# XPath("@title")%>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<asp:Repeater ID="voci" runat="server" DataSource='<%# XPathSelect("voce") %>'>
<ItemTemplate>
<li>
<a href='<%# XPath("@url").ToString().Replace("~/","")%>'>
<i class='<%# XPath("@description")%>'></i>
<%# XPath("@title")%>
</a>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</li>
</ItemTemplate>
<SeparatorTemplate>
</SeparatorTemplate>
</asp:Repeater>
<li>
<a id="A5" runat="server" class="navbar-brand" href="~/help/IT">
<i class="fa fa-briefcase"></i>
Help
</a>
</li>
</ul>
</div>
<div class="content">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
Autocomplete!
<uc1:mod_autocomplete ID="mod_autocomplete1" runat="server" minCharAutocomplete="1" contextKey="c" labelRicerca="[C]liente" showKey="false" ServicePath="WS/DataFeed.asmx/test" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" EnableCaching="false"></asp:XmlDataSource>
</div>
</div>
</div>
</asp:Content>
+1 -25
View File
@@ -12,31 +12,7 @@ namespace GMW
{
protected void Page_Load(object sender, EventArgs e)
{
// se l'utente c'è...
if (user_std.UtSn.isAuth && !Page.IsPostBack)
{
forzaUpdateMenu();
updateTreeMenu();
}
}
/// <summary>
/// aggiornamento del menù
/// </summary>
private void updateTreeMenu()
{
XmlDataSource1.Data = user_std.UtSn.mappaSito;
//user_std.UtSn.ricaricaMappaSito();
//XmlDataSource1.Data = user_std.UtSn.mappaSitoLive;
XmlDataSource1.XPath = "mainMenu/menu";
XmlDataSource1.DataBind();
}
/// <summary>
/// forza l'update del menù sx
/// </summary>
public void forzaUpdateMenu()
{
user_std.UtSn.ricaricaMappaSito();
updateTreeMenu();
}
}
}
+2 -29
View File
@@ -13,39 +13,12 @@ namespace GMW {
public partial class test {
/// <summary>
/// itemPlaceholderContainer control.
/// mod_autocomplete1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlGenericControl itemPlaceholderContainer;
/// <summary>
/// menu control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Repeater menu;
/// <summary>
/// A5 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlAnchor A5;
/// <summary>
/// XmlDataSource1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.XmlDataSource XmlDataSource1;
protected global::GMW.WebUserControls.mod_autocomplete mod_autocomplete1;
}
}