/// <summary> /// The event this handles fires after a document is published in the back office and the cache is updated. /// We render out the page and store it's HTML in the database for retrieval by the indexer. /// </summary> /// <param name="sender">Document being published</param> /// <param name="e">Event Arguments</param> /// <remarks> /// the indexer thread doesn't always access to a fully initialised umbraco core to do the rendering, /// whereas this event always should, hence this method rather than doing both rendering and indexing /// in the same thread /// </remarks> private void ContentAfterUpdateDocumentCache(Document sender, DocumentCacheEventArgs e) { if (sender == null || sender.Id < 1) { return; } var id = sender.Id; // get config and check we're enabled and good to go if (!CheckConfig()) { return; } // this can take a while... Library.SetTimeout(Config.Instance.GetByKey("ScriptTimeout")); var nodeTypeAlias = sender.ContentType.Alias; var renderer = Manager.Instance.DocumentRendererFactory.CreateNew(nodeTypeAlias); string fullHtml; if (renderer.Render(id, out fullHtml)) { HtmlCache.Store(id, ref fullHtml); } else { HtmlCache.Remove(id); } }
/// <summary> /// Render a single document to cache /// </summary> /// <param name="Content"></param> protected static void RenderNodeToCache(IContent Content) { if (Content != null && Content.Trashed != true && Content.Published) { /*if (doc.PublishWithResult(user)) * { * umbraco.library.UpdateDocumentCache(doc.Id); * }*/ var nodeTypeAlias = Content.ContentType.Alias; var renderer = Manager.Instance.DocumentRendererFactory.CreateNew(nodeTypeAlias); string fullHtml; if (renderer.Render(Content.Id, out fullHtml)) { HtmlCache.Store(Content.Id, ref fullHtml); } else { HtmlCache.Remove(Content.Id); } } }