Buscar contenidos

martes, 24 de octubre de 2017

Nuget MVCGrid.net

Link

MVCGrid.Net

A grid for ASP.NET MVC and Bootstrap with ajax paging and sorting. Also has filtering support, export to csv, back button support, and graceful degradation.
The primary goal of this project is to provide the core grid functionality, along with a very simple and easy-to-use client-side API to allow you to easily add the additional front-end interaction you need. You can add it to your project very easily and get it running with minimal effort, but it also has the extensibility to customize when needed.
You configure your grids on app start, and provide a function callback to actually query your data. The library will handle the ajax requests. It will parse and validate the requested options and then pass the QueryOptions to your function to retrieve the data.

Features

  • Uses your existing model objects
  • Server-side sorting and paging using AJAX
  • updates query string to support maintaining grid state when navigating back
  • gracefully degrades on older browsers (works on IE8)
  • Built-in exporting to csv
  • Filtering and column visibility support with minimal client-side code

viernes, 13 de octubre de 2017

Cómo habilitar tracing en WCF


Link artículo

<system.diagnostics>
 <sources>
  <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
   <listeners>
    <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\logs\Traces.svclog"/>
   </listeners>
  </source>
 </sources>
</system.diagnostics>

Cloud computing, conceptualización


viernes, 6 de octubre de 2017

C# Método dinámico Verbo Post HttpClient WebAPIClient

Demo consumo WebAPI





Método WebAPI


    // POST api/values
        [HttpPost]
        public InfoPersonal Post(Persona persona)
        {
            InfoPersonal infoPersonal = new InfoPersonal()
            {
                personaId = persona.Id,
                celular = 123456,
                direccion="centro alajuela"
            };

            return infoPersonal;

  

Clase de Input Output de ejemplo


    public partial class Persona
    {
        public int Id { get; set; }
        public string Nombre { get; set; }
        public System.DateTime Nacimiento { get; set; }
        public int Edad { get; set; }
    }


    public class InfoPersonal
    {
        public int personaId { get; set; }
        public string direccion { get; set; }
        public int celular { get; set; }

    }

Clase para consumo de WebAPI



 public class WebAPIClientManager
    {
        string _baseAddress = "";

        public WebAPIClientManager(string baseAddress)
        {
            _baseAddress = baseAddress;
        }

        public TOutput VerbPost<TInput, TOutput>(string methodRouteURL, TInput modelInput, TOutput modelOuput)
        {
            using (System.Net.Http.HttpClient client = new HttpClient())
            {
                System.Uri baseUri = new Uri(_baseAddress);

                var requestUri = new Uri(baseUri, methodRouteURL);

                using (var requestWriter = new System.IO.StringWriter())
                {
                    var requestSerializer = JsonSerializer.Create();

                    requestSerializer.Serialize(requestWriter, modelInput);

                    var content = new StringContent(requestWriter.ToString(), System.Text.Encoding.UTF8, "application/json");

                    var responseMessage = client.PostAsync(requestUri, content).Result;

                    responseMessage.EnsureSuccessStatusCode();

                    var stream = responseMessage.Content.ReadAsStreamAsync().Result;

                    using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream)))
                    {
                        var serializer = new JsonSerializer();

                        modelOuput = serializer.Deserialize<TOutput>(jsonReader);

                        return modelOuput;
                    }
                }

            }

        }

    }