Example #1
0
        private string hallarTiempo()
        {
            tolls t = tolls.T;
            int   i = Lot.Exc.leerExcel().Count / 1000;

            return(i.ToString());
        }
Example #2
0
        private List <Lote> crearLote(SqlDataReader dr)
        {
            List <Lote> lot = new List <Lote>();
            tolls       t   = tolls.T;
            Marcador    m;
            string      nombre;
            DateTime    creacion;

            Lote.tipoLote    tipoLot;
            Lote.tipoRecurso tipoUni;
            Lote.tipoEstado  estadoLot;
            bool             eliminado;
            Lote             l;

            while (dr.Read())
            {
                m      = t.hallarMarcador(dr["nombreMarc"].ToString());
                nombre = dr["nombre"].ToString();
                DateTime.TryParse(dr["creacion"].ToString(), out creacion);
                tipoLot   = t.tipoLote(dr["tipoLote"].ToString());
                tipoUni   = t.tipoUnidadLote(dr["tipoUnidad"].ToString());
                estadoLot = t.estadoLote(dr["estadoLote"].ToString());
                eliminado = t.elLoteEstaEliminado(estadoLot);
                l         = new Lote(nombre, creacion, estadoLot, tipoLot, eliminado);
                l.Marc    = m;
                lot.Add(l);
            }
            return(lot);
        }
Example #3
0
        public List <Marcador> cargarMarcadores()
        {
            tolls           t    = tolls.T;
            Sistema         s    = Sistema.Sis;
            List <Marcador> marc = new List <Marcador>();

            s.accionoBaseDatos("Se buscan todos los marcadores");
            SqlConnection cn = Coneccion.CrearConeccionSql
                                   (CadenaDeConecciones.tiposDeConeccion.paraDominio);
            SqlCommand cmd = new SqlCommand(Query_s.todoMarcadores, cn);

            Marcador.tipoMarcador tipo;
            try
            {
                Coneccion.AbrirConeccion(cn);
                s.accionoBaseDatos("Se ejecuta la query: " + cmd.CommandText);
                SqlDataReader datos = cmd.ExecuteReader();
                while (datos.Read())
                {
                    tipo = t.tipoMarcador(datos["tipoMarcador"].ToString());
                    marc.Add(new Marcador(datos["nombre"].ToString(), tipo));
                }
                s.accionoBaseDatos("Buscar marcadores", "OK");
            }
            catch (SqlException e)
            {
                s.accionoBaseDatos("Buscar marcadores", "Error: " + e.Message);
            }
            finally
            {
                Coneccion.CerrarConeccion(cn);
            }
            return(marc);
        }
Example #4
0
        public List <Lote> cargaLotesUnaSemana()
        {
            Sistema s = Sistema.Sis;
            tolls   t = tolls.T;

            s.accionoBaseDatos("Se ejecuta cargar lotes una semana");
            List <Lote>   lot = new List <Lote>();
            SqlConnection cn  = Coneccion.CrearConeccionSql
                                    (CadenaDeConecciones.tiposDeConeccion.paraDominio);
            SqlCommand cmd = new SqlCommand(Query_s.cargarLotes1Semana, cn);

            try
            {
                Coneccion.AbrirConeccion(cn);
                cmd.Parameters.Add(new SqlParameter("@fecha", DateTime.Today.AddDays(-8)));
                cmd.Parameters.Add(new SqlParameter("@estado", Lote.tipoEstado.ParaCargar.ToString()));
                s.accionoBaseDatos("Se ejecuta la query: " + cmd.CommandText);
                SqlDataReader datos = cmd.ExecuteReader();
                lot = crearLote(datos);
                s.accionoBaseDatos("Lote una semana", "OK");
            }
            catch (SqlException e)
            {
                s.accionoBaseDatos("Lotes una semana", "Error: " + e.Message);
            }
            finally
            {
                Coneccion.CerrarConeccion(cn);
            }
            return(lot);
        }
Example #5
0
        public Lote buscarLote(string pNombre)
        {
            tolls   t   = tolls.T;
            Sistema s   = Sistema.Sis;
            Lote    lot = null;

            s.accionoBaseDatos("Busqueda de lote con el nombre: " + pNombre);
            SqlConnection cn = Coneccion.CrearConeccionSql
                                   (CadenaDeConecciones.tiposDeConeccion.paraDominio);
            SqlCommand cmd = new SqlCommand(Query_s.buscarLote, cn);

            try
            {
                Coneccion.AbrirConeccion(cn);
                cmd.Parameters.Add(new SqlParameter("@pNombre", pNombre));
                s.accionoBaseDatos("Se ejecuto la query:" + cmd.CommandText);
                s.accionoBaseDatos("@pNombre paso a valer:" + pNombre);
                SqlDataReader datos = cmd.ExecuteReader();
                lot = crearLote(datos).ElementAt(0);
                s.accionoBaseDatos("Buscar Lote", "OK");
            }
            catch (SqlException e)
            {
                s.accionoBaseDatos("Buscar Lote", "Error: " + e.Message);
            }
            finally
            {
                Coneccion.CerrarConeccion(cn);
            }
            return(lot);
        }
