Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves a page from the wiki and save it locally in order to be merged to the active document.
        /// </summary>
        /// <param name="pageFullName">The full name of the wiki page.</param>
        /// <param name="localFileName">String reference to the file path of the created document.</param>
        private void OpenForMerge(String pageFullName, out String localFileName)
        {
            String content = Client.GetRenderedPageContent(pageFullName);
            String suffix  = "__LATEST";
            String folder  = addin.AddinSettings.PagesRepository + "TempPages";

            localFileName = pageFullName.Replace(".", "-") + suffix;
            ConvertToNormalFolder(folder);
            ConversionManager pageConverter;

            //TODO: The converter info should be merged.
            pageConverter = new ConversionManager(addin.AddinSettings, addin.serverURL, folder, pageFullName, localFileName, addin.Client);
            //pageConverters.Add(pageFullName + suffix, pageConverter);

            content       = pageConverter.ConvertFromWebToWord(content);
            localFileName = folder + "\\" + localFileName + ".html";
            addin.currentLocalFilePath = localFileName;
            StringBuilder pageContent = new StringBuilder(content);

            //Process the content
            pageContent.Insert(0, startDocument);
            pageContent.Append(endDocument);
            //Save the file
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            StreamWriter writer = new StreamWriter(localFileName, false, Encoding.UTF8);

            writer.Write(pageContent.ToString());
            writer.Close();
        }