Example #1
0
        public static void fnGrabarErrorEbayArticulo(string articulo, string error)
        {
            MyEntityModel.RepuestosDeMovilesDbContext dbContext = new MyEntityModel.RepuestosDeMovilesDbContext();
            EBAY_SEGUIMIENTO ebay_seguimiento = new EBAY_SEGUIMIENTO();

            try
            {
                ebay_seguimiento = dbContext.EBAY_SEGUIMIENTO.Where(w => w.ARTICULO == articulo).FirstOrDefault();
            }
            catch (Exception edb)
            {
                Console.WriteLine("Error en dbContext " + edb);
                return;
            }
            if (ebay_seguimiento == null)
            {
                return;
            }
            ebay_seguimiento.TextoError = error;
            try
            {
                dbContext.SaveChanges();
            }
            catch
            {
            }
        }
Example #2
0
        public static ItemType LeerArticuloEbay(String ArticuloID)
        {
            MyEntityModel.RepuestosDeMovilesDbContext dbContext = new MyEntityModel.RepuestosDeMovilesDbContext();
            EBAY_SEGUIMIENTO es = dbContext.EBAY_SEGUIMIENTO.Where(w => w.ARTICULO == ArticuloID).FirstOrDefault();

            if (es != null)
            {
                return(LeerArticuloEbay(ArticuloID, es.VENDEDOR));
            }
            return(null);
        }
Example #3
0
        public string LeerArticuloEbay(String ArticuloID, string cuenta, string articulo_mio, string codigo)
        {
            MyEntityModel.RepuestosDeMovilesDbContext dbContext    = new MyEntityModel.RepuestosDeMovilesDbContext();
            MyEntityModel.ApplicationDbContextSql     dbContextSql = new MyEntityModel.ApplicationDbContextSql();
            CredencialesEbay credencialeebay = new CredencialesEbay();

            credencialeebay.cuenta = cuenta;
            ItemType    Item;
            GetItemCall ap = new GetItemCall(credencialeebay.context);

            ap.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
            ap.IncludeItemSpecifics = true;

            try
            {
                Item = ap.GetItem(ArticuloID);
            }
            catch (ApiException oApiEx)
            {
                // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do
                Console.WriteLine("1 " + oApiEx.Message);
                return(oApiEx.Message);
            }
            catch (SdkException oSdkEx)
            {
                // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do
                Console.WriteLine("2 " + oSdkEx.Message);
                return(oSdkEx.Message);
            }
            catch (Exception oEx)
            {
                // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do
                Console.WriteLine("3 " + oEx.Message);
                return(oEx.Message);
            }
            EBAY_SEGUIMIENTO ebay_seguimiento = new EBAY_SEGUIMIENTO();

            try
            {
                ebay_seguimiento = dbContext.EBAY_SEGUIMIENTO.Where(w => w.ARTICULO == Item.ItemID).FirstOrDefault();
            }
            catch (Exception edb)
            {
                Console.WriteLine("Error en dbContext " + edb);
            }
            if (ebay_seguimiento != null)
            {
                ebay_seguimiento.Descripcion     = Item.Description;
                ebay_seguimiento.DISPONIBLES     = Item.Quantity - Item.SellingStatus.QuantitySold;
                ebay_seguimiento.ENVIO           = (decimal?)Item.ShippingDetails.ShippingServiceOptions[0].ShippingServiceCost.Value;
                ebay_seguimiento.IMAGEN_EBAY     = Item.PictureDetails.PictureURL[0];
                ebay_seguimiento.PRECIO          = (decimal?)Item.StartPrice.Value;
                ebay_seguimiento.SUBTITULO       = Item.SubTitle;
                ebay_seguimiento.TITULO          = Item.Title;
                ebay_seguimiento.VENDIDOS        = Item.SellingStatus.QuantitySold;
                ebay_seguimiento.VENDIDOS_SEMANA = Ventas(ebay_seguimiento.ARTICULO_MIO, ebay_seguimiento.VENDEDOR, 7);
                ebay_seguimiento.VENDIDOS_MES    = Ventas(ebay_seguimiento.ARTICULO_MIO, ebay_seguimiento.VENDEDOR, 30);
                ebay_seguimiento.FECHA           = DateTime.Now;
                ebay_seguimiento.PictureURL      = string.Join("\t", Item.PictureDetails.PictureURL.ToArray());
                dbContext.SaveChanges();
                return("");
            }
            else
            {
                ebay_seguimiento                 = new EBAY_SEGUIMIENTO();
                ebay_seguimiento.VENDEDOR        = Item.Seller.UserID;
                ebay_seguimiento.ARTICULO        = Item.ItemID;
                ebay_seguimiento.CODIGO          = codigo;
                ebay_seguimiento.TITULO          = Item.Title;
                ebay_seguimiento.SUBTITULO       = Item.SubTitle;
                ebay_seguimiento.Descripcion     = Item.Description;
                ebay_seguimiento.DISPONIBLES     = Item.Quantity - Item.SellingStatus.QuantitySold;
                ebay_seguimiento.ENVIO           = (decimal?)Item.ShippingDetails.ShippingServiceOptions[0].ShippingServiceCost.Value;
                ebay_seguimiento.IMAGEN_EBAY     = Item.PictureDetails.PictureURL[0];
                ebay_seguimiento.PRECIO          = (decimal?)Item.StartPrice.Value;
                ebay_seguimiento.VENDIDOS        = Item.SellingStatus.QuantitySold;
                ebay_seguimiento.VENDIDOS_SEMANA = Ventas(ebay_seguimiento.ARTICULO_MIO, ebay_seguimiento.VENDEDOR, 7);
                ebay_seguimiento.VENDIDOS_MES    = Ventas(ebay_seguimiento.ARTICULO_MIO, ebay_seguimiento.VENDEDOR, 30);
                ebay_seguimiento.FECHA           = DateTime.Now;
                ebay_seguimiento.PictureURL      = string.Join("\t", Item.PictureDetails.PictureURL);
                dbContext.EBAY_SEGUIMIENTO.Add(ebay_seguimiento);
                dbContext.SaveChanges();
            }
            return("");
        }
