private void EnviarEmailNoficacion(TicketWS.agente age)
 {
     if (EnvioCorreoNotificacion.NuevoComentario(ticket, age) == false)
     {
         MessageBox.Show(
             "Ha ocurrido un error al enviar el correo de notificación al agente",
             "Correo no enviado",
             MessageBoxButtons.OK, MessageBoxIcon.Information
             );
     }
 }
Example #2
0
        public static bool NuevoComentario(TicketWS.ticket ticket, TicketWS.agente age)
        {
            StreamReader streamReader = new StreamReader("../../emails/EmailNotificacionComentario.html", System.Text.Encoding.UTF8);
            string       body         = streamReader.ReadToEnd();

            body = body.Replace("*NOMBREPH*", age.nombre);
            body = body.Replace("*APELLIDOPH*", age.apellidoPaterno);
            body = body.Replace("*TIPOPH*", "empleado");
            body = body.Replace("*TICKETIDPH*", ticket.ticketId.ToString());
            body = body.Replace("*ASUNTOPH*", ticket.asunto);

            EmailWS.YanapayEmail correo = new EmailWS.YanapayEmail();
            correo.FromAddress  = "*****@*****.**";
            correo.ToRecipients = age.personaEmail;
            correo.Subject      = "Yanapay - Nuevo comentario";
            correo.Body         = body;
            correo.IsHtml       = true;

            return(servicioEmail.EnviarCorreo(correo));
        }
Example #3
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            if (rtfComentario.Text == "")
            {
                MessageBox.Show(
                    "Falta indicar el comentario de la resolución.",
                    "Error de comentario",
                    MessageBoxButtons.OK, MessageBoxIcon.Information
                    );
                return;
            }
            if (Regex.Matches(rtfComentario.Text, @"[a-zA-Z]").Count == 0)
            {
                MessageBox.Show(
                    "El comentario no es válido.",
                    "Error de comentario",
                    MessageBoxButtons.OK, MessageBoxIcon.Information
                    );
                return;
            }
            bool tareasCompletadas = true;

            var tck = new TareaWS.ticket();

            tck.ticketId = ticket.ticketId;
            var tareas = tareaDAO.listarTareasPorTicket(tck);

            if (tareas != null)
            {
                foreach (var t in tareas)
                {
                    if (t.completado == false)
                    {
                        tareasCompletadas = false;
                        break;
                    }
                }
            }


            if (tareasCompletadas)
            {
                if (MessageBox.Show("¿Está seguro de que desea cerrar el ticket?", "Resolución de ticket", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    var ag = new TicketWS.agente();
                    ag.agenteId = frmLogin.agenteLogueado.agenteId;

                    ticket.estado = estResuelto;

                    // Creamos el cambio de estado
                    var cambioEstado = new TicketWS.cambioEstadoTicket();
                    cambioEstado.comentario           = rtfComentario.Text;
                    cambioEstado.agenteResponsable    = ag;
                    cambioEstado.estadoTo             = estResuelto;
                    cambioEstado.cambioEstadoTicketId = 0;

                    // Registrar el cambio de estado

                    // Agregarlo al historial del ticket
                    BindingList <TicketWS.cambioEstadoTicket> historialEstados;

                    if (ticket.historialEstado == null)
                    {
                        historialEstados = new BindingList <TicketWS.cambioEstadoTicket>();     // Si no tiene se crea una lista
                    }                                                                           // Sino se crea una lista a partir de este
                    else
                    {
                        historialEstados = new BindingList <TicketWS.cambioEstadoTicket>(ticket.historialEstado.ToList());
                    }
                    historialEstados.Add(cambioEstado);

                    // Se vuelve de nuevo a Array para ser asignado al ticket
                    ticket.historialEstado = historialEstados.ToArray();

                    // Se actualiza el ticket
                    if (ticketDAO.actualizarTicket(ticket) > -1)
                    {
                        MessageBox.Show(
                            "Se ha cerrado el ticket correctamente.",
                            "Actualización exitosa",
                            MessageBoxButtons.OK, MessageBoxIcon.Information
                            );

                        // Enviar correo al alumno
                        EnviarEmailNotificacion(ticket, cambioEstado);

                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        MessageBox.Show(
                            "Ha ocurrido un error con la actualización",
                            "Actualización no realizada",
                            MessageBoxButtons.OK, MessageBoxIcon.Information
                            );
                        this.Close();
                    }
                }
            }
            else
            {
                MessageBox.Show("Tiene tareas no completadas, por favor complete las tareas antes de cerrar el ticket.",
                                "Tareas incompletas", MessageBoxButtons.OK);
                this.Close();
            }
        }
