protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { //list to the init event of the application base, this allows us to bind to the actual HttpApplication events UmbracoApplicationBase.ApplicationInit += UmbracoApplicationBase_ApplicationInit; // Map the Custom routes DialogueRoutes.MapRoutes(RouteTable.Routes, UmbracoContext.Current.ContentCache, UmbracoContext.Current.UrlProvider); MemberService.Saved += MemberServiceSaved; MemberService.Deleting += MemberServiceOnDeleting; ContentService.Trashing += ContentService_Trashing; PageCacheRefresher.CacheUpdated += PageCacheRefresher_CacheUpdated; DomainCacheRefresher.CacheUpdated += DomainCacheRefresher_CacheUpdated; // Sync the badges // Do the badge processing var unitOfWorkManager = new UnitOfWorkManager(ContextPerRequest.Db); using (var unitOfWork = unitOfWorkManager.NewUnitOfWork()) { try { ServiceFactory.BadgeService.SyncBadges(); unitOfWork.Commit(); } catch (Exception ex) { AppHelpers.LogError(string.Format("Error processing badge classes: {0}", ex.Message)); } } }
/// <summary> /// At the end of a request, we'll check if there is a flag in the request indicating to rebuild the routes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// In some cases many articulate roots might be published at one time but we only want to rebuild the routes once so we'll do it once /// at the end of the request. /// </remarks> private static void UmbracoApplication_PostRequestHandlerExecute(object sender, EventArgs e) { if (ApplicationContext.Current == null) { return; } if (ApplicationContext.Current.ApplicationCache.RequestCache.GetCacheItem("dialogue-refresh-routes") == null) { return; } //the token was found so that means one or more articulate root nodes were changed in this request, rebuild the routes. DialogueRoutes.MapRoutes(RouteTable.Routes, UmbracoContext.Current.ContentCache, UmbracoContext.Current.UrlProvider); }