public void SetStrategy(KCBulkProductSyncConfig config)
        {
            switch (config.SyncType)
            {
            case KCBulkProductSyncTypesConstants.Custom:
                if (config.DateTo.GetValueOrDefault() == default)
                {
                    throw new PXException(KCMessages.DateShouldBeSet(KCConstants.DateTo));
                }
                if (config.DateFrom.GetValueOrDefault() == default)
                {
                    throw new PXException(KCMessages.DateShouldBeSet(KCConstants.DateFrom));
                }
                if (config.DateTo < config.DateFrom)
                {
                    throw new PXException(KCMessages.DateToBiggerThanDateFrom);
                }
                _strategy = new KCCustomSync(Graph, config.DateFrom.GetValueOrDefault(), config.DateTo.GetValueOrDefault());
                break;

            case KCBulkProductSyncTypesConstants.Delta:
                _strategy = new KCDeltaSync(Graph);
                break;

            case KCBulkProductSyncTypesConstants.Full:
                _strategy = new KCFullSync(Graph);
                break;

            default:
                throw new ArgumentException(KCMessages.UnsupportedSyncType);
            }
        }
        public static void ProcessStore(KCStore store, CancellationToken token)
        {
            KCBulkProductMaint      graph        = CreateInstance <KCBulkProductMaint>();
            KCBulkUploader          bulkUploader = new KCBulkUploader(graph, logger.LoggerProperties, token);
            KCBulkProductSyncConfig config       = new KCBulkProductSyncConfig {
                SyncType = store.SyncType ?? KCBulkProductSyncTypesConstants.Delta, DateFrom = store.DateFrom, DateTo = store.DateTo
            };

            bulkUploader.SetStrategy(config);
            bulkUploader.ExportProducts(store);
        }
        public virtual IEnumerable stores()
        {
            KCBulkProductSyncConfig filter = Config.Current;

            if (filter == null)
            {
                yield break;
            }

            bool found = false;

            foreach (KCStore item in Stores.Cache.Inserted)
            {
                found       = true;
                item.Entity = KCConstants.Product;
                yield return(item);
            }

            if (found)
            {
                yield break;
            }

            foreach (KCSiteMaster result in StoreConfig.Select())
            {
                KCStore store = new KCStore
                {
                    SiteMasterCD = result.SiteMasterCD,
                    AccountId    = result.AccountId,
                    Descr        = result.Descr,
                    Entity       = KCConstants.Product
                };

                yield return(Stores.Insert(store));
            }
            Stores.Cache.IsDirty = false;
        }