miércoles, 24 de septiembre de 2014

El Libro del Día: Pro ASP.NET Web API Security

El Libro del Día: 2014-09-24

Titulo: Pro ASP.NET Web API Security
Autor: Badrinarayanan Lakshmiraghavan
Editorial: Apress
Nro Paginas: 403

Capítulos:
Chapter 1: Welcome to ASP.NET Web API
Chapter 2: Building RESTful Services
Chapter 3: Extensibility Points
Chapter 4: HTTP Anatomy and Security
Chapter 5: Identity Management
Chapter 6: Encryption and Signing
Chapter 7: Custom STS through WIF
Chapter 8: Knowledge Factors
Chapter 9: Ownership Factors
Chapter 10: Web Tokens
Chapter 11: OAuth 2.0 Using Live Connect API
Chapter 12: OAuth 2.0 from the Ground Up
Chapter 13: OAuth 2.0 Using DotNetOpenAuth
Chapter 14: Two-Factor Authentication
Chapter 15: Security Vulnerabilities
Appendix: ASP.NET Web API Security Distilled

Descarga:
Pro_ASPNET_WebAPI_Security

martes, 23 de septiembre de 2014

El Libro del Día: Practical ASP.NET Web API

El Libro del Día: 2014-09-23

Titulo: Practical ASP.NET Web API
Autor: Badrinarayanan Lakshmiraghavan
Editorial: Apress
Nro Paginas: 329

Capítulos:
Chapter 1: Building a Basic Web API
Chapter 2: Debugging and Tracing
Chapter 3: Media-Type Formatting CLR Objects
Chapter 4: Customizing Response
Chapter 5: Binding an HTTP Request into CLR Objects
Chapter 6: Validating Requests
Chapter 7: Managing Controller Dependencies
Chapter 8: Extending the Pipeline
Chapter 9: Hosting ASP.NET Web API
Chapter 10: Securing ASP.NET Web API
Chapter 11: Consuming ASP.NET Web API
Chapter 12: Building a Performant Web API

Descarga:
Practical_ASPNET_WebAPI

lunes, 22 de septiembre de 2014

El Libro del Día: Beginning ASP.NET Security

El Libro del Día: 2014-09-22

Titulo: Beginning ASP.NET Security
Autor: Barry Dorrans
Editorial: Wrox
Nro Paginas: 440

Capítulos:
CHAPTER 1 Why Web Security Matters
PART I THE ASP.NET SECURITY BASICS
CHAPTER 2 How the Web Works
CHAPTER 3 Safely Accepting User Input
CHAPTER 4 Using Query Strings, Form Fields, Events, and Browser Information
CHAPTER 5 Controlling Information
CHAPTER 6 Keeping Secrets Secret - Hashing and Encrypton
PART II SECURING COMMON ASP.NET TASKS
CHAPTER 7 Adding Usernames and Passwords
CHAPTER 8 Securely Accessing Databases
CHAPTER 9 Using the File System
CHAPTER 10 Securing XML
PART III ADVANCED ASP.NET SCENARIOS
CHAPTER 11 Sharing Data with Windows Communication Foundation
CHAPTER 12 Securing Rich Internet Applications
CHAPTER 13 Understanding Code Access Security
CHAPTER 14 Securing Internet Information Server (IIS)
CHAPTER 15 Third-Party Authentication
CHAPTER 16 Secure Development with the ASP.NET MVC Framework

Descarga:
Beginning_ASPNET_Security

domingo, 21 de septiembre de 2014

El Libro del Día: Beginning ASP.NET 4.5 in C#

El Libro del Día: 2014-09-21

Titulo: Beginning ASP.NET 4.5 in C#
Autor: Matthew MacDonald
Editorial: Apress
Nro Paginas: 900

Capítulos:
Part 1: Introducing .NET
Chapter 1: The Big Picture
Chapter 2: The C# Language
Chapter 3: Types, Objects, and Namespaces
Part 2: Developing ASP.NET Applications
Chapter 4: Visual Studio
Chapter 5: Web Form Fundamentals
Chapter 6: Web Controls
Chapter 7: Error Handling, Logging, and Tracing
Chapter 8: State Management
Part 3: Building Better Web Forms
Chapter 9: Validation
Chapter 10: Rich Controls
Chapter 11: User Controls and Graphics
Chapter 12: Styles, Themes, and Master Pages
Chapter 13: Website Navigation
Part 4: Working with Data
Chapter 14: ADO.NET Fundamentals
Chapter 15: Data Binding
Chapter 16: The Data Controls
Chapter 17: Files and Streams
Chapter 18: XML
Part 5: Website Security
Chapter 19: Security Fundamentals
Chapter 20: Membership
Chapter 21: Profiles
Part 6: Advanced ASP.NET
Chapter 22: Component-Based Programming
Chapter 23: Caching
Chapter 24: LINQ and the Entity Framework
Chapter 25: ASP.NET AJAX
Chapter 26: Deploying ASP.NET Applications

