public void EnviarEmailConfirmacao(TicketMensagemRequest request,
                                    TicketMensagem ticketMensagem,
                                    TicketResponse ticket,
                                    AtendenteEmpresa atendenteEmpresa,
                                    UsuarioCliente usuarioCliente,
                                    List <AtendenteEmpresa> listaAtendentes)
 {
     //Se for mensagem enviada pelo atendimento (suporte) e interno
     if (request.UserType == "S" && request.Interno)
     {
         //Se for nova mensagem interna criada pelo suporte
         Emailer.EnviarEmailInterno(ticket, ticketMensagem, atendenteEmpresa, listaAtendentes);
     }
     else
     {
         if (request.UserType == "S" && !request.Interno)
         {
             //Se for nova mensagem (não interna) criada pelo suporte
             Emailer.EnviarEmailNovaMensagemCliente(ticket, ticketMensagem);
         }
         else
         {
             if (request.UserType == "C")
             {
                 //Se for nova mensagem criada pelo cliente
                 Emailer.EnviarEmailNovaMensagemSuporte(ticket, ticketMensagem, usuarioCliente, listaAtendentes);
             }
         }
     }
 }
예제 #2
0
        public void EnviarEmailConfirmacao(string userTypeAgent,
                                           StatusTicket statusTicket,
                                           Classificacao classificacao,
                                           Ticket ticket,
                                           UsuarioCliente usuarioCliente,
                                           AtendenteEmpresa atendenteEmpresa,
                                           List <AtendenteEmpresa> listaAtendentes,
                                           string acao)
        {
            //Verifica se o novo atendimento foi criado pelo cliente ou pelo suporte
            if (userTypeAgent == "S") //suporte
            {
                if (acao == "insert")
                {
                    //Envia email ao cliente, confirmando que um novo ticket de atendimento foi cadastrado com sucesso pelo suporte
                    Emailer.EnviarEmailNovoTicketCliente(ticket, usuarioCliente);

                    //Envia email ao suporte, confirmando que um novo ticket de atendimento foi cadastrado com sucesso pelo suporte
                    //permitindo que todos os atendentes envolvidos, fiquem cientes do novo atendimento
                    Emailer.EnviarEmailNovoTicketSuporte(ticket, usuarioCliente, atendenteEmpresa, listaAtendentes);
                }
                else
                {
                    if (acao == "update")
                    {
                        //Envia email ao cliente, confirmando atualização do ticket
                        Emailer.EnviarEmailAlteracaoStatusTicketCliente(ticket, statusTicket, usuarioCliente);
                    }
                    else
                    {
                        //Envia email ao cliente, confirmando atualização da classificacao do atendimento
                        Emailer.EnviarEmailAlteracaoClassificacaoCliente(ticket, classificacao, usuarioCliente);
                    }
                }
            }
            else //cliente
            {
                if (acao == "insert")
                {
                    //Envia email ao suporte, confirmando que um novo ticket de atendimento foi cadastrado com sucesso pelo cliente
                    Emailer.EnviarEmailNovoTicketSuporte(ticket, usuarioCliente, listaAtendentes);
                }
                else
                {
                    //Envia email ao suporte, confirmando atualização do ticket
                    //Emailer.EnviarEmailMensagemSuportee(ticket.Id, usuarioCliente);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Método que envia email para o suporte, informando de nova mensagem interna
        /// </summary>
        /// <param name="ticket"></param>
        /// <param name="ticketMensagem"></param>
        /// <param name="atendenteEmpresa"></param>
        /// <param name="listaAtendentes"></param>
        public static void EnviarEmailInterno(TicketResponse ticket, TicketMensagem ticketMensagem, AtendenteEmpresa atendenteEmpresa, List <AtendenteEmpresa> listaAtendentes)
        {
            var subject       = string.Empty;
            var emailFrom     = string.Empty;
            var emailsEmCopia = MontarListaEmailsEmCopia(listaAtendentes);

            try
            {
                subject   = "Confirmação de novo atendimento interno - Ticket #" + ticket.Id.ToString();
                emailFrom = ConfigurationManager.AppSettings["EmailSuporte"].ToString();

                Email.SendNetEmail(emailFrom, atendenteEmpresa.Email, emailsEmCopia, Email.FormatarCorpoNovaMensagemInterna(ticket, ticketMensagem, atendenteEmpresa), subject, true, System.Net.Mail.MailPriority.High);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #4
0
        /// <summary>
        /// Método que envia email para o suporte, informando de novo ticket criado pelo suporte (em nome do cliente)
        /// </summary>
        /// <param name="ticket"></param>
        /// <param name="usuarioCliente"></param>
        /// <param name="atendenteEmpresa"></param>
        /// <param name="listaAtendentes"></param>
        public static void EnviarEmailNovoTicketSuporte(Ticket ticket, UsuarioCliente usuarioCliente, AtendenteEmpresa atendenteEmpresa, List <AtendenteEmpresa> listaAtendentes)
        {
            var subject       = string.Empty;
            var emailFrom     = string.Empty;
            var emailsEmCopia = MontarListaEmailsEmCopia(listaAtendentes);

            try
            {
                subject   = "Confirmação de novo atendimento - Ticket #" + ticket.Id.ToString();
                emailFrom = ConfigurationManager.AppSettings["EmailSuporte"].ToString();

                Email.SendNetEmail(emailFrom, atendenteEmpresa.Email, emailsEmCopia, Email.FormatarCorpoNovoChamadoSuporte(ticket, usuarioCliente), subject, true, System.Net.Mail.MailPriority.High);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #5
0
        public IHttpActionResult Insert([FromBody] TicketMensagemRequest request)
        {
            UsuarioCliente          usuarioCliente   = null;
            AtendenteEmpresa        atendenteEmpresa = null;
            Ticket                  ticket           = null;
            List <AtendenteEmpresa> listaAtendentes  = null;

            try
            {
                //Valida objeto
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Dados inválidos."));
                }

                var entity            = Mapper.Map <TicketMensagemRequest, TicketMensagem>(request);
                var pathAnexosUsuario = request.PathAnexos;

                ticket = _ticketBusiness.GetById(request.IdTicket);

                ticket.DataHoraAlteracao      = DateTime.Now;
                ticket.DataHoraUltimaMensagem = DateTime.Now;

                //Se for uma mensagem interna enviada pelo suporte
                if (request.UserType == "S" && request.Interno)
                {
                    entity.IdAtendenteEmpresa = request.IdAutor;
                    ticket.IdStatusTicket     = request.IdStatusTicket > 0 ? request.IdStatusTicket : 5; //Em Análise
                }
                else
                {
                    //Se for uma mensagem enviada pelo suporte
                    if (request.UserType == "S" && !request.Interno)
                    {
                        entity.IdAtendenteEmpresa = request.IdAutor;
                        ticket.IdStatusTicket     = request.IdStatusTicket > 0 ? request.IdStatusTicket : 4; //Pendente com Cliente
                    }
                    else
                    {
                        //Se for uma mensagem enviada pelo usuário cliente
                        if (request.UserType == "C")
                        {
                            entity.IdUsuarioCliente = request.IdAutor;
                            ticket.IdStatusTicket   = 1; //Aguardando Atendimento
                        }
                    }
                }

                //Insere a nova mensagem
                _ticketMensagemBusiness.Insert(ref entity);

                if (entity.Id > 0)
                {
                    //Atualiza o status do ticket, para refletir o novo momento do atendimento
                    _ticketBusiness.UpdateStatusTicket(ticket);

                    //Monta response
                    _result = Ok(Retorno <TicketMensagemResponse> .Criar(true, "Inclusão Realizada Com Sucesso", Mapper.Map <TicketMensagem, TicketMensagemResponse>(entity)));

                    if (Directory.Exists(pathAnexosUsuario))
                    {
                        //Zipa todos os anexos
                        var zipName = Arquivo.Compress(ConfigurationManager.AppSettings["CaminhoFisicoAnexo"], pathAnexosUsuario, entity.Id);

                        //======================================
                        //Guarda anexo (zip) no banco de dados
                        //======================================
                        var anexo = new Anexo
                        {
                            IdTicketMensagem = entity.Id,
                            Nome             = zipName
                        };

                        _anexoBusiness.Insert(ref anexo);
                    }

                    //===========================================================================================
                    //Enviar email de confirmação de nova mensagem
                    //===========================================================================================

                    var ticketResponse = _ticketBusiness.GetByIdFilled(request.IdTicket, false);

                    if (request.UserType == "S")
                    {
                        usuarioCliente   = _usuarioClienteBusiness.GetById(ticketResponse.UsuarioCliente.Id);
                        atendenteEmpresa = _atendenteEmpresaBusiness.GetById(request.IdAutor);

                        if (atendenteEmpresa.Copia)
                        {
                            listaAtendentes = _atendenteEmpresaBusiness.GetList(x => x.IdEmpresa == atendenteEmpresa.IdEmpresa && x.Id != atendenteEmpresa.Id).ToList();
                        }
                    }
                    else
                    {
                        usuarioCliente  = _usuarioClienteBusiness.GetById(request.IdAutor);
                        listaAtendentes = _atendenteEmpresaBusiness.GetAll(ticketResponse.UsuarioCliente.Cliente.IdEmpresa).ToList();
                    }

                    try
                    {
                        _ticketMensagemBusiness.EnviarEmailConfirmacao(request, entity, ticketResponse, atendenteEmpresa, usuarioCliente, listaAtendentes);
                    }
                    catch (Exception)
                    {
                        //Monta response
                        _result = Ok(Retorno <TicketMensagemResponse> .Criar(true, "Inclusão Realizada Com Sucesso - Email de confirmação não enviado", Mapper.Map <TicketMensagem, TicketMensagemResponse>(entity)));
                    }

                    //===========================================================================================
                }

                //Retorna o response
                return(_result);
            }
            catch (Exception)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
 public bool UpdatePassword(AtendenteEmpresa atendente)
 {
     return(_repository.UpdatePassword(atendente));
 }
 public bool Update(AtendenteEmpresa entity)
 {
     return(_repository.Update(entity));
 }
 public void Insert(ref AtendenteEmpresa entity)
 {
     _repository.Insert(ref entity);
 }
예제 #9
0
        public IHttpActionResult ChangePassword([FromBody] ChangePasswordRequest changePasswordRequest)
        {
            AtendenteEmpresa atendente = null;
            UsuarioCliente   usuario   = null;

            using (var responseMsg = new HttpResponseMessage())
            {
                IHttpActionResult result = null;

                try
                {
                    //Se o email enviado é null, retornar BadRequest
                    if (changePasswordRequest == null)
                    {
                        return(BadRequest("Dados inválidos."));
                    }

                    if (changePasswordRequest.UserType == Tipos.Login.Atendimento)
                    {
                        atendente = _atendenteEmpresaBusiness.GetByUsernameAndPassword(changePasswordRequest.Username, changePasswordRequest.OldPassword);

                        if (atendente != null)
                        {
                            atendente.Password   = changePasswordRequest.NewPassword;
                            atendente.Provisorio = false;

                            if (_atendenteEmpresaBusiness.UpdatePassword(atendente))
                            {
                                atendente.Password = "******";

                                //Monta response
                                result = Ok(Retorno <AtendenteEmpresa> .Criar(true, "Troca de Senha Realizada Com Sucesso.", atendente));
                            }
                        }
                    }
                    else
                    {
                        usuario = _usuarioClienteBusiness.GetByUsernameAndPassword(changePasswordRequest.Username, changePasswordRequest.OldPassword);

                        if (usuario != null)
                        {
                            usuario.Password   = changePasswordRequest.NewPassword;
                            usuario.Provisorio = false;

                            if (_usuarioClienteBusiness.UpdatePassword(usuario))
                            {
                                usuario.Password = "******";

                                //Monta response
                                result = Ok(Retorno <UsuarioCliente> .Criar(true, "Troca de Senha Realizada Com Sucesso.", usuario));
                            }
                        }
                    }

                    //Retorna o response com o token
                    return(result);
                }
                catch (Exception ex)
                {
                    return(InternalServerError(ex));
                }
            }
        }
예제 #10
0
        /// <summary>
        /// Método que formata o corpo do email de aviso de nova mensagem interna,
        /// enviado apenas para o atendimento (suporte).
        /// </summary>
        /// <param name="ticket"></param>
        /// <param name="ticketMensagem"></param>
        /// <param name="atendenteEmpresa"></param>
        /// <returns></returns>
        public static string FormatarCorpoNovaMensagemInterna(TicketResponse ticket, TicketMensagem ticketMensagem, AtendenteEmpresa atendenteEmpresa)
        {
            var corpo = new StringBuilder();

            var logo = ConfigurationManager.AppSettings["LogoCabecalho"];

            corpo.Append("<html>");
            corpo.Append("<head>");
            corpo.Append("<title>SAC - Sistema de Atendimento ao Cliente</title>");
            corpo.Append("<style type=\"text/css\">");
            corpo.Append("body");
            corpo.Append("{");
            corpo.Append("    margin:0px;");
            corpo.Append("    padding:0px;");
            corpo.Append("    font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif;");
            corpo.Append("    height:100%;");
            corpo.Append("    width:100%;");
            corpo.Append("    font-size:11pt;");
            corpo.Append("}");
            corpo.Append("</style>");
            corpo.Append("</head>");
            corpo.Append("<body>");
            corpo.Append("<table cellspacing=\"4\" cellpadding=\"4\" border=\"0\" style=\"width:700px;\">");
            corpo.Append("<tr><td style=\"text-align: left; vertical-align: middle\"><img src=\"" + logo + "\" alt=\"\" /></td></tr>");
            corpo.Append("<tr><td><br />");
            corpo.Append("Prezado Suporte,<br /><br />");

            corpo.Append("Confirmado o recebimento de nova mensagem interna de atendimento - Ticket " + ticket.Titulo + " - (#" + ticket.Id + "), criado pelo atendente " + atendenteEmpresa.Nome + ".<br /><br />");

            corpo.Append("</td></tr>");
            corpo.Append("<tr><td><br />");

            corpo.Append("<h3>Ticket</h3><hr><br />");

            corpo.Append("<table style=\"width: 70%;\" cellpadding=\"4\" cellspacing=\"4\">");
            corpo.Append("    <tr><td style=\"width:20%; vertical-align:top\"><strong>Usuário</strong></td>");
            corpo.Append("        <td style=\"width:80%\">" + ticket.UsuarioCliente.Nome + " (" + ticket.UsuarioCliente.Email + ")</td></tr>");
            corpo.Append("    <tr><td style=\"width:20%; vertical-align:top\"><strong>Classificação</strong></td>");
            corpo.Append("        <td>" + ticket.Classificacao.Nome + "</td></tr>");
            corpo.Append("    <tr><td style=\"width:20%; vertical-align:top\"><strong>Categoria</strong></td>");
            corpo.Append("        <td>" + ticket.Categoria.Nome + "</td></tr>");
            corpo.Append("    <tr><td style=\"width:20%; vertical-align:top\"><strong>Título</strong></td>");
            corpo.Append("        <td>" + ticket.Titulo + "</td></tr>");
            corpo.Append("    <tr><td style=\"width:20%; vertical-align:top\"><strong>Descrição</strong></td>");
            corpo.Append("        <td>" + ticket.Descricao.Replace("\n", "<br />").Replace("\r", "") + "</td></tr>");
            corpo.Append("</table>");

            corpo.Append("</td></tr>");
            corpo.Append("<tr><td><br />");

            corpo.Append("<h3>Nova Mensagem</h3><hr><br />");
            corpo.Append("<p>" + ticketMensagem.Descricao.Replace("\n", "<br />").Replace("\r", "") + "</p><br /><br />");

            corpo.Append("Acesse o <a href='" + ConfigurationManager.AppSettings["SistemaAtendimentoAssinatura"] + "'>sistema de atendimento</a> para dar prosseguimento ao suporte.<br /><br />");

            corpo.Append("</td></tr>");
            corpo.Append("<tr><td><br />");

            corpo.Append("Atenciosamente,<br />");
            corpo.Append(ConfigurationManager.AppSettings["TextoAssinatura"] + "<br />");
            corpo.Append("<a href='" + ConfigurationManager.AppSettings["UrlAssinatura"] + "'>" + ConfigurationManager.AppSettings["SiteAssinatura"] + "</a><br />");
            corpo.Append(ConfigurationManager.AppSettings["TelefonesAssinatura"] + "<br />");
            corpo.Append("</td></tr>");
            corpo.Append("</table>");
            corpo.Append("</body>");
            corpo.Append("</html>");

            return(corpo.ToString());
        }
예제 #11
0
        //[AllowAnonymous]
        public IHttpActionResult UpdateClassificacao([FromBody] TicketUpdateClassificacaoRequest request)
        {
            AtendenteEmpresa        atendenteEmpresa = null;
            List <AtendenteEmpresa> listaAtendentes  = null;

            try
            {
                //Valida objeto
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Dados inválidos."));
                }

                var entityInDb = _ticketBusiness.GetById(request.Id);

                //Verifica se objeto existe
                if (entityInDb == null)
                {
                    return(NotFound());
                }

                entityInDb.IdClassificacao   = request.IdClassificacao;
                entityInDb.DataHoraAlteracao = DateTime.Now;

                if (_ticketBusiness.Update(entityInDb))
                {
                    //Recupera o ticket atualizado
                    entityInDb = _ticketBusiness.GetById(request.Id);

                    //Monta response
                    _result = Ok(Retorno <Ticket> .Criar(true, "Atualização Realizada Com Sucesso", entityInDb));

                    //===========================================================================================
                    //Enviar email de atualização do atendimento
                    //===========================================================================================
                    var usuarioCliente = _usuarioClienteBusiness.GetById(request.IdUsuarioCliente);
                    var classificacao  = _classificacaoBusiness.GetById(entityInDb.IdClassificacao);

                    if (request.UserTypeAgent == "S")
                    {
                        atendenteEmpresa = _atendenteEmpresaBusiness.GetById(request.IdAtendente);

                        if (atendenteEmpresa != null)
                        {
                            if (atendenteEmpresa.Copia)
                            {
                                listaAtendentes = _atendenteEmpresaBusiness.GetList(x => x.IdEmpresa == atendenteEmpresa.IdEmpresa && x.Id != atendenteEmpresa.Id).ToList();
                            }
                        }
                    }

                    try
                    {
                        _ticketBusiness.EnviarEmailConfirmacao(request.UserTypeAgent, null, classificacao, entityInDb, usuarioCliente, atendenteEmpresa, listaAtendentes, nameof(classificacao));
                    }
                    catch (Exception)
                    {
                        //Monta response
                        _result = Ok(Retorno <Ticket> .Criar(true, "Atualização Realizada Com Sucesso - Email de confirmação não enviado", entityInDb));
                    }

                    //===========================================================================================

                    //Retorna o response
                    return(_result);
                }
                else
                {
                    return(BadRequest("Nenhum registro atualizado. Verifique os dados enviados."));
                }
            }
            catch (Exception)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
예제 #12
0
        //[AllowAnonymous]
        public IHttpActionResult Insert([FromBody] TicketRequest request)
        {
            UsuarioCliente          usuarioCliente   = null;
            AtendenteEmpresa        atendenteEmpresa = null;
            List <AtendenteEmpresa> listaAtendentes  = null;

            try
            {
                //Valida objeto
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Dados inválidos."));
                }

                var entity            = Mapper.Map <TicketRequest, Ticket>(request);
                var pathAnexosUsuario = request.PathAnexos;

                entity.DataHoraInicial = DateTime.Now;

                _ticketBusiness.Insert(ref entity);

                if (entity.Id > 0)
                {
                    //Monta response
                    _result = Ok(Retorno <TicketResponse> .Criar(true, "Inclusão Realizada Com Sucesso", Mapper.Map <Ticket, TicketResponse>(entity)));

                    //Trata dos anexos
                    if (Directory.Exists(pathAnexosUsuario))
                    {
                        //Zipa todos os anexos
                        var zipName = Arquivo.Compress(ConfigurationManager.AppSettings["CaminhoFisicoAnexo"], pathAnexosUsuario, entity.Id);

                        //======================================
                        //Guarda anexo (zip) no banco de dados
                        //======================================
                        var anexo = new Anexo
                        {
                            IdTicket = entity.Id,
                            Nome     = zipName
                        };

                        _anexoBusiness.Insert(ref anexo);
                    }

                    //===========================================================================================
                    //Enviar email de confirmação de criação do novo atendimento
                    //===========================================================================================

                    var ticketResponse = _ticketBusiness.GetByIdFilled(entity.Id, false);

                    if (request.UserTypeAgent == "S")
                    {
                        usuarioCliente   = _usuarioClienteBusiness.GetById(request.IdUsuarioCliente);
                        atendenteEmpresa = _atendenteEmpresaBusiness.GetById(request.IdAtendente);

                        if (atendenteEmpresa != null)
                        {
                            if (atendenteEmpresa.Copia)
                            {
                                listaAtendentes = _atendenteEmpresaBusiness.GetList(x => x.IdEmpresa == atendenteEmpresa.IdEmpresa && x.IdEmpresa != atendenteEmpresa.IdEmpresa).ToList();
                            }
                        }
                    }
                    else
                    {
                        usuarioCliente  = _usuarioClienteBusiness.GetById(request.IdUsuarioCliente);
                        listaAtendentes = _atendenteEmpresaBusiness.GetAll(ticketResponse.UsuarioCliente.Cliente.IdEmpresa).ToList();
                    }

                    var statusTicket = _statusTicketBusiness.GetById(request.IdStatusTicket);

                    try
                    {
                        _ticketBusiness.EnviarEmailConfirmacao(request.UserTypeAgent, statusTicket, null, entity, usuarioCliente, atendenteEmpresa, listaAtendentes, "insert");
                    }
                    catch (Exception)
                    {
                        //Monta response
                        _result = Ok(Retorno <TicketResponse> .Criar(true, "Inclusão Realizada Com Sucesso - Email de confirmação não enviado", Mapper.Map <Ticket, TicketResponse>(entity)));
                    }

                    //===========================================================================================
                }

                //Retorna o response
                return(_result);
            }
            catch (Exception)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }