Exemplo n.º 1
0
        protected void HTTPmenu(string area, HTTPendpoint HTTP)
        {
            api_reports.Add(area, new KeyValuePair <int, string>(HTTP.getFullCount(), "Basic"));

            // create index
            StringBuilder sb = new StringBuilder();

            sb.Append(html_header);
            sb.Append("<h3>Interface:");
            sb.Append("Commands");
            sb.Append("</h3><br/>");
            sb.Append("<h4>Build: ");
            sb.Append(buildVersion);
            sb.Append("</h4><br/>");
            sb.Append("<table class='datatable table table-striped table-bordered'><thead><tr><th>Workspace</th><th>Commands</th></tr></thead><tbody>");
            foreach (string workspace in HTTP.getEndPoints())
            {
                string workspace_link = "<a href='[[AREA]]" + workspace + ".html'>" + workspace + "</a>";
                sb.Append("<tr><td>");
                sb.Append(workspace_link);
                sb.Append("</td><td>");
                sb.Append(HTTP.getEndpointCount(workspace).ToString());
                sb.Append("</td></tr>");
            }
            sb.Append("</tbody></table>");
            sb.Replace("[[SUBFOLDER]]", "");
            sb.Replace("[[RETURNROOT]]", "../");
            sb.Replace("[[AREA]]", area);
            sb.Append(html_footer);
            sb = DebugModeCreateWiki.MenuActive(sb, area);
            io.WriteFile("" + area + ".html", sb.ToString());
        }
Exemplo n.º 2
0
 protected void HTTPWorkspaces(string area, HTTPendpoint HTTP)
 {
     foreach (string workspace in HTTP.getEndPoints())
     {
         StringBuilder sb = new StringBuilder();
         sb.Append(html_header);
         sb.Append("<h3>Interface: <a href='[[AREA]].html'>[[AREA]]</a>");
         if (workspace != "")
         {
             sb.Append(" / [[WORKSPACE]]");
         }
         sb.Append("</h3><br/>");
         sb.Append("<h4>Build: ");
         sb.Append(buildVersion);
         sb.Append("</h4><br/>");
         sb.Append("<table class='datatable table table-striped table-bordered'><thead><tr><th>Command</th><th>Min args (+1 for HTTP)</th></tr></thead><tbody>");
         foreach (string c in HTTP.getEndpointCommands(workspace))
         {
             int args = HTTP.getCommandArgCount(workspace, c);
             sb.Append("<tr><td><a href='[[AREA]]");
             sb.Append(workspace);
             sb.Append(c);
             sb.Append(".html'>");
             sb.Append(c);
             sb.Append("</a></td><td>");
             int argcount = args - 1;
             if (argcount < 0)
             {
                 argcount = 0;
             }
             sb.Append(argcount.ToString());
             sb.Append("</td></tr>");
         }
         sb.Append("</tbody></table>");
         sb.Replace("[[SUBFOLDER]]", "");
         sb.Replace("[[RETURNROOT]]", "../");
         sb.Replace("[[WORKSPACE]]", workspace);
         sb.Replace("[[AREA]]", area);
         sb.Append(html_footer);
         sb = DebugModeCreateWiki.MenuActive(sb, area);
         string target_file = "" + area + "" + workspace + ".html";
         io.WriteFile(target_file, sb.ToString());
     }
 }
