public void Initialize(int feedId, bool isIncremental, DateTime?fromTime, DateTime executionTime) { //_feedId = feedId; _isIncrementalRun = isIncremental; _fromTime = fromTime; // First get rules associated with this feed var rules = _feedRuleService.GetFeedRuleModels(feedId, executionTime).ToList(); // Instantiate the IFeedGeneratorCmsDataService _feedGeneratorCmsDataService = new FeedGeneratorCmsDataService(_feedCmsProductArciveEntryService, null); // If it's an incremental run, get the rule set at the time of of the previous execution // Then make comparisons to check if there were updates to rules. If there were rule updates, // then populate the secondary rule services which will be used to determine if a product is modified // even if the product data hasn't changed if (!_isIncrementalRun || !_fromTime.HasValue) { return; } var previousRules = _feedRuleService.GetFeedRuleModels(feedId, _fromTime.Value).ToList(); if (!previousRules.Any()) { return; } _feedGeneratorCmsDataServicePast = new FeedGeneratorCmsDataService(_feedCmsProductArciveEntryService, fromTime); HaveRulesChanged = !AreSameRules(new RuleComparisonData { RuleSet = rules, FeedGeneratorCmsDataService = _feedGeneratorCmsDataService }, new RuleComparisonData { RuleSet = previousRules, FeedGeneratorCmsDataService = _feedGeneratorCmsDataServicePast }); }
public void Initialize(int feedId, bool isIncremental, DateTime?fromTime, DateTime executionTime, GoogleRunFeedType runFeedType) { _log.Debug("Inside Initialize() of GooglePlaFeedRuleHelper."); _isIncrementalRun = isIncremental; _fromTime = fromTime; _runFeedType = runFeedType; // First get rules associated with this feed var rules = _feedRuleService.GetFeedRuleModels(feedId, executionTime).ToList(); _exclusionRules.AddRange(rules.Where(r => r.FeedRule.FeedRuleType == FeedRuleType.Exclusion)); var cpcRuleModels = rules.Where(frm => frm.FeedRule.FeedRuleType == FeedRuleType.CPC_Value).ToList(); var customLabel0RuleModels = rules.Where(frm => frm.FeedRule.FeedRuleType == FeedRuleType.Custom_Label_0).ToList(); var customLabel1RuleModels = rules.Where(frm => frm.FeedRule.FeedRuleType == FeedRuleType.Custom_Label_1).ToList(); var customLabel2RuleModels = rules.Where(frm => frm.FeedRule.FeedRuleType == FeedRuleType.Custom_Label_2).ToList(); var customLabel3RuleModels = rules.Where(frm => frm.FeedRule.FeedRuleType == FeedRuleType.Custom_Label_3).ToList(); var customLabel4RuleModels = rules.Where(frm => frm.FeedRule.FeedRuleType == FeedRuleType.Custom_Label_4).ToList(); var dynamicMerchLabelRuleModels = rules.Where(frm => frm.FeedRule.FeedRuleType == FeedRuleType.Dynamic_Merch_Label).ToList(); // Instantiate the IFeedGeneratorCmsDataService _feedGeneratorCmsDataService = new FeedGeneratorCmsDataService(_feedCmsProductArchiveEntryService, null); // Instantiate the rule evaluator services _exclusionRuleEvaluatorService = new RuleEvaluatorService(_exclusionRules, _feedGeneratorCmsDataService, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); _cpcRuleEvaluatorService = new RuleEvaluatorService(cpcRuleModels, _feedGeneratorCmsDataService, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); _customLabel0Service = new RuleEvaluatorService(customLabel0RuleModels, _feedGeneratorCmsDataService, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); _customLabel1Service = new RuleEvaluatorService(customLabel1RuleModels, _feedGeneratorCmsDataService, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); _customLabel2Service = new RuleEvaluatorService(customLabel2RuleModels, _feedGeneratorCmsDataService, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); _customLabel3Service = new RuleEvaluatorService(customLabel3RuleModels, _feedGeneratorCmsDataService, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); _customLabel4Service = new RuleEvaluatorService(customLabel4RuleModels, _feedGeneratorCmsDataService, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); _dynamicMerchLabelService = new RuleEvaluatorService(dynamicMerchLabelRuleModels, _feedGeneratorCmsDataService, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); // If it's an incremental run, get the rule set at the time of of the previous execution // Then make comparisons to check if there were updates to rules. If there were rule updates, // then populate the secondary rule services which will be used to determine if a product is modified // even if the product data hasn't changed if (!_isIncrementalRun || !_fromTime.HasValue) { _log.Debug("Exiting Initialize() of GooglePlaFeedRuleHelper without initializing past rules."); return; } var previousRules = _feedRuleService.GetFeedRuleModels(feedId, _fromTime.Value).ToList(); _exclusionRulesPast.AddRange(previousRules.Where(r => r.FeedRule.FeedRuleType == FeedRuleType.Exclusion)); _feedGeneratorCmsDataServicePast = new FeedGeneratorCmsDataService(_feedCmsProductArchiveEntryService, fromTime); _exclusionRuleEvaluatorServicePast = new RuleEvaluatorService(_exclusionRulesPast, _feedGeneratorCmsDataServicePast, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); _haveExclusionRulesChanged = !AreSameRules(new RuleComparisonData { RuleSet = _exclusionRules, FeedGeneratorCmsDataService = _feedGeneratorCmsDataService }, new RuleComparisonData { RuleSet = _exclusionRulesPast, FeedGeneratorCmsDataService = _feedGeneratorCmsDataServicePast }); _log.DebugFormat("Exiting Initialize() of GooglePlaFeedRuleHelper after initializing past rules. HaveExclusionRulesChanged is {0}.", _haveExclusionRulesChanged); }
public void Initialize(int feedId, bool isIncremental, DateTime?fromTime, DateTime executionTime) { //_feedId = feedId; _isIncrementalRun = isIncremental; _fromTime = fromTime; // First get rules associated with this feed var rules = _feedRuleService.GetFeedRuleModels(feedId, executionTime).ToList(); _zeroCommissionRules.AddRange(rules.Where(r => r.FeedRule.FeedRuleType == FeedRuleType.No_Commission)); _promotionalTextRules.AddRange(rules.Where(r => r.FeedRule.FeedRuleType == FeedRuleType.Promotional_Text)); // Instantiate the IFeedGeneratorCmsDataService _feedGeneratorCmsDataService = new FeedGeneratorCmsDataService(_feedCmsProductArciveEntryService, null); // Instantiate the rule evaluator services _zeroCommissionRuleEvaluatorService = new RuleEvaluatorService(_zeroCommissionRules, _feedGeneratorCmsDataService, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); _promotionalTextRuleEvaluatorService = new RuleEvaluatorService(_promotionalTextRules, _feedGeneratorCmsDataService, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); // If it's an incremental run, get the rule set at the time of of the previous execution // Then make comparisons to check if there were updates to rules. If there were rule updates, // then populate the secondary rule services which will be used to determine if a product is modified // even if the product data hasn't changed if (!_isIncrementalRun || !_fromTime.HasValue) { return; } var previousRules = _feedRuleService.GetFeedRuleModels(feedId, _fromTime.Value).ToList(); if (!previousRules.Any()) { return; } _zeroCommissionRulesPast.AddRange(previousRules.Where(r => r.FeedRule.FeedRuleType == FeedRuleType.No_Commission)); _promotionalTextRulesPast.AddRange(previousRules.Where(r => r.FeedRule.FeedRuleType == FeedRuleType.Promotional_Text)); _feedGeneratorCmsDataServicePast = new FeedGeneratorCmsDataService(_feedCmsProductArciveEntryService, fromTime); _zeroCommissionRuleEvaluatorServicePast = new RuleEvaluatorService(_zeroCommissionRulesPast, _feedGeneratorCmsDataServicePast, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); _promotionalTextRuleEvaluatorServicePast = new RuleEvaluatorService(_promotionalTextRulesPast, _feedGeneratorCmsDataServicePast, _feedGeneratorIndigoCategoryService, _allowRuleOptimizations, _allowRuleEntryRemovals, _allowIEnumerableRuleEvaluations); HaveRulesChanged = !AreSameRules(new RuleComparisonData { RuleSet = rules, FeedGeneratorCmsDataService = _feedGeneratorCmsDataService }, new RuleComparisonData { RuleSet = previousRules, FeedGeneratorCmsDataService = _feedGeneratorCmsDataServicePast }); }