Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ServiceReference1.RegistrarGastosClient obj = new ServiceReference1.RegistrarGastosClient();
                ServiceReference1.Inmuebles obj2 = new ServiceReference1.Inmuebles();
                ServiceReference1.Inmuebles rpta = new ServiceReference1.Inmuebles();
                obj2.codigo = codigo.Text;
                obj2.direccion = direccion.Text;
                obj2.gAlquiler = Convert.ToDecimal(galquiler.Text);
                obj2.gMantenimiento = Convert.ToDecimal(gmant.Text);
                obj2.gAdicionales = Convert.ToDecimal(gadicionales.Text);
                rpta =obj.CrearInmueble(obj2);
                if (rpta != null)
                {
                    MessageBox.Show("Correcto", "Registro creado",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
                    codigo.Text = "";
                    direccion.Text = "";
                    galquiler.Text = "";
                    gmant.Text = "";
                    gadicionales.Text = "";
                }
                    
            }
            catch (FaultException<ServiceReference1.Excepciones> error)
            {
                MessageBox.Show(error.Detail.Descripcion, "Service error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                
            }

        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ServiceReference1.RegistrarGastosClient obj  = new ServiceReference1.RegistrarGastosClient();
                ServiceReference1.Inmuebles             obj2 = new ServiceReference1.Inmuebles();
                ServiceReference1.Inmuebles             rpta = new ServiceReference1.Inmuebles();
                obj2.codigo         = codigo.Text;
                obj2.direccion      = direccion.Text;
                obj2.gAlquiler      = Convert.ToDecimal(galquiler.Text);
                obj2.gMantenimiento = Convert.ToDecimal(gmant.Text);
                obj2.gAdicionales   = Convert.ToDecimal(gadicionales.Text);
                obj2.idInquilino    = int.Parse(cboInquilino.SelectedValue.ToString());
                rpta = obj.CrearInmueble(obj2);
                if (rpta != null)
                {
                    decimal total_ = Convert.ToDecimal(galquiler.Text) + Convert.ToDecimal(gmant.Text) + Convert.ToDecimal(gadicionales.Text);
                    MessageBox.Show("Correcto", "Registro creado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    codigo.Text       = "";
                    direccion.Text    = "";
                    galquiler.Text    = "";
                    gmant.Text        = "";
                    gadicionales.Text = "";


                    ConnectionFactory connectionFactory = new ConnectionFactory();
                    connectionFactory.Uri = new Uri("amqp://*****:*****@wasp.rmq.cloudamqp.com/gvxavqvf");
                    IConnection connection = connectionFactory.CreateConnection();
                    var         queueName  = "inquilino" + obj2.idInquilino;
                    IModel      model      = connection.CreateModel();
                    model.QueueDeclare(queueName, false, false, false, null);
                    var exchangeName = "";
                    var routingKey   = "inquilino" + obj2.idInquilino;
                    var data         = Encoding.UTF8.GetBytes(total_.ToString());
                    model.BasicPublish(exchangeName, routingKey, true, null, data);
                }
            }
            catch (FaultException <ServiceReference1.Excepciones> error)
            {
                MessageBox.Show(error.Detail.Descripcion, "Service error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void BtnEnviar_Click(object sender, EventArgs e)
        {
            JavaScriptSerializer js      = new JavaScriptSerializer();
            HttpWebRequest       request = (HttpWebRequest)WebRequest.Create("http://*****:*****@gmail.com&passwd=59cxmaq9&dest={celular}&msg={sms}";

            //es posible utilizar el remitente en Am´erica pero s´ı en Espa~na y Europa
            //Descomentar la l´ınea solo si se cuenta con un remitente autorizado por Altiria
            //cmd=cmd + "&senderId=remitente";
            // Se codifica en utf-8
            byte[] lbPostBuffer = System.Text.Encoding.GetEncoding("utf-8").GetBytes(lcPostData);
            loHttp.Method        = "POST";
            loHttp.ContentType   = "application/x-www-form-urlencoded";
            loHttp.ContentLength = lbPostBuffer.Length;
            //Fijamos tiempo de espera de respuesta = 60 seg
            loHttp.Timeout = 60000;
            String error     = "";
            String response2 = "";

            // Env´ıa la peticion
            try
            {
                Stream loPostData = loHttp.GetRequestStream();
                loPostData.Write(lbPostBuffer, 0, lbPostBuffer.Length);
                loPostData.Close();
                // Prepara el objeto para obtener la respuesta
                HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();
                // La respuesta vendr´ıa codificada en utf-8
                Encoding     enc = System.Text.Encoding.GetEncoding("utf-8");
                StreamReader loResponseStream =
                    new StreamReader(loWebResponse.GetResponseStream(), enc);
                // Conseguimos la respuesta en una cadena de texto
                response2 = loResponseStream.ReadToEnd();
                loWebResponse.Close();
                loResponseStream.Close();
            }
            catch (WebException ex)
            {
                if (ex.Status == WebExceptionStatus.ConnectFailure)
                {
                    error = "Error en la conexion";
                }
                else if (ex.Status == WebExceptionStatus.Timeout)
                {
                    error = "Error TimeOut";
                }
                else
                {
                    error = ex.Message;
                }
            }
            MessageBox.Show("Mensaje Enviado Correctamente", "Registro creado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }