internal string FillTemplate(FeatureTemplate ftpl)
        {
            // Current template fields
            string[][] templateFields = new string[][]
            {
                new string[] { "$feature$", ftpl.FillTemplate() },
                new string[] { "01-09-2009", DateTime.Now.ToString("yyyy-MM-dd") },
                new string[] { "$time$", DateTime.Now.ToString("HH:mm:ss") },
                new string[] { "$date$", DateTime.Now.ToString("yyyy-MM-dd") },
                new string[] { "$user$", SystemInformation.UserName },
                new string[] { "$value$", ftpl.Context.ToString() },
                new string[] { "$$", "$" },
                new string[] { "^^", "^" },
                new string[] { "@@", "@" }
            };

            string output = Content;

            foreach (string[] kv in templateFields)
            {
                output = output.Replace(kv[0], kv[1]);
            }

            return(output);
        }
Esempio n. 2
0
            //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());
                }
            }
Esempio n. 3
0
        /// <summary>
        /// Generate the TOC
        /// </summary>
        private void PrepareTOC(Article.Article artc)
        {
            // Create a TOC Article
            Article.Article tocArticle = artc;

            FeatureTemplate tocTemplate = NonParameterizedTemplate.Spawn(FindTemplate(tocArticle.GetType().FullName, tocArticle), this, tocArticle) as FeatureTemplate;

            tocArticle.Title = tocArticle.Title ?? tocTemplate.GetTitle();

            // Populate Toc Article
            tocArticle.Content = globalTemplate.FillTemplate(tocTemplate);

            // Create child TOC if they are empty
            if (tocArticle.Children != null)
            {
                for (int i = 0; i < tocArticle.Children.Count; i++)
                {
                    PrepareTOC(tocArticle.Children.Data[i]);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Fill in template details
        /// </summary>
        public override string FillTemplate()
        {
            // Get the value of this item
            object value = ExecuteMethod(this.Context);

            if (value == null)
            {
                return("");
            }

            FeatureTemplate ftpl = NonParameterizedTemplate.Spawn(Parent.FindTemplate(value.GetType().FullName, value) as NonParameterizedTemplate, Parent, value) as FeatureTemplate;

            // Current template fields
            string[][] templateFields = new string[][]
            {
                new string[] { "$feature$", ftpl == null ? "" : ftpl.FillTemplate() },
                new string[] { "$date$", DateTime.Now.ToString("yyyy-MM-dd") },
                new string[] { "$time$", DateTime.Now.ToString("HH:mm:ss") },
                new string[] { "$user$", SystemInformation.UserName },
                new string[] { "$value$", this.Escaped ? value.ToString().Replace(">", "&gt;").Replace("<", "&lt;").Replace("$", "&#036;").Replace("@", "&#064;").Replace("^", "&#094;") : value.ToString().Replace("$", "&#036;").Replace("@", "&#064;").Replace("^", "&#094;").Replace("\\", "\\\\") }, // Clean Template parameters from TOSTRING()
                new string[] { "$$", "&#036;" },
                new string[] { "@@", "&#064;" },
                new string[] { "^^", "&#094;" },
                new string[] { "$version$", Assembly.GetEntryAssembly().GetName().Version.ToString() },
                new string[] { "$typeName$", Context == null ? "" : Context.GetType().Name }
            };

            // Output
            string output = Content.Clone() as string;

            foreach (string[] kv in templateFields)
            {
                output = output.Replace(kv[0], kv[1]);
            }

            return(output);
        }
        internal string FillTemplate(FeatureTemplate ftpl)
        {
            // Current template fields
            string[][] templateFields = new string[][] 
            {
                new string[] { "$feature$", ftpl.FillTemplate() },
                new string[] { "01-09-2009", DateTime.Now.ToString("yyyy-MM-dd") },
                new string[] { "$time$", DateTime.Now.ToString("HH:mm:ss") },
                new string[] { "$date$", DateTime.Now.ToString("yyyy-MM-dd") },
                new string[] { "$user$", SystemInformation.UserName },
                new string[] { "$value$", ftpl.Context.ToString()} ,
                new string[] { "$$", "&#036;" },
                new string[] { "^^", "&#094;" },
                new string[] { "@@", "&#064;" }
            };

            string output = Content;

            foreach (string[] kv in templateFields)
                output = output.Replace(kv[0], kv[1]);

            return output;
        }
Esempio n. 6
0
        public override string FillTemplate()
        {
            // First... see if there is a feature that could process this item
            if (Context == null)
            {
                return("");
            }

            FeatureTemplate ftpl = Content.Contains("$feature$") ? NonParameterizedTemplate.Spawn(Parent.FindTemplate(Context.GetType().FullName, Context) as NonParameterizedTemplate, Parent, Context) as FeatureTemplate : null;

            // Current template fields
            string[][] templateFields = new string[][]
            {
                new string[] { "$feature$", ftpl == null ? "" : ftpl.FillTemplate() },
                new string[] { "$date$", DateTime.Now.ToString("yyyy-MM-dd") },
                new string[] { "$time$", DateTime.Now.ToString("HH:mm:ss") },
                new string[] { "$user$", SystemInformation.UserName },
                new string[] { "$guid$", Guid.NewGuid().ToString() },
                new string[] { "$value$", escaped ? Context.ToString().Replace(">", "&gt;").Replace("<", "&lt;").Replace("$", "&#036;").Replace("@", "&#64;").Replace("^", "&#094;") : Context.ToString().Replace("$", "&#036;").Replace("@", "&#64;").Replace("^", "&#094;").Replace("\\", "\\\\") },             // Clean Template parameters from TOSTRING()
                new string[] { "$$", "&#036;" },
                new string[] { "@@", "&#064;" },
                new string[] { "^^", "&#094;" },
                new string[] { "$version$", Assembly.GetEntryAssembly().GetName().Version.ToString() },
                new string[] { "$typeName$", Context == null ? "" : Context.GetType().Name }
            };

            if (this.Context is Feature && (this.Context as Feature).Annotations.Exists(o => o is SuppressBrowseAnnotation))
            {
                System.Diagnostics.Trace.WriteLine(String.Format("Feature '{0}' won't be published as a SuppressBrowse annotation was found", (this.Context as Feature).Name), "warn");
                return("");
            }

            string output = Content.Clone() as string;

            foreach (string[] kv in templateFields)
            {
                output = output.Replace(kv[0], kv[1]);
            }

            // Process output for literals
            #region Literals
            while (output.Contains("$"))
            {
                int litPos = output.IndexOf('$');
                int ePos   = output.IndexOf('$', litPos + 1);

                System.Diagnostics.Debug.Assert(ePos != -1, String.Format("Template field not closed at '{0}'", this.Name));

                string parmName = output.Substring(litPos + 1, ePos - litPos - 1);

                // First, we'll look for a property template that has the specific name
                object content = GetContextPropertyValue(parmName);
                string value   = content == null ? "" : content.ToString().Replace("$", "&#036;").Replace("@", "&#064;").Replace("^", "&#094;");
                output = output.Replace(string.Format("${0}$", parmName), string.Format("{0}", value));
            }
            #endregion

            #region Arrays
            while (output.Contains("@"))
            {
                int    litPos   = output.IndexOf('@');
                int    ePos     = output.IndexOf('@', litPos + 1);
                string parmName = output.Substring(litPos + 1, ePos - litPos - 1);

                // First, we'll look for a property template that has the specific name
                object[] value = ConvertToObjectArray(GetContextPropertyValue(parmName));

                if (value != null)
                {
                    foreach (object o in value)
                    {
                        string ovalue = o == null ? "" : o.ToString().Replace("$", "&#36;").Replace("@", "&#64;").Replace("^", "&#094;");
                        output = output.Replace(string.Format("@{0}@", parmName), string.Format("{0}@{1}@", ovalue, parmName));
                    }
                    output = output.Replace(string.Format("@{0}@", parmName), "");
                }
                else
                {
                    output = output.Replace(string.Format("@{0}@", parmName), "");
                }
            }
            #endregion

            return(output);
        }
Esempio n. 7
0
        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);
        }