Example #4
0
        public static ItemType LeerArticuloEbay(String ArticuloID, string cuenta)
        {
            new Thread(delegate() {
                fnNotificacion(" Leyendo " + ArticuloID);
            }).Start();

            MyEntityModel.RepuestosDeMovilesDbContext dbContext    = new MyEntityModel.RepuestosDeMovilesDbContext();
            MyEntityModel.ApplicationDbContextSql     dbContextSql = new MyEntityModel.ApplicationDbContextSql();
            CredencialesEbay credencialeebay = new CredencialesEbay();

            credencialeebay.cuenta = cuenta;
            ItemType    Item;
            GetItemCall ap = new GetItemCall(credencialeebay.context);

            ap.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
            ap.IncludeItemSpecifics = true;

            try
            {
                Notificacion(ArticuloID, 1);
                Item = ap.GetItem(ArticuloID);
            }
            catch (ApiException oApiEx)
            {
                // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do
                Debug.WriteLine("1 " + oApiEx.Message);
                fnGrabarErrorEbayArticulo(ArticuloID, oApiEx.Message);
                return(null);
            }
            catch (SdkException oSdkEx)
            {
                // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do
                Debug.WriteLine("2 " + oSdkEx.Message);
                fnGrabarErrorEbayArticulo(ArticuloID, oSdkEx.Message);
                return(null);
            }
            catch (Exception oEx)
            {
                // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do
                Debug.WriteLine("3 " + oEx.Message);
                fnGrabarErrorEbayArticulo(ArticuloID, oEx.Message);
                return(null);
            }
            EBAY_SEGUIMIENTO ebay_seguimiento = new EBAY_SEGUIMIENTO();

            try
            {
                ebay_seguimiento = dbContext.EBAY_SEGUIMIENTO.Where(w => w.ARTICULO == Item.ItemID).FirstOrDefault();
            }
            catch (Exception edb)
            {
                Debug.WriteLine("Error en dbContext " + edb);
            }
            if (ebay_seguimiento != null)
            {
                Debug.WriteLine("Articulo " + ArticuloID + " Leido");
                fnCopiarArticuloEbaySeguimiento(Item, ebay_seguimiento);
                try
                {
                    dbContext.SaveChanges();
                    Debug.WriteLine("Articulo " + ArticuloID + " Grabado");
                }
                catch
                {
                    Debug.WriteLine("Articulo " + ArticuloID + " ****** ERROR AL GRABAR ******");
                }
            }
            return(Item);
        }
