private static RuleInfo ReadRule(SqlDataReader reader) { try { IMetadataManager iMetadataManager = new MetadataManager.Contracts.MetadataManager(); List <SourceInfo> lstSource = reader.IsDBNull(4) ? null : Newtonsoft.Json.JsonConvert.DeserializeObject <List <SourceInfo> >(reader.GetString(4)); List <TargetInfo> lstTarget = reader.IsDBNull(5) ? null : Newtonsoft.Json.JsonConvert.DeserializeObject <List <TargetInfo> >(reader.GetString(5)); RuleTypeEnum ruleType = reader.IsDBNull(3) ? RuleTypeEnum.Visibility : (RuleTypeEnum)reader.GetInt32(3); string strRuleTypeName = ruleType.ToString(); string entityId = reader.IsDBNull(8) ? string.Empty : reader.GetString(8); string entityName = (entityId == null) ? string.Empty : iMetadataManager.GetEntityNameByEntityContext(entityId); var rule = new RuleInfo { TenantId = reader.IsDBNull(0) ? Guid.Empty : reader.GetGuid(0), Id = reader.IsDBNull(1) ? Guid.Empty : reader.GetGuid(1), RuleName = reader.IsDBNull(2) ? string.Empty : reader.GetString(2), RuleType = reader.IsDBNull(3) ? RuleTypeEnum.Visibility : (RuleTypeEnum)reader.GetInt32(3), Source = reader.IsDBNull(4) ? string.Empty : reader.GetString(4), Target = reader.IsDBNull(5) ? string.Empty : reader.GetString(5), SourceList = lstSource, TargetList = lstTarget, UpdatedBy = reader.IsDBNull(7) ? Guid.Empty : reader.GetGuid(7), RuleTypeName = strRuleTypeName, EntityId = entityId, EntityName = entityName }; return(rule); } catch (System.Exception ex) { throw ex.InnerException; } }
private RuleInfo GenerateRule( string displayName, int value, int scoreId, string ruleCondition, RuleTypeEnum ruleType, string ruleParameter = null, bool belongsToPersona = true) { var codeName = ValidationHelper.GetCodeName(displayName, 100); var ruleInfo = RuleInfoProvider.GetRules().WithCodeName(codeName).FirstOrDefault(); if (ruleInfo != null) { return(ruleInfo); } var ruleObj = new RuleInfo { RuleScoreID = scoreId, RuleDisplayName = displayName, RuleName = codeName, RuleValue = value, RuleType = ruleType, RuleParameter = ruleParameter, RuleCondition = ruleCondition, RuleBelongsToPersona = belongsToPersona }; RuleInfoProvider.SetRuleInfo(ruleObj); return(ruleObj); }
public Rule AddRule(RuleTypeEnum ruleType) { Rule rule = SchemaFactory.CreateRule(ruleType); this.Add(rule); return(rule); }
public Rule AddRule(RuleTypeEnum ruleType, string value) { Rule rule = SchemaFactory.CreateRule(ruleType); rule.Value = value; this.Add(rule); return(rule); }
public Rule AddRule(RuleTypeEnum ruleType, string value, string exProperty) { Rule rule = SchemaFactory.CreateRule(ruleType); rule.Value = value; rule.ExProperty = exProperty; this.Add(rule); return(rule); }
/// <summary> /// Initializes controls (and preselects rule type). /// </summary> private void InitControls() { if (!RequestHelper.IsPostBack()) { radType.Items.Add(new ListItem(GetString("om.score.attribute"), ((int)RuleTypeEnum.Attribute).ToString())); radType.Items.Add(new ListItem(GetString("om.score.activity"), ((int)RuleTypeEnum.Activity).ToString())); RuleTypeEnum rt = RuleTypeEnum.Attribute; if (EditForm.EditedObject != null) { // Initialize attribute type from edited object (if any) RuleInfo ri = (RuleInfo)EditForm.EditedObject; rt = ri.RuleType; // Init rule validity controls if (EditForm.Data["RuleValidity"] != null) { string strValidity = ValidationHelper.GetString(EditForm.Data["RuleValidity"], null); validity.Validity = (ValidityEnum)Enum.Parse(typeof(ValidityEnum), strValidity); if (validity.Validity == ValidityEnum.Until) { validity.ValidUntil = ValidationHelper.GetDateTime(EditForm.Data["RuleValidUntil"], DateTimeHelper.ZERO_TIME); } else { validity.ValidFor = ValidationHelper.GetInteger(EditForm.Data["RuleValidFor"], 0); } } } radType.Items[0].Selected = radType.Items[1].Selected = false; for (int i = radType.Items.Count - 1; i >= 0; i--) { bool selected = ValidationHelper.GetInteger(radType.Items[i].Value, 0) == (int)rt; radType.Items[i].Selected = selected; if (selected) { radType.SelectedValue = Convert.ToString((int)rt); } } } txtValue.MaxLength = ValidationHelper.MAX_INT_LENGTH; txtValue.FilterType = AjaxControlToolkit.FilterTypes.Numbers | AjaxControlToolkit.FilterTypes.Custom; txtValue.ValidChars = "-"; txtMaxPoints.MaxLength = ValidationHelper.MAX_INT_LENGTH; txtMaxPoints.FilterType = AjaxControlToolkit.FilterTypes.Numbers | AjaxControlToolkit.FilterTypes.Custom; txtMaxPoints.ValidChars = "-"; txtMaxPoints.Enabled = ValidationHelper.GetBoolean(chkRecurring.Value, false); drpAttribute.SelectedIndexChanged += new EventHandler(drpAttribute_SelectedIndexChanged); pnlGeneral.GroupingText = GetString("general.general"); pnlActivity.GroupingText = GetString("om.score.activityvalidity"); pnlSettings.GroupingText = GetString("om.score.rulesettings"); }
public int Test3(RuleTypeEnum ruleTypeEnum) { if (ruleTypeEnum != RuleTypeEnum.Initial) { return((int)RuleTypeEnum.Initial); } else { return((int)RuleTypeEnum.ToChooseProcess); } }
private RuleInfo GenerateBaseRule(RuleTypeEnum ruleType, int siteId) { return(new RuleInfo { RuleType = ruleType, RuleSiteID = siteId, RuleValue = StaticRandom.Next(10, 1000), RuleIsRecurring = false, RuleName = "Rule-" + Guid.NewGuid() }); }
public static RuleTypeEnum GetEnum(string name) { string[] types = Enum.GetNames(typeof(RuleTypeEnum)); foreach (var type in types) { RuleTypeEnum ruleTypeEnum = (RuleTypeEnum)Enum.Parse(typeof(RuleTypeEnum), type); if (name.Equals(ToType(ruleTypeEnum))) { return(ruleTypeEnum); } } return(RuleTypeEnum.UNKNOWN); }
public Rule AddIntervalRule(RuleTypeEnum ruleType, string ruleValue, bool isInclude) { Rule rule = SchemaFactory.CreateRule(ruleType); rule.Value = ruleValue; if (isInclude) { rule.ExProperty = "include"; } else { rule.ExProperty = "not include"; } this.Add(rule); return rule; }
public Rule AddIntervalRule(RuleTypeEnum ruleType, string ruleValue, bool isInclude) { Rule rule = SchemaFactory.CreateRule(ruleType); rule.Value = ruleValue; if (isInclude) { rule.ExProperty = "include"; } else { rule.ExProperty = "not include"; } this.Add(rule); return(rule); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.RuleType = ((RuleTypeEnum)(binaryReader.ReadInt16())); this.Squad = binaryReader.ReadShortBlockIndex1(); this.SquadGroup = binaryReader.ReadShortBlockIndex1(); this.A = binaryReader.ReadInt16(); this.X = binaryReader.ReadSingle(); this.TriggerVolume = binaryReader.ReadShortBlockIndex1(); this.fieldpad = binaryReader.ReadBytes(2); this.ExitConditionScript = binaryReader.ReadString32(); this.FieldShortInteger = binaryReader.ReadInt16(); this.fieldpad0 = binaryReader.ReadBytes(2); this.OrderCompletionConditionFlags = ((Flags)(binaryReader.ReadInt32())); return(pointerQueue); }
private RuleInfo GenerateRule(int siteId) { var random = StaticRandom.NextDouble(); RuleTypeEnum ruleType = random < 0.166 ? RuleTypeEnum.Attribute : random < 0.333 ? RuleTypeEnum.Macro : RuleTypeEnum.Activity; switch (ruleType) { case RuleTypeEnum.Activity: return(GenerateActivityRule(siteId)); case RuleTypeEnum.Attribute: return(GenerateAttributeRule(siteId)); case RuleTypeEnum.Macro: return(GenerateMacroRule(siteId)); } return(null); }
public static Rule CreateRule(RuleTypeEnum ruleType) { Rule rule = null; switch (ruleType) { case RuleTypeEnum.MAX_LENGTH_RULE: rule = new MaxLengthRule(); break; case RuleTypeEnum.MIN_LENGTH_RULE: rule = new MinLengthRule(); break; case RuleTypeEnum.MAX_VALUE_RULE: rule = new MaxValueRule(); break; case RuleTypeEnum.MIN_VALUE_RULE: rule = new MinValueRule(); break; case RuleTypeEnum.MAX_INPUT_NUM_RULE: rule = new MaxInputNumRule(); break; case RuleTypeEnum.MIN_INPUT_NUM_RULE: rule = new MinInputNumRule(); break; case RuleTypeEnum.VALUE_TYPE_RULE: rule = new ValueTypeRule(); break; case RuleTypeEnum.REQUIRED_RULE: rule = new RequiredRule(); break; case RuleTypeEnum.DISABLE_RULE: rule = new DisableRule(); break; case RuleTypeEnum.MAX_DECIMAL_DIGITS_RULE: rule = new MaxDecimalDigitsRule(); break; case RuleTypeEnum.MIN_DECIMAL_DIGITS_RULE: rule = new MinDecimalDigitsRule(); break; case RuleTypeEnum.REGEX_RULE: rule = new RegexRule(); break; case RuleTypeEnum.SET_RULE: rule = new SetRule(); break; case RuleTypeEnum.TIP_RULE: rule = new TipRule(); break; case RuleTypeEnum.DEV_TIP_RULE: rule = new DevTipRule(); break; case RuleTypeEnum.READ_ONLY_RULE: rule = new ReadOnlyRule(); break; case RuleTypeEnum.MAX_TARGET_SIZE_RULE: rule = new MaxTargetSizeRule(); break; case RuleTypeEnum.MIN_TARGET_SIZE_RULE: rule = new MinTargetSizeRule(); break; case RuleTypeEnum.MAX_IMAGE_SIZE_RULE: rule = new MaxImageSizeRule(); break; case RuleTypeEnum.MIN_IMAGE_SIZE_RULE: rule = new MinImageSizeRule(); break; } return rule; }
public static string ToType(RuleTypeEnum ruleTypeEnum) { switch (ruleTypeEnum) { case RuleTypeEnum.MAX_LENGTH_RULE: return("maxLengthRule"); case RuleTypeEnum.MIN_LENGTH_RULE: return("minLengthRule"); case RuleTypeEnum.MAX_VALUE_RULE: return("maxValueRule"); case RuleTypeEnum.MIN_VALUE_RULE: return("minValueRule"); case RuleTypeEnum.MAX_INPUT_NUM_RULE: return("maxInputNumRule"); case RuleTypeEnum.MIN_INPUT_NUM_RULE: return("minInputNumRule"); case RuleTypeEnum.VALUE_TYPE_RULE: return("valueTypeRule"); case RuleTypeEnum.REQUIRED_RULE: return("requiredRule"); case RuleTypeEnum.DISABLE_RULE: return("disableRule"); case RuleTypeEnum.MAX_DECIMAL_DIGITS_RULE: return("maxDecimalDigitsRule"); case RuleTypeEnum.MIN_DECIMAL_DIGITS_RULE: return("minDecimalDigitsRule"); case RuleTypeEnum.REGEX_RULE: return("regexRule"); case RuleTypeEnum.SET_RULE: return("setRule"); case RuleTypeEnum.TIP_RULE: return("tipRule"); case RuleTypeEnum.DEV_TIP_RULE: return("devTipRule"); case RuleTypeEnum.READ_ONLY_RULE: return("readOnlyRule"); case RuleTypeEnum.MAX_TARGET_SIZE_RULE: return("maxTargetSizeRule"); case RuleTypeEnum.MIN_TARGET_SIZE_RULE: return("minTargetSizeRule"); case RuleTypeEnum.MAX_IMAGE_SIZE_RULE: return("maxImageSizeRule"); case RuleTypeEnum.MIN_IMAGE_SIZE_RULE: return("minImageSizeRule"); default: return(""); } }
public static Rule CreateRule(RuleTypeEnum ruleType) { Rule rule = null; switch (ruleType) { case RuleTypeEnum.MAX_LENGTH_RULE: rule = new MaxLengthRule(); break; case RuleTypeEnum.MIN_LENGTH_RULE: rule = new MinLengthRule(); break; case RuleTypeEnum.MAX_VALUE_RULE: rule = new MaxValueRule(); break; case RuleTypeEnum.MIN_VALUE_RULE: rule = new MinValueRule(); break; case RuleTypeEnum.MAX_INPUT_NUM_RULE: rule = new MaxInputNumRule(); break; case RuleTypeEnum.MIN_INPUT_NUM_RULE: rule = new MinInputNumRule(); break; case RuleTypeEnum.VALUE_TYPE_RULE: rule = new ValueTypeRule(); break; case RuleTypeEnum.REQUIRED_RULE: rule = new RequiredRule(); break; case RuleTypeEnum.DISABLE_RULE: rule = new DisableRule(); break; case RuleTypeEnum.MAX_DECIMAL_DIGITS_RULE: rule = new MaxDecimalDigitsRule(); break; case RuleTypeEnum.MIN_DECIMAL_DIGITS_RULE: rule = new MinDecimalDigitsRule(); break; case RuleTypeEnum.REGEX_RULE: rule = new RegexRule(); break; case RuleTypeEnum.SET_RULE: rule = new SetRule(); break; case RuleTypeEnum.TIP_RULE: rule = new TipRule(); break; case RuleTypeEnum.DEV_TIP_RULE: rule = new DevTipRule(); break; case RuleTypeEnum.READ_ONLY_RULE: rule = new ReadOnlyRule(); break; case RuleTypeEnum.MAX_TARGET_SIZE_RULE: rule = new MaxTargetSizeRule(); break; case RuleTypeEnum.MIN_TARGET_SIZE_RULE: rule = new MinTargetSizeRule(); break; case RuleTypeEnum.MAX_IMAGE_SIZE_RULE: rule = new MaxImageSizeRule(); break; case RuleTypeEnum.MIN_IMAGE_SIZE_RULE: rule = new MinImageSizeRule(); break; } return(rule); }
private RuleInfo GenerateBaseRule(RuleTypeEnum ruleType, int siteId) { return new RuleInfo { RuleType = ruleType, RuleSiteID = siteId, RuleValue = StaticRandom.Next(10, 1000), RuleIsRecurring = false, RuleName = "Rule-" + Guid.NewGuid() }; }
private static RuleInfo GenerateBasicScoringRule(ScoreInfo score, string displayName, int ruleValue, RuleTypeEnum ruleType, string ruleCondition, string ruleParameter = null) { var rule = new RuleInfo { RuleScoreID = score.ScoreID, RuleDisplayName = displayName, RuleName = "Rule-" + Guid.NewGuid(), RuleValue = ruleValue, RuleType = ruleType, RuleParameter = ruleParameter, RuleCondition = ruleCondition, RuleSiteID = score.ScoreSiteID, RuleBelongsToPersona = false, RuleIsRecurring = false }; rule.Insert(); return rule; }
//public void AddRule(string ruleName, Type entityType, string condition, LuaFunction action) //{ // AddRuleData(ruleName, entityType, condition, action, RuleTypeEnum.Lambda); //} private void AddRuleData(string ruleName, Type entityType, object condition, object action, RuleTypeEnum type) { var ruleData = new RuleData() { IsEnabled = true, EntityType = entityType, RuleCondition = condition, RuleName = ruleName, RuleType = type }; //if (action is LuaFunction) //{ // ruleData.Action = entity => { ((LuaFunction)action).Call(entity); }; //} if (action is Action <INeonIoTEntity> action1) { ruleData.Action = action1; } _logger.LogInformation($"Adding rule {ruleName} for entity {entityType.Name} [Type: {type}]"); Rules.Add(ruleData); AddRuleExecution(ruleData); }
public Rule AddRule(RuleTypeEnum ruleType, string value) { Rule rule = SchemaFactory.CreateRule(ruleType); rule.Value = value; this.Add(rule); return rule; }
public static Rule CreateRule(RuleTypeEnum ruleType) { return(RuleTypeEnumHelper.CreateRule(ruleType)); }
public static Rule CreateRule(RuleTypeEnum ruleType) { return RuleTypeEnumHelper.CreateRule(ruleType); }
public Rule AddRule(RuleTypeEnum ruleType, string value, string exProperty) { Rule rule = SchemaFactory.CreateRule(ruleType); rule.Value = value; rule.ExProperty = exProperty; this.Add(rule); return rule; }
/** * xml Element to Rule * @param ruleEle * @param fieldId * @return * @throws TopSchemaException */ private static Rule ElementToRule(XmlElement ruleEle, string fieldId) { if (ruleEle == null) { return(null); } String ruleName = XmlUtils.GetAttributeValue(ruleEle, "name"); if (StringUtil.IsEmpty(ruleName)) { throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_31001, fieldId); } String ruleValue = XmlUtils.GetAttributeValue(ruleEle, "value"); if (StringUtil.IsEmpty(ruleValue)) { throw new TopSchemaException(TopSchemaErrorCodeEnum.ERROR_CODE_31002, fieldId); } Rule rule = null; RuleTypeEnum ruleEnum = RuleTypeEnumHelper.GetEnum(ruleName); if (ruleEnum != RuleTypeEnum.UNKNOWN) { rule = SchemaFactory.CreateRule(ruleEnum); } else { rule = SchemaFactory.CreateCustomRule(ruleName, ruleValue); } if (ruleName.Equals(RuleTypeEnumHelper.ToType(RuleTypeEnum.TIP_RULE)) && !StringUtil.IsEmpty(ruleValue)) { String url = XmlUtils.GetAttributeValue(ruleEle, "url"); ((TipRule)rule).Url = url; } if (ruleName.Equals(RuleTypeEnumHelper.ToType(RuleTypeEnum.DEV_TIP_RULE)) && !StringUtil.IsEmpty(ruleValue)) { String url = XmlUtils.GetAttributeValue(ruleEle, "url"); ((DevTipRule)rule).Url = url; } String unit = XmlUtils.GetAttributeValue(ruleEle, "unit"); if (ruleName.Equals(RuleTypeEnumHelper.ToType(RuleTypeEnum.MAX_TARGET_SIZE_RULE)) && !StringUtil.IsEmpty(ruleValue)) { MaxTargetSizeRule mtsRule = (MaxTargetSizeRule)rule; mtsRule.Unit = unit; } else if (ruleName.Equals(RuleTypeEnumHelper.ToType(RuleTypeEnum.MIN_TARGET_SIZE_RULE)) && !StringUtil.IsEmpty(ruleValue)) { MinTargetSizeRule misRule = (MinTargetSizeRule)rule; misRule.Unit = unit; } String exProperty = XmlUtils.GetAttributeValue(ruleEle, "exProperty"); if (!StringUtil.IsEmpty(exProperty)) { rule.ExProperty = exProperty; } rule.Value = ruleValue; XmlElement dependGroupEle = XmlUtils.GetChildElement(ruleEle, "depend-group"); DependGroup dependGroup = ElementToDependGroup(dependGroupEle, fieldId); rule.DependGroup = dependGroup; return(rule); }
public Rule AddRule(RuleTypeEnum ruleType) { Rule rule = SchemaFactory.CreateRule(ruleType); this.Add(rule); return rule; }
public static string ToType(RuleTypeEnum ruleTypeEnum) { switch (ruleTypeEnum) { case RuleTypeEnum.MAX_LENGTH_RULE: return "maxLengthRule"; case RuleTypeEnum.MIN_LENGTH_RULE: return "minLengthRule"; case RuleTypeEnum.MAX_VALUE_RULE: return "maxValueRule"; case RuleTypeEnum.MIN_VALUE_RULE: return "minValueRule"; case RuleTypeEnum.MAX_INPUT_NUM_RULE: return "maxInputNumRule"; case RuleTypeEnum.MIN_INPUT_NUM_RULE: return "minInputNumRule"; case RuleTypeEnum.VALUE_TYPE_RULE: return "valueTypeRule"; case RuleTypeEnum.REQUIRED_RULE: return "requiredRule"; case RuleTypeEnum.DISABLE_RULE: return "disableRule"; case RuleTypeEnum.MAX_DECIMAL_DIGITS_RULE: return "maxDecimalDigitsRule"; case RuleTypeEnum.MIN_DECIMAL_DIGITS_RULE: return "minDecimalDigitsRule"; case RuleTypeEnum.REGEX_RULE: return "regexRule"; case RuleTypeEnum.SET_RULE: return "setRule"; case RuleTypeEnum.TIP_RULE: return "tipRule"; case RuleTypeEnum.DEV_TIP_RULE: return "devTipRule"; case RuleTypeEnum.READ_ONLY_RULE: return "readOnlyRule"; case RuleTypeEnum.MAX_TARGET_SIZE_RULE: return "maxTargetSizeRule"; case RuleTypeEnum.MIN_TARGET_SIZE_RULE: return "minTargetSizeRule"; case RuleTypeEnum.MAX_IMAGE_SIZE_RULE: return "maxImageSizeRule"; case RuleTypeEnum.MIN_IMAGE_SIZE_RULE: return "minImageSizeRule"; default: return ""; } }