Example #6
0
        private Sistema()
        {
            tolls t = tolls.T;

            Lotes      = new List <Lote>();
            Frec       = new List <Frecuencia>();
            Marcadores = new List <Marcador>();
            m_app      = new App();
            precarga();
        }
Example #7
0
        /**
         * @fn  public void iniciarSubida()
         *
         * @brief   Es el metodo que toma todos los lotes
         *          que ahi en el sistema para cargar.
         *
         * @author  WINMACROS
         * @date    17/07/2017
         */

        public void iniciarSubida()
        {
            m_app = new App();
            tolls t = tolls.T;

            List <Lote>     lotesParaCargar = t.lotesPara(Lote.tipoEstado.ParaCargar);
            List <Marcador> campanasDistintasParaEliminar = t.campanasParaEliminarDistintas(lotesParaCargar);
            List <Marcador> campanasDistintas             = t.campanasDistintaslotes(lotesParaCargar);

            iniciarSubidaAux(campanasDistintas, campanasDistintasParaEliminar, lotesParaCargar);
        }
Example #8
0
        /**
         * @fn  public void cargarContacto(string pContacto)
         *
         * @brief   Incerta una liea en el excel.
         *
         * @author  WINMACROS
         * @date    14/07/2017
         *
         * @param   pContacto   Linea separada por ; cada campo para insertar en
         *                      el excel.
         */

        public void cargarContacto(string pContacto)
        {
            tolls t = tolls.T;

            t.matarProceso("EXCEL");
            StreamWriter sR = new StreamWriter(Direccion.ToString(), true);

            if (pContacto.Split(';').Count() == 30) // si tiene mas o menos que 30 seldas esta mal la linea
            {
                sR.WriteLine(pContacto);
            }
            sR.Close();
        }
Example #9
0
        /**
         * @fn  public void hacerScore()
         *
         * @brief   Lee linea por linea y si donde va la id no dice id
         *          llama a un metodo auxiliar el cual calcula el scor
         *          y lo inserta en la abse.
         *
         * @author  WINMACROS
         * @date    14/07/2017
         */

        public void hacerScore()
        {
            String dir = Direccion.ToString();

            string[] aux;
            tolls    t = tolls.T;

            foreach (var aux2 in File.ReadLines(dir))
            {
                aux = aux2.Split(';');
                if (aux.ElementAt(0) != "id")
                {
                    t.poblarScore(aux);
                }
            }
        }
Example #10
0
        /**
         * @fn  public resultAgregarLote agregarLote(Lote pLote)
         *
         * @brief   Validador al momento de agregar un lote al sistema.
         *
         * @author  WINMACROS
         * @date    17/07/2017
         *
         * @param   pLote   Lote a validar.
         *
         * @return  Resultado de validacion.
         */

        public resultAgregarLote agregarLote(Lote pLote)
        {
            tolls             t   = tolls.T;
            resultAgregarLote ret = resultAgregarLote.agrego;

            Lote.tipoLote tipoLoteXNom = t.tipoLoteXNombreArchivo(pLote.Exc.Direccion);
            bool          excel        = pLote.Exc.validarExcel();

            if (!excel)
            {
                ret = resultAgregarLote.excelDeficiente;
            }
            else if (pLote.Exc.Direccion.Extencion != ".csv")
            {
                ret = resultAgregarLote.errorEnExtencion;
            }
            else if (tipoLoteXNom == Lote.tipoLote.errorCampana)
            {
                ret = resultAgregarLote.nombreMalEscrito;
            }
            else if (tipoLoteXNom != pLote.LoteTipo)
            {
                ret = resultAgregarLote.nombreDistintoCampana;
            }
            else if (pLote.Nombre.Length > 32)
            {
                ret = resultAgregarLote.nombreLargo;
            }
            else if (!pLote.asignarMarcador())
            {
                ret = resultAgregarLote.noExisteCampanaSistema;
            }
            else if (existeLote(pLote))
            {
                ret = resultAgregarLote.elLoteYaExiste;
            }
            else
            {
                Lotes.Add(pLote);
            }
            accionesCodigo("Se intenta cargar el lote:" + pLote.ToString() + " Al sistema. ", ret.ToString());
            return(ret);
        }
