Exemplo n.º 1
0
        public void DeleteTablesThenPopulate()
        {
            DataClasses1DataContext context = new DataClasses1DataContext();

            List<tblItem> items= (from i in context.tblItems select i).ToList<tblItem>();
            List<tblCategory> categories = (from i in context.tblCategories select i).ToList<tblCategory>();

            try
            {
                context.tblCategories.DeleteAllOnSubmit(categories);
                context.tblItems.DeleteAllOnSubmit(items);
                context.SubmitChanges();
            }
            catch (Exception e)
            {
                string er = e.ToString();
            }

            this.EbayTopLevelCategories();
            List<string> cats = this.GetCategories();
            for (int i = 0; i <= 30; i++)
            {
                this.FindByCategory(new string[] { cats[i] });
            }
        }
Exemplo n.º 2
0
        public List<tblItem> FindByKeyWord(String items)
        {
            List<tblItem> prodlist = new List<tblItem> { };
            FindItemsAdvancedRequest request = new FindItemsAdvancedRequest();
            //request.affiliate.trackingId = null;
            //request.affiliate.networkId = "9";
            // Set request parameters
            request.keywords = items;
            ItemFilter filter1 = new ItemFilter();
            ItemFilter filter2 = new ItemFilter();
            ItemFilter filter3 = new ItemFilter();
            filter3.name = ItemFilterType.Condition;
            filter3.value = new string[] { "1000" };

            ItemFilter[] filters = { filter3/*, filter2, filter3*/ };

            request.itemFilter = filters;
            //request.categoryId = items;
            if (request.keywords == null)
            {
                request.keywords = "ipod";
            }
            PaginationInput pi = new PaginationInput();
            pi.entriesPerPage = 100;
            pi.entriesPerPageSpecified = true;
            request.paginationInput = pi;

            // Call the service
            FindItemsAdvancedResponse response = m_client.findItemsAdvanced(request);

            SearchItem[] listing = response.searchResult.item;

            if (listing != null)
            {

                foreach (SearchItem i in listing)
                {
                    tblItem items_tbl = new tblItem();
                    items_tbl.item_category = i.primaryCategory.categoryId;
                    items_tbl.item_title = i.title;
                    items_tbl.item_id = i.itemId;
                    items_tbl.gallery_url = i.galleryURL;
                    items_tbl.listing_url = i.viewItemURL;

                    prodlist.Add(items_tbl);
                    try
                    {
                        DataClasses1DataContext context = new DataClasses1DataContext();
                        context.tblItems.InsertOnSubmit(items_tbl);
                        context.SubmitChanges();
                    }
                    catch (Exception e)
                    {
                        string s = e.Message;
                    }

                }

                return prodlist;
            }

            return prodlist;
        }
Exemplo n.º 3
0
        //get categories from item table
        //count number of occurances for each
        //insert into table vaules category - category count
        //return ordered list in decending order
        public void SetCategoryCount()
        {
            DataClasses1DataContext context = new DataClasses1DataContext();
            var result = from i in context.tblItems select i.item_category;
            var d = result.Distinct();
            List<string> dlist = d.ToList<string>();
            foreach (string s in d)
            {
                //update
                var query= from update in context.cat_counts
                           where update.category_id==s
                           select update;
                m_log.Add(query.ToString());
                var cnt = context.tblItems.Count(p => p.item_category == s);
                foreach(cat_count up in query)
                {
                    dlist.Remove(up.category_id);
                    up.category_count = cnt;
                }//update

                try
                {

                    context.SubmitChanges();
                    m_log.Add(context.Log.ToString());
                }
                catch (Exception e)
                {
                    string er = e.Message;
                }
            }
            foreach (string s in dlist)
            {

                var cnt = context.tblItems.Count(p => p.item_category == s);
                cat_count catcnt = new cat_count();

                catcnt.category_id = s;
                catcnt.category_count = cnt;

                try
                {
                    context.cat_counts.InsertOnSubmit(catcnt);
                    context.SubmitChanges();
                    m_log.Add(context.Log.ToString());
                }
                catch (Exception e)
                {
                    string er = e.Message;
                }
            }
        }
Exemplo n.º 4
0
        public void EbayTopLevelCategories()
        {
            GetCategoriesCall Categories = new GetCategoriesCall(m_api);
            Categories.LevelLimit = 2;
            Categories.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);

            CategoryTypeCollection cats =Categories.GetCategories();

            foreach (CategoryType category in cats)
            {
                m_cats = new tblCategory();
                m_cats.category_id= category.CategoryID;
                m_cats.category_level = category.CategoryLevel.ToString();
                m_cats.category_name = category.CategoryName;
                m_cats.category_parent = category.CategoryParentID[0].ToString();
                DataClasses1DataContext db = new DataClasses1DataContext();

                try
                {
                    DataClasses1DataContext context = new DataClasses1DataContext();
                  //  context.Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["EbayFactoryConnectionString"].ConnectionString;
                    context.tblCategories.InsertOnSubmit(m_cats);

                    context.SubmitChanges();
                }
                catch(Exception e)
                {
                    string er = e.Message;
                }

            }
        }