예제 #1
0
        public void CreateCacheFolder(Data.ONNotebook notebook)
        {
            if (string.IsNullOrEmpty(BasedPath))
            {
                Log.Error("BasedPath cannot be null");
                return;
            }
            if (notebook == null)
            {
                Log.Error("Notebook cannot be null");
                throw new ArgumentNullException("notebook");
            }
            string baseDir = Path.Combine(BasedPath, notebook.Name);

            Directory.CreateDirectory(baseDir);

            if (Config.Current.RefreshCache)
            {
                Log.Information("Refreshing the cache folder");
                // delete entire cache folder
                Directory.Delete(baseDir, true);
            }
            SetIncludeOnlySection(notebook);
            SetExcludeSection(notebook);

            foreach (Data.ONSection section in notebook.Sections)
            {
                if (!section.Exclude)
                {
                    PDFExportSection(baseDir, section);
                }
            }
        }
예제 #2
0
        private void PDFCombineAll(string basedName, Data.ONNotebook notebook)
        {
            if (notebook == null)
            {
                throw new ArgumentNullException("notebook");
            }

            if (!InitDocument(Path.Combine(basedName, notebook.Name) + ".pdf"))
            {
                return;
            }

            TOCHandler.Init(pdfDocument, pdfWriter);

            PdfOutline root = pdfWriter.DirectContent.RootOutline;

            TOCHandler.BeginTocEntry();
            foreach (Data.ONSection section in notebook.Sections)
            {
                if (!section.Exclude)
                {
                    TOCHandler.AddTocEntry(section.Name, pdfWriter.CurrentPageNumber);
                    TOCHandler.BeginTocEntry();
                    PDFCombineSection(root, section);
                    TOCHandler.EndTocEntry();
                }
            }
            TOCHandler.EndTocEntry();

            TOCHandler.WriteTocEntries();
            TOCHandler.Close();
            CloseDocument();
        }
예제 #3
0
        private Data.ONNotebook SelectNotebook(string notebookName, string xml)
        {
            try
            {
                XDocument outputXML = XDocument.Parse(xml);

                Data.ONNotebook notebooks = (from notebook in outputXML.Descendants(oneNS + "Notebook")
                                             where notebook.Attribute("name").Value == notebookName
                                             select new Data.ONNotebook
                {
                    Name = notebook.Attribute("name").Value,
                    ID = notebook.Attribute("ID").Value,
                    LastModifiedTime = Convert.ToDateTime(notebook.Attribute("lastModifiedTime").Value),
                    Sections = SelectSections(notebook),
                }).First();
                return(notebooks);
            }
            catch (InvalidOperationException)
            {
                // source is empty
                return(null);
            }
            catch (ArgumentNullException)
            {
                // source is null
                return(null);
            }
            catch (System.Xml.XmlException ex)
            {
                // problem with input XML
                Log.Error(ex.Message);
                return(null);
            }
        }
예제 #4
0
 public Data.ONNotebook GetNotebook(string notebookName)
 {
     try
     {
         Data.ONNotebook notebook = (from nb in listNotebooks
                                     where nb.Name.ToLower() == notebookName.ToLower()
                                     select nb).First();
         return(notebook);
     }
     catch (InvalidOperationException)
     {
         return(null);
     }
     catch (ArgumentNullException)
     {
         return(null);
     }
 }