using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace ASP.NET.DataTables
{
using System.Globalization;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using ASP.NET.DataTables.DataAccess;
/// <summary>
/// Summary description for Services
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class Services : System.Web.Services.WebService
{
/// <summary>The convert.</summary>
/// <param name="record">The record.</param>
/// <returns>The <see cref="string"/>.</returns>
public string[] Convert(object record)
{
var properties = from p in record.GetType().GetProperties()
select
p.GetValue(record, null) == null ? string.Empty : p.GetValue(record, null).ToString();
return properties.ToArray();
}
/// <summary>The obtener equipos.</summary>
/// <returns>The <see cref="string"/>.</returns>
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
public string ObtenerEquipos()
{
var echo = int.Parse(HttpContext.Current.Request.Params["sEcho"]);
var displayLength = HttpContext.Current.Request.Params["iDisplayLength"];
var displayStart = HttpContext.Current.Request.Params["iDisplayStart"];
var sortOrder = HttpContext.Current.Request.Params["sSortDir_0"].ToString(CultureInfo.CurrentCulture);
var sortColumn = HttpContext.Current.Request.Params["iSortCol_0"].ToString(CultureInfo.CurrentCulture);
var search = HttpContext.Current.Request.Params["sSearch"];
var filter = new DaoEquipos().ObetenerEquipos(search, int.Parse(displayLength), int.Parse(displayStart));
var json = from r in filter.Elementos
select
Convert(
new
{
r.Id,
r.Posicion,
Nombre = string.Format("<div class=\"stats_texto\"><div id=\"div_especial\" class=\"logo_tabla\"><img src=\"/assets/img/spacer.gif\" id=\"tabla_logo\" border=\"0\" class=\"stats_texto_logo logocligaFMF {1}\"></div><div id=\"div_especial\">{0}</div>", r.Nombre, r.Logo),
r.JJ,
r.Puntos,
r.Logo
});
var serializer = new JavaScriptSerializer();
return
serializer.Serialize(
new
{
echo,
iTotalRecords = filter.Count,
iTotalDisplayRecords = filter.Count,
aaData = json
});
}
}
}
WebService que contiene una función que regresa los datos consultados a la base de datos, para mostrarse mediante el plug-in DataTable.js
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.