Exemplo n.º 1
0
        public bool Is_Exist_Local(DataLoad data)
        {
            bool result = true;
            Logs log    = new Logs();

            try
            {
                Query local = new Query();
                if (!local.Check_Exits_Product(data.Sku, data.CategoryId))
                {
                    Product product    = local.Insert_Product(data);
                    long    product_id = product.Id;
                    local.Insert_Product_Category(product.Id, data.CategoryId);
                    Pinterest pinterest = local.Insert_Pinterest(product_id, data);
                    local.Insert_Product_Link_Pinterest(product_id, pinterest.Id);
                    data.TypeName = local.Get_Product_Type_By_Id(data.Type).Name;
                    result        = false;
                }
            }
            catch (Exception ex)
            {
                log.IErrors("Logic - Is_Exist_Local: " + ex.Message);
            }
            return(result);
        }
Exemplo n.º 2
0
        public Product Insert_Product(DataLoad data)
        {
            MoneyDataContext db   = new MoneyDataContext();
            Product          prod = new Product
            {
                Sku           = data.Sku,
                Group_Id      = data.GroupId,
                Name          = data.Title,
                Description   = data.Description,
                Url_Source    = data.Url,
                Url_Name      = data.UrlName,
                ProductTypeId = data.Type,
                Image         = data.Image,
                Price         = data.Price,
                Keywords      = data.Keywords,
                CreatedDate   = DateTime.Now,
                Source_Id     = 1
            };

            try
            {
                db.Products.InsertOnSubmit(prod);
                db.SubmitChanges();
            }
            catch (Exception ex) { }
            return(prod);
        }
Exemplo n.º 3
0
        // Insert Pinterest

        public Pinterest Insert_Pinterest(long product_id, DataLoad data)
        {
            MoneyDataContext db   = new MoneyDataContext();
            Pinterest        prod = new Pinterest
            {
                Board        = data.Tag,
                Backlink     = data.UrlName,
                Note         = data.Description,
                Image_Url    = data.Image,
                Type         = 1,
                Is_Pin       = 0,
                Created_Date = DateTime.Now
            };

            try
            {
                db.Pinterests.InsertOnSubmit(prod);
                db.SubmitChanges();
            }
            catch (Exception ex) { }
            return(prod);
        }
Exemplo n.º 4
0
        public int execute(DataLoad data)
        {
            int  status = 0;
            Logs log    = new Logs();

            try
            {
                if (!Is_Exist_Local(data))
                {
                    status = 1;
                }
                else
                {
                    log.ILogs("Exist: " + data.Sku);
                    status = 2;
                }
            }
            catch (Exception ex)
            {
                log.IErrors("Logic - Execute: " + ex.Message);
            }
            return(status);
        }
Exemplo n.º 5
0
        public DataLoad GetHtml(string url_sun)
        {
            DataLoad data = new DataLoad();

            try
            {
                string       html = GetAjaxData(url_sun);
                HtmlDocument doc  = new HtmlDocument();
                doc.LoadHtml(html);
                var titleTag = doc.DocumentNode.SelectSingleNode("//title").InnerText;
                data.Title = titleTag;
                data.Url   = url_sun;
                var meta = doc.DocumentNode.SelectNodes("//meta");
                foreach (var node in meta)
                {
                    //Description
                    if (node.GetAttributeValue("name", String.Empty) == "Description")
                    {
                        data.Description = node.GetAttributeValue("content", String.Empty) + " | Best T-Shirts USA are very happy to make you beutiful - Shirts as unique as you are.";
                    }
                    //Keyword
                    if (node.GetAttributeValue("name", String.Empty) == "Keywords")
                    {
                        data.Keywords = node.GetAttributeValue("content", String.Empty);
                    }
                }
                //Group ID
                var groupNote = doc.DocumentNode.SelectSingleNode("//input[@name='MockupGroup']");
                data.GroupId = groupNote.Attributes["value"].Value;

                //SKU
                var skuNote = doc.DocumentNode.SelectSingleNode("//input[@name='mockupID']");
                data.Sku = skuNote.Attributes["value"].Value;

                //Cate
                var catNote = doc.DocumentNode.SelectSingleNode("//input[@name='catName']");
                data.CategoryName = catNote.Attributes["value"].Value;

                //Cate
                var imgNote = doc.DocumentNode.SelectSingleNode("//img[@id='MainImgShow']");
                data.Image = imgNote.Attributes["src"].Value;

                //Url name
                data.UrlName = ToUrlSlug(titleTag).ToLower();

                //Price
                var priceNote = doc.DocumentNode.SelectNodes("//select[@id='shirtTypes']//option");

                string optionNote = "";
                foreach (HtmlNode node in priceNote)
                {
                    optionNote = node.NextSibling.InnerHtml;
                    break;
                }
                var text_option = optionNote.Split('$');
                data.Price = decimal.Parse(text_option[1]);
                //string type_array = text_option[0].Split(' ')[0];
            }
            catch (Exception ex)
            {
            }
            return(data);
        }