public void NotifyEvent(string eventName, object dataParameter, int terminalId, int departmentId, int userRoleId, int ticketTypeId, Action <ActionData> dataAction) { var dataObject = dataParameter.ToDynamic(); _settingService.ClearSettingCache(); var rules = _cacheService.GetAppRules(eventName, terminalId, departmentId, userRoleId, ticketTypeId); foreach (var rule in rules.Where(x => string.IsNullOrEmpty(x.EventConstraints) || SatisfiesConditions(x, dataObject))) { if (!CanExecuteRule(rule, dataObject)) { continue; } foreach (var actionContainer in rule.Actions.OrderBy(x => x.SortOrder).Where(x => CanExecuteAction(x, dataObject))) { var container = actionContainer; var action = _cacheService.GetActions().Single(x => x.Id == container.AppActionId); var clonedAction = ObjectCloner.Clone(action); var containerParameterValues = container.ParameterValues ?? ""; _settingService.ClearSettingCache(); clonedAction.Parameter = _settingService.ReplaceSettingValues(clonedAction.Parameter); containerParameterValues = _settingService.ReplaceSettingValues(containerParameterValues); containerParameterValues = ReplaceParameterValues(containerParameterValues, dataObject); clonedAction.Parameter = _expressionService.ReplaceExpressionValues(clonedAction.Parameter, dataObject); containerParameterValues = _expressionService.ReplaceExpressionValues(containerParameterValues, dataObject); var data = new ActionData { Action = clonedAction, DataObject = dataObject, ParameterValues = containerParameterValues }; dataAction.Invoke(data); } } }
public string Process(string input, object dataObject) { _settingService.ClearSettingCache(); var result = _settingService.ReplaceSettingValues(input); if (dataObject != null) { result = ReplaceParameterValues(result, dataObject); result = ReplaceModelData(result, dataObject); result = _expressionService.ReplaceExpressionValues(result, dataObject); } return(result); }