Descarga:
Beginning_ASPNET_4.5_C#

sábado, 20 de septiembre de 2014

El Libro del Día: Professional ASP.NET Design Patterns

El Libro del Día: 2014-09-20

Titulo: Professional ASP.NET Design Patterns
Autor: Scott Millett
Editorial: Wrox
Nro Paginas: 722

Capítulos:
Part I Introducing Patterns and Principles
Chapter 1 The Pattern for Successful Applications
Chapter 2 Dissecting the Pattern’s Pattern
Part II The Anatomy of an AS P.NE T Application: Learning and Applying Patterns
Chapter 3 Layering Your Application and Separating Your Concerns
Chapter 4 The Business Logic Layer: Organization
Chapter 5 The Business Logic Layer: Patterns
Chapter 6 The Service Layer
Chapter 7 The Data Access Layer
Chapter 8 The Presentation Layer
Chapter 9 The User Experience Layer
Part III Case Study: The Online E-Commerce Store
Chapter 10 Requirements and Infrastructure
Chapter 11 Creating The Product Catalog
Chapter 12 Implementing the Shopping Basket
Chapter 13 Customer Membership
Chapter 14 Ordering and Payment

Descarga:
Professional_ASPNET_DesignPatterns

viernes, 19 de septiembre de 2014

El Libro del Día: Professional ASP.NET 4 in C# and VB

El Libro del Día: 2014-09-19

Titulo: Professional ASP.NET 4 in C# and VB
Autor: Bill Evjen, Scott Hanselman, Devin Rader
Editorial: Wrox
Nro Paginas: 1539

Capítulos:
Chapter 1 Application and Page Frameworks
Chapter 2 ASP.NET Server Controls and Client-Side Scripts
Chapter 3 ASP.NET Web Server Controls
Chapter 4 Validation Server Controls
Chapter 5 Working with Master Pages
Chapter 6 Themes and Skins
Chapter 7 Data Binding
Chapter 8 Data Management with ADO.NET
Chapter 9 Querying with LINQ
Chapter 10 Working with XML and LINQ to XML
Chapter 11 Introduction to the Provider Model
Chapter 12 Extending the Provider Model
Chapter 13 Site Navigation
Chapter 14 Personalization
Chapter 15 Membership and Role Management
Chapter 16 Portal Frameworks and Web Parts
Chapter 17 HTML and CSS Design with ASP.NET
Chapter 18 ASP.NET AJAX
Chapter 19 ASP.NET AJAX Control Toolkit
Chapt er 20 Security
Chapter 21 State Management
Chapter 22 Caching
Chapter 23 Debugging and Error Handling
Chapter 24 File I/O and Streams
Chapter 25 User and Server Controls
Chapter 26 Modules and Handlers
Chapter 27 ASP.NET MVC
Chapter 28 Using Business Objects
Chapter 29 ADO.NET Entity Framework
Chapter 30 ASP.NET Dynamic Data
Chapter 31 Working with Services
Chapter 32 Building Global Applications
Chapter 33 Configuration
Chapter 34 Instrumentation
Chapter 35 Administration and Management
Chapter 36 Packaging and Deploying ASP.NET Applications
Appendix A Migrating Older ASP.NET Projects
Appendix B ASP.NET Ultimate Tools
Appendix C Silverlight 3 and ASP.NET
Appendix D Dynamic Types and Languages
Appendix E ASP.NET Online Resources

Descarga:
Professional_ASPNET4_C#_VB

jueves, 18 de septiembre de 2014

El Demo del Día: Copiar Datos de Excel en el DataGridView de WinForms

Copiar Datos de Excel en el DataGridView de WinForms

Después de un tiempo, volvemos a publicar un nuevo Demo, esta vez a pedido de un alumno, que desea copiar que su aplicación tenga la funcionalidad de copiar datos de la Grilla (DataGridView) a Excel (esto es automático, no es necesario programar nada) y desde Excel hacia la aplicación (esto si requiere de programar usando el objeto Clipboard de WinForms).

Como siempre nuestro desarrollo lo haremos con Listas de Objetos (como debe ser para ahorrar memoria y no con DataSet), ademas usaremos Reflection para convertir los datos que vienen como cadenas desde Excel al tipo de datos adecuado del objeto.

Crear una Aplicación Windows Forms en C#

