/// <summary>
        /// Builds the children and returns newly built nodes
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="source">The source.</param>
        /// <param name="defShapeType">Type of the definition shape.</param>
        /// <param name="defLinkType">Type of the definition link.</param>
        /// <param name="doDegradeImportance">if set to <c>true</c> [do degrade importance].</param>
        /// <returns></returns>
        public List <diagramNode> buildChildren(diagramModel model, diagramNode parent, IEnumerable source, diagramNodeShapeEnum defShapeType = diagramNodeShapeEnum.normal, diagramLinkTypeEnum defLinkType = diagramLinkTypeEnum.normal, bool doDegradeImportance = true)
        {
            List <diagramNode> childNodes = new List <diagramNode>();

            if (source == null)
            {
                return(childNodes);
            }

            foreach (IObjectWithPathAndChildSelector child in source)
            {
                diagramNode node = buildNode(model, child);
                node.shapeType = getShapeTypeEnum(child, defShapeType);
                //node.relatedObject = child;
                childNodes.Add(node);
                if (doDegradeImportance)
                {
                    node.importance = parent.importance - 1;
                }
                node.color = getColor(node);
            }

            foreach (diagramNode child in childNodes)
            {
                diagramLink link = model.AddLink(parent, child, diagramLinkTypeEnum.normal);
                link.type        = getLinkTypeEnum(child, defLinkType);
                link.description = getLinkDescription(link, "");
            }
            return(childNodes);
        }
Пример #2
0
        public static diagramModel buildModel(this spiderWeb source, List <spiderPage> selectedPages, diagramModel output = null)
        {
            if (output == null)
            {
                output = new diagramModel("Web structure", "Representation of crawled section of the web site structure.", diagramDirectionEnum.TB);
            }

            if (!imbWEMManager.settings.postReportEngine.reportBuildDoGraphs)
            {
                return(output);
            }

            foreach (spiderPage sp in selectedPages)
            {
                string desc = sp.url + " sc(" + sp.marks.score + ")";
                output.AddNode(desc, diagramNodeShapeEnum.circle, "", sp.originHash);
            }

            foreach (spiderLink sl in source.webLinks.items.Values)
            {
                if (selectedPages.Contains(sl.targetedPage) && selectedPages.Contains(sl.originPage))
                {
                    var from = output.GetNodeByHash(sl.originHash);
                    var to   = output.GetNodeByHash(sl.targetedPage.originHash);

                    string desc = " i(" + sl.iterationDiscovery + ") sc(" + sl.marks.score + ")";

                    output.AddLink(from, to, diagramLinkTypeEnum.normal, desc, sl.originHash);
                }
            }

            return(output);
        }
        //public virtual

        /// <summary>
        /// Builds a node.
        /// </summary>
        /// <param name="model">The diagram model.</param>
        /// <param name="source">The source object to build from</param>
        /// <returns></returns>
        public override diagramNode buildNode(diagramModel model, IObjectWithPathAndChildSelector source)
        {
            string      name        = getNodeName(source, "NaN");
            string      description = getNodeDescription(source, name);
            diagramNode node        = model.AddNode(description, diagramNodeShapeEnum.normal, name);

            node.relatedObject = source;

            return(node);
        }
Пример #4
0
        /// <summary>
        /// Builds the link path hierarchy model
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="selectedPages">The selected pages.</param>
        /// <param name="output">The output.</param>
        /// <returns></returns>
        public static diagramModel buildModel(this linknodeBuilder source, List <spiderPage> selectedPages, diagramModel output = null)
        {
            if (output == null)
            {
                output = new diagramModel("URL path structure", "Representation of url path structure based on detected links.", diagramDirectionEnum.LR);
            }

            if (!imbWEMManager.settings.postReportEngine.reportBuildDoGraphs)
            {
                return(output);
            }

            Dictionary <diagramNode, List <linknodeElement> > links     = new Dictionary <diagramNode, List <linknodeElement> >();
            Dictionary <diagramNode, List <linknodeElement> > new_links = new Dictionary <diagramNode, List <linknodeElement> >();

            var rootNode = output.AddNode("Root" + " (" + source.root.score + ")", diagramNodeShapeEnum.circle);

            links.Add(rootNode, source.root.items.Values.ToList());
            int c = 0;

            do
            {
                new_links = new Dictionary <diagramNode, List <linknodeElement> >();

                foreach (var pair in links)
                {
                    foreach (linknodeElement el in pair.Value)
                    {
                        var parentNode = output.AddNode(el.name + " (" + el.score + ")", diagramNodeShapeEnum.rounded);
                        if (el.items.Count > 0)
                        {
                            new_links.Add(parentNode, el.items.Values.ToList());
                            output.AddLink(pair.Key, parentNode, diagramLinkTypeEnum.normal);
                        }
                        else
                        {
                            output.AddLink(pair.Key, parentNode, diagramLinkTypeEnum.dotted);
                        }
                        c++;
                        if (c > it_limit)
                        {
                            return(output);
                        }
                    }
                }

                links = new_links;
            } while (links.Count > 0);

            return(output);
        }
        /// <summary>
        /// Gets the output links declaration.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public override string getOutputLinksDeclaration(diagramModel model)
        {
            string output  = "";
            string newLine = "";

            // link declaration
            foreach (diagramLink link in model.links)
            {
                newLine = getLinkDeclaration(link);
                output  = output.add(newLine, Environment.NewLine);
            }

            return(output);
        }
        /// <summary>
        /// Gets the output nodes declaration.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public override string getOutputNodesDeclaration(diagramModel model)
        {
            string output  = "";
            string newLine = "";

            // node declaration
            foreach (diagramNode node in model.nodes.Values)
            {
                newLine = getNodeDeclaration(node);
                output  = output.add(newLine, Environment.NewLine);
            }

            return(output);
        }
        /// <summary>
        /// Builds the diagram model from an object with children
        /// </summary>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public override diagramModel buildModel(diagramModel output, IObjectWithPathAndChildSelector source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("can-t build model :: source is null" + "Diagram = source is null");
            }
            if (output == null)
            {
                output = new diagramModel("", "", diagramDirectionEnum.LR);
                if (source is IObjectWithNameAndDescription)
                {
                    IObjectWithNameAndDescription source_IObjectWithNameAndDescription = (IObjectWithNameAndDescription)source;
                    output.name        = source_IObjectWithNameAndDescription.name;
                    output.description = source_IObjectWithNameAndDescription.description;
                }
            }

            diagramNode parent = buildNode(output, source);
            //parent.relatedObject = source;

            List <diagramNode> childNodes = new List <diagramNode>();

            childNodes = buildChildren(output, parent, source, diagramNodeShapeEnum.normal, diagramLinkTypeEnum.normal, true);
            int c = 1;

            while (childNodes.Any())
            {
                c++;
                if (c > childDepthLimit)
                {
                    break;
                }
                List <diagramNode> newChildNodes = new List <diagramNode>();
                foreach (diagramNode childNode in childNodes)
                {
                    if (childNode.relatedObject is IEnumerable)
                    {
                        newChildNodes.AddRange(buildChildren(output, childNode, childNode.relatedObject as IEnumerable, diagramNodeShapeEnum.normal, diagramLinkTypeEnum.normal, true));
                    }
                }

                childNodes = newChildNodes;
            }

            return(output);
        }
        /// <summary>
        /// Gets the output.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="colorProvider">The color provider.</param>
        /// <returns></returns>
        public override string getOutput(diagramModel model, acePaletteProvider colorProvider)
        {
            string output  = "";
            string newLine = "";

            output += "<div class=\"mermaid\" id=\"monotone\">" + Environment.NewLine + Environment.NewLine;

            output += model.diagramClassName + " " + model.direction.ToString() + ";" + Environment.NewLine;

            output += getOutputNodesDeclaration(model) + Environment.NewLine;

            output += getOutputLinksDeclaration(model) + Environment.NewLine;

            if (colorProvider != null)
            {
                output += getOutputStyleDeclaration(model, colorProvider) + Environment.NewLine + Environment.NewLine;
            }

            output += "</div>";

            return(output);
        }
        /// <summary>
        /// Gets the output style declaration.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="colorProvider">The color provider.</param>
        /// <returns></returns>
        public override string getOutputStyleDeclaration(diagramModel model, acePaletteProvider colorProvider)
        {
            string output  = "";
            string newLine = "";

            // node declaration
            foreach (diagramNode node in model.nodes.Values)
            {
                newLine = "style N" + node.name + " ";

                colorProvider.setVariation(node.importance, false, -1, false, (acePaletteRole)node.color);

                newLine += " fill:" + colorProvider.bgColor.ColorToHex(); //.toHexColor(true);

                //   newLine += ";";
                //acePaletteVariationRole varRole = node.color;

                output = output.add(newLine, Environment.NewLine);
            }

            return(output);
        }
