public void ProcessMessage(object MsgBody, string MQPath)
        {
            try
            {

                //// get the response message queue path from the response format name
                //// string MQResponsePath = RespFormatName.Split(':')[1];
                //// open the respone message queue
                //MessageQueue MQueue = new MessageQueue(MQPath);
                //// create a message out of the message body we got passed along
                //// so we can read the message body in the format originally sent
                //Message Msg = new Message();

                //Msg.BodyStream = new System.IO.MemoryStream((Byte[])MsgBody);
                //Msg.Formatter = new XmlMessageFormatter(new Type[] { typeof(CorreoAltaUsuario) });
                //// gets the Order from the message body passed along
                //CorreoAltaUsuario TheOrder = (CorreoAltaUsuario)Msg.Body;
                //// send the order unprocessed to the response message queue
                //// specified by the received message (so by the message sender)
                //MQueue.Send(TheOrder);
                //// close the response message queue again






                System.Messaging.MessageQueue mq;

                if (MessageQueue.Exists(@".\Private$\RestauranteQueue"))
                    mq = new System.Messaging.MessageQueue(@".\Private$\RestauranteQueue");
                else
                    mq = MessageQueue.Create(@".\Private$\RestauranteQueue");

                System.Messaging.Message mes;
                string m;


                mes = mq.Receive(new TimeSpan(0, 0, 3));
                mes.Formatter = new XmlMessageFormatter(new Type[] { typeof(CorreoAltaUsuario) });
                CorreoAltaUsuario TheOrder = (CorreoAltaUsuario)mes.Body;




                Mailer CorreoSolicitud = new Mailer();
                List<String> listCorreso = new List<string>();
                listCorreso.Add(TheOrder.CorreoUsuario);
                CorreoSolicitud.Notificacion.CorreosPara = listCorreso;
                CorreoSolicitud.Notificacion.ConCopia = "";
                CorreoSolicitud.Notificacion.Asunto = TheOrder.Asunto;
                CorreoSolicitud.Notificacion.Cuerpo = TheOrder.Mensaje;
                CorreoSolicitud.Enviar();


                //MQueue.Close();
            }
            // catch any exception to keep the MSMQ trigger service ok
            catch (Exception)
            {


            }
        }
        public ActionResult Create(UsuarioRestaurante view, FormCollection formCollection)
        {
            UsuarioRestaurante model = view;
            ProxyApiComun      api   = new ProxyApiComun();
            List <Telefono>    listTelefonoRegistrar = new List <Telefono>();

            try
            {
                model.Telefonos = JsonConvert.SerializeObject(listTelefonoRegistrar);

                ObtenerTipoTelefonoResponse responseTipoTelefono = api.ObtenerTipoTelefonos();


                model.ListTipoTelefono = new List <SelectListItemCustom>();
                model.ListTipoTelefono.Add(new SelectListItemCustom {
                    Text = "Seleccionar", Value = "0", Selected = true
                });

                foreach (TipoTelefono item in responseTipoTelefono.TipoTelefonos)
                {
                    model.ListTipoTelefono.Add(new SelectListItemCustom {
                        Text = item.DescripcionTelefono, Value = item.CodigoTelefono.ToString()
                    });
                }


                if (formCollection[$"slCodigoContacto"] != null && formCollection[$"txtCodigoContacto"] != null)
                {
                    string codigoTipoTelefno = "";
                    string numeroTelefno     = "";

                    codigoTipoTelefno = formCollection["slCodigoContacto"].ToString();
                    numeroTelefno     = formCollection["txtCodigoContacto"].ToString();

                    listTelefonoRegistrar.Add(new Telefono()
                    {
                        CodigoTipoTelefono = codigoTipoTelefno.Trim() == string.Empty ? 0 : Convert.ToInt32(codigoTipoTelefno),
                        NumeroTelefono     = numeroTelefno,
                        CodigoUsuario      = 0
                    });
                }

                int contador = 1;

                for (int i = 0; i < formCollection.Count; i++)
                {
                    if (formCollection[$"slCodigoContacto{contador}"] != null &&
                        formCollection[$"txtCodigoContacto{contador}"] != null)
                    {
                        string codigoTipoTelefno = "";
                        string numeroTelefno     = "";
                        codigoTipoTelefno = formCollection[$"slCodigoContacto{contador}"].ToString();
                        numeroTelefno     = formCollection[$"txtCodigoContacto{contador}"].ToString();


                        listTelefonoRegistrar.Add(new Telefono()
                        {
                            CodigoTipoTelefono = codigoTipoTelefno.Trim() == string.Empty?0: Convert.ToInt32(codigoTipoTelefno),
                            NumeroTelefono     = numeroTelefno,
                            CodigoUsuario      = 0
                        });
                    }

                    contador++;
                }

                model.Telefonos = JsonConvert.SerializeObject(listTelefonoRegistrar);



                // TODO: Add insert logic here

                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("MensajeGeneral", "Ingrese los campos obligatorio");
                    return(View(model));
                }
                else
                {
                    if (!this.IsCaptchaValid(""))
                    {
                        ModelState.AddModelError("MensajeGeneral", "Invalid Captcha");
                        return(View(model));
                    }
                    else
                    {
                        RegistrarUsuarioRestauranteRequest reqeust = new RegistrarUsuarioRestauranteRequest();

                        reqeust.Usuario     = model.Usuario;
                        reqeust.Restaurante = model.Restaurante;
                        reqeust.Telefonos   = listTelefonoRegistrar;

                        RegistrarUsuarioRestauranteResponse objRespuesta = new ProxyApiUsuario().RegistrarUsuarioRestaurante(reqeust);

                        if (objRespuesta.status.estado == 0)
                        {
                            // enviar a cola mensajes para envio de correo

                            string link           = "http://localhost:59052/Usuario/ActivarCuenta?CodigoUsuario=" + objRespuesta.CodigoUsuario;
                            string DetalleMensaje = " Para activar la cuenta ingrese al siguiente enlace ";


                            CorreoAltaUsuario objCorreoAltaUsuario = new CorreoAltaUsuario();


                            //Mailer CorreoSolicitud = new Mailer();
                            //List<String> listCorreso = new List<string>();
                            //listCorreso.Add(model.Usuario.usua_email);
                            //CorreoSolicitud.Notificacion.CorreosPara = listCorreso;
                            //CorreoSolicitud.Notificacion.ConCopia = "";
                            //CorreoSolicitud.Notificacion.Asunto = " Activar cuenta";
                            //CorreoSolicitud.Notificacion.Cuerpo = new FormatoCorreo().BodyMensaje(model.Usuario.usua_nomb, DetalleMensaje, link);
                            //CorreoSolicitud.Enviar();

                            objCorreoAltaUsuario.CodigoUsuario = model.Usuario.usua_id;
                            objCorreoAltaUsuario.CorreoUsuario = model.Usuario.usua_email;
                            objCorreoAltaUsuario.Asunto        = " Activar cuenta";
                            objCorreoAltaUsuario.Mensaje       = new FormatoCorreo().BodyMensaje(model.Usuario.usua_nomb, DetalleMensaje, link);


                            this.CrearCola();
                            this.EnviarMensajeCola(objCorreoAltaUsuario);


                            return(View("Correcto", model));
                        }
                        else
                        {
                            ModelState.AddModelError("MensajeGeneral", objRespuesta.status.mensaje);

                            return(View(model));
                        }
                    }
                }
            }
            catch (Exception err)
            {
                ModelState.AddModelError("MensajeGeneral", err);

                return(View(model));
            }
        }