Пример #1
0
        /// <summary>
        /// Renders as dropdown.
        /// </summary>
        /// <param name="menu">The menu.</param>
        /// <param name="converter">The converter.</param>
        /// <returns></returns>
        public static string RenderAsToolbar(this reportLinkCollection menu, converterBase converter, bootstrap_size size = bootstrap_size.unknown)
        {
            if (size == bootstrap_size.unknown)
            {
                if (menu is reportLinkToolbar)
                {
                    reportLinkToolbar menu_reportLinkToolbar = (reportLinkToolbar)menu;
                    size = menu_reportLinkToolbar.size;
                }
                else
                {
                    size = bootstrap_size.md;
                }
            }

            var Group = menu.GetGroupOfFirstLink();

            if (Group == null)
            {
                return("");
            }

            string currentGroup = Group.name;

            StringBuilder output = new StringBuilder();

            output.AppendLine(converter.GetContainerOpen(bootstrap_containers.buttontoolbar, bootstrap_color.primary, size, menu.title, "#"));

            output.AppendLine(converter.GetContainerOpen(bootstrap_containers.buttongroup, bootstrap_color.primary, size, currentGroup.imbTitleCamelOperation(), "#"));

            foreach (reportLink link in menu)
            {
                if (link.state != reportLinkState.pathIsUrl)
                {
                    throw new aceReportException("Link was not compiled!! compile links before rendering", aceReportExceptionType.executeScriptError);
                }
                if (link.group.name != currentGroup)
                {
                    output.AppendLine(converter.GetContainerClose(bootstrap_containers.buttongroup));
                    currentGroup = link.group.name;
                    output.AppendLine(converter.GetContainerOpen(bootstrap_containers.buttongroup, bootstrap_color.primary, size, currentGroup.imbTitleCamelOperation(), "#"));
                }
                output.AppendLine(converter.GetContent(bootstrap_component.button, link.importance.ConvertToBootstrapColor(), size, link.linkTitle, link.linkPath));
            }

            output.AppendLine(converter.GetContainerClose(bootstrap_containers.buttongroup));

            output.AppendLine(converter.GetContainerClose(bootstrap_containers.buttontoolbar));
            string outstr = output.ToString();

            return(outstr);
        }
Пример #2
0
        public void createNewFile(IRenderExecutionContext context, IMetaContentNested oldScope)
        {
            ITextRender render = sourceRender.outputRender;
            string      ext    = format.getDefaultExtension();

            string filename = (oldScope.name + filenameSufix).getFilename(ext);

            string filepath = context.directoryScope.FullName.add(filename, "\\");

            // String folderPath = context.data.getProperString(oldScope.path, templateFieldBasic.path_folder, templateFieldBasic.document_path, templateFieldBasic.documentset_path);

            PropertyCollection content_blocks = render.getContentBlocks(true, format);
            IMetaContentNested sc             = (IMetaContentNested)oldScope;

            string codeOutput = template;

            try
            {
                IConverterRender cr = (IConverterRender)render;

                reportLinkCollectionSet menu    = new reportLinkCollectionSet();
                reportLinkToolbar       toolbar = new reportLinkToolbar();
                // sc.GetLinkCollection((deliveryInstance)context, format, sourceRender.levelsOfNewDirectory, false);

                // <---------- MENU ----------------------------
                if (oldScope is metaPage)
                {
                    metaPage oldScope_metaPage = (metaPage)oldScope;
                    menu.Add("Document set", oldScope_metaPage.menu_documentSetMenu.CompileLinkCollection(context as deliveryInstance, format, levelsOfNewDirectory));
                    menu.Add("Document", oldScope_metaPage.menu_documentmenu.CompileLinkCollection(context as deliveryInstance, format, levelsOfNewDirectory));
                    menu.Add("Page", oldScope_metaPage.menu_pagemenu.CompileLinkCollection(context as deliveryInstance, format, levelsOfNewDirectory));

                    menu.Add("Root", oldScope_metaPage.menu_rootmenu.CompileLinkCollection(context as deliveryInstance, format, levelsOfNewDirectory));

                    toolbar = oldScope_metaPage.toolbar_pagetools;
                }

                string menuRender = menu.RenderSetAsDropDowns(cr.converter);
                content_blocks.add(templateFieldSubcontent.html_mainnav, menuRender, false);

                // <---------------- TOOL BAR
                if (toolbar != null)
                {
                    if (toolbar.Any())
                    {
                        string toolbarRender = toolbar.CompileLinkCollection(context as deliveryInstance, format, levelsOfNewDirectory).RenderAsToolbar(cr.converter);
                        content_blocks.add(templateFieldSubcontent.html_toolbar, toolbarRender, false);
                    }
                }

                // <---------------- LINKS
                // codeOutput = codeOutput.CompileLinksInTemplate(context as deliveryInstance, format, levelsOfNewDirectory);
            }
            catch (Exception ex)
            {
                throw new aceReportException("Auto-menu creation : " + ex.Message + " Automenu creation for " + oldScope.path);
            }

            if (context is deliveryInstance)
            {
                deliveryInstance contextDeliveryInstance = (deliveryInstance)context;
                contextDeliveryInstance.unit.blockBuilder.BuildDynamicNavigationTemplates(contextDeliveryInstance, content_blocks);
            }

            codeOutput = codeOutput.applyToContent(false, content_blocks);// openBase.openFileToString(tempfile.FullName, true, false);

            codeOutput = codeOutput.applyToContent(false, context.data);

            codeOutput = codeOutput.CompileLinksInTemplate(context as deliveryInstance, format, levelsOfNewDirectory);

            codeOutput = codeOutput.Replace("..//", "../");
            codeOutput = codeOutput.Replace(" href=\"/", " href=\"");

            //var savedfile = codeOutput.saveStringToFile(filepath, imbSCI.Cores.enums.getWritableFileMode.overwrite, Encoding.UTF8);

            context.saveFileOutput(codeOutput, filepath, getFolderPathForLinkRegistry(context), description);

            //IDocScriptExecutionContext docContext = context as IDocScriptExecutionContext;

            //docContext.linkRegistry[context.directoryScope.FullName].AddLink(filename, "", filepath);
        }