/// <summary> /// Creates the rule from an Xml element /// </summary> /// <param name="element">The XmlElement from which to create the rule</param> public override void CreateFromXml(System.Xml.XmlElement element) { foreach (XmlElement child in element.ChildNodes) { if (child.Name.Equals("friendlyRule")) { this.friendlyRule = child.InnerText; } else if (child.Name.Equals("expression")) { this.expression = child.InnerText; } else if (child.Name.Equals("destinationColumnName")) { this.destinationColumnName = child.InnerText; } else if (child.Name.Equals("destinationColumnType")) { this.destinationColumnType = child.InnerText; } } if (DestinationColumnType.Equals("System.String")) { this.variableType = DashboardVariableType.Text; } else if (DestinationColumnType.Equals("System.DateTime")) { this.variableType = DashboardVariableType.Date; } else { this.variableType = DashboardVariableType.Numeric; } }
/// <summary> /// Constructor for conditional assignment with custom column type /// </summary> public Rule_ConditionalAssign(DashboardHelper dashboardHelper, string friendlyRule, string destinationColumnName, string destinationColumnType, /*Dictionary<string, object> conditions*/ object assignValue, object elseValue, string condition) { this.friendlyRule = friendlyRule; this.destinationColumnName = destinationColumnName; this.destinationColumnType = destinationColumnType; this.DashboardHelper = dashboardHelper; this.condition = condition; if (DestinationColumnType.Equals("System.String")) { this.variableType = DashboardVariableType.Text; } else if (DestinationColumnType.Equals("System.Boolean")) { this.variableType = DashboardVariableType.YesNo; } else { this.variableType = DashboardVariableType.Numeric; } //this.conditions = conditions; this.assignValue = assignValue; this.elseValue = elseValue; if (elseValue == null) { UseElse = false; } else { UseElse = true; } }
/// <summary> /// Constructor for simple assignment with custom column type /// </summary> public Rule_ExpressionAssign(DashboardHelper dashboardHelper, string friendlyRule, string destinationColumnName, string destinationColumnType, string expression) { this.friendlyRule = friendlyRule; this.destinationColumnName = destinationColumnName; this.destinationColumnType = destinationColumnType; this.DashboardHelper = dashboardHelper; if (DestinationColumnType.Equals("System.String")) { this.variableType = DashboardVariableType.Text; } else { this.variableType = DashboardVariableType.Numeric; } this.expression = expression; }
/// <summary> /// Creates the rule from an Xml element /// </summary> /// <param name="element">The XmlElement from which to create the rule</param> public override void CreateFromXml(System.Xml.XmlElement element) { foreach (XmlElement child in element.ChildNodes) { if (child.Name.ToLowerInvariant().Equals("friendlyrule")) { this.friendlyRule = child.InnerText.Replace("&", "&").Replace("<", "<").Replace(">", ">"); } else if (child.Name.ToLowerInvariant().Equals("destinationcolumnname")) { this.destinationColumnName = child.InnerText; } else if (child.Name.ToLowerInvariant().Equals("destinationcolumntype")) { this.destinationColumnType = child.InnerText; } else if (child.Name.ToLowerInvariant().Equals("datafilters")) { this.DataFilters = new DataFilters(this.dashboardHelper); this.DataFilters.CreateFromXml(child); } else if (child.Name.ToLowerInvariant().Equals("useelse")) { this.UseElse = bool.Parse(child.InnerText); } } if (DestinationColumnType.Equals("System.String")) { this.variableType = DashboardVariableType.Text; } else if (destinationColumnType.Equals("System.Boolean")) { this.variableType = DashboardVariableType.YesNo; } else { this.variableType = DashboardVariableType.Numeric; } foreach (XmlElement child in element.ChildNodes) { if (child.Name.ToLowerInvariant().Equals("assignvalue")) { if (child.InnerText.Equals(" ")) { this.assignValue = " "; } else { //this.assignValue = child.InnerText.Replace("&", "&").Replace("<", "<").Replace(">", ">"); string strValue = child.InnerText.Replace("&", "&").Replace("<", "<").Replace(">", ">"); if (variableType == DashboardVariableType.Numeric) { decimal d; bool success = Decimal.TryParse(strValue, NumberStyles.Any, CultureInfo.InvariantCulture, out d); if (success) { this.assignValue = d; } //this.elseValue = decimal.Parse() } else { this.assignValue = strValue; } } } else if (child.Name.ToLowerInvariant().Equals("elsevalue")) { if (child.InnerText.Equals(" ")) { this.elseValue = " "; } else { string strValue = child.InnerText.Replace("&", "&").Replace("<", "<").Replace(">", ">"); if (variableType == DashboardVariableType.Numeric) { decimal d; bool success = Decimal.TryParse(strValue, NumberStyles.Any, CultureInfo.InvariantCulture, out d); if (success) { this.elseValue = d; } //this.elseValue = decimal.Parse() } else { this.elseValue = strValue; } } } } }
/// <summary> /// Creates the rule from an Xml element /// </summary> /// <param name="element">The XmlElement from which to create the rule</param> public override void CreateFromXml(System.Xml.XmlElement element) { foreach (XmlElement child in element.ChildNodes) { if (child.Name.ToLower().Equals("friendlyrule")) { this.friendlyRule = child.InnerText.Replace("&", "&").Replace("<", "<").Replace(">", ">"); } else if (child.Name.ToLower().Equals("destinationcolumnname")) { this.destinationColumnName = child.InnerText; } else if (child.Name.ToLower().Equals("destinationcolumntype")) { this.destinationColumnType = child.InnerText; } else if (child.Name.ToLower().Equals("datafilters")) { this.DataFilters = new DataFilters(this.dashboardHelper); this.DataFilters.CreateFromXml(child); } else if (child.Name.ToLower().Equals("assignvalue")) { if (child.InnerText.Equals(" ")) { this.assignValue = " "; } else { this.assignValue = child.InnerText.Replace("&", "&").Replace("<", "<").Replace(">", ">"); } } else if (child.Name.ToLower().Equals("elsevalue")) { if (child.InnerText.Equals(" ")) { this.elseValue = " "; } else { this.elseValue = child.InnerText.Replace("&", "&").Replace("<", "<").Replace(">", ">"); } } else if (child.Name.ToLower().Equals("useelse")) { this.UseElse = bool.Parse(child.InnerText); } } if (DestinationColumnType.Equals("System.String")) { this.variableType = DashboardVariableType.Text; } else if (destinationColumnType.Equals("System.Boolean")) { this.variableType = DashboardVariableType.YesNo; } else { this.variableType = DashboardVariableType.Numeric; } }