Crear un nuevo proyecto de tipo Windows Forms y llamarle "CopiarExcel". Cambiarle de nombre al formulario por el de "frmProducto".

Crear la clase: "beProducto" para la lista de objetos

using System;
namespace CopiarExcel
{
    public class beProducto
    {
        public int IdProducto { get; set; }
        public string Nombre { get; set; }
        public decimal Precio { get; set; }
        public short Stock { get; set; }
    }
}

Agregar un control DataGridView sobre el formulario, cambiarle al nombre de "dgvProducto" y acoplarlo para que se vea similar a la siguiente figura:


Escribir el siguiente código en el formulario:

using System.IO;
using System.Reflection;

namespace CopiarExcel
{
    public partial class frmProducto : Form
    {
        private List<beProducto> lbeProducto;

        public frmProducto()
        {
            InitializeComponent();
        }

        private void cargarProductos(object sender, EventArgs e)
        {
            lbeProducto = new List<beProducto>();
            Random oRandom = new Random();
            beProducto obeProducto;
            for(int i=1;i<=10;i++)
            {
                obeProducto = new beProducto();
                obeProducto.IdProducto = i;
                obeProducto.Nombre = String.Format("Producto {0}", i);
                obeProducto.Precio = oRandom.Next(100)+10;
                obeProducto.Stock = (short)(oRandom.Next(10) + 1);
                lbeProducto.Add(obeProducto);
            }
            dgvProducto.DataSource = lbeProducto;
        }

        private void pegarExcel(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.V)
            {
                string formato = DataFormats.CommaSeparatedValue;
                object contenido = Clipboard.GetData(formato);
                if (contenido != null && contenido is MemoryStream)
                {
                    byte[] buffer;
                    using (MemoryStream ms = (MemoryStream)contenido) buffer = ms.ToArray();
                    string lista = Encoding.UTF8.GetString(buffer).Replace("\r\n", ",");
                    string[] data = lista.Split(',');
                    PropertyInfo[] propiedades = lbeProducto[0].GetType().GetProperties();
                    if ((data.Length - 1) % propiedades.Length == 0)
                    {
                        beProducto obeProducto = null;
                        PropertyInfo propiedad;
                        int c = 0;
                        Type tipo = null;
                        while (c < data.Length - 1)
                        {
                            for (int i = 0; i < propiedades.Length; i++)
                            {
                                if (i == 0) obeProducto = new beProducto();
                                propiedad = obeProducto.GetType().GetProperty(propiedades[i].Name);
                                tipo = propiedad.PropertyType;
                                propiedad.SetValue(obeProducto, Convert.ChangeType(data[c], tipo));
                                if (i == propiedades.Length - 1) lbeProducto.Add(obeProducto);
                                c++;
                            }
                        }
                        dgvProducto.DataSource = null;
                        dgvProducto.DataSource = lbeProducto;
                    }
                    else MessageBox.Show
                    ("Numero de columnas a copiar del Excel y la Grilla deben ser iguales");
                }
                else MessageBox.Show("No hay un rango de celdas a copiar");
            }
        }
    }
}

Nota: Para copiar desde Excel a la grilla se debe pulsar la tecla Ctrl + V y la cantidad de columnas debe ser la misma que la de la grilla (en realidad la de las propiedades de la clase beProducto o la que fuera).

Probar la Aplicación Creada

Grabar el proyecto y ejecutarlo con F5. Se mostrará la siguiente ventana con los datos de los productos creados en el evento Load del formulario:


Crear un archivo de Excel con la misma estructura de los Productos, tal como se muestra a continuación:


Copiar (Ctrl + C) el rango de celdas que se desea llevar a la aplicación (sin incluir las cabeceras) y en cualquier celda de la grilla Pegar (Ctrl + V), y se copiaran los registros seleccionados en Excel, tal como se muestra a continuación:


Si desean se puede ir copiando por partes (filas) pero si es necesario seleccionar todas las columnas, ya que el objeto necesita de valores.

Nota: El procedimiento contrario, es decir desde la Aplicación (DataGridView) a Excel es automatico, solo hay que marcar el rango de celdas del DataGridView, Ctrl + C y luego en Excel Ctrl + V.

Comentario Final

En este post hemos visto como agregar la funcionalidad de Copiar Datos Externos a la aplicación, en este caso desde Excel, pero el procedimiento sera similar desde cualquier origen. Para ello hemos usado el objeto ClipBoard y para trabajar con objetos hemos usado Reflection, lo que quiere decir que el demo lo puedes probar con cualquier objeto que definan.

Saludos a todos los visitantes asiduos del Blog y ya saben que pueden hacer sus pedidos en los comentarios.

Descarga: