Example #1
0
        //=====================================================================

        /// <summary>
        /// This is called to perform the actual conversion
        /// </summary>
        public void ConvertTopics()
        {
            FileParser fileParser = new FileParser();
            string filename;

            this.ReportProgress("Conversion started at {0:MM/dd/yyyy hh:mm tt}\r\n",
                DateTime.Now);

            topics.AddTopicsFromFolder(sourcePath, topicDictionary);
            topics.ParseFiles(fileParser, imageDictionary);

            foreach(Topic t in topics)
                this.ConvertTopic(t);

            // Save the content layout and media content files
            filename = Path.Combine(destPath, "_ContentLayout.content");
            this.ReportProgress("Saving content layout file: {0}", filename);
            topics.Save(filename);

            if(images.Count != 0)
            {
                filename = Path.Combine(destPath, @"Media\_MediaFiles.xml");

                if(!Directory.Exists(Path.GetDirectoryName(filename)))
                    Directory.CreateDirectory(Path.GetDirectoryName(filename));

                this.ReportProgress("Saving media content file: {0}", filename);
                images.Save(filename);
            }

            if(tokens.Count != 0)
            {
                filename = Path.Combine(destPath, "_ContentTokens.tokens");
                this.ReportProgress("Saving tokens file: {0}", filename);
                
                using(StreamWriter sw = new StreamWriter(filename, false,
                  Encoding.UTF8))
                {
                    sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    sw.WriteLine("<content xml:space=\"preserve\" " +
                        "xmlns:ddue=\"http://ddue.schemas.microsoft.com/" +
                        "authoring/2003/5\" xmlns:xlink=\"http://www.w3.org/" +
                        "1999/xlink\">");

                    foreach(string key in tokens.Keys)
                        sw.WriteLine("  <item id=\"{0}\">{{@{1}}}</item>",
                            key, HttpUtility.HtmlEncode(tokens[key]));

                    sw.WriteLine("</content>");
                }
            }

            this.ReportProgress("\r\nConversion finished successfully at " +
                "{0:MM/dd/yyyy hh:mm tt}", DateTime.Now);
        }
Example #2
0
        //=====================================================================

        /// <summary>
        /// This is called to perform the actual conversion
        /// </summary>
        public void ConvertTopics()
        {
            FileParser fileParser = new FileParser();
            string     filename;

            this.ReportProgress("Conversion started at {0:MM/dd/yyyy hh:mm tt}\r\n",
                                DateTime.Now);

            topics.AddTopicsFromFolder(sourcePath, topicDictionary);
            topics.ParseFiles(fileParser, imageDictionary);

            foreach (Topic t in topics)
            {
                this.ConvertTopic(t);
            }

            // Save the content layout and media content files
            filename = Path.Combine(destPath, "_ContentLayout.content");
            this.ReportProgress("Saving content layout file: {0}", filename);
            topics.Save(filename);

            if (images.Count != 0)
            {
                filename = Path.Combine(destPath, @"Media\_MediaFiles.xml");

                if (!Directory.Exists(Path.GetDirectoryName(filename)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(filename));
                }

                this.ReportProgress("Saving media content file: {0}", filename);
                images.Save(filename);
            }

            if (tokens.Count != 0)
            {
                filename = Path.Combine(destPath, "_ContentTokens.tokens");
                this.ReportProgress("Saving tokens file: {0}", filename);

                using (StreamWriter sw = new StreamWriter(filename, false,
                                                          Encoding.UTF8))
                {
                    sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    sw.WriteLine("<content xml:space=\"preserve\" " +
                                 "xmlns:ddue=\"http://ddue.schemas.microsoft.com/" +
                                 "authoring/2003/5\" xmlns:xlink=\"http://www.w3.org/" +
                                 "1999/xlink\">");

                    foreach (string key in tokens.Keys)
                    {
                        sw.WriteLine("  <item id=\"{0}\">{{@{1}}}</item>",
                                     key, HttpUtility.HtmlEncode(tokens[key]));
                    }

                    sw.WriteLine("</content>");
                }
            }

            this.ReportProgress("\r\nConversion finished successfully at " +
                                "{0:MM/dd/yyyy hh:mm tt}", DateTime.Now);
        }
Example #3
0
        //=====================================================================

        /// <summary>
        /// Parse the topic and its sub-topic files to extract the information for conversion
        /// </summary>
        /// <param name="fileParser">The file parser</param>
        /// <param name="imageDictionary">The image dictionary</param>
        public void ParseFile(FileParser fileParser, Dictionary<FilePath, ImageReference> imageDictionary)
        {
            if(sourceFile != null && !String.IsNullOrEmpty(sourceFile.Path))
            {
                fileParser.ParseFile(sourceFile);

                if(fileParser.TopicId != Guid.Empty)
                    id = fileParser.TopicId;

                if(!String.IsNullOrEmpty(fileParser.RevisionNumber))
                    revisionNumber = fileParser.RevisionNumber;

                title = fileParser.Title;
                topicAbstract = fileParser.TopicAbstract;
                body = fileParser.Body;
                tocExclude = fileParser.TocExclude;
                defaultTopic = fileParser.IsDefaultTopic;
                splitToc = fileParser.SplitToc;
                sortOrder = fileParser.SortOrder;
                helpAttributes = fileParser.HelpAttributes;
                helpKeywords = fileParser.HelpKeywords;
            }

            subtopics.ParseFiles(fileParser, imageDictionary);
        }