Esempio n. 1
0
        public void CreaPrecioAlbacete(string code, string min, string max, string medida, string fecha, int semana, DateTime date)
        {
            string[] datos = fecha.Split('-');
            Precio   Pmin  = new Precio();

            Pmin.codigo     = code;
            Pmin.precio     = double.Parse(min);
            Pmin.dia        = System.Convert.ToInt16(datos[0]);
            Pmin.semana     = semana;
            Pmin.numMes     = System.Convert.ToInt16(datos[1]);
            Pmin.nomMes     = ConvierteMesInv(datos[1]);
            Pmin.año        = System.Convert.ToInt16(datos[2]);
            Pmin.fecha      = fecha;
            Pmin.tipoPrecio = "min";
            Pmin.fuente     = "Albacete";
            Pmin.medida     = medida;
            Precio Pmax = new Precio();

            Pmax.codigo     = code;
            Pmax.precio     = double.Parse(max);
            Pmax.dia        = System.Convert.ToInt16(datos[0]);
            Pmax.semana     = semana;
            Pmax.numMes     = System.Convert.ToInt16(datos[1]);
            Pmax.nomMes     = ConvierteMesInv(datos[1]);
            Pmax.año        = System.Convert.ToInt16(datos[2]);
            Pmax.fecha      = fecha;
            Pmax.tipoPrecio = "max";
            Pmax.fuente     = "Albacete";
            Pmax.medida     = medida;
            GuardaPrecioAlbacete(Pmin, date);
            GuardaPrecioAlbacete(Pmax, date);
        }
Esempio n. 2
0
        public void GuardaPrecioVac(Precio p, DateTime date)
        {
            DateTime dateP = new DateTime(p.año, p.numMes, p.dia);

            if (dateP > date)
            {
                elasticClient.Index(p, es => es
                                    .Index("agroesi")
                                    .Type("precio")
                                    );
            }
        }
Esempio n. 3
0
        public void PreciosVac(string[] partes, string code, string file)
        {
            DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
            Calendar           cal = dfi.Calendar;

            string[] partes_nombre = file.Split('\\');
            string[] nombre        = partes_nombre[1].Split('.')[0].Split('_');

            int    año     = System.Convert.ToInt16(nombre[2]);
            int    num_mes = System.Convert.ToInt16(ConvierteMes(nombre[1]));
            string nom_mes = nombre[1];
            int    dia     = System.Convert.ToInt16(nombre[0]);
            int    semana  = 0;
            string fecha   = null;

            if (dia < 10)
            {
                fecha = "0" + dia + "-" + CompruebaMes(num_mes) + "-" + año;
            }
            else
            {
                fecha = dia + "-" + CompruebaMes(num_mes) + "-" + año;
            }

            DateTime date = new DateTime(año, num_mes, dia);

            semana = System.Convert.ToInt16(cal.GetWeekOfYear(date, dfi.CalendarWeekRule, dfi.FirstDayOfWeek).ToString());

            string medida      = "Euros/kg";
            string tipo_precio = "med";
            Precio p           = new Precio();

            p.codigo     = code;
            p.precio     = double.Parse(partes[7]);
            p.dia        = dia;
            p.semana     = semana;
            p.numMes     = num_mes;
            p.nomMes     = nom_mes;
            p.año        = año;
            p.fecha      = fecha;
            p.tipoPrecio = tipo_precio;
            p.fuente     = "Talavera";
            p.medida     = medida;
            GuardaPrecioVac(p, ultimoTal());
        }