Esempio n. 1
0
        public string TieneDatosReales(int id)
        {
            string   conStr = WebConfigurationManager.ConnectionStrings["ConStr"].ToString();
            ADO_Core AdoObj = new ADO_Core(conStr);

            SqlDataReader dr = AdoObj.GetDataReader("Exec sp_DatosReales " + id.ToString());

            string TieneDatosReales = "";


            while (dr.Read())
            {
                TieneDatosReales = dr["Tiene"].ToString();
            }

            AdoObj.Dispose();
            AdoObj = null;

            if (TieneDatosReales == "True")
            {
                return("Ok");
            }
            else
            {
                return("Bad");
            }
        }
Esempio n. 2
0
        public string ActivaHost(string id, bool estatus)
        {
            try
            {
                var result = db.AspNetUsers.Where(w => w.Id == id).FirstOrDefault();
                result.Estatus = estatus;

                db.SaveChanges();

                string   conStrr = WebConfigurationManager.ConnectionStrings["ConStr"].ToString();
                ADO_Core adoC    = new ADO_Core(conStrr);

                int eje = adoC.Execute("Exec sp_hostliberacontactos '" + id + "'");
                adoC.Dispose();
                adoC = null;


                return("Ok");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return("Bad");
            }
        }
Esempio n. 3
0
        public string AddProgramacionBIDAX(int id, int MedioContacto, string FechaHora, string Descripcion)
        {
            try
            {
                ProgramacionBIDA programacionBIDA = new ProgramacionBIDA();

                DateTime f = DateTime.Now;

                DateTime fechaHora = Convert.ToDateTime(FechaHora);

                programacionBIDA.ContactoId = id;
                programacionBIDA.SubCanalId = MedioContacto;
                programacionBIDA.FechaHora  = fechaHora;
                programacionBIDA.Acuerdo    = true;
                programacionBIDA.Realizada  = false;


                programacionBIDA.Comentario = Descripcion;

                db.ProgramacionBIDA.Add(programacionBIDA);
                db.SaveChanges();



                // actualiza el estatus de la tabla interacciones
                EstatusBIDA estatusBIDA = new EstatusBIDA();

                var interR = db.Interacciones.Where(w => w.ContactoId == id).FirstOrDefault();
                interR.EstatusBIDAId = 5;

                db.SaveChanges();


                // ejecuta el store procedure para la siguiente interaccion
                string mensaje = string.Empty;

                string   conStr = WebConfigurationManager.ConnectionStrings["ConStr"].ToString();
                ADO_Core adoC   = new ADO_Core(conStr);

                SqlDataReader dr = adoC.GetDataReader("Exec sp_SiguienteInteraccion " + id.ToString());

                if (dr.HasRows)
                {
                    dr.Read();
                    mensaje = dr["Mensaje"].ToString();
                }

                adoC.Dispose();
                adoC = null;

                return(mensaje);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return("Bad");
            }
        }
Esempio n. 4
0
        public string NoContesta(int id)
        {
            string mensaje = string.Empty;

            try
            {
                // graba el estatus a 3 en contactos
                var resCont = db.Contactos.Where(w => w.ContactoId == id).FirstOrDefault();
                resCont.EstatusBIDA = 3;
                db.SaveChanges();



                // ejecuta el store procedure para la siguiente interaccion
                string   conStr = WebConfigurationManager.ConnectionStrings["ConStr"].ToString();
                ADO_Core adoC   = new ADO_Core(conStr);

                SqlDataReader dr = adoC.GetDataReader("Exec sp_SiguienteInteraccion " + id.ToString());

                if (dr.HasRows)
                {
                    dr.Read();
                    mensaje = dr["Mensaje"].ToString();
                }

                adoC.Dispose();
                adoC = null;

                // ejemplo: Telefónica 2019 - 07 - 25 08:01
                // Telefónica 2019 - 07 - 25 08:01
                // 2019 - 07 - 25 08:01

                string   msgTemp = mensaje.Replace("Telefónica ", string.Empty);
                DateTime tmpD    = Convert.ToDateTime(msgTemp);



                // graba interaccion
                Interacciones interacciones = new Interacciones();

                interacciones.ContactoId    = id;
                interacciones.SubCanalId    = 2;
                interacciones.UsuarioHOST   = null;
                interacciones.EstatusBIDAId = 3;
                if (!string.IsNullOrEmpty(mensaje) && !string.IsNullOrWhiteSpace(mensaje))
                {
                    interacciones.FechaInteraccion = tmpD;
                }
                else
                {
                    interacciones.FechaInteraccion = DateTime.Now;
                }

                interacciones.Descripcion    = string.Empty;
                interacciones.Comentarios    = string.Empty;
                interacciones.Interes        = false;
                interacciones.CausaNoInterId = null;

                db.Interacciones.Add(interacciones);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
            }

            return(mensaje);
        }
Esempio n. 5
0
        public ActionResult Interaccion(Interaccion modelo, int SubCanalIdH, int numTab = 0)
        {
            try
            {
                int DatosReales = 0;
                DatosReales = db.DatosReales.Where(w => w.ContactoId == modelo.id).Count();

                var contac           = db.View_Lista_Contactos.Where(w => w.ContactoId == modelo.id).FirstOrDefault();
                int StatusBIDAActual = contac.EstatusBIDA;

                string Usuario_ID = Session["Usuario_ID"].ToString();

                Interacciones interacciones = new Interacciones();

                interacciones.ContactoId    = modelo.id;
                interacciones.SubCanalId    = SubCanalIdH;
                interacciones.UsuarioHOST   = Usuario_ID;
                interacciones.EstatusBIDAId = 5;

                if ((StatusBIDAActual == 1) && (DatosReales > 0))
                {
                    interacciones.EstatusBIDAId = 5;

                    // actualliza estatusbida en contactos
                    var contacto1 = db.Contactos.Where(w => w.ContactoId == modelo.id).FirstOrDefault();
                    contacto1.EstatusBIDA = 5;
                    db.SaveChanges();
                }
                else if ((StatusBIDAActual == 1) && (DatosReales == 0))
                {
                    interacciones.EstatusBIDAId = 2;
                    // actualliza estatusbida en contactos
                    var contacto1 = db.Contactos.Where(w => w.ContactoId == modelo.id).FirstOrDefault();
                    contacto1.EstatusBIDA = 2;
                    db.SaveChanges();
                }

                interacciones.FechaInteraccion = DateTime.Now;
                interacciones.Descripcion      = modelo.Descripcion;
                interacciones.Comentarios      = modelo.ResumenConversacion;
                interacciones.Interes          = false;

                if (numTab == 2)
                {
                    interacciones.CausaNoInterId      = modelo.CausaNoInterId;
                    interacciones.ComentarioNoInteres = modelo.ComentariosNoIntetres;
                    interacciones.EstatusBIDAId       = 4;


                    // actualliza estatusbida en contactos
                    var contacto1 = db.Contactos.Where(w => w.ContactoId == modelo.id).FirstOrDefault();
                    contacto1.EstatusBIDA = 4;
                    db.SaveChanges();
                }

                if (numTab == 3)
                {
                    // actualliza estatusbida en contactos
                    var contacto1 = db.Contactos.Where(w => w.ContactoId == modelo.id).FirstOrDefault();
                    contacto1.EstatusBIDA = 4;
                    db.SaveChanges();
                }

                if (numTab == 4)
                {
                    // actualliza estatusbida en contactos
                    var contacto1 = db.Contactos.Where(w => w.ContactoId == modelo.id).FirstOrDefault();
                    contacto1.EstatusBIDA = 3;
                    db.SaveChanges();
                }


                db.Interacciones.Add(interacciones);
                db.SaveChanges();

                // ejecuta el store procedure sp_SiguienteInteraccion
                string   ConStr  = WebConfigurationManager.ConnectionStrings["ConStr"].ToString();
                ADO_Core adoC    = new ADO_Core(ConStr);
                string   mensaje = string.Empty;

                string sqlStr = String.Format("Exec sp_SiguienteInteraccion {0}, {1}", modelo.id, 0);

                SqlDataReader dr = adoC.GetDataReader(sqlStr);
                if (dr.HasRows)
                {
                    dr.Read();
                    mensaje = dr["Mensaje"].ToString();
                }

                adoC.Dispose();
                adoC = null;



                // liberar contacto
                var rcont = db.Contactos.Where(w => w.ContactoId == modelo.id).FirstOrDefault();
                rcont.UsuarioHOST = null;
                db.SaveChanges();



                ViewBag.botonDisabled = string.Empty;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(RedirectToAction("Interaccion", "Host", new { id = modelo.id }));
        }
Esempio n. 6
0
        public ActionResult InteraccionTelefono(int id, string back)
        {
            Interaccion interaccion = new Interaccion();

            try
            {
                ViewBag.ID                 = id;
                ViewBag.Regreso            = back;
                ViewBag.botonDisabled      = "disabled";
                ViewBag.DesarrolloIdAsigna = new SelectList(db.Desarrollo.OrderBy(w => w.DesarrolloNombre), "DesarrolloId", "DesarrolloNombre");

                // subcanals
                ViewBag.SubCanalId        = new SelectList(db.SubCanales.OrderBy(w => w.SubCanalNombre), "SubCanalId", "SubCanalNombre");
                ViewBag.SubCanalIdAcuerdo = new SelectList(db.SubCanales.OrderBy(w => w.SubCanalNombre), "SubCanalId", "SubCanalNombre");

                // Desarrollo
                ViewBag.DesarrolloId = new SelectList(db.Desarrollo.OrderBy(w => w.DesarrolloNombre), "DesarrolloId", "DesarrolloNombre");

                // Modelo
                ViewBag.DesarrolloModeloId = new SelectList(db.DesarrolloModelo.OrderBy(w => w.DesarrolloModeloNombre), "DesarrolloModeloId", "DesarrolloModeloNombre");

                // Causa no Interesado
                ViewBag.CausaNoInterId = new SelectList(db.CausaNoInter.OrderBy(w => w.CausaNoInterNombre), "CausaNoInterId", "CausaNoInterNombre");


                // Lee datos del CONTACTO
                int Desarrollo_Id = 0;
                int subCanalId    = 0;

                var DatLead = from x in db.View_Datos_Contacto
                              where x.ContactoId == id
                              select x;
                int EstatusBIDA = 0;

                foreach (var item in DatLead)
                {
                    interaccion.id = id;
                    interaccion.NombreContactoCompleto = item.NombreContacto + " " + item.Apellidos;
                    EstatusBIDA   = item.EstatusBIDA;
                    Desarrollo_Id = item.DesarrolloId;
                    subCanalId    = item.SubCanalId;
                }

                ViewBag.Desarrollo_Id = Desarrollo_Id;
                ViewBag.Subcanal      = subCanalId;



                if (EstatusBIDA == 5)
                {
                    ViewBag.botonDisabled = string.Empty;
                }


                ViewBag.ContactoNombre = interaccion.NombreContactoCompleto;
                ViewBag.EstatusBida    = EstatusBIDA;

                // Lee datos reales del Lead
                var datReal = from x in db.DatosReales
                              where x.ContactoId == id
                              select x;
                foreach (var item in datReal)
                {
                    interaccion.NombreReal          = item.Nombre;
                    interaccion.ApellidoPaternoReal = item.ApellidoPaterno;
                    interaccion.ApellidoMaternoReal = item.ApellidoMaterno;
                    interaccion.TelefonoReal        = item.Telefono;
                    interaccion.CorreoReal          = item.Correo;
                }


                // lee interaccion final
                var interacc = db.Interacciones.OrderByDescending(w => w.InteraccionId).FirstOrDefault(w => w.ContactoId == id);

                var IdInteraccion = 0;

                if (interacc != null)
                {
                    IdInteraccion                   = interacc.InteraccionId;
                    interaccion.Descripcion         = interacc.Descripcion;
                    interaccion.ResumenConversacion = interacc.Comentarios;

                    // ejecuta la siguiente interaccion
                    string   conStr    = WebConfigurationManager.ConnectionStrings["ConStr"].ToString();
                    ADO_Core AdoC      = new ADO_Core(conStr);
                    string   stringCmd = string.Format("Exec sp_SiguienteInteraccion {0}, {1}", id, IdInteraccion);

                    string        Mensaje = string.Empty;
                    SqlDataReader dr      = AdoC.GetDataReader(stringCmd);
                    if (dr.HasRows)
                    {
                        dr.Read();
                        Mensaje = dr["mensaje"].ToString();
                    }
                    AdoC.Dispose();


                    ViewBag.SiguienteInteraccion = Mensaje;
                }
            }
            catch (Exception ex)
            {
            }

            return(View(interaccion));
        }
Esempio n. 7
0
        public string AddProgramacion_BIDA(int id, int MedioContacto, string FechaHora, string Descripcion)
        {
            try
            {
                ProgramacionBIDA programacionBIDA = new ProgramacionBIDA();

                DateTime f         = DateTime.Now;
                DateTime fechaHora = Convert.ToDateTime(FechaHora);

                programacionBIDA.ContactoId = id;
                programacionBIDA.SubCanalId = MedioContacto;
                programacionBIDA.FechaHora  = fechaHora;
                programacionBIDA.Acuerdo    = true;
                programacionBIDA.Realizada  = false;
                programacionBIDA.Comentario = Descripcion;

                db.ProgramacionBIDA.Add(programacionBIDA);
                db.SaveChanges();

                // lee el id del registro agregad

                var programacionId = db.ProgramacionBIDA.Max(w => w.ProgramacionId);


                // actualiza la interaccion en estatus 2
                //var resInte = db.Interacciones.Where(w => w.InteraccionId == interaccionID).FirstOrDefault();
                //resInte.EstatusBIDAId = 2;
                //db.SaveChanges();


                // ejecuta el store procedure para la siguiente interaccion
                string mensaje = string.Empty;

                string   conStr = WebConfigurationManager.ConnectionStrings["ConStr"].ToString();
                ADO_Core adoC   = new ADO_Core(conStr);

                string        cmd = String.Format("Exec sp_SiguienteInteraccion {0}, {1}", id, programacionId);
                SqlDataReader dr  = adoC.GetDataReader(cmd);

                if (dr.HasRows)
                {
                    dr.Read();
                    mensaje = dr["Mensaje"].ToString();
                }

                if (string.IsNullOrWhiteSpace(mensaje) || string.IsNullOrEmpty(mensaje))
                {
                    mensaje = "No se pudo calcular la siguietne interacción.";
                }

                adoC.Dispose();
                adoC = null;


                // Libera el contatactoId
                var resContacto = db.Contactos.Where(w => w.ContactoId == id).FirstOrDefault();
                resContacto.UsuarioHOST = null;
                db.SaveChanges();;

                return(mensaje);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return("Bad");
            }
        }