Exemplo n.º 3
0
        protected void HTTPCommands(string area, HTTPendpoint HTTP)
        {
            foreach (string workspace in HTTP.getEndPoints())
            {
                mdWiki.AppendLine("## " + workspace);
                mdWiki.AppendLine(" ");
                foreach (string c in HTTP.getEndpointCommands(workspace))
                {
                    mdWiki.AppendLine("### " + c);
                    mdWiki.AppendLine(" ");
                    StringBuilder sb           = new StringBuilder();
                    StringBuilder mdWikiArgs   = new StringBuilder();
                    StringBuilder mdWIkiReplys = new StringBuilder();
                    sb.Append(html_header);
                    sb.Append("<h3>Build: ");
                    sb.Append(buildVersion);
                    sb.Append("</h3><br/>");
                    sb.Append("<h4>Interface: <a href='[[AREA]].html'>[[AREA]]</a>");
                    if (workspace != "")
                    {
                        sb.Append(" / <a href='[[AREA]][[WORKSPACE]].html'>[[WORKSPACE]]</a>");
                    }
                    sb.Append("</h4><hr/><h3>[[COMMAND]]</h3>");
                    sb.Append("[[URLENDPOINT]]/[[WORKSPACE]]/[[COMMAND]]/[[URLADDON]]<br/>");
                    sb.Append("Method: [[APIMETHOD]]");
                    sb.Append("<br/> OR <br/>");

                    StringBuilder CommandExample = new StringBuilder();
                    Dictionary <string, KeyValuePair <string, string> > values = HTTP.getCommandArgs(workspace, c);
                    CommandExample.Append("[[COMMAND]]");
                    sb.Append("[[COMMAND]]");
                    string        addon  = "";
                    List <string> argsim = new List <string>(values.Keys);
                    argsim.Remove("token");
                    if (argsim.Count > 0)
                    {
                        CommandExample.Append("|||");
                        sb.Append("|||");
                    }
                    foreach (string entry in argsim)
                    {
                        sb.Append(addon);
                        sb.Append("{");
                        sb.Append(entry);
                        sb.Append("}");
                        CommandExample.Append(addon + "{" + entry + "}");
                        addon = "~#~";
                    }
                    sb.Append("<br/><br/>");
                    sb.Append("[[HELP]]");

                    int ValueCount = values.Count;


                    if (ValueCount > 0)
                    {
                        sb.Append("<hr/><h4>Args helper</h4>");
                        sb.Append("<table class='table table-striped table-bordered'><thead><tr><td>Name</td><th>Type</th><th>Hint</th></tr></thead><tbody>");
                        mdWikiArgs.AppendLine("|Name|Type|Hint|");
                        mdWikiArgs.AppendLine("| ------ | ------- | ---------------------------- |");
                        foreach (KeyValuePair <string, KeyValuePair <string, string> > entry in values)
                        {
                            string hint = entry.Value.Value;
                            string type = entry.Value.Key;

                            if (entry.Value.Key.Contains("Optional") == true)
                            {
                                type = type.Replace("Optional", "{Optional} ");
                            }
                            else if (entry.Value.Key == "URLARG")
                            {
                                type = "URL arg";
                            }
                            sb.Append("<tr><td>" + entry.Key + "</td><td>" + type + "</td><td>" + hint + "</td></tr>");
                            mdWikiArgs.AppendLine("| " + entry.Key + " | " + type + " | " + hint + " |");
                        }
                        sb.Append("</tbody></table>");
                    }

                    string[] returnvalues        = HTTP.getReturnsValues(workspace, c);
                    string[] returnvaluesfailure = HTTP.getReturnsFailureValues(workspace, c);
                    if ((returnvalues.Length > 0) || (returnvaluesfailure.Length > 0))
                    {
                        sb.Append("<hr/><h4>Replys</h4>");
                        sb.Append("<ul class=\"list-unstyled\">");

                        foreach (string entry in returnvalues)
                        {
                            sb.Append("<li class=\"text-success\">☑ " + entry + "</li>");
                            mdWIkiReplys.AppendLine("- [:heavy_check_mark:] " + entry);
                        }
                        foreach (string entry in returnvaluesfailure)
                        {
                            sb.Append("<li class=\"text-danger\">❌ <strong>" + entry + "</strong></li>");
                            mdWIkiReplys.AppendLine("- [:x:] " + entry);
                        }
                        sb.Append("</ul>");
                    }
                    sb = DebugModeCreateWiki.MenuActive(sb, area);

                    sb.Append(html_footer);
                    sb.Replace("[[COMMAND]]", c);
                    sb.Replace("[[URLENDPOINT]]", "http://localhost:8080");
                    sb.Replace("[[APIMETHOD]]", HTTP.getCommandMethod(workspace, c));
                    sb.Replace("[[URLADDON]]", getURLargs(values));
                    sb.Replace("[[HELP]]", HTTP.getCommandAbout(workspace, c));
                    sb.Replace("[[MINARGS]]", ValueCount.ToString());
                    sb.Replace("[[WORKSPACE]]", workspace);
                    sb.Replace("[[AREA]]", area);
                    sb.Replace("[[SUBFOLDER]]", "");
                    sb.Replace("[[RETURNROOT]]", "../");

                    mdWiki.AppendLine("[[URLENDPOINT]]/[[WORKSPACE]]/[[COMMAND]]/[[URLADDON]]");
                    mdWiki.AppendLine(" ");
                    mdWiki.AppendLine("Method: [[APIMETHOD]]");
                    mdWiki.AppendLine(" ");
                    mdWiki.AppendLine("OR");
                    mdWiki.AppendLine(" ");
                    mdWiki.AppendLine(CommandExample.ToString());
                    mdWiki.AppendLine(" ");
                    mdWiki.AppendLine("[[HELP]]");
                    mdWiki.AppendLine(" ");
                    string target_file = "" + area + "" + workspace + "" + c + ".html";
                    io.WriteFile(target_file, sb.ToString());
                    mdWiki.AppendLine("***Args helper***");
                    mdWiki.AppendLine(" ");
                    mdWiki.AppendLine(mdWikiArgs.ToString());
                    mdWiki.AppendLine("***Replys***");
                    mdWiki.AppendLine(" ");
                    mdWiki.AppendLine(mdWIkiReplys.ToString());
                    mdWiki.AppendLine(" ");

                    mdWiki.Replace("[[COMMAND]]", c);
                    mdWiki.Replace("[[URLENDPOINT]]", "http://localhost:8080");
                    mdWiki.Replace("[[APIMETHOD]]", HTTP.getCommandMethod(workspace, c));
                    mdWiki.Replace("[[URLADDON]]", getURLargs(values));
                    mdWiki.Replace("[[HELP]]", HTTP.getCommandAbout(workspace, c));
                    mdWiki.Replace("[[MINARGS]]", ValueCount.ToString());
                    mdWiki.Replace("[[WORKSPACE]]", workspace);
                    mdWiki.Replace("[[AREA]]", area);
                    mdWiki.Replace("[[SUBFOLDER]]", "");
                    mdWiki.Replace("[[RETURNROOT]]", "../");
                }
            }
        }