/// <summary> /// Creates a new ViewSnippet Form and precompiles this form with the content of the given snippet /// </summary> /// <param name="pluginManager"></param> /// <param name="snippetId">ID of the snppet to display</param> public static IManageSnippetForm PrepareViewSnippetForm(IPluginManager pluginManager, long snippetId) { if (pluginManager == null) { return(null); } if (snippetId <= 0) { return(null); } // read snippets and populate the List SnippetsWS snippetRepo = new SnippetsWS(); log.DebugFormat("Reading snippet {0}", snippetId); Snippet snip = snippetRepo.GetSnippetByID(snippetId); if (snip == null) { log.WarnFormat("Snippet {0} is null", snippetId); return(null); } //CG: Add +1 to the view stats System.Threading.Tasks.Task.Factory.StartNew(() => snippetRepo.StoreHit(snip)); // Open "Add Snippet" Window log.DebugFormat("Loading snippet {0}", snippetId); pluginManager.ClosePublishSnippetWindow(); IManageSnippetForm viewSnipForm = pluginManager.CreateViewSnippetForm(); viewSnipForm.PrepareViewSnippet(snip); return(viewSnipForm); }
/// <summary> /// Creates a new ViewSnippet Form and precompiles this form with the content of the given snippet /// </summary> /// <param name="pluginManager"></param> /// <param name="snippetId">ID of the snppet to display</param> public static IManageSnippetForm PrepareViewSnippetForm(IPluginManager pluginManager, long snippetId) { if (pluginManager == null) return null; if (snippetId <= 0) return null; // read snippets and populate the List SnippetsWS snippetRepo = new SnippetsWS(); log.DebugFormat("Reading snippet {0}", snippetId); Snippet snip = snippetRepo.GetSnippetByID(snippetId); if (snip == null) { log.WarnFormat("Snippet {0} is null", snippetId); return null; } //CG: Add +1 to the view stats System.Threading.Tasks.Task.Factory.StartNew(() => snippetRepo.StoreHit(snip)); // Open "Add Snippet" Window log.DebugFormat("Loading snippet {0}", snippetId); pluginManager.ClosePublishSnippetWindow(); IManageSnippetForm viewSnipForm = pluginManager.CreateViewSnippetForm(); viewSnipForm.PrepareViewSnippet(snip); return viewSnipForm; }