コード例 #1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            RouteCollection routes = RouteTable.Routes;

            PageRouteService pageRouteService = new PageRouteService(new Rock.Data.RockContext());
            var pageRoutes = pageRouteService.Queryable().ToList();


            // Check to see if we have any missing routes.  If so, simply run reregister.
            foreach (var pageRoute in pageRoutes)
            {
                var route = routes.OfType <Route>().Where(a => a.Url == pageRoute.Route && a.PageIds().Contains(pageRoute.PageId)).FirstOrDefault();

                if (route == null)
                {
                    nbNotification.NotificationBoxType = Rock.Web.UI.Controls.NotificationBoxType.Warning;
                    nbNotification.Text = "Routes were out-of-date.  Running reregister routes.";

                    ReRegisterRoutes();
                    break;
                }
            }

            // Check to see if we have any missing shortcodes
            var outOfDate = RockDateTime.Now.AddMinutes(-30);
            var sc        = new LavaShortcodeService(new Rock.Data.RockContext()).Queryable().Where(l => l.CreatedDateTime > outOfDate || l.ModifiedDateTime > outOfDate).ToList();

            if (sc.Count > 0)
            {
                nbNotification.NotificationBoxType = Rock.Web.UI.Controls.NotificationBoxType.Warning;
                nbNotification.Text = "Shortcodes were out-of-date.  Running register shortcodes. " + sc.Count;
                foreach (var code in sc)
                {
                    // register shortcode
                    if (code.TagType == TagType.Block)
                    {
                        Template.RegisterShortcode <DynamicShortcodeBlock>(code.TagName);
                    }
                    else
                    {
                        Template.RegisterShortcode <DynamicShortcodeInline>(code.TagName);
                    }
                }

                LavaShortcodeCache.Clear();
            }
        }
コード例 #2
0
 /// <summary>
 /// Clears all of the entries from the shortcode cache.
 /// </summary>
 public static void ClearCache()
 {
     LavaShortcodeCache.Clear();
 }