Пример #10
0
 public abstract diagramModel buildModel(diagramModel output, T source);
 public override void render(diagramModel model, ITextRender render)
 {
     throw new NotImplementedException();
 }
 public abstract string getOutputLinksDeclaration(diagramModel model);
 public abstract string getOutput(diagramModel model, acePaletteProvider colorProvider);
Пример #14
0
 public abstract diagramNode buildNode(diagramModel model, IObjectWithPathAndChildSelector source);
Пример #15
0
 public abstract diagramModel buildModel(diagramModel output, IObjectWithPathAndChildSelector source);
        /// <summary>
        /// Compiles complex appends. Returns <c>appendType</c> if it is no match for this <c>runner</c>.
        /// </summary>
        /// <param name="ins">The ins.</param>
        /// <remarks>OK for multimpleruns</remarks>
        /// <returns><c>appendType.none</c> if executed, other <c>appendType</c> if no match for this run method</returns>
        protected appendType runComplexInstruction(IRenderExecutionContext context, docScriptInstruction ins)
        {
            ITextRender render = outputRender; //builder.documentBuilder;

            switch (ins.type)
            {
            //// ****************************** External executable
            case appendType.exe:

                IExeAppend exe = (IExeAppend)ins[d.dsa_value];
                exe.execute(context, render);

                break;

            /////////////////////// ---------------------------------
            case appendType.button:

                string          btn_caption = (string)ins[d.dsa_title];                  //.getProperString(d.dsa_title);
                string          btn_url     = (string)ins[d.dsa_url];                    //.getProperString(d.dsa_url);
                bootstrap_color btn_color   = (bootstrap_color)ins[d.dsa_styleTarget];   // ins.getProperEnum<bootstrap_color>(bootstrap_color.info, d.dsa_styleTarget);
                bootstrap_size  btn_size    = (bootstrap_size)ins[d.dsa_stylerSettings]; // ins.getProperEnum<bootstrap_size>(bootstrap_size.md, d.dsa_stylerSettings);

                render.AppendDirect(render.converter.GetButton(btn_caption, btn_url, btn_color.ToString(), btn_size.ToString()));

                break;

            case appendType.attachment:
                string att_caption = (string)ins[d.dsa_title]; //.getProperString(d.dsa_title);
                string att_url     = (string)ins[d.dsa_url];   //.getProperString(d.dsa_url);

                string filename = ins[d.dsa_title].toStringSafe().getFilename();
                att_url = att_url.or(filename);

                bootstrap_color att_color = (bootstrap_color)ins[d.dsa_styleTarget];    //.getProperEnum<bootstrap_color>(bootstrap_color.primary, d.dsa_styleTarget);
                bootstrap_size  att_size  = (bootstrap_size)ins[d.dsa_stylerSettings];  // ins.getProperEnum<bootstrap_size>(bootstrap_size.sm, d.dsa_stylerSettings);

                string output = "";
                if (ins.containsKey(d.dsa_content))
                {
                    DataTable dt = ins[d.dsa_content] as DataTable;     //.getProperObject<DataTable>(d.dsa_content);
                    if (dt != null)
                    {
                        dataTableExportEnum format = (dataTableExportEnum)ins[d.dsa_format];     //>(dataTableExportEnum.excel, d.dsa_format);
                        if (imbSciStringExtensions.isNullOrEmpty(att_url))
                        {
                            att_url = dt.TableName.getFilename().getCleanPropertyName().Replace(" ", "").ToLower();
                        }

                        att_url = dt.serializeDataTable(format, att_url, context.directoryScope);
                    }
                    else
                    {
                        output = ins[d.dsa_content] as string;
                    }
                }

                if (ins.containsAllOfTypes(typeof(FileInfo)))
                {
                    FileInfo fi = ins.getProperObject <FileInfo>();
                    att_url = fi.Name;
                    fi.CopyTo(att_url);
                }

                att_url = att_url.removeStartsWith(context.directoryScope.FullName).Trim('\\').removeStartsWith("/");

                string bootstrapButton = render.converter.GetButton(att_caption, att_url, att_color.toString(), att_size.toString());

                render.AppendDirect(bootstrapButton);
                break;

            case appendType.i_chart:
                List <object> parameters = (List <object>)ins[d.dsa_value];   //.getProperObject<List<Object>>(d.dsa_value);

                string chstr = charts.chartTools.buildChart((chartTypeEnum)parameters[0], (chartFeatures)parameters[1], (DataTable)parameters[2], (chartSizeEnum)parameters[3], ins.getProperEnum <chartTypeEnum>(chartTypeEnum.none, d.dsa_format));
                render.AppendDirect(chstr);
                break;

            case appendType.direct:
                render.AppendDirect((string)ins[d.dsa_contentLine]);
                break;

            case appendType.toFile:
                string toFile_outputpath = ins.getProperString(d.dsa_path);
                toFile_outputpath = context.directoryScope.FullName.add(toFile_outputpath, "\\");
                render.AppendToFile(toFile_outputpath, ins.getProperString(d.dsa_contentLine));
                break;

            case appendType.fromFile:
                string fromFile_sourcepath           = ins[d.dsa_path].toStringSafe();
                bool   fromFile_isLocalSource        = (bool)ins[d.dsa_on];
                templateFieldSubcontent fromFile_key = (templateFieldSubcontent)ins[d.dsa_key];
                if (fromFile_isLocalSource)
                {
                    fromFile_sourcepath = context.directoryScope.FullName.add(fromFile_sourcepath, "\\");
                }

                if (File.Exists(fromFile_sourcepath))
                {
                    render.AppendFromFile(fromFile_sourcepath, fromFile_key, fromFile_isLocalSource);
                }
                else
                {
                    render.AppendLabel("File " + fromFile_sourcepath + " not found", true, bootstrap_style.style_warning);
                }

                break;

            case appendType.file:
                string file_sourcepath     = ins.getProperString(d.dsa_path);
                string file_outputpath     = ins.getProperString(d.dsa_name);
                bool   file_isDataTemplate = (bool)ins.getProperField(d.dsa_on);
                bool   file_isLocalSource  = (bool)ins.getProperField(d.dsa_relative);
                file_outputpath = context.directoryScope.FullName.add(file_outputpath, "\\");

                if (file_isLocalSource)
                {
                    fromFile_sourcepath = context.directoryScope.FullName.add(file_sourcepath, "\\");
                }

                string templateNeedle = ins.getProperString("none", d.dsa_styleTarget);
                if (templateNeedle != "none")
                {
                    deliveryUnit dUnit = (deliveryUnit)context.dUnit;
                    deliveryUnitItemContentTemplated templateItem = dUnit.findDeliveryUnitItemWithTemplate(templateNeedle);

                    string __filecontent = openBase.openFileToString(file_sourcepath, true, false);
                    templateItem.saveOutput(context, __filecontent, context.data, file_outputpath, file_isDataTemplate);
                }
                else
                {
                    render.AppendFile(file_sourcepath, file_outputpath, file_isDataTemplate);
                }

                break;

            case appendType.image:
                diagramModel            model  = ins.getProperObject <diagramModel>(d.dsa_value);
                diagramOutputEngineEnum engine = ins.getProperEnum <diagramOutputEngineEnum>(diagramOutputEngineEnum.mermaid, d.dsa_format);
                if (model != null)
                {
                    deliveryUnit      dUnit     = (deliveryUnit)context.dUnit;
                    diagramOutputBase diaOutput = null;
                    if (outputRender is builderForMarkdown)
                    {
                        diaOutput = engine.getOutputEngine();
                    }
                    if (diaOutput == null)
                    {
                        diaOutput = new diagramMermaidOutput();
                    }
                    string diaString = diaOutput.getOutput(model, dUnit.theme.palletes);
                    render.AppendDirect(diaString);
                }
                else
                {
                    render.AppendImage(ins.getProperString(d.dsa_path), ins.getProperString(d.dsa_contentLine), ins.getProperString(d.dsa_name));
                }

                break;

            case appendType.math:
                render.AppendMath(ins.getProperString(d.dsa_contentLine), ins.getProperString(d.dsa_format));
                break;

            case appendType.label:
                render.AppendLabel(ins.getProperString(d.dsa_contentLine), !ins.isHorizontal, ins.getProperString(d.dsa_styleTarget));
                break;

            case appendType.panel:
                render.AppendPanel(ins.getProperString(d.dsa_contentLine), ins.getProperString(d.dsa_title), ins.getProperString(d.dsa_description), ins.getProperString(d.dsa_styleTarget));
                break;

            case appendType.frame:
                render.AppendFrame(ins.getProperString(d.dsa_contentLine), ins.getProperInt32(-1, d.dsa_w), ins.getProperInt32(-1, d.dsa_h), ins.getProperString(d.dsa_title), ins.getProperString(d.dsa_description), (IEnumerable <string>)ins.getProperField(d.dsa_content));
                break;

            case appendType.placeholder:
                render.AppendPlaceholder(ins.getProperField(d.dsa_name), ins.isHorizontal);
                break;

            case appendType.list:
                render.AppendList((IEnumerable <object>)ins.getProperField(d.dsa_content), (bool)ins.getProperField(d.dsa_on));
                break;

            case appendType.footnote:
                throw new NotImplementedException("No implementation for: " + ins.type.ToString());
                break;

            case appendType.c_line:

                render.AppendHorizontalLine();

                break;

            case appendType.c_data:
                object dataSource = ins.getProperField(d.dsa_dataPairs, d.dsa_dataList, d.dsa_value);
                string _head      = ins.getProperString("", d.dsa_title, d.dsa_name);
                string _foot      = ins.getProperString("", d.dsa_footer, d.dsa_description);
                if (dataSource is PropertyCollection)
                {
                    PropertyCollection pairs = dataSource as PropertyCollection;
                    string             sep   = ins.getProperString(d.dsa_separator);
                    if (imbSciStringExtensions.isNullOrEmpty(_foot))
                    {
                        _foot = pairs.getAndRemoveProperString(d.dsa_footer, d.dsa_description);
                    }
                    if (imbSciStringExtensions.isNullOrEmpty(_head))
                    {
                        _head = pairs.getAndRemoveProperString(d.dsa_title, d.dsa_description);
                    }

                    if (!imbSciStringExtensions.isNullOrEmpty(_foot))
                    {
                        pairs.Add(d.dsa_footer.ToString(), _foot);
                    }
                    if (!imbSciStringExtensions.isNullOrEmpty(_head))
                    {
                        pairs.Add(d.dsa_title.ToString(), _head);                                                   // list.Insert(0, _head);
                    }
                    render.AppendPairs(pairs, ins.isHorizontal, sep);
                    // pair
                }
                else if (dataSource is IList <object> )
                {
                    IList <object> list = dataSource as IList <object>;
                    if (!imbSciStringExtensions.isNullOrEmpty(_foot))
                    {
                        list.Add(_foot);
                    }
                    if (!imbSciStringExtensions.isNullOrEmpty(_head))
                    {
                        list.Insert(0, _head);
                    }

                    render.AppendList(list, false);
                }
                break;

            case appendType.c_pair:
                render.AppendPair(ins.getProperString(d.dsa_key, d.dsa_name, d.dsa_title),
                                  ins.getProperField(d.dsa_value, d.dsa_contentLine, d.dsa_dataField, d.dsa_content),
                                  true,
                                  ins.getProperString(" ", d.dsa_separator)
                                  );
                break;

            case appendType.c_table:
                try
                {
                    DataTable dt2 = (DataTable)ins[d.dsa_dataTable];     // .getProperObject<DataTable>(d.dsa_dataTable);
                    if (dt2.Rows.Count == 0)
                    {
                    }
                    dt2.ExtendedProperties.add(templateFieldDataTable.data_tablename, ins[d.dsa_title], true);
                    dt2.ExtendedProperties.add(templateFieldDataTable.data_tabledesc, ins[d.dsa_description], true);
                    dt2 = dt2.CompileTable(context as deliveryInstance, reportOutputFormatName.htmlViaMD, levelsOfNewDirectory);     //  <------------- privremeni hack

                    render.AppendTable(dt2, true);
                }
                catch (Exception ex)
                {
                }
                break;

            case appendType.c_link:
                render.AppendLink(ins.getProperString(d.dsa_url, d.dsa_value),
                                  ins.getProperString(d.dsa_name, d.dsa_contentLine, d.dsa_key), ins.getProperString(d.dsa_title, d.dsa_description, d.dsa_footer),
                                  ins.getProperEnum <appendLinkType>(appendLinkType.link));
                break;

            case appendType.section:
                render.AppendSection(
                    ins.getProperString(d.dsa_contentLine),
                    ins.getProperString(d.dsa_title, d.dsa_name),
                    ins.getProperString(d.dsa_description),
                    ins.getProperField(d.dsa_content) as IEnumerable <string>);
                break;

            case appendType.c_section:
                render.AppendSection(
                    ins.getProperString(d.dsa_contentLine),
                    ins.getProperString(d.dsa_title, d.dsa_name),
                    ins.getProperString(d.dsa_description),
                    ins.getProperField(d.dsa_content) as IEnumerable <string>);
                break;

            case appendType.c_open:
                render.open(ins.getProperString("section", d.dsa_contentLine, d.dsa_name, d.dsa_key), ins.getProperString(d.dsa_title), ins.getProperString(d.dsa_description));
                break;

            case appendType.c_close:
                render.close(ins.getProperString("none", d.dsa_contentLine, d.dsa_name, d.dsa_key));
                break;

            case appendType.source:
                string        sourcecode = "";
                List <string> scode      = ins.getProperObject <List <string> >(d.dsa_content);

                sourcecode = scode.toCsvInLine(Environment.NewLine);
                string sc_name     = ins.getProperString("code", d.dsa_name);
                string sc_desc     = ins.getProperString("", d.dsa_description, d.dsa_footer);
                string sc_title    = ins.getProperString("", d.dsa_title);
                string sc_typename = ins.getProperString("html", d.dsa_class_attribute);

                render.open(sc_name, sc_title, sc_desc);
                render.AppendCode(sourcecode, sc_typename);
                render.close();
                //render.close(ins.getProperString("none", d.dsa_contentLine, d.dsa_name, d.dsa_key));
                break;

            default:
                //executionError(String.Format("Instruction ({0}) not supported by runComplexInstruction() method", ins.type.ToString()), ins);
                return(ins.type);

                break;
            }

            return(appendType.none);
        }
 public abstract string getOutputStyleDeclaration(diagramModel model, acePaletteProvider colorProvider);
 public abstract void render(diagramModel model, ITextRender render);
Пример #19
0
 public abstract diagramNode buildNode(diagramModel model, T source);
 public metaDiagramBlock(diagramModel __diagram, diagramOutputEngineEnum __engine)
 {
     diagram = __diagram;
 }