Ejemplo n.º 1
0
        public ActionResult FixEbayConditions()
        {
            var token = repository.GetOAuthToken(subdomainid.Value, OAuthTokenType.EBAY, true);

            var service = new CategoryService(token.token_key);

            var tobechecked = db.ebay_categories.Where(x => x.leaf && !x.ebay_conditions.Any());

            foreach (var category in tobechecked)
            {
                var call = service.GetCategoryFeatures(category.categoryid, category.siteid.ToEnum <SiteCodeType>());

                var features = call.CategoryList;

                CategoryFeatureType feature = features[0];

                if (features.Count > 1)
                {
                    return(Content("more feature: " + category.categoryid));
                }

                // if condition is available
                if (feature.ConditionEnabledSpecified && (feature.ConditionEnabled == ConditionEnabledCodeType.Enabled || feature.ConditionEnabled == ConditionEnabledCodeType.Required))
                {
                    //iterate through each condition node
                    foreach (ConditionType condition in feature.ConditionValues.Condition)
                    {
                        var con = new ebay_condition();
                        con.name  = condition.DisplayName;
                        con.value = condition.ID;
                        if (!category.ebay_conditions.Any(x => x.name == con.name && x.value == con.value && x.ebayrowid == category.id))
                        {
                            category.ebay_conditions.Add(con);
                            db.SubmitChanges();
                        }
                    }
                }
            }

            return(Content("done"));
        }
Ejemplo n.º 2
0
        public ActionResult TestEbayCategories()
        {
            var token = repository.GetOAuthToken(subdomainid.Value, OAuthTokenType.EBAY, true);

            var service = new CategoryService(token.token_key);

            foreach (var category in db.ebay_categories.AsQueryable().Where(x => x.leaf))
            {
                if (category.done.HasValue && category.done.Value)
                {
                    continue;
                }
                var call = service.GetCategoryFeatures(category.categoryid, category.siteid.ToEnum <SiteCodeType>());

                var features = call.CategoryList;

                if (features.Count > 1)
                {
                    Syslog.Write(string.Format("{0} more than 1 features", category.categoryid));
                }

                // get listing duration
                foreach (ListingDurationReferenceType type in call.SiteDefaults.ListingDuration)
                {
                    foreach (ListingDurationDefinitionType def in call.FeatureDefinitions.ListingDurations.ListingDuration)
                    {
                        if (def.durationSetID == type.Value)
                        {
                            foreach (string entry in def.Duration)
                            {
                                var duration = new ebay_listingduration();
                                duration.listingtypeid = type.type.ToString();
                                duration.duration      = entry;
                                if (!category.ebay_listingdurations.Any(x => x.listingtypeid == duration.listingtypeid &&
                                                                        x.duration == duration.duration))
                                {
                                    category.ebay_listingdurations.Add(duration);
                                }
                            }
                        }
                    }
                }

                CategoryFeatureType feature = features[0];

                // if condition is available
                if (feature.ConditionEnabledSpecified && (feature.ConditionEnabled == ConditionEnabledCodeType.Enabled || feature.ConditionEnabled == ConditionEnabledCodeType.Required))
                {
                    //iterate through each condition node
                    foreach (ConditionType condition in feature.ConditionValues.Condition)
                    {
                        var con = new ebay_condition();
                        con.name  = condition.DisplayName;
                        con.value = condition.ID;
                        if (!category.ebay_conditions.Any(x => x.name == con.name && x.value == con.value && x.ebayrowid == category.id))
                        {
                            category.ebay_conditions.Add(con);
                            db.SubmitChanges();
                        }
                    }
                }

                if (feature.ReturnPolicyEnabled)
                {
                    category.requiresReturnPolicy = true;
                }
                else
                {
                    category.requiresReturnPolicy = false;
                }
                category.done = true;
                db.SubmitChanges();
            }

            return(Content("done"));
        }
