protected override void RunCallback() { _api.Connect(); var dbFactory = new DbFactory(); var time = new TimeService(dbFactory); var settings = new SettingsService(dbFactory); var lastSyncDate = settings.GetListingsSendDate(_api.Market, _api.MarketplaceId); LogWrite("Last sync date=" + lastSyncDate); if (!lastSyncDate.HasValue || (time.GetUtcTime() - lastSyncDate) > _betweenProcessingInverval) { var sync = new MagentoItemsSync(_api, dbFactory, GetLogger(), time); sync.SyncAttributeOptions(); //sync.SyncCategories(); sync.SendItemUpdates(); settings.SetListingsSendDate(time.GetUtcTime(), _api.Market, _api.MarketplaceId); } }
public void SubmitPrice(Magento20MarketApi api) { var sync = new MagentoItemsSync(api, _dbFactory, _log, _time); sync.SendPriceUpdates(); }
public void SyncAttributeOptions(Magento20MarketApi api) { var sync = new MagentoItemsSync(api, _dbFactory, _log, _time); sync.SyncAttributeOptions(); }
public void SubmitParentItems(Magento20MarketApi api, IList <string> skuList) { var sync = new MagentoItemsSync(api, _dbFactory, _log, _time); IList <int> itemIdList = null; if (skuList != null) { using (var db = _dbFactory.GetRWDb()) { var query = from pi in db.ParentItems.GetAll() where pi.Market == (int)MarketType.Magento && skuList.Contains(pi.ASIN) select pi; itemIdList = query.Select(i => i.Id).ToList(); } } else { using (var db = _dbFactory.GetRDb()) { itemIdList = db.ParentItems.GetAll() .Where(i => i.Market == (int)MarketType.Magento) .OrderBy(i => i.Id) .Select(i => i.Id) .ToList(); } } _log.Info("ParentItems to update=" + itemIdList?.Count); //itemIdList = itemIdList.Skip(400).ToList(); sync.SendParentItemUpdates(itemIdList); }
public void SubmitItems(Magento20MarketApi api, IList <string> styleList) { var sync = new MagentoItemsSync(api, _dbFactory, _log, _time); IList <int> itemIdList = null; //using (var db = _dbFactory.GetRDb()) //{ // //var styleIdList = db.StyleFeatureValues.GetAll().Select(fv => fv.StyleId).ToList(); // var fromDate = DateTime.Today.AddHours(13); // var styleIdList = db.Styles.GetAll().Where(st => st.StyleID == "Citizen EM0420-54D") // .Select(st => st.Id) // .ToList(); // //db.Styles.GetAll().Where(st => st.LiteCountingDate > fromDate).Select(st => st.Id).ToList(); // itemIdList = db.Items.GetAll() // .Where(i => i.StyleId.HasValue && // styleIdList.Contains(i.StyleId.Value) && // (i.ItemPublishedStatus == (int)PublishedStatuses.Published // || i.ItemPublishedStatus == (int)PublishedStatuses.New // || i.ItemPublishedStatus == (int)PublishedStatuses.PublishingErrors // || i.ItemPublishedStatus == (int)PublishedStatuses.HasChanges) && // //i.ItemPublishedStatusDate < fromDate && // i.Market == (int)MarketType.Magento) // .Select(i => i.Id).ToList(); //} if (styleList != null) { using (var db = _dbFactory.GetRWDb()) { var query = from i in db.Items.GetAll() join l in db.Listings.GetAll() on i.Id equals l.ItemId join st in db.Styles.GetAll() on i.StyleId equals st.Id where l.Market == (int)MarketType.Magento && styleList.Contains(st.StyleID) select i; //var query = from i in db.Items.GetAll() // join st in db.Styles.GetAll() on i.StyleId equals st.Id // where i.Market == (int)MarketType.Magento // && st.DropShipperId == DSHelper.UltraluxId // select i; itemIdList = query.Select(i => i.Id).ToList(); } } else { using (var db = _dbFactory.GetRDb()) { itemIdList = db.Items.GetAll() .Where(i => i.Market == (int)MarketType.Magento) .OrderBy(i => i.Id) .Select(i => i.Id) .ToList(); } } _log.Info("Items to update=" + itemIdList?.Count); //itemIdList = itemIdList.Skip(400).ToList(); sync.SendItemUpdates(itemIdList); }