Está en la página 1de 5

PRACTICA SISTEMAS DISTRIBUIDOS USO DE SERVIDORES WEB DE REFERENCIA

TRADUCTOR DE IDIOMAS
CODIGO DEL FORMULARIO
Public Class Form1 Private AppId As String = "AB13BEE13E3C5413302B66BEEB883DB51188E4AC" Private Diccionario_IdiomasOrig As New Dictionary(Of String, String) Private Diccionario_IdiomasTraducido As New Dictionary(Of String, String) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim bingTranslator As New ServicioTraductor.LanguageServiceClient("BasicHttpBinding_LanguageService") Dim sLenguajes() As String = bingTranslator.GetLanguageNames(AppId, "es") Dim sLenguajesID() As String = bingTranslator.GetLanguages(AppId) Dim i As Integer For i = 0 To sLenguajes.Length - 1 ComboBox1.Items.Add(sLenguajes(i)) ComboBox2.Items.Add(sLenguajes(i)) Diccionario_IdiomasOrig.Add(sLenguajes(i), sLenguajesID(i)) Diccionario_IdiomasTraducido.Add(sLenguajes(i), sLenguajesID(i)) Next ComboBox1.SelectedIndex = ComboBox1.FindString("Espaol") ComboBox2.SelectedIndex = ComboBox2.FindString("Ingls") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim bingTranslator As New ServicioTraductor.LanguageServiceClient("BasicHttpBinding_LanguageService") Dim IdiomadeOrigen As String = "" Diccionario_IdiomasOrig.TryGetValue(ComboBox1.Text, IdiomadeOrigen) Dim IdiomaTraducido As String = "" Diccionario_IdiomasTraducido.TryGetValue(ComboBox2.Text, IdiomaTraducido) RichTextBox2.Text = bingTranslator.Translate(AppId, RichTextBox1.Text, IdiomadeOrigen, IdiomaTraducido) Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub

Private Sub RichTextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox2.TextChanged End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged End Sub End Class

CAPTURAS DE PANTALLA

CONVERTIDOR DE MONEDA
CODIGO DE LA PAGINA HTML

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ConvMoneda._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Pgina sin ttulo</title> </head> <body> <form id="form1" runat="server"> <div>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CONVERSOR DE MONEDA <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Utilizando el servidor de referencia: http ://www.webservicex.net/CurrencyConvertor.asmx <br /> <br /> Moneda de Origen de acuerdo a las normas del<br /> &nbsp;&nbsp;&nbsp;servidor de referencia Ej. Dollar = USD &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; Cantidad o Monto a convertir<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <br /><br /><br /> Moneda Destino de acuerdo a las normas del<br /> &nbsp;&nbsp;&nbsp;servidor de referencia Ej. Boliviano = BOB<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <asp:Button ID="Button1" runat="server" Text="Convertir el monto introducido" Width="190px" onclick="Button1_Click" /> <br /> <br /> <asp:Label ID="Label1" runat="server" Text="Monto convertido"></asp:Label> </div> </form> </body> </html>

CODIGO DEL SERVIDOR


using using using using using using using System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; ConvMoneda.CurrencyConv;

namespace ConvMoneda { public partial class _Default : System.Web.UI.Page { protected void Button1_Click(object sender, EventArgs e) { string moneda1 = TextBox1.Text; string moneda2 = TextBox4.Text; CurrencyConvertor cv = new CurrencyConvertor(); Currency Mn = (Currency)Enum.Parse(typeof(Currency), moneda1); Currency Mn2 = (Currency)Enum.Parse(typeof(Currency), moneda2); double moneda = Double.Parse(TextBox2.Text); double tipodecambio = cv.ConversionRate(Mn,Mn2); double mconvertida = tipodecambio*moneda; Label1.Text = mconvertida.ToString(); } } }

CAPTURAS DE PANTALLA

También podría gustarte