Welcome to 3Dev Blogs Sign in | Join | Help
<May 2008>
SuMoTuWeThFrSa
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Navigation

Syndication

Eventos con .NET Remoting Parte II

Proyecto ServerP

ServerP.cs

using System;

using System.Collections.Generic;

using System.Text;

using System.Runtime.Remoting;

 

namespace ServerP

{

class Program

{

static void Main(string[] args)

{

RemotingConfiguration.Configure("ServerP.exe.config", false);

Console.WriteLine("Hello from the Server");

Console.ReadLine();

}

}

}

 

ServerP.exe.config

 

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<system.runtime.remoting>

<application>

<channels>

<channel port="6000" displayName="CakeServerChannel" ref="tcp">

<serverProviders>

<formatter ref="binary" typeFilterLevel="Full" />

</serverProviders>

<clientProviders>

<formatter ref="binary" />

</clientProviders>

</channel>

</channels>

<service>

<wellknown type="OrdenBL.Orden, OrdenBL"

objectUri="Orden" mode="Singleton"/>

</service>

</application>

</system.runtime.remoting>

</configuration>

 

Proyecto Entidades

Person.cs

using System;

using System.Collections.Generic;

using System.Text;

namespace Entidades

{

[Serializable]

public class Person

{

private string nombre;

public string Nombre

{

get { return nombre; }

set { nombre = value; }

}

private string apellido;

public string Apellido

{

get { return apellido; }

set { apellido = value; }

}

private int edad;

public int Edad

{

get { return edad; }

set { edad = value; }

}

private string direccion;

public string Direccion

{

get { return direccion; }

set { direccion = value; }

}

}

}

 

Proyecto DAPerson, disculpen la cadena de conexion

using System;

using System.Collections.Generic;

using System.Text;

using System.Data;

using System.Data.SqlClient;

using Entidades;

namespace DAPerson

{

public class DALPerson

{

public List<Person> GetDAPersons()

{

string cn = @"Data Source=.\sql2005;Initial Catalog=DemoPerson;Integrated Security=True;Pooling=False";

List<Person> persons = new List<Person>();

using (SqlConnection cnn = new SqlConnection(cn))

{

using (SqlCommand cmd = new SqlCommand("getPersons", cnn))

{

cmd.CommandType = CommandType.StoredProcedure;

cnn.Open();

SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleResult | CommandBehavior.CloseConnection);

while (reader.Read())

{

Person pp = new Person();

pp.Nombre = reader["Nombre"].ToString();

pp.Apellido = reader["Apellido"].ToString();

pp.Edad = Convert.ToInt32(reader["Edad"]);

pp.Direccion = reader["Direccion"].ToString();

persons.Add(pp);

}

 

}

}

return persons;

}

public void SetDAPerson(Person person)

{

string cn = @"Data Source=.\sql2005;Initial Catalog=DemoPerson;Integrated Security=True;Pooling=False";

using (SqlConnection cnn = new SqlConnection(cn))

{

using (SqlCommand cmd = new SqlCommand("setPerson", cnn))

{

cmd.CommandType = CommandType.StoredProcedure;

cnn.Open();

cmd.Parameters.Add("@Nombre", SqlDbType.VarChar).Value = person.Nombre;

cmd.Parameters.Add("@Apellido", SqlDbType.VarChar).Value = person.Apellido;

cmd.Parameters.Add("@Edad", SqlDbType.Int).Value = person.Edad;

cmd.Parameters.Add("@Direccion", SqlDbType.VarChar).Value = person.Direccion;

cmd.ExecuteNonQuery();

}

}

}

}

}

Published Thursday, May 01, 2008 8:10 PM by jfrancia

Comments

No Comments

Anonymous comments are disabled
Powered by Community Server, by Telligent Systems