protected override void RunCallback()
        {
            var dbFactory = new DbFactory();
            var time      = new TimeService(dbFactory);
            var log       = GetLogger();

            var settings            = new SettingsService(dbFactory);
            var styleHistoryService = new StyleHistoryService(log, time, dbFactory);
            var styleManager        = new StyleManager(log, time, styleHistoryService);

            var templatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                            Path.Combine(AppSettings.TemplateDirectory, TemplateHelper.EBayDescriptionTemplateName));
            var templateMultiListingPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                        Path.Combine(AppSettings.TemplateDirectory, TemplateHelper.EBayDescriptionMultiListingTemplateName));

            var lastSyncDate          = settings.GetListingsSendDate(_api.Market, _api.MarketplaceId);
            var isManualSyncRequested = settings.GetListingsManualSyncRequest(_api.Market, _api.MarketplaceId);
            var pauseStatus           = settings.GetListingsSyncPause(_api.Market, _api.MarketplaceId) ?? false;

            LogWrite("Last sync date=" + lastSyncDate + ", manually sync=" + isManualSyncRequested);

            if (pauseStatus)
            {
                LogWrite("Listings sync in pause");
                return;
            }

            if (!lastSyncDate.HasValue ||
                (time.GetUtcTime() - lastSyncDate) > _betweenProcessingInverval ||
                isManualSyncRequested == true)
            {
                var sync = new eBayItemsSync(log,
                                             time,
                                             _api,
                                             dbFactory,
                                             styleManager,
                                             AppSettings.eBayImageDirectory,
                                             AppSettings.eBayImageBaseUrl,
                                             AppSettings.LabelDirectory);

                sync.SendItemUpdates();

                settings.SetListingsSendDate(time.GetUtcTime(), _api.Market, _api.MarketplaceId);
                settings.SetListingsManualSyncRequest(false, _api.Market, _api.MarketplaceId);
            }
        }
Exemplo n.º 2
0
        public void SubmitItems(eBayApi api, IList <string> skuList)
        {
            List <long> itemIds = null;

            if (skuList != null)
            {
                using (var db = _dbFactory.GetRWDb())
                {
                    //itemIds =
                    //    db.Items.GetAll().Where(i => i.ItemPublishedStatus == (int)PublishedStatuses.Published
                    //                                 && i.Market == (int)MarketType.eBay)
                    //        .Select(i => i.Id)
                    //        .ToList()
                    //        .Select(l => (long)l)
                    //    .ToList();

                    itemIds = db.Listings.GetAll().Where(l => skuList.Contains(l.SKU) &&
                                                         l.Market == (int)MarketType.eBay)
                              .Select(l => l.ItemId)
                              .ToList()
                              .Select(l => (long)l)
                              .ToList();
                }
            }

            var sync = new eBayItemsSync(_log,
                                         _time,
                                         api,
                                         _dbFactory,
                                         _styleManager,
                                         AppSettings.eBayImageDirectory,
                                         AppSettings.eBayImageBaseUrl,
                                         AppSettings.LabelDirectory);

            sync.SendItemUpdates(itemIds);
        }