Example #1
0
    private void RefreshText()
    {
        string hdnValueTrim = hdnValue.Value.Trim();

        if (hdnValueTrim.StartsWithCSafe("rule(", true))
        {
            // Empty rule designer condition is not considered as rule conditions
            if (hdnValueTrim.EqualsCSafe("Rule(\"\", \"<rules></rules>\")", true))
            {
                hdnValue.Value = "";
            }
            else
            {
                bool   failToParseXml = false;
                string ruleText       = MacroRuleTree.GetRuleText(hdnValueTrim, true, out failToParseXml);
                if (failToParseXml)
                {
                    // If failed to parse the rule, extract the condition
                    MacroExpression xml = MacroExpression.ExtractParameter(hdnValueTrim, "rule", 0);
                    if (xml != null)
                    {
                        string user = null;
                        hdnValue.Value = MacroResolver.RemoveMacroSecurityParams(ValidationHelper.GetString(xml.Value, ""), out user);
                    }
                }
                else
                {
                    // Display rule text
                    ltlMacro.Text    = ruleText;
                    txtMacro.Visible = false;
                    pnlRule.Visible  = true;
                    return;
                }
            }
        }

        txtMacro.Text    = hdnValue.Value;
        hdnValue.Value   = null;
        txtMacro.Visible = true;
        pnlRule.Visible  = false;

        pnlUpdate.Update();
    }
    /// <summary>
    /// Extracs the condition from Rule method.
    /// </summary>
    public string ConditionFromExpression(string expression)
    {
        MacroExpression xml = null;

        try
        {
            xml = MacroExpression.ExtractParameter(expression, "rule", 1);
        }
        catch { }


        string user = null;

        if (xml == null)
        {
            return(MacroResolver.RemoveMacroSecurityParams(expression, out user));
        }
        else
        {
            // Returns first parameter of the expression
            return(MacroResolver.RemoveMacroSecurityParams(ValidationHelper.GetString(xml.Value, ""), out user));
        }
    }