Ejemplo n.º 3
0
        public ActionResult PopulateNewEbaySiteDetails(SiteCodeType site)
        {
            var token = repository.GetOAuthToken(subdomainid.Value, OAuthTokenType.EBAY, true);

            var service = new CategoryService(token.token_key);

            // get categories
            if (db.ebay_categories.Count(x => x.siteid == site.ToString()) == 0)
            {
                var collections = service.GetCategories(site);

                foreach (CategoryType category in collections)
                {
                    var entry = new ebay_category();
                    entry.siteid     = site.ToString();
                    entry.categoryid = int.Parse(category.CategoryID);
                    entry.level      = category.CategoryLevel;
                    entry.name       = category.CategoryName;
                    entry.parentid   = int.Parse(category.CategoryParentID[0]);
                    entry.leaf       = category.LeafCategory;

                    db.ebay_categories.InsertOnSubmit(entry);
                }

                repository.Save();
            }

            var resp = service.GetEbayDetails(site);

            // populate dispatch time
            if (db.ebay_dispatchtimes.Count(x => x.siteid == site.ToString()) == 0)
            {
                foreach (DispatchTimeMaxDetailsType entry in resp.DispatchTimeMaxDetails)
                {
                    var time = new ebay_dispatchtime();
                    time.siteid       = site.ToString();
                    time.name         = entry.Description;
                    time.dispatchTime = entry.DispatchTimeMax;
                    db.ebay_dispatchtimes.InsertOnSubmit(time);
                }

                repository.Save();
            }

            // populate shipping locations
            if (db.ebay_shippinglocations.Count(x => x.siteid == site.ToString()) == 0)
            {
                foreach (ShippingLocationDetailsType entry in resp.ShippingLocationDetails)
                {
                    var loc = new ebay_shippinglocation();
                    loc.description = entry.Description;
                    loc.location    = entry.ShippingLocation;
                    loc.siteid      = site.ToString();
                    db.ebay_shippinglocations.InsertOnSubmit(loc);
                }
                repository.Save();
            }

            // populate shipping services
            if (db.ebay_shippingservices.Count(x => x.siteid == site.ToString()) == 0)
            {
                // shipping details
                foreach (ShippingServiceDetailsType entry in resp.ShippingServiceDetails)
                {
                    var ship = new ebay_shippingservice();
                    ship.siteid            = site.ToString();
                    ship.description       = entry.Description;
                    ship.servicetype       = entry.ShippingService;
                    ship.isInternational   = entry.InternationalService;
                    ship.requiresDimension = entry.DimensionsRequired;
                    ship.requiresWeight    = entry.WeightRequired;

                    db.ebay_shippingservices.InsertOnSubmit(ship);
                }
                repository.Save();
            }

            // now go through and populate category related services
            foreach (var category in db.ebay_categories.AsQueryable().Where(x => x.leaf))
            {
                if (category.done.HasValue && category.done.Value)
                {
                    continue;
                }
                var call = service.GetCategoryFeatures(category.categoryid, category.siteid.ToEnum <SiteCodeType>());

                var features = call.CategoryList;

                if (features.Count > 1)
                {
                    Syslog.Write(string.Format("{0} more than 1 features", category.categoryid));
                }

                // get listing duration
                foreach (ListingDurationReferenceType type in call.SiteDefaults.ListingDuration)
                {
                    foreach (ListingDurationDefinitionType def in call.FeatureDefinitions.ListingDurations.ListingDuration)
                    {
                        if (def.durationSetID == type.Value)
                        {
                            foreach (string entry in def.Duration)
                            {
                                var duration = new ebay_listingduration();
                                duration.listingtypeid = type.type.ToString();
                                duration.duration      = entry;
                                if (!category.ebay_listingdurations.Any(x => x.listingtypeid == duration.listingtypeid &&
                                                                        x.duration == duration.duration))
                                {
                                    category.ebay_listingdurations.Add(duration);
                                }
                            }
                        }
                    }
                }

                CategoryFeatureType feature = features[0];

                // if condition is available
                if (feature.ConditionEnabledSpecified && (feature.ConditionEnabled == ConditionEnabledCodeType.Enabled || feature.ConditionEnabled == ConditionEnabledCodeType.Required))
                {
                    //iterate through each condition node
                    foreach (ConditionType condition in feature.ConditionValues.Condition)
                    {
                        var con = new ebay_condition();
                        con.name  = condition.DisplayName;
                        con.value = condition.ID;
                        if (!category.ebay_conditions.Any(x => x.name == con.name && x.value == con.value && x.ebayrowid == category.id))
                        {
                            category.ebay_conditions.Add(con);
                            db.SubmitChanges();
                        }
                    }
                }

                if (feature.ReturnPolicyEnabled)
                {
                    category.requiresReturnPolicy = true;
                }
                else
                {
                    category.requiresReturnPolicy = false;
                }
                category.done = true;
                db.SubmitChanges();
            }

            return(Content("done"));
        }