Ejemplo n.º 1
0
        //public static void HtmlPagesToDocx(string file, string imageDirectory, IEnumerable<BlogDemoorDetailData> pages, string footerText = null)
        //{
        //    OXmlDoc.Create(file, HtmlPagesToOXmlElements(pages.Select(page => DetailDataToHtmlPage(page)), imageDirectory, footerText));
        //}

        public static void HtmlPagesToDocx(string file, string imageDirectory, IEnumerable <HtmlPage> pages, string footerText = null)
        {
            //HtmlToOXmlElements_v2 htmlToOXmlElements = HtmlToOXmlElements_v2.Create(BlogDemoor_v4.GetConfigElement().zXPathElement("HtmlToDocx"), imageDirectory);
            HtmlToOXmlElements_v2 htmlToOXmlElements = CreateHtmlToOXmlElements(BlogDemoor_v4.GetConfigElement(), imageDirectory);

            OXmlDoc.Create(file, HtmlPagesToOXmlElements(htmlToOXmlElements, pages, footerText));
        }
Ejemplo n.º 2
0
        public static IEnumerable <HtmlPage> GetHtmlPages(BlogDemoor_v4 dataManager, IEnumerable <int> detailIds)
        {
            IEnumerable <BlogDemoorDetailData> pages = ReadDetails(dataManager, detailIds);

            pages = pages.zAction(page => Trace.WriteLine($"title \"{page.Title}\" url \"{page.SourceUrl}\""));
            return(pages.Select(page => DetailDataToHtmlPage(page)));
        }
Ejemplo n.º 3
0
 public static IEnumerable <BlogDemoorDetailData> ReadDetails(BlogDemoor_v4 dataManager, IEnumerable <int> detailIds)
 {
     foreach (int detailId in detailIds)
     {
         yield return(dataManager.DetailDataManager.LoadFromId(detailId));
     }
 }
Ejemplo n.º 4
0
        public static void Test_Trace_HtmlToOXml_v2(string file, string imageDirectory)
        {
            string traceFile = file + ".oxml.json";
            //HtmlToOXmlElements_v2.ToOXmlXElements(HtmlDocReader.ReadFile(file), imageDirectory).zSave(traceFile);
            //HtmlToOXmlElements_v2 htmlToOXmlElements = HtmlToOXmlElements_v2.Create(BlogDemoor_v4.GetConfigElement().zXPathElement("HtmlToDocx"), imageDirectory);
            HtmlToOXmlElements_v2 htmlToOXmlElements = CreateHtmlToOXmlElements(BlogDemoor_v4.GetConfigElement(), imageDirectory);

            htmlToOXmlElements.ToOXmlXElements(HtmlDocReader.ReadFile(file)).zSave(traceFile, jsonIndent: true);
        }
Ejemplo n.º 5
0
        public static void Test_BlogDemoorToDocx(string file, IEnumerable <int> detailIds, string footerText, string parameters = null)
        {
            BlogDemoor_v4 dataManager = WebData.CreateDataManager_v4(parameters);

            //IEnumerable<BlogDemoorDetailData> pages = ReadDetails(dataManager, detailIds);
            //pages = pages.zAction(page => Trace.WriteLine($"title \"{page.Title}\" url \"{page.SourceUrl}\""));
            //IEnumerable<HtmlPage> htmlPages = pages.Select(page => DetailDataToHtmlPage(page));
            //string imageDirectory = dataManager.DetailDataManager.WebLoadImageManager.WebImageCacheManager.UrlCache.CacheDirectory;
            //HtmlToOXmlElements_v2 htmlToOXmlElements = HtmlToOXmlElements_v2.Create(dataManager.ConfigElement.zXPathElement("HtmlToDocx"), imageDirectory);
            OXmlDoc.Create(file, HtmlPagesToOXmlElements(CreateHtmlToOXmlElements(dataManager), GetHtmlPages(dataManager, detailIds), footerText));
        }
Ejemplo n.º 6
0
        //public static void Test_HtmlToDocx_v1(string file, string imageDirectory, string oxmlHeaderFile = null, string title = null)
        //{
        //    IEnumerable<OXmlElement> elements = new OXmlElement[0];
        //    if (oxmlHeaderFile != null)
        //        elements = zmongo.BsonRead<OXmlElement>(oxmlHeaderFile);
        //    if (title != null)
        //        elements = elements.Union(GetTitle(title));
        //    OXmlDoc.Create(file + ".docx", elements.Union(HtmlToOXmlElements_v2.ToOXmlXElements(HtmlDocReader.ReadFile(file), imageDirectory)));
        //}

        //public static void Test_HtmlPagesToDocx(string file, string imageDirectory, string title, string date, string footerText = null)
        //{
        //    HtmlPage htmlPage = new HtmlPage { Title = title, Date = date, HtmlNodes = HtmlDocReader.ReadFile(file) };
        //    HtmlPagesToDocx(file + ".docx", imageDirectory, new HtmlPage[] { htmlPage, htmlPage, htmlPage }, footerText);
        //}

        public static void Test_BlogDemoorToDocx(string file, string footerText, int limit = 0, int skip = 0, string parameters = null)
        {
            BlogDemoor_v4 dataManager = WebData.CreateDataManager_v4(parameters);

            //IEnumerable<BlogDemoorDetailData> pages = dataManager.HeaderDetailManager.LoadDetails(startPage, maxPage, reloadHeaderPage, reloadDetail, loadImageFromWeb, loadImageToData, refreshImage, refreshDocumentStore);
            //pages = pages.Reverse();
            //if (limit != 0)
            //    pages = pages.Take(limit);
            //pages = pages.zAction(page => Trace.WriteLine($"title \"{page.Title}\" url \"{page.SourceUrl}\""));
            //IEnumerable<HtmlPage> htmlPages = pages.Select(page => DetailDataToHtmlPage(page));
            //string imageDirectory = dataManager.DetailDataManager.WebLoadImageManager.WebImageCacheManager.UrlCache.CacheDirectory;
            //HtmlToOXmlElements_v2 htmlToOXmlElements = HtmlToOXmlElements_v2.Create(dataManager.ConfigElement.zXPathElement("HtmlToDocx"), imageDirectory);
            OXmlDoc.Create(file, HtmlPagesToOXmlElements(CreateHtmlToOXmlElements(dataManager), GetHtmlPages(dataManager, limit, skip), footerText));
        }