Example #4
0
        private void btnSeleccionar_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("¿Desea atender este ticket?", "Seleccionar ticket", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                TicketWS.ticket tck = (TicketWS.ticket)dgvTicketsEspera.CurrentRow.DataBoundItem;

                // Verificar que el ticket no ha sido asignado
                TicketWS.ticket tckBD = ticketDAO.buscarTicketPorId(tck.ticketId);
                if (tckBD.agente.agenteId != 0)
                {
                    MessageBox.Show(
                        "Este ticket ya ha sido asignado a otro agente",
                        "Asignación no realizada",
                        MessageBoxButtons.OK, MessageBoxIcon.Information
                        );
                    Refrescar();
                    dgvTicketsEspera.AutoGenerateColumns = false;
                    dgvTicketsEspera.DataSource          = ticketsEnEspera;
                    return;
                }

                TicketWS.estadoTicket estAsignado = new TicketWS.estadoTicket();
                estAsignado.estadoId = (int)Estado.Asignado;
                estAsignado.nombre   = "ASIGNADO";

                tck.estado = estAsignado;

                // Registrar el cambio de estado
                var historialEstados = new BindingList <TicketWS.cambioEstadoTicket>();

                var cambioEstado = new TicketWS.cambioEstadoTicket();
                cambioEstado.comentario = "El ticket fue asignado a un " + agente.rol.nombre.ToLower() + ".";
                var ag = new TicketWS.agente();
                ag.agenteId = agente.agenteId;
                cambioEstado.agenteResponsable = ag;
                cambioEstado.estadoTo          = estAsignado;

                historialEstados.Add(cambioEstado);

                tck.agente.agenteId = agente.agenteId;
                // Asignar la lista de cambios de estado
                tck.historialEstado = historialEstados.ToArray();

                if (ticketDAO.actualizarTicket(tck) > -1)
                {
                    MessageBox.Show(
                        "Se te ha asignado el ticket correctamente",
                        "Asignación exitosa",
                        MessageBoxButtons.OK, MessageBoxIcon.Information
                        );

                    // Enviar correo al alumno
                    EnviarEmailNotificacion(tck, cambioEstado);
                }
                else
                {
                    MessageBox.Show(
                        "Ha ocurrido un error con la asignación",
                        "Asginación no realizada",
                        MessageBoxButtons.OK, MessageBoxIcon.Information
                        );
                }
                Refrescar();
                dgvTicketsEspera.AutoGenerateColumns = false;
                dgvTicketsEspera.DataSource          = ticketsEnEspera;
            }
        }
Example #5
0
        private void btnReasignar_Click(object sender, EventArgs e)
        {
            if (rtfComentario.Text == "")
            {
                MessageBox.Show(
                    "Falta indicar el comentario de la recategorizacion.",
                    "Error de comentario",
                    MessageBoxButtons.OK, MessageBoxIcon.Information
                    );
                return;
            }
            if (Regex.Matches(rtfComentario.Text, @"[a-zA-Z]").Count == 0)
            {
                MessageBox.Show(
                    "El comentario de la recategorizacion de contener al menos una letra.",
                    "Error de comentario",
                    MessageBoxButtons.OK, MessageBoxIcon.Information
                    );
                return;
            }
            if (MessageBox.Show("¿Desea reasignar la categoria?", "Reasignar Categoria", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                ticket.agente = null;

                CategoriaWS.categoria cat    = (CategoriaWS.categoria)dgvCategoria.CurrentRow.DataBoundItem;
                TicketWS.categoria    cateGo = new TicketWS.categoria();
                cateGo.nombre      = cat.nombre;
                cateGo.categoriaId = cat.categoriaId;
                ticket.categoria   = cateGo;

                TicketWS.estadoTicket estRecategorizado = new TicketWS.estadoTicket();
                estRecategorizado.estadoId = (int)Estado.Recategorizado;
                estRecategorizado.nombre   = "RECATEGORIZADO";
                ticket.estado = estRecategorizado;

                var ag = new TicketWS.agente();
                ag.agenteId = agente.agenteId;

                // Creamos el cambio de estado
                var cambioEstado = new TicketWS.cambioEstadoTicket();
                cambioEstado.comentario           = "El ticket ha sido recategorizado";
                cambioEstado.agenteResponsable    = ag;
                cambioEstado.estadoTo             = estRecategorizado;
                cambioEstado.cambioEstadoTicketId = 0;

                // Registrar el cambio de estado

                // Agregarlo al historial del ticket
                BindingList <TicketWS.cambioEstadoTicket> historialEstados;

                if (ticket.historialEstado == null)
                {
                    historialEstados = new BindingList <TicketWS.cambioEstadoTicket>();     // Si no tiene se crea una lista
                }                                                                           // Sino se crea una lista a partir de este
                else
                {
                    historialEstados = new BindingList <TicketWS.cambioEstadoTicket>(ticket.historialEstado.ToList());
                }
                historialEstados.Add(cambioEstado);

                // Se vuelve de nuevo a Array para ser asignado al ticket
                ticket.historialEstado = historialEstados.ToArray();

                // Creamos la transferencia interna
                var transfer = new TicketWS.transferenciaInterna();
                transfer.agenteResponsable = ag;
                transfer.comentario        = rtfComentario.Text;
                transfer.categoriaTo       = cateGo;
                transfer.transferenciaId   = 0;

                // Registrar la transferenica

                BindingList <TicketWS.transferenciaInterna> historialTransfInterna;

                if (ticket.historialTransfInterna == null)
                {
                    historialTransfInterna = new BindingList <TicketWS.transferenciaInterna>();
                }
                else
                {
                    historialTransfInterna = new BindingList <TicketWS.transferenciaInterna>(ticket.historialTransfInterna.ToList());
                }
                historialTransfInterna.Add(transfer);

                ticket.historialTransfInterna = historialTransfInterna.ToArray();

                // Se actualiza el ticket
                if (ticketDAO.actualizarTicket(ticket) > -1)
                {
                    MessageBox.Show(
                        "Se ha cambiado la categoría seleccionada.",
                        "Reasignación exitosa",
                        MessageBoxButtons.OK, MessageBoxIcon.Information
                        );

                    // Enviar correo al alumno
                    cambioEstado.comentario = rtfComentario.Text;
                    EnviarEmailNotificacion(ticket, cambioEstado);

                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(
                        "Ha ocurrido un error con la reasignación",
                        "Reasignación no realizada",
                        MessageBoxButtons.OK, MessageBoxIcon.Information
                        );
                    this.Close();
                }
            }
        }