//DOC: Documentation Required /// <summary> /// /// </summary> public void Start(object state) { // Process the global template Article.Article art = new MohawkCollege.EHR.gpmr.Pipeline.Renderer.Deki.Article.Article(); //if (FeatureTemplate.Feature.Contains(".SubSystem")) // System.Diagnostics.Debugger.Break(); // Process the global template art.Content = FeatureTemplate.FillTemplate(); art.Title = FeatureTemplate.GetTitle(); art.Name = FeatureTemplate.Context is Feature ? (FeatureTemplate.Context as Feature).Name : art.Title; art.Abstract = FeatureTemplate.GetAbstract(); string ParentName = FeatureTemplate.GetPath(); // Modify the article collection lock (ArticleCollection) { // See if master appears anywhere? if (ParentName == null && ArticleCollection.Find(ParentName) == null) { ArticleCollection.Add(art); } else if (ParentName == null) { foreach (Article.Article cart in ArticleCollection.Find(ParentName).Children ?? new ArticleCollection()) { art.Children.Add(cart); } ArticleCollection.Remove(ArticleCollection.Find(ParentName)); ArticleCollection.Add(art); } else if (ArticleCollection.Find(ParentName) != null) { if (ArticleCollection.Find(ParentName).Children == null) { ArticleCollection.Find(ParentName).Children = new ArticleCollection(); } ArticleCollection.Find(ParentName).Children.Add(art); } else { Article.Article Parent = new MohawkCollege.EHR.gpmr.Pipeline.Renderer.Deki.Article.Article(); Parent.Title = ParentName; Parent.Children = new ArticleCollection(); ArticleCollection.Add(Parent); Parent.Children.Add(art); } } if (this.OnComplete != null) { OnComplete(this, new EventArgs()); } }
//DOC: Documentation Required /// <summary> /// /// </summary> public void Start(object state) { // Process the global template Article.Article art = new MohawkCollege.EHR.gpmr.Pipeline.Renderer.Deki.Article.Article(); //if (FeatureTemplate.Feature.Contains(".SubSystem")) // System.Diagnostics.Debugger.Break(); // Process the global template art.Content = FeatureTemplate.FillTemplate(); art.Title = FeatureTemplate.GetTitle(); art.Name = FeatureTemplate.Context is Feature ? (FeatureTemplate.Context as Feature).Name : art.Title; art.Abstract = FeatureTemplate.GetAbstract(); string ParentName = FeatureTemplate.GetPath(); // Modify the article collection lock (ArticleCollection) { // See if master appears anywhere? if (ParentName == null && ArticleCollection.Find(ParentName) == null) ArticleCollection.Add(art); else if (ParentName == null) { foreach (Article.Article cart in ArticleCollection.Find(ParentName).Children ?? new ArticleCollection()) art.Children.Add(cart); ArticleCollection.Remove(ArticleCollection.Find(ParentName)); ArticleCollection.Add(art); } else if (ArticleCollection.Find(ParentName) != null) { if (ArticleCollection.Find(ParentName).Children == null) ArticleCollection.Find(ParentName).Children = new ArticleCollection(); ArticleCollection.Find(ParentName).Children.Add(art); } else { Article.Article Parent = new MohawkCollege.EHR.gpmr.Pipeline.Renderer.Deki.Article.Article(); Parent.Title = ParentName; Parent.Children = new ArticleCollection(); ArticleCollection.Add(Parent); Parent.Children.Add(art); } } if (this.OnComplete != null) OnComplete(this, new EventArgs()); }
private void PersistArticle(MohawkCollege.EHR.gpmr.Pipeline.Renderer.Deki.Article.Article art, string p) { Dictionary <string, StringCollection> parameters = hostContext.Data["CommandParameters"] as Dictionary <string, StringCollection>; string path = parameters.ContainsKey("deki-nopub-root") ? parameters["deki-nopub-root"][0] : p; // Step 1. Check that dir exists if (!Directory.Exists(p)) { Directory.CreateDirectory(p); } if (!Directory.Exists(Path.GetDirectoryName(Path.Combine(p, art.Url.Replace("/", "\\"))))) { Directory.CreateDirectory(Path.GetDirectoryName(Path.Combine(p, art.Url.Replace("/", "\\")))); } // Step 2. Prepare a writer, etc... TextWriter tw = null; try { tw = File.CreateText(Path.ChangeExtension(Path.Combine(p, art.Url), ".html")); tw.Write(string.Format("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"><head><title>{1}</title><style type=\"text/css\"><!--{2}--></style></head><body><h1>{1}</h1>{0}</body></html>", art.Content.Replace("href=\"~", string.Format("href=\"file://{0}", path)).Replace(".deki\"", ".html\"").Replace(".deki#", ".html#"), art.Title, docTemplate.Style)); tw.Close(); System.Diagnostics.Trace.Write(".", "debug"); // Children... create a dir and store em if (art.Children != null) { foreach (Article.Article child in art.Children) { PersistArticle(child, p); } } } catch { throw; } finally { if (tw != null) { tw.Close(); } } }
private void PublishArticle(DekiCommunicator dc, MohawkCollege.EHR.gpmr.Pipeline.Renderer.Deki.Article.Article a, string path, Dictionary <string, String> properties) { // Clean article to remove .html string Html = a.Content.Replace(".deki\"", "\""); Html = Html.Replace(".deki#", "#"); Html = Html.Replace("\"~/", string.Format("\"{0}/", path)); // Publish away! path = path.Replace("/", "%2f"); // Try twice to publish for (int i = 0; i < 5; i++) { try { dc.Publish(Html, string.Format("{0}%2f{1}", path, a.Url.Replace("/", "%2f")), a.Title); foreach (var kv in properties) { try { dc.PublishProperty(kv.Key, kv.Value, string.Format("{0}%2f{1}", path, a.Url.Replace("/", "%2f"))); } catch { } // Don't care if properties are not published } // Throttling is required to allow time for the MySQL server in deki to catch-up with the // GPMR process. This is needed because the MySQL server on Deki-Hayes can become bogged // down when submitting massive amounts of content. Thread.Sleep(250); break; } catch (Exception e) { System.Diagnostics.Trace.WriteLine(string.Format("{0}, retrying publish operation for {1}", e.Message, a.Title), "warn"); } } System.Diagnostics.Trace.Write(".", "information"); if (a.Children != null) { foreach (Article.Article ca in a.Children) { PublishArticle(dc, ca, path, properties); } } }
public ArticleCollection Process(ClassRepository rep) { ArticleCollection artc = new ArticleCollection(); List<Feature> features = new List<Feature>(); foreach (KeyValuePair<string, Feature> kv in rep) features.Add(kv.Value); // Sort so classes are processed first features.Sort(delegate(Feature a, Feature b) { if ((a is SubSystem) && !(b is SubSystem)) return -1; else if ((b is SubSystem) && !(a is SubSystem)) return 1; else if ((a is Class) && !(b is Class)) return 1; else if ((b is Class) && !(a is Class)) return -1; else return a.GetType().Name.CompareTo(b.GetType().Name); }); //var vocabArticle = new MohawkCollege.EHR.gpmr.Pipeline.Renderer.Deki.Article.Article() //{ // Title = "Vocabulary", // Children = new ArticleCollection() //}; //vocabArticle.Children.Add(new Article.Article() { Title = "Code Systems" }); //vocabArticle.Children.Add(new Article.Article() { Title = "Concept Domains" }); //vocabArticle.Children.Add(new Article.Article() { Title = "Value Sets" }); //artc.Add(vocabArticle); WaitThreadPool wtp = new WaitThreadPool(); // A thread that does the doohickey thing Thread doohickeyThread = new Thread((ThreadStart)delegate() { string[] hickeythings = { "|", "/", "-", "\\" }; int hickeyThingCount = 0; try { while (true) { int cPosX = Console.CursorLeft, cPosY = Console.CursorTop; Console.SetCursorPosition(1, cPosY); Console.Write(hickeythings[hickeyThingCount++ % hickeythings.Length]); Console.SetCursorPosition(cPosX, cPosY); Thread.Sleep(1000); } } catch { } }); doohickeyThread.Start(); // Loop through each feature foreach (Feature f in features) { // Find the feature template FeatureTemplate ftpl = NonParameterizedTemplate.Spawn(FindTemplate(f.GetType().FullName, f) as NonParameterizedTemplate, this, f) as FeatureTemplate; if (ftpl == null) System.Diagnostics.Trace.WriteLine(string.Format("Feature '{0}' won't be published as no feature template could be located", f.Name), "warn"); else if(f.Annotations.Find(o=>o is SuppressBrowseAnnotation) != null) System.Diagnostics.Trace.WriteLine(String.Format("Feature '{0}' won't be published as a SuppressBrowse annotation was found", f.Name), "warn"); else if(ftpl.NewPage) { System.Diagnostics.Trace.WriteLine(string.Format("Queueing ({1}) '{0}'...", f.Name, f.GetType().Name), "debug"); // Create a new worker Worker w = new Worker(); w.ArticleCollection = artc; w.FeatureTemplate = ftpl; w.OnComplete += delegate(object sender, EventArgs e) { Worker wrkr = sender as Worker; System.Diagnostics.Trace.WriteLine(String.Format("Rendered ({1}) '{0}'...", (wrkr.FeatureTemplate.Context as Feature).Name, wrkr.FeatureTemplate.Context.GetType().Name), "debug"); }; wtp.QueueUserWorkItem(w.Start); } } System.Diagnostics.Trace.WriteLine("Waiting for work items to complete...", "debug"); wtp.WaitOne(); doohickeyThread.Abort(); ArticleCollection retVal = new ArticleCollection(); Article.Article MasterTOC = new MohawkCollege.EHR.gpmr.Pipeline.Renderer.Deki.Article.Article(); MasterTOC.Children = artc; System.Diagnostics.Trace.WriteLine("Creating Table of Contents...", "information"); PrepareTOC(MasterTOC); MasterTOC.Children = null; artc.Add(MasterTOC); return artc; }
public ArticleCollection Process(ClassRepository rep) { ArticleCollection artc = new ArticleCollection(); List <Feature> features = new List <Feature>(); foreach (KeyValuePair <string, Feature> kv in rep) { features.Add(kv.Value); } // Sort so classes are processed first features.Sort(delegate(Feature a, Feature b) { if ((a is SubSystem) && !(b is SubSystem)) { return(-1); } else if ((b is SubSystem) && !(a is SubSystem)) { return(1); } else if ((a is Class) && !(b is Class)) { return(1); } else if ((b is Class) && !(a is Class)) { return(-1); } else { return(a.GetType().Name.CompareTo(b.GetType().Name)); } }); //var vocabArticle = new MohawkCollege.EHR.gpmr.Pipeline.Renderer.Deki.Article.Article() //{ // Title = "Vocabulary", // Children = new ArticleCollection() //}; //vocabArticle.Children.Add(new Article.Article() { Title = "Code Systems" }); //vocabArticle.Children.Add(new Article.Article() { Title = "Concept Domains" }); //vocabArticle.Children.Add(new Article.Article() { Title = "Value Sets" }); //artc.Add(vocabArticle); WaitThreadPool wtp = new WaitThreadPool(); // A thread that does the doohickey thing Thread doohickeyThread = new Thread((ThreadStart) delegate() { string[] hickeythings = { "|", "/", "-", "\\" }; int hickeyThingCount = 0; try { while (true) { int cPosX = Console.CursorLeft, cPosY = Console.CursorTop; Console.SetCursorPosition(1, cPosY); Console.Write(hickeythings[hickeyThingCount++ % hickeythings.Length]); Console.SetCursorPosition(cPosX, cPosY); Thread.Sleep(1000); } } catch { } }); doohickeyThread.Start(); // Loop through each feature foreach (Feature f in features) { // Find the feature template FeatureTemplate ftpl = NonParameterizedTemplate.Spawn(FindTemplate(f.GetType().FullName, f) as NonParameterizedTemplate, this, f) as FeatureTemplate; if (ftpl == null) { System.Diagnostics.Trace.WriteLine(string.Format("Feature '{0}' won't be published as no feature template could be located", f.Name), "warn"); } else if (f.Annotations.Find(o => o is SuppressBrowseAnnotation) != null) { System.Diagnostics.Trace.WriteLine(String.Format("Feature '{0}' won't be published as a SuppressBrowse annotation was found", f.Name), "warn"); } else if (ftpl.NewPage) { System.Diagnostics.Trace.WriteLine(string.Format("Queueing ({1}) '{0}'...", f.Name, f.GetType().Name), "debug"); // Create a new worker Worker w = new Worker(); w.ArticleCollection = artc; w.FeatureTemplate = ftpl; w.OnComplete += delegate(object sender, EventArgs e) { Worker wrkr = sender as Worker; System.Diagnostics.Trace.WriteLine(String.Format("Rendered ({1}) '{0}'...", (wrkr.FeatureTemplate.Context as Feature).Name, wrkr.FeatureTemplate.Context.GetType().Name), "debug"); }; wtp.QueueUserWorkItem(w.Start); } } System.Diagnostics.Trace.WriteLine("Waiting for work items to complete...", "debug"); wtp.WaitOne(); doohickeyThread.Abort(); ArticleCollection retVal = new ArticleCollection(); Article.Article MasterTOC = new MohawkCollege.EHR.gpmr.Pipeline.Renderer.Deki.Article.Article(); MasterTOC.Children = artc; System.Diagnostics.Trace.WriteLine("Creating Table of Contents...", "information"); PrepareTOC(MasterTOC); MasterTOC.Children = null; artc.Add(MasterTOC); return(artc); }