Example #5
0
        private void leer()
        {
            MyEntityModel.ApplicationDbContextSql     dbContext          = new MyEntityModel.ApplicationDbContextSql();
            MyEntityModel.RepuestosDeMovilesDbContext dbcontextRepuestos = new MyEntityModel.RepuestosDeMovilesDbContext();

            TextFieldParser parser = new TextFieldParser(buttonEditFichero.Text, Encoding.Default);

            parser.HasFieldsEnclosedInQuotes = true;
            parser.SetDelimiters(",");
            string   articuloID = "";
            string   sprecio    = "";
            string   concepto;
            decimal  comision;
            DateTime fecha;
            decimal  precio;
            string   sfecha, nombreCategoriaRaiz, nombre;
            long     categoria;


            string[] fields;

            while (!parser.EndOfData)
            {
                fields = parser.ReadFields();
                if (fields.Count() == 8)        // linea
                {
                    precio = 0;

                    var values = fields[1].Split(';');
                    if (values.Count() == 2)     // Linea de venta
                    {
                        simpleButtonImportar.Text = articuloID;
                        Application.DoEvents();
                        articuloID = nombreCategoriaRaiz = "";
                        categoria  = 0;
                        nombre     = fields[1];
                        var values2 = values[1].Split(' ');
                        sprecio    = values2[3];
                        precio     = MyEntityModel.FuncionesEbay.fnSpreciodprecio(sprecio);
                        concepto   = fields[3];
                        comision   = MyEntityModel.FuncionesEbay.fnSpreciodprecio(fields[4].Split(' ')[0]);
                        articuloID = fields[2];
                        sfecha     = fields[0].Replace("PDT", "");
                        DateTime.TryParseExact(sfecha.Trim(), "dd-MMM-yy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out fecha);

                        MyEntityModel.EBAY_SEGUIMIENTO ebay_seguimiento = ebay_seguimiento_lista.Where(w => w.ARTICULO == articuloID).FirstOrDefault();
                        if (ebay_seguimiento == null)
                        {
                            ebay_seguimiento = dbcontextRepuestos.EBAY_SEGUIMIENTO.Where(w => w.ARTICULO == articuloID).FirstOrDefault();
                            if (ebay_seguimiento != null)
                            {
                                ebay_seguimiento_lista.Add(ebay_seguimiento);
                            }
                        }

                        if (ebay_seguimiento != null)
                        {
                            categoria = Convert.ToInt64(ebay_seguimiento.PrimaryCategoryID);
                            Categorias categoria_lista = categorias_lista.Where(w => w.categoriaID == categoria).FirstOrDefault();
                            if (categoria_lista == null)
                            {
                                nombreCategoriaRaiz = MyEntityModel.FuncionesEbay.fnNombreCategoriaRaiz(categoria);
                                categorias_lista.Add(new Categorias {
                                    categoriaID = categoria, NombreRaiz = nombreCategoriaRaiz
                                });
                            }
                            else
                            {
                                nombreCategoriaRaiz = categoria_lista.NombreRaiz;
                            }
                        }

                        MyEntityModel.ComisionesEbay comisionesEbay = new MyEntityModel.ComisionesEbay();
                        try
                        {
                            comisionesEbay.Articulo            = articuloID;
                            comisionesEbay.Categoria           = categoria;
                            comisionesEbay.Comision            = comision;
                            comisionesEbay.Cuenta              = "ofertasparati";
                            comisionesEbay.Fecha               = fecha;
                            comisionesEbay.Nombre              = nombre;
                            comisionesEbay.NombreCategoriaRaiz = nombreCategoriaRaiz;
                            comisionesEbay.Precio              = precio;
                            if (precio != 0)
                            {
                                comisionesEbay.Porcentaje = decimal.Multiply(100, comision);
                                comisionesEbay.Porcentaje = decimal.Divide(comisionesEbay.Porcentaje, precio);
                                dbContext.comisionesEbay.Add(comisionesEbay);
                                dbContext.SaveChanges();
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }

            parser.Close();

            return;
        }