Ejemplo n.º 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
            {
                try
                {
                    string ruleText = MacroRuleTree.GetRuleText(hdnValueTrim, true, true, TimeZoneTransformation);

                    // Display rule text
                    ltlMacro.Text    = ruleText;
                    txtMacro.Visible = false;
                    pnlRule.Visible  = true;

                    pnlUpdate.Update();

                    return;
                }
                catch
                {
                    // If failed to parse the rule, extract the condition
                    MacroExpression xml = MacroExpression.ExtractParameter(hdnValueTrim, "rule", 0);
                    if (xml != null)
                    {
                        string user;
                        hdnValue.Value = MacroSecurityProcessor.RemoveMacroSecurityParams(ValidationHelper.GetString(xml.Value, ""), out user);
                    }
                }
            }
        }


        if (string.IsNullOrEmpty(hdnValue.Value) && !string.IsNullOrEmpty(DefaultConditionText))
        {
            ltlMacro.Text    = DefaultConditionText;
            txtMacro.Text    = "";
            txtMacro.Visible = false;
            pnlRule.Visible  = true;
        }
        else
        {
            txtMacro.Text    = hdnValue.Value;
            hdnValue.Value   = null;
            txtMacro.Visible = true;
            pnlRule.Visible  = false;
        }

        pnlUpdate.Update();
    }
    /// <summary>
    /// Parses the rule tree from Rule expression.
    /// </summary>
    public void ParseFromExpression(string expression)
    {
        MacroExpression xml = MacroExpression.ExtractParameter(expression, "rule", 1);

        if (xml?.Type == ExpressionType.Value)
        {
            // Load from the XML
            LoadFromXML(xml.Value.ToString());
            return;
        }

        // If something went wrong, assign null to the state variable
        ViewState["RuleTree"] = null;
    }
Ejemplo n.º 3
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>
    /// Extracts the condition from Rule method.
    /// </summary>
    public string ConditionFromExpression(string expression)
    {
        MacroExpression xml = null;

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

        MacroIdentityOption identityOption;

        if (xml == null)
        {
            return(MacroSecurityProcessor.RemoveMacroSecurityParams(expression, out identityOption));
        }

        // Returns first parameter of the expression
        return(MacroSecurityProcessor.RemoveMacroSecurityParams(ValidationHelper.GetString(xml.Value, ""), out identityOption));
    }
Ejemplo n.º 5
0
    /// <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));
        }
    }