Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is true that only the data tier is for WCF?
Message
De
28/01/2013 23:54:18
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Windows Communication Foundation (WCF)
Versions des environnements
Environment:
VB 9.0
OS:
Windows Server 2008
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01564433
Message ID:
01564436
Vues:
39
I create data tiers all the time without WCF.

Why not use Workflow Foundation for business workflow?

>Hello
>I want to know if the only data tier is used to be created as WCF project in .NET solution.
>or it can be more than one WCF project in a solution for example business workflow.
>Here is an example used in WCF, i showed below the code of an example.
>
>implementing interfaces
>
>
>
> NOTA: puede usar el comando "Cambiar nombre" del menú contextual para cambiar el nombre de clase "MAIRServicio" en el código, en svc y en el archivo de configuración a la vez.
>Imports System.Data
>Imports System.Data.SqlClient
>Imports System.Configuration
>Imports EntidadesNegocio
>'Imports Sistema.Componentes
>
>Public Class MAIRServicio
>    Implements IMAIRServicio
>
>    Private Cnx As SqlConnection
>    Private Dap As SqlDataAdapter
>    Private Cmd As SqlCommand
>    Private Tb As DataSet
>    Private Function getCadenaConexion() As String
>        Dim strCnx As String = ConfigurationManager.ConnectionStrings("MiConexion").ConnectionString
>
>        If strCnx Is String.Empty Then
>            Return String.Empty
>        Else
>            Return strCnx
>        End If
>    End Function
>
>    'Public Function RUNSql(ByVal Sentencia As String) As Integer
>    Public Function RUNSql(ByVal Sentencia As String) As DataSet
>
>        'Private Cnx As SqlConnection
>        'Call getCadenaConexion()
>        Dap = New SqlDataAdapter(Sentencia, getCadenaConexion())
>        Tb = New DataSet
>        Dap.Fill(Tb)
>
>        Return Tb
>    End Function
>
>
>
>
>
>#Region "Factura"
>
>    Public Function FacturaPrincipal_ins(ByVal FacturaPrincipalx As Factura) As Integer Implements IMAIRServicio.FacturaPrincipal_ins
>        Cnx = New SqlConnection(getCadenaConexion)
>        Cmd = New SqlCommand("sp_ins_FacturaPrincipal", Cnx)
>        With Cmd
>            .CommandType = CommandType.StoredProcedure
>            .Parameters.AddWithValue("@NumeroFactura", FacturaPrincipalx.NumeroFactura)
>            .Parameters.AddWithValue("@CodigoGuia", FacturaPrincipalx.CodigoGuia)
>            .Parameters.AddWithValue("@CodigoCliente", FacturaPrincipalx.CodigoCliente)
>            .Parameters.AddWithValue("@Subtotal", FacturaPrincipalx.Subtotal)
>            .Parameters.AddWithValue("@Igv", FacturaPrincipalx.Igv)
>            .Parameters.AddWithValue("@Total", FacturaPrincipalx.Total)
>            .Parameters.Add("@Codigo", SqlDbType.Int).Direction = ParameterDirection.Output
>        End With
>        Try
>            Cnx.Open()
>            Cmd.ExecuteNonQuery()
>            Cnx.Close()
>            Return Cmd.Parameters("@Codigo").Value
>        Catch ex As Exception
>            Throw New Exception(ex.Message)
>        End Try
>
>    End Function
>
>    Public Function FacturaPrincipal_upd(ByVal FacturaPrincipalx As Factura) As Integer Implements IMAIRServicio.FacturaPrincipal_upd
>
>
>        Cnx = New SqlConnection(getCadenaConexion)
>
>
>        Dim grabo As Int16
>        Cmd = New SqlCommand("sp_upd_FacturaPrincipal", Cnx)
>        With Cmd
>            .CommandType = CommandType.StoredProcedure
>            .Parameters.AddWithValue("@NumeroFactura", FacturaPrincipalx.NumeroFactura)
>            .Parameters.AddWithValue("@CodigoGuia", FacturaPrincipalx.CodigoGuia)
>            .Parameters.AddWithValue("@CodigoCliente", FacturaPrincipalx.CodigoCliente)
>            .Parameters.AddWithValue("@Subtotal", FacturaPrincipalx.Subtotal)
>            .Parameters.AddWithValue("@Igv", FacturaPrincipalx.Igv)
>            .Parameters.AddWithValue("@Total", FacturaPrincipalx.Total)
>
>        End With
>        Try
>            Cnx.Open()
>            Cmd.ExecuteNonQuery()
>            Cnx.Close()
>            ' grabo = 1   si grabo, grabo = 0  no grabo 
>            grabo = 1
>            Return grabo
>        Catch ex As Exception
>            Throw New Exception(ex.Message)
>            grabo = 0
>            Return grabo
>        End Try
>
>    End Function
>
>
>    Public Function FacturaPrincipal_del(ByVal FacturaPrincipalx As Factura) As Integer Implements IMAIRServicio.FacturaPrincipal_del
>
>        Cnx = New SqlConnection(getCadenaConexion)
>
>        Dim borrar As Int16
>        Cmd = New SqlCommand("sp_del_FacturaPrincipal", Cnx)
>        Cmd.CommandType = CommandType.StoredProcedure
>        Cmd.Parameters.Add("@CodigoFactura", SqlDbType.Int).Value = FacturaPrincipalx.CodigoFactura
>        'Dim n As Int16
>        Cnx.Open()
>        Try
>            borrar = Cmd.ExecuteNonQuery
>        Catch ex As Exception
>            borrar = 0
>        End Try
>
>        Cnx.Close()
>        Return borrar
>    End Function
>
>    Public Function FacturaPrincipal_Listar() As System.Data.DataSet Implements IMAIRServicio.FacturaPrincipal_Listar
>        Dim Dap As New SqlDataAdapter("sp_lis_Factura", Cnx)
>        Dim dst As New DataSet
>        Dap.Fill(dst, "Facturas")
>        Return dst
>    End Function
>#End Region
>
>#Region "Cliente"
>    'Public Sub RUNSql(ByVal Sentencia As String)
>    '    Da = New SqlDataAdapter(Sentencia, Cn)
>    '    Ds = New DataSet
>    '    Da.Fill(Ds)
>    'End Sub
>
>    Function Clientes_cargar() As DataSet Implements IMAIRServicio.Clientes_cargar
>        Dim sentencia As String
>        sentencia = "Select * from Clientes"
>        Dim registros As DataSet
>        registros = New DataSet
>        registros = RUNSql(sentencia)
>        'registros.Tables(0).Columns(0).ind 
>        Return registros
>        'Call RUNSql(sentencia)
>        'Return 0
>    End Function
>
>
>
>    Public Function Cliente_ins(ByVal Clientex As Cliente) As Integer Implements IMAIRServicio.Cliente_ins
>        Cnx = New SqlConnection(getCadenaConexion)
>        Cmd = New SqlCommand("sp_ins_clientes", Cnx)
>        With Cmd
>            .CommandType = CommandType.StoredProcedure
>            .Parameters.AddWithValue("@NombreCliente", Clientex.NombreCliente)
>            .Parameters.AddWithValue("@Direccion", Clientex.Direccion)
>            .Parameters.AddWithValue("@Telefono", Clientex.Telefono)
>            .Parameters.AddWithValue("@NombreContacto", Clientex.NombreContacto)
>            .Parameters.Add("@Codigo", SqlDbType.Int).Direction = ParameterDirection.Output
>        End With
>        Try
>            Cnx.Open()
>            Cmd.ExecuteNonQuery()
>            Cnx.Close()
>            Return Cmd.Parameters("@Codigo").Value
>            MsgBox("se supone que todo salio bien")
>        Catch ex As Exception
>            Throw New Exception(ex.Message)
>        End Try
>    End Function
>
>#End Region
>
>End Class
>
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform