Beispiel #1
0
        private void PrintChapter(DocumentationChapter relation, Document document)
        {
            var chapter       = relation.Chapter;
            var parameters    = GetParameters(relation.Parameters);
            var chapterNumber = relation.ChapterNumber;
            var title         = parameters.ContainsKey("title") ? parameters["title"] : chapter.Name;

            if (chapter is Chapter)
            {
                GenerateChapterHeader(title, chapterNumber, relation.Title, relation.NewPage, document);

                if (!string.IsNullOrWhiteSpace((chapter as Chapter).Content))
                {
                    _parent.Add(_htmlToPdf.Parse(ChapterService.GetContent(chapter as Chapter), parameters));
                }

                Flush(document);
            }
            else if (chapter is GeneratedChapter)
            {
                GenerateChapterContent(chapter as GeneratedChapter, chapterNumber, relation.Title, relation.NewPage, parameters, document);
                Flush(document);
            }
            else if (chapter is PdfChapter)
            {
                GenerateChapterHeader(title, chapterNumber, relation.Title, relation.NewPage, document);
                var root = RootDirectory;
                var file = string.Format("{0}/{1}", root, relation.File.GetPath());
                _parent.Add(_docxToPdf.Parse(file));
                Flush(document);
            }
        }
Beispiel #2
0
        public void AddChapter(Documentation documentation, int chapterId, string chapter, string parameters, int?fileId)
        {
            var item = fileId.HasValue ?
                       UnitOfWork.AllChaptersRepository.Get(c => c is PdfChapter).Single() :
                       UnitOfWork.AllChaptersRepository.GetByKey(chapterId);

            var relation = new DocumentationChapter
            {
                Documentation = documentation,
                Chapter       = item,
                ChapterNumber = chapter,
                Parameters    = parameters,
                FileId        = fileId
            };

            item.DocumentationChapters.Add(relation);
        }