Exemple #1
0
        public Ticket CrearTicketAndroid(int idUsuario, int idUsuarioSolicito, int idArbol, string latitudinicio, string longitudinicio,
                                         string fechaalta, string latitudfin, string longitudfin, string costo, int idCanal, bool campoRandom, bool esTercero, bool esMail)
        {
            try
            {
                using (BusinessTicket negocio = new BusinessTicket())
                {
                    List <HelperCampoMascaraCaptura> campos = new List <HelperCampoMascaraCaptura>();
                    campos.Add(new HelperCampoMascaraCaptura {
                        IdCampo = 17, NombreCampo = "LATITUDINICIO", Valor = latitudinicio
                    });
                    campos.Add(new HelperCampoMascaraCaptura {
                        IdCampo = 18, NombreCampo = "LONGITUDINICIO", Valor = longitudinicio
                    });
                    campos.Add(new HelperCampoMascaraCaptura {
                        IdCampo = 19, NombreCampo = "FECHAALTA", Valor = DateTime.Now.ToString("yyyy-MM-dd")
                    });
                    campos.Add(new HelperCampoMascaraCaptura {
                        IdCampo = 20, NombreCampo = "LATITUDFIN", Valor = latitudfin
                    });
                    campos.Add(new HelperCampoMascaraCaptura {
                        IdCampo = 21, NombreCampo = "LONGITUDFIN", Valor = latitudfin
                    });
                    campos.Add(new HelperCampoMascaraCaptura {
                        IdCampo = 22, NombreCampo = "COSTO", Valor = costo
                    });

                    return(negocio.CrearTicket(idUsuario, idUsuarioSolicito, idArbol, campos, idCanal, campoRandom, esTercero, esMail));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #2
0
 public void CambiarAsignacionTicket(int idTicket, int idEstatusAsignacion, int idUsuarioAsignado, int idUsuarioAsigna, string comentario)
 {
     try
     {
         using (BusinessTicket negocio = new BusinessTicket())
         {
             negocio.CambiarAsignacionTicket(idTicket, idEstatusAsignacion, idUsuarioAsignado, idUsuarioAsigna, comentario);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #3
0
 public void AutoAsignarTicket(int idTicket, int idUsuario)
 {
     try
     {
         using (BusinessTicket negocio = new BusinessTicket())
         {
             negocio.AutoAsignarTicket(idTicket, idUsuario);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #4
0
 public List <HelperTickets> ObtenerTickets(int idUsuario, int pageIndex, int pageSize)
 {
     try
     {
         using (BusinessTicket negocio = new BusinessTicket())
         {
             return(negocio.ObtenerTickets(idUsuario, pageIndex, pageSize));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #5
0
 public HelperDetalleTicket ObtenerDetalleTicketNoRegistrado(int idTicket, string cveRegistro)
 {
     try
     {
         using (BusinessTicket negocio = new BusinessTicket())
         {
             return(negocio.ObtenerDetalleTicketNoRegistrado(idTicket, cveRegistro));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #6
0
 public Ticket CrearTicket(int idUsuario, int idArbol, List <HelperCampoMascaraCaptura> lstCaptura, bool campoRandom)
 {
     try
     {
         using (BusinessTicket negocio = new BusinessTicket())
         {
             return(negocio.CrearTicket(idUsuario, idArbol, lstCaptura, campoRandom));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #7
0
 public HelperDetalleTicket ObtenerDetalleTicket(int idTicket)
 {
     try
     {
         using (BusinessTicket negocio = new BusinessTicket())
         {
             return(negocio.ObtenerDetalleTicket(idTicket));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #8
0
 public void ConfirmaPreTicket(string guid, int idUsuario)
 {
     try
     {
         using (BusinessTicket negocio = new BusinessTicket())
         {
             negocio.ConfirmaPreTicket(guid, idUsuario);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #9
0
 public PreTicketCorreo ObtenerPreticketCorreo(string guid)
 {
     try
     {
         using (BusinessTicket negocio = new BusinessTicket())
         {
             return(negocio.ObtenerPreticketCorreo(guid));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #10
0
 public List <int> CapturaCasillaTicket(int idTicket, string nombreCampo)
 {
     try
     {
         using (BusinessTicket negocio = new BusinessTicket())
         {
             return(negocio.CapturaCasillaTicket(idTicket, nombreCampo));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #11
0
 public PreTicket GeneraPreticket(int idArbol, int idUsuarioSolicita, int idUsuarioLevanto, string observaciones)
 {
     try
     {
         using (BusinessTicket negocio = new BusinessTicket())
         {
             return(negocio.GeneraPreticket(idArbol, idUsuarioSolicita, idUsuarioLevanto, observaciones));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #12
0
                public static MailMessage CreateReplyComentarioTicket(Mail source)
                {
                    MailMessage reply;

                    try
                    {
                        reply = new MailMessage()
                        {
                            From = new MailAddress(source.To[0].Address),
                        };
                        reply.To.Add(source.From.Address);
                        reply.ReplyToList.Add(source.From.Address);
                        //todo cambiar el correo al que se usa
                        string       respuesta  = source.TextBody.Split(new[] { "De: [email protected]" }, StringSplitOptions.None)[0];
                        Attachment[] attachment = source.Attachments;

                        string id = source.Headers.GetValueOfKey("Message-ID");
                        reply.Headers.Add("In-Reply-To", id);

                        string        references      = source.Headers.GetValueOfKey("References");
                        string[]      referencesArray = references.Split('~');
                        List <string> lstTickets      = referencesArray.Where(w => w.Contains("ticket")).Distinct().ToList();
                        if (lstTickets.Count > 1)
                        {
                            return(null);
                        }
                        string   stringTicket   = lstTickets.First();
                        string[] ticketContains = stringTicket.Split('&');

                        if (ticketContains.Count() <= 0)
                        {
                            return(null);
                        }

                        int idticket = int.Parse(ticketContains[1]);
                        if (idticket == 0)
                        {
                            return(null);
                        }
                        HelperDetalleTicket ticket = new BusinessTicket().ObtenerDetalleTicket(idticket);
                        //new BusinessSecurity.Autenticacion().GetUserInvitadoDataAutenticate((int)BusinessVariables.EnumTiposUsuario.Cliente);
                        Usuario user           = new BusinessUsuarios().ObtenerDetalleUsuario(ticket.IdUsuarioLevanto);
                        bool    eliminoarchivo = false;
                        if (attachment.Any())
                        {
                            string        attname;
                            List <string> archivos = new List <string>();
                            foreach (Attachment att in attachment)
                            {
                                string extension = Path.GetExtension(att.Name);
                                if (extension != null)
                                {
                                    ParametrosGenerales parametros = new BusinessParametros().ObtenerParametrosGenerales();
                                    double tamañoArchivo           = double.Parse(parametros.TamanoDeArchivo);
                                    List <ArchivosPermitidos> archivospermitidos = new BusinessParametros().ObtenerArchivosPermitidos();
                                    if (archivospermitidos.Any(a => a.Extensiones.Contains(extension)))
                                    {
                                        attname = String.Format("{0}_{1}_{2}{3}{4}{5}{6}{7}{8}", att.Name.Replace(extension, string.Empty), idticket, DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, extension);
                                        att.SaveAs(String.Format("{0}{1}", ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["RepositorioMascara"] + ConfigurationManager.AppSettings["CarpetaTemporal"], attname), true);

                                        if (File.Exists(String.Format("{0}{1}", ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["RepositorioMascara"] + ConfigurationManager.AppSettings["CarpetaTemporal"], attname)))
                                        {
                                            long length = new FileInfo(String.Format("{0}{1}", ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["RepositorioMascara"] + ConfigurationManager.AppSettings["CarpetaTemporal"], attname)).Length;

                                            if (((length / 1024) / 1024) <= tamañoArchivo)
                                            {
                                                archivos.Add(attname);
                                            }
                                            else
                                            {
                                                if (File.Exists(String.Format("{0}{1}", ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["RepositorioMascara"] + ConfigurationManager.AppSettings["CarpetaTemporal"], attname)))
                                                {
                                                    File.Delete(String.Format("{0}{1}", ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["RepositorioMascara"] + ConfigurationManager.AppSettings["CarpetaTemporal"], attname));
                                                }
                                                eliminoarchivo = true;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        eliminoarchivo = true;
                                    }
                                }
                            }
                            new BusinessAtencionTicket().AgregarComentarioConversacionTicket(idticket, user.Id, respuesta, false, archivos, false, false);
                        }
                        else
                        {
                            new BusinessAtencionTicket().AgregarComentarioConversacionTicket(idticket, user.Id, respuesta, false, null, false, false);
                        }

                        if (string.IsNullOrEmpty(references))
                        {
                            references += "~ticket&" + idticket + "~";
                        }
                        if (!references.Contains("ticket&"))
                        {
                            references += "~ticket&" + idticket + "~";
                        }

                        reply.Headers.Add("References", references);

                        if (!source.Subject.StartsWith("Re:", StringComparison.OrdinalIgnoreCase))
                        {
                            reply.Subject = "Re: ";
                        }
                        reply.Subject += source.Subject;

                        reply.Subject    = reply.Subject.Replace("(Trial Version)", string.Empty).Trim();
                        reply.IsBodyHtml = true;
                        reply.Body       = GeneraRespuesta(source.From.Address, source.From.Address, source.HtmlBody, source.SentDate.ToString(CultureInfo.InvariantCulture), eliminoarchivo);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                    return(reply);
                }
Exemple #13
0
                public static MailMessage CreateReplyNewTicket(Mail source)
                {
                    MailMessage reply = new MailMessage();

                    try
                    {
                        string      attname;
                        ArbolAcceso arbol;
                        Mascara     mascara;

                        ObtenerFormulario(out arbol, out mascara);

                        Attachment att = source.Attachments.Any() ? source.Attachments[0] : null;
                        bool       agregaArchivo;
                        bool       eliminoArchivo;
                        string     subject = source.Subject.Replace("(Trial Version)", string.Empty).Trim();
                        List <HelperCampoMascaraCaptura> capturaMascara = GeneraCaptura(mascara, source.From.Address, subject, source.TextBody, source.Attachments, out attname, out agregaArchivo, out eliminoArchivo);

                        Usuario user = new BusinessUsuarios().GetUsuarioByCorreo(source.From.Address);
                        if (user == null)
                        {
                            string[]        nombreCompleto  = source.From.Name.Trim().Split(' ');
                            string          nombre          = nombreCompleto.Any() ? nombreCompleto.Length > 3 ? string.Format("{0} {1}", nombreCompleto[0], 1) : nombreCompleto[0] : string.Empty;
                            string          apellidoPaterno = nombreCompleto.Length > 4 ? nombreCompleto[nombreCompleto.Length - 2] : nombreCompleto.Length > 1 ? nombreCompleto[1] : string.Empty;
                            string          apellidoMaterno = nombreCompleto.Length > 4 ? nombreCompleto[nombreCompleto.Length - 1] : nombreCompleto.Length > 2 ? nombreCompleto[2] : string.Empty;
                            PreTicketCorreo preticket       = new BusinessTicket().GeneraPreticketCorreo(nombre, apellidoPaterno, apellidoMaterno, source.From.Address.Trim(), subject, source.TextBody, attname);
                            if (preticket != null)
                            {
                                if (att != null && agregaArchivo)
                                {
                                    File.Move(ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["CarpetaTemporal"] + attname, ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["CarpetaTemporal"] + attname.Replace("ticketid", preticket.Guid));
                                    attname = attname.Replace("ticketid", preticket.Guid);
                                    BusinessFile.MoverTemporales(ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["CarpetaTemporal"], ConfigurationManager.AppSettings["RepositorioCorreos"], new List <string> {
                                        attname
                                    });
                                    BusinessFile.CopiarArchivo(ConfigurationManager.AppSettings["RepositorioCorreos"], ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["RepositorioMascara"], attname);
                                }
                                reply.From = new MailAddress(source.To[0].Address);
                                reply.To.Add(source.From.Address);
                                reply.ReplyToList.Add(source.To[0].Address);
                                string id = source.Headers.GetValueOfKey("Message-ID");
                                reply.Headers.Add("In-Reply-To", id);
                                string references = source.Headers.GetValueOfKey("References");

                                if (string.IsNullOrEmpty(references))
                                {
                                    references += "~guidpreticket&" + preticket.Guid + "~";
                                }

                                reply.Headers.Add("References", references);

                                reply.Subject = "Confirmar Ticket";

                                reply.Subject    = reply.Subject.Replace("(Trial Version)", string.Empty).Trim();
                                reply.IsBodyHtml = true;
                                reply.Body       = GeneraRespuestaPreTicketCorreo(source.From.Address, source.From.Name, source.HtmlBody, source.SentDate.ToString(CultureInfo.InvariantCulture), preticket.Guid, eliminoArchivo);
                            }
                        }
                        else
                        {
                            Ticket ticket = new BusinessTicket().CrearTicket(user.Id, user.Id, arbol.Id, capturaMascara, (int)BusinessVariables.EnumeradoresKiiniNet.EnumCanal.Correo, mascara.Random, true, true);
                            if (ticket != null)
                            {
                                if (att != null && agregaArchivo)
                                {
                                    File.Move(ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["CarpetaTemporal"] + attname, ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["CarpetaTemporal"] + attname.Replace("ticketid", ticket.Id.ToString()));
                                    attname = attname.Replace("ticketid", ticket.Id.ToString());
                                    BusinessFile.MoverTemporales(ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["CarpetaTemporal"], ConfigurationManager.AppSettings["RepositorioCorreos"], new List <string> {
                                        attname
                                    });
                                    BusinessFile.CopiarArchivo(ConfigurationManager.AppSettings["RepositorioCorreos"], ConfigurationManager.AppSettings["Repositorio"] + ConfigurationManager.AppSettings["RepositorioMascara"], attname);
                                }
                                reply.From = new MailAddress(source.To[0].Address);
                                reply.To.Add(source.From.Address);
                                reply.ReplyToList.Add(source.To[0].Address);
                                string id = source.Headers.GetValueOfKey("Message-ID");
                                reply.Headers.Add("In-Reply-To", id);
                                string references = source.Headers.GetValueOfKey("References");

                                if (string.IsNullOrEmpty(references))
                                {
                                    references += "~ticket&" + ticket.Id + "~";
                                }

                                reply.Headers.Add("References", references);

                                if (!source.Subject.StartsWith("Re:", StringComparison.OrdinalIgnoreCase))
                                {
                                    reply.Subject = "Re: ";
                                }

                                reply.Subject += source.Subject;

                                reply.Subject    = reply.Subject.Replace("(Trial Version)", string.Empty).Trim();
                                reply.IsBodyHtml = true;
                                reply.Body       = GeneraRespuestaTicket(source.From.Address, source.From.Name, source.HtmlBody, source.SentDate.ToString(CultureInfo.InvariantCulture), ticket.Id, ticket.ClaveRegistro, eliminoArchivo);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }

                    return(reply);
                }