Esempio n. 1
0
        /// <summary>
        /// This will create a single OpenXML document.  After it is created, it should be opened and a new Table of Contents before printing to PDF.
        /// </summary>
        internal static PrintResult BuildTtfBook(bool draft)
        {
            var styleSource = ModelMap.StyleSource;

            _filePath = ModelMap.FilePath + ModelMap.FolderSeparator + ".." + ModelMap.FolderSeparator + "TTF-Book.docx";
            try
            {
                InitWorkingDocument(styleSource);
                _document.MainDocumentPart.Document.AppendChild(new Body());
            }
            catch (Exception ex)
            {
                _log.Error("Artifact Output Folder: " + _outputFolder + " cannot be created.");
                _log.Error(ex);
                return(new PrintResult
                {
                    OpenXmlDocument = ""
                });
            }

            CommonPrinter.AddTaxonomyInfo(_document, ModelManager.Taxonomy.Version);

            _log.Info("Adding Bases");
            CommonPrinter.AddSectionPage(_document, "Base Tokens");
            foreach (var b in ModelManager.Taxonomy.BaseTokenTypes.Values)
            {
                BasePrinter.PrintTokenBase(_document, b, true);
            }
            Save();

            _log.Info("Adding Behaviors");
            CommonPrinter.AddSectionPage(_document, "Behaviors");
            foreach (var b in ModelManager.Taxonomy.Behaviors.Values)
            {
                BehaviorPrinter.PrintBehavior(_document, b, true);
            }
            Save();

            _log.Info("Adding Behavior-Groups");
            CommonPrinter.AddSectionPage(_document, "Behavior Groups");
            foreach (var b in ModelManager.Taxonomy.BehaviorGroups.Values)
            {
                BehaviorGroupPrinter.PrintBehaviorGroup(_document, b, true);
            }
            Save();

            _log.Info("Adding Property-Sets");
            CommonPrinter.AddSectionPage(_document, "Property Sets");
            foreach (var ps in ModelManager.Taxonomy.PropertySets.Values)
            {
                PropertySetPrinter.AddPropertySetProperties(_document, ps, true);
            }
            Save();

            _log.Info("Adding Template Formulas");
            CommonPrinter.AddSectionPage(_document, "Template Formulas");
            foreach (var tf in ModelManager.Taxonomy.TemplateFormulas.Values)
            {
                FormulaPrinter.PrintFormula(_document, tf, true);
            }
            Save();

            _log.Info("Adding Template Definitions");
            CommonPrinter.AddSectionPage(_document, "Template Definitions");
            foreach (var td in ModelManager.Taxonomy.TemplateDefinitions.Values)
            {
                DefinitionPrinter.PrintDefinition(_document, td, true);
            }
            Save();

            _log.Info("Adding Specifications");
            CommonPrinter.AddSectionPage(_document, "Token Specifications");
            foreach (var tf in ModelManager.Taxonomy.TemplateDefinitions.Keys)
            {
                var spec = Printer.TaxonomyClient.GetTokenSpecification(new TokenTemplateId
                {
                    DefinitionId = tf
                });
                if (spec == null)
                {
                    continue;
                }
                SpecificationPrinter.PrintSpecification(_document, spec);
            }
            Save();

            Utils.InsertCustomWatermark(_document, draft ? ModelMap.DraftWaterMark : ModelMap.WaterMark);
            Utils.AddFooter(_document, "Token Taxonomy Framework" + " - " + ModelManager.Taxonomy.Version.Version + ": " + ModelManager.Taxonomy.Version.StateHash);
            Save();
            return(GetPrintResult());
        }