Example #1
0
        /// <summary>
        /// Returns the message to be displayed when a node publishing limit has been reached
        /// </summary>
        /// <returns></returns>
        public string GetMessage()
        {
            //Custom message overrides everything
            if (!string.IsNullOrEmpty(CustomMessage))
            {
                return(CustomMessage);
            }

            //Return a standard message if this rule is created on the fly based on a special document property value
            if (FromProperty)
            {
                return(string.Format("Node saved but not published. Max allowed child nodes for this specific node: {0}.", MaxNodes.ToString()));
            }

            //This is the message that is returned when a rule is in the config file, and no custom message has been defined.
            return(string.Format(
                       "Node saved but not published. Max allowed nodes {1} directly under {2}: {0}."
                       , MaxNodes.ToString()
                       , ChildDocType.Equals("*") ? "of any type" : string.Format("of type \"{0}\"", ChildDocType)
                       , ParentDocType.Equals("*") ? "any node" : string.Format("nodes of type \"{0}\"", ParentDocType)
                       ));
        }
Example #2
0
        /// <summary>
        /// Returns the warning message to be displayed on publishing a node when a rule is in effect but the limit has not been reached.
        /// </summary>
        /// <param name="currentNodeCount"></param>
        /// <returns></returns>
        public string GetWarningMessage(int currentNodeCount)
        {
            //Custom message overrides everything
            if (!string.IsNullOrEmpty(CustomWarningMessage))
            {
                return(CustomWarningMessage);
            }

            //Return a standard message if this rule is created on the fly based on a special document property value
            if (FromProperty)
            {
                return(string.Format("Restrictions for this node are in place. You have published {0} out {1} allowed child nodes.", (currentNodeCount + 1).ToString(), MaxNodes.ToString()));
            }

            //This is the message that is returned when a rule is in the config file, and no custom message has been defined.
            return(string.Format(
                       "Restrictions in place. {3} directly under {2}: {1} of {0} allowed."
                       , MaxNodes.ToString()
                       , (currentNodeCount + 1).ToString()
                       , ParentDocType.Equals("*") ? "any node" : string.Format("nodes of type \"{0}\"", ParentDocType)
                       , ChildDocType.Equals("*") ? "Any node" : string.Format("Nodes of type \"{0}\"", ChildDocType)
                       ));
        }