Example #11
0
        /**
         * @fn  public void cargarScore()
         *
         * @brief   Funcion utilizada para insertarle el score a un lote
         *          antes de ser cargado a inconsert.
         *
         * @author  WINMACROS
         * @date    14/07/2017
         */

        public void cargarScore()
        {
            tolls t = tolls.T;

            t.matarProceso("EXCEL");
            string          nuevaUrl = @"\\CGMSERVER\Archivos\DOCUMENTOS C+G\CGM & ASOC\AREA ESTRATEGIA Y COBRANZAS\Allyson\Cargas inConcert\Automaticos\lotesConScore\";
            StreamWriter    file     = new StreamWriter(nuevaUrl + Exc.Direccion.Nombre + Exc.Direccion.Extencion, false);
            List <string[]> excel    = Exc.leerExcel();

            if (excel.ElementAt(0)[8] == "Score")
            {
                baseDatos bd       = baseDatos.Bd;
                int       cantCamp = 0;
                int       id       = 0;
                OrdenarBigFish(excel);
                foreach (string[] f in excel)
                {
                    cantCamp = f.Count();
                    int.TryParse(f[0].Substring(3), out id);
                    for (int i = 0; i < cantCamp; i++)
                    {
                        if (i == 8 && id != 0)
                        {
                            file.Write(bd.buscarScore(id) + ";");
                        }
                        else
                        {
                            file.Write(f[i] + ";");
                        }
                    }

                    file.WriteLine("");
                }
                file.Close();

                Exc = new Excel {
                    Direccion = new URL(Exc.Direccion.Nombre + Exc.Direccion.Extencion, nuevaUrl)
                };
            }
        }
Example #12
0
        /**
         * @fn  public static void cargarLoteAMotor()
         *
         * @brief   Carga los lotes que hay en sistema
         *          y los que son del motor se los asigna
         *          a la lista loter para cargar.
         *
         * @author  WINMACROS
         * @date    17/07/2017
         */

        public static void cargarLoteAMotor()
        {
            Sistema s = Sistema.Sis;
            tolls   t = tolls.T;

            s.accionesCodigo("Carga de lotes a los motores");
            List <Lote> lot       = t.lotesPara(Lote.tipoEstado.ParaCargar);
            DateTime    loteDesde = DateTime.Today;

            foreach (Marcador m in t.campanasDistintaslotes(lot))
            {
                s.accionesCodigo("Para la campaña: " + m.Nombre + " Estan los lotes: ");
                m.LotesParaCargar = new List <LoteMarcador>();//cuidadod aca reseteo lista cada ves que cargo nuevos lotes por si las deudas
                foreach (Lote l in lot)
                {
                    if (l.Marc.Equals(m))
                    {
                        s.accionesCodigo(l.ToString());
                        LoteMarcador lotMarc = new LoteMarcador(l, loteDesde, LoteMarcador.fechaHastaLote(loteDesde, l));
                        m.LotesParaCargar.Add(lotMarc);
                    }
                }
            }
        }
Example #13
0
        private void iniciarSubidaAux(List <Marcador> pCampanasDisitntas, List <Marcador> pCampanasParaEliminar, List <Lote> pLotesParaCargar)
        {
            accionesCodigo("Iniciar subida");
            accionesCodigo("------------------");
            accionesCodigo("------------------");
            accionesCodigo("------------------");

            /* try {
             *   foreach (Lote lo in pLotesParaCargar)
             *       lo.cargarScore();
             * }
             * catch (Exception) { }*/

            tolls     t  = tolls.T;
            baseDatos bd = baseDatos.Bd;

            Marcador.cargarLoteAMotor();

            foreach (Marcador m in pCampanasDisitntas)
            {
                m.asignarFrec();//Asigna las frecuencias separando todos los lotes por campaña que existan
            }
            foreach (Lote l in pLotesParaCargar)
            {
                bd.agregarLote(l);//Agrega el lote a la base de datos
            }
            iniciarYLogear(Sistema.navegadores.fx.ToString());

            foreach (Marcador m in pCampanasParaEliminar)
            {
                m.eliminarLotes();
            }

            List <Lote> lotesParaEliminar = t.lotesPara(Lote.tipoEstado.paraEliminar);

            foreach (Lote l in lotesParaEliminar)
            {
                l.eliminarImportacion(0);
            }

            m_app.iimClose();

            iniciarYLogear(Sistema.navegadores.silent.ToString());
            foreach (Lote l in pLotesParaCargar)
            {
                l.crearNuevaImportacion();
            }

            m_app.iimClose();

            iniciarYLogear(Sistema.navegadores.fx.ToString());
            foreach (Marcador m in pCampanasDisitntas)
            {
                m.cargarLotesAlMarcador();
            }

            m_app.iimClose();

            accionesCodigo("------------------");
            accionesCodigo("------------------");
            accionesCodigo("Finalizo la carga de los lotes solicitados");
            accionesCodigo("------------------");
            accionesCodigo("------------------");
        }