Ejemplo n.º 7
0
        public static void Test_HtmlToDocx(string file, string imageDirectory, string title = null, string footerText = null)
        {
            IEnumerable <OXmlElement> elements =
                GetDocDefaults().Union(
                    GetStyles()).Union(
                    GetDocSection()).Union(
                    GetHeaderFooter(footerText));

            if (title != null)
            {
                elements = elements.Union(GetTitle(title));
            }
            //HtmlToOXmlElements_v2 htmlToOXmlElements = HtmlToOXmlElements_v2.Create(BlogDemoor_v4.GetConfigElement().zXPathElement("HtmlToDocx"), imageDirectory);
            HtmlToOXmlElements_v2 htmlToOXmlElements = CreateHtmlToOXmlElements(BlogDemoor_v4.GetConfigElement(), imageDirectory);

            //elements = elements.Union(HtmlToOXmlElements_v2.ToOXmlXElements(HtmlDocReader.ReadFile(file), imageDirectory));
            elements = elements.Union(htmlToOXmlElements.ToOXmlXElements(HtmlDocReader.ReadFile(file)));
            OXmlDoc.Create(file + ".docx", elements);
        }
Ejemplo n.º 8
0
        public static void Test_BlogDemoorToOXml(string file, IEnumerable <int> detailIds, string footerText, string parameters = null)
        {
            BlogDemoor_v4 dataManager = WebData.CreateDataManager_v4(parameters);
            //string imageDirectory = dataManager.DetailDataManager.WebLoadImageManager.WebImageCacheManager.UrlCache.CacheDirectory;
            //HtmlToOXmlElements_v2 htmlToOXmlElements = HtmlToOXmlElements_v2.Create(dataManager.ConfigElement.zXPathElement("HtmlToDocx"), imageDirectory);
            HtmlToOXmlElements_v2 htmlToOXmlElements = CreateHtmlToOXmlElements(dataManager);
            int i = 0;

            foreach (HtmlPage page in GetHtmlPages(dataManager, detailIds))
            {
                string traceFile = file;
                if (i != 0)
                {
                    traceFile += $".{i}";
                }
                traceFile += ".oxml.json";
                //htmlToOXmlElements.ToOXmlXElements(page.HtmlNodes).zSave(traceFile, jsonIndent: true);
                HtmlPageToOXmlElements(htmlToOXmlElements, page, footerText).zSave(traceFile, jsonIndent: true);
            }
        }
Ejemplo n.º 9
0
        public static IEnumerable <HtmlPage> GetHtmlPages(BlogDemoor_v4 dataManager, int limit = 0, int skip = 0)
        {
            int  startPage            = 1;
            int  maxPage              = 0;
            bool reloadHeaderPage     = false;
            bool reloadDetail         = false;
            bool loadImageFromWeb     = false;
            bool loadImageToData      = false;
            bool refreshImage         = false;
            bool refreshDocumentStore = false;
            IEnumerable <BlogDemoorDetailData> pages = dataManager.HeaderDetailManager.LoadDetails(startPage, maxPage, reloadHeaderPage, reloadDetail, loadImageFromWeb, loadImageToData, refreshImage, refreshDocumentStore);

            pages = pages.Reverse();
            if (skip != 0)
            {
                pages = pages.Skip(skip);
            }
            if (limit != 0)
            {
                pages = pages.Take(limit);
            }
            pages = pages.zAction(page => Trace.WriteLine($"title \"{page.Title}\" url \"{page.SourceUrl}\""));
            return(pages.Select(page => DetailDataToHtmlPage(page)));
        }
Ejemplo n.º 10
0
 public static HtmlToOXmlElements_v2 CreateHtmlToOXmlElements(BlogDemoor_v4 dataManager)
 {
     return(CreateHtmlToOXmlElements(dataManager.ConfigElement, dataManager.DetailDataManager.WebLoadImageManager.WebImageCacheManager.UrlCache.CacheDirectory));
 }