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"); } }
public string AddProgramacionBIDA(int ContactoId, int MedioContacto, string FechaHora, string Descripcion, int interaccionID) { try { ProgramacionBIDA programacionBIDA = new ProgramacionBIDA(); DateTime f = DateTime.Now; DateTime fechaHora = Convert.ToDateTime(FechaHora); programacionBIDA.ContactoId = ContactoId; programacionBIDA.SubCanalId = MedioContacto; programacionBIDA.FechaHora = fechaHora; programacionBIDA.Acuerdo = true; programacionBIDA.Realizada = false; programacionBIDA.Comentario = Descripcion; db.ProgramacionBIDA.Add(programacionBIDA); db.SaveChanges(); // CIERRA ACUERDO //var result = db.Interacciones.Where(w => w.InteraccionId == interaccionID).FirstOrDefault(); //result.WhatsAppCerrado = true; //db.SaveChanges(); //// ejecuta el store procedure para la siguiente interaccion //string mensaje = ""; //string conStr = WebConfigurationManager.ConnectionStrings["ConStr"].ToString(); //ADO_Core adoC = new ADO_Core(conStr); //SqlDataReader dr = adoC.GetDataReader("Exec sp_SiguienteInteraccion " + ContactoId.ToString()); //if (dr.HasRows) //{ // dr.Read(); // mensaje = dr["Mensaje"].ToString(); //} //if (mensaje == "") // mensaje = "No se pudo calcular la siguietne interacción."; //adoC.Dispose(); //adoC = null; return("Ok"); } catch (Exception ex) { Console.WriteLine(ex.Message); return("Bad"); } }
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"); } }