public string GetUserProfileValidators( IRuleEvaluatorService ruleService, OperationRelatedModel modelValidation, string code, int operationId, int contractId, string mainOperationNumber, int clauseId, int clauseIndividualId, string clauseExtensionId, decimal amount) { string validator = RunNewRulesEngine( modelValidation, code, clauseExtensionId, contractId, amount); if (!string.IsNullOrEmpty(validator)) { return(validator); } return(RunOldRulesEngine( ruleService, code, operationId, contractId, mainOperationNumber, clauseId, clauseIndividualId, clauseExtensionId, amount)); }
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 }); }
public static string GetValidators( IRuleEvaluatorService ruleService, decimal currentAmount) { Dictionary <string, string> variablesList = new Dictionary <string, string>(); variablesList.Add("Role", string.Empty); string calculatedValidators = ruleService.EvaluateST( SP_VALIDATORS_RULE_ID, variablesList, currentAmount); Logger.GetLogger().WriteDebug("SupervisionPlanWorkflowManager", "Validators calculated: " + calculatedValidators); if (!calculatedValidators.Contains("Error")) { return(calculatedValidators.Replace("\"", string.Empty)); } return(string.Empty); }
public StageFourController(IBasicDataModelRepository basicDataModelRepository, IK2ServiceProxy k2ServiceProxy, IOperationModelRepository operationClauseClient, IGlobalModelRepository globalRepository, IResultsMatrixModelRepository resultsMatrixRepository, IVerifyContentModelRepositoryService clientVerifyContent, IPMIDetailsModelRepository clientPMIDetails, IRuleEvaluatorService ruleService, ICacheManagement cacheData) { _basicDataModelRepository = basicDataModelRepository; _k2ServiceProxy = k2ServiceProxy; _operationClauseClient = operationClauseClient; _globalRepository = globalRepository; _resultsMatrixRepository = resultsMatrixRepository; _clientVerifyContent = clientVerifyContent; _clientPMIDetails = clientPMIDetails; _ruleService = ruleService; _cacheData = cacheData; }
string RunOldRulesEngine( IRuleEvaluatorService ruleService, string code, int operationId, int contractId, string mainOperationNumber, int clauseId, int clauseIndividualId, string clauseExtensionId, decimal amount) { Dictionary <string, string> variablesList = new Dictionary <string, string>(); variablesList.Add("OperationId", operationId.ToString()); variablesList.Add("ContractId", contractId.ToString()); variablesList.Add("MainOperationNumber", mainOperationNumber); using (var dbOptimaContainer = new OptimaContainer()) { variablesList.Add("ValidationStageAprobId", dbOptimaContainer.ConvergenceMasterData .Where(a => a.Code == ClauseConstants.APPROVED_CLAUSE_STATUS).ToString()); } variablesList.Add("ClauseId", clauseId.ToString()); variablesList.Add("ClauseIndividualId", clauseIndividualId.ToString()); variablesList.Add("ClauseExtensionId", clauseExtensionId); variablesList.Add("Role", string.Empty); variablesList.Add("Temp", string.Empty); string validatorCandidates = ruleService.EvaluateST(int.Parse(code), variablesList, amount); if (!validatorCandidates.Contains("Error")) { validatorCandidates = validatorCandidates.Replace("\"", string.Empty); } return(validatorCandidates); }
public void GetValidatorAndPopupMessage( IRuleEvaluatorService ruleService, OperationRelatedModel modelValidation, string code, int operationId, int contractId, string mainOperationNumber, int clauseId, int clauseIndividualId, string clauseExtensionId, decimal amount, out string mandatoryValidator, out string popupMessage) { mandatoryValidator = GetUserProfileValidators( ruleService, modelValidation, code, operationId, contractId, mainOperationNumber, clauseId, clauseIndividualId, clauseExtensionId, amount); popupMessage = _businessRuleService.GetPopupMessage(); Logger.GetLogger() .WriteDebug( "ClauseBusinessLogic", string.Format( "Validator is: {0} and popup message is: {1}", mandatoryValidator, popupMessage)); }
public static string GetValidators( IRuleEvaluatorService ruleService, decimal currentAmount, K2CallType callType) { Dictionary <string, string> variablesList = new Dictionary <string, string>(); variablesList.Add("Role", string.Empty); string calculatedValidators = ruleService.EvaluateST( callType == K2CallType.September ? PMI_VALIDATORS_SEPTEMBER_RULE_ID : PMI_VALIDATORS_NOT_SEPTEMBER_RULE_ID, variablesList, currentAmount); Logger.GetLogger().WriteDebug("PMIWorkflowValidationManager", "Validators calculated: " + calculatedValidators); if (!calculatedValidators.Contains("Error")) { return(calculatedValidators.Replace("\"", string.Empty)); } return(string.Empty); }