Пример #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());
        }
Пример #2
0
        public string CreateRoot()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(html_header);
            sb.Append("<h3>Build: ");
            sb.Append(buildVersion);
            sb.Append("</h3><br/>");
            sb.Append("<table class='table table-striped table-bordered'><thead><tr><th>Interface</th><th>Commands</th><th>Status</th></tr></thead><tbody>");
            foreach (KeyValuePair <string, KeyValuePair <int, string> > entry in api_reports)
            {
                sb.Append("<tr>");
                sb.Append("<td><a href='[[SUBFOLDER]]");
                sb.Append(entry.Key);
                sb.Append(".html'>");
                sb.Append(entry.Key);
                sb.Append("</a></td>");
                sb.Append("<td>");
                sb.Append(entry.Value.Key.ToString());
                sb.Append("</td><td>");
                sb.Append(entry.Value.Value);
                sb.Append("</td></tr>");
            }
            sb.Append("</tbody></table>");
            sb.Replace("[[AREA]]", "Home");
            sb.Replace("[[SUBFOLDER]]", "files/");
            sb.Replace("[[RETURNROOT]]", "");
            sb = DebugModeCreateWiki.MenuActive(sb, "Home");
            sb.Append(html_footer);
            return(sb.ToString());
        }
Пример #3
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());
     }
 }
Пример #4
0
 protected void InterfaceWorkspaces(string area, API_supported_interface shared_interface)
 {
     string[] cmds = shared_interface.GetCommandsList();
     foreach (string workspace in shared_interface.GetAllWorkspaces())
     {
         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</th></tr></thead><tbody>");
         foreach (string c in cmds)
         {
             if (shared_interface.GetCommandWorkspace(c) == workspace)
             {
                 int args = shared_interface.GetCommandArgs(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>");
                 sb.Append(args.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());
     }
 }
Пример #5
0
        protected void InterfaceIndex(string area, API_supported_interface shared_interface)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(html_header);
            sb.Append("<h3>Interface:");
            sb.Append(area);
            sb.Append("</h3><br/>");
            sb.Append("<h4>Build: ");
            sb.Append(buildVersion);
            sb.Append("</h4><br/>");
            string[] cmds = shared_interface.GetCommandsList();
            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 shared_interface.GetAllWorkspaces())
            {
                int commands_count = 0;
                foreach (string c in cmds)
                {
                    if (shared_interface.GetCommandWorkspace(c) == workspace)
                    {
                        commands_count++;
                    }
                }

                string workspace_link = "<a href='[[AREA]]" + workspace + ".html'>" + workspace + "</a>";
                sb.Append("<tr><td>");
                sb.Append(workspace_link);
                sb.Append("</td><td>");
                sb.Append(commands_count.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());
        }
Пример #6
0
        protected void InterfaceCommands(string area, API_supported_interface shared_interface, bool track_commands = false)
        {
            string[] cmds           = shared_interface.GetCommandsList();
            string   interface_name = shared_interface.GetType().Name;

            foreach (string c in cmds)
            {
                if (track_commands == true)
                {
                    if (seen_command_names.ContainsKey(c) == false)
                    {
                        seen_command_names.Add(c, interface_name);
                    }
                    else
                    {
                        LogFormater.Debug("command " + c + " from " + interface_name + " overlaps an ready loaded command from " + seen_command_names[c] + "");
                    }
                }
                string workspace = shared_interface.GetCommandWorkspace(c);


                StringBuilder sb = 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>");
                int      loop      = 0;
                int      minargs   = shared_interface.GetCommandArgs(c);
                string[] arg_types = shared_interface.GetCommandArgTypes(c);
                string[] arg_hints = shared_interface.GetCommandArgHints(c);
                if (area == "Core")
                {
                    StringBuilder ExampleCall = new StringBuilder();
                    ExampleCall.Append("Example: [[COMMAND]]");
                    ExampleCall.Append("|||");
                    string addon = "";
                    while (loop < minargs)
                    {
                        ExampleCall.Append(addon);
                        addon = "~#~";
                        string hint_value = "";
                        if (arg_hints.Length > loop)
                        {
                            if (arg_hints[loop] != null)
                            {
                                string[] bits = arg_hints[loop].Split("<br/>", StringSplitOptions.RemoveEmptyEntries);
                                if (bits.Length >= 1)
                                {
                                    hint_value = bits[0];
                                }
                            }
                        }
                        if (hint_value != "")
                        {
                            ExampleCall.Append(hint_value);
                        }
                        else
                        {
                            ExampleCall.Append("?");
                            LogFormater.Debug("[WikiMake] " + area + " Command " + c + " missing some required hint values");
                        }
                        loop++;
                    }
                    sb.Append(ExampleCall.ToString());
                    sb.Append("<hr style='border-top: 1px dashed #dcdcdc;'>");
                }



                sb.Append("[[HELP]]");
                if (arg_types.Length > 0)
                {
                    sb.Append("<hr/><h4>Args helper</h4>");
                    loop = 0;

                    sb.Append("<table class='table table-striped table-bordered'><thead><tr><td>Num</td><th>Type</th><th>Required</th><th>Hint</th></tr></thead><tbody>");
                    while (loop < arg_types.Length)
                    {
                        string hint = "";
                        if (arg_hints.Length > loop)
                        {
                            hint = arg_hints[loop];
                        }
                        string Required = "X";
                        if ((loop + 1) > minargs)
                        {
                            Required = "";
                        }
                        sb.Append("<tr><td>" + (loop + 1).ToString() + "</td><td>" + arg_types[loop] + "</td><td>" + Required + "</td><td>" + hint + "</td></tr>");

                        loop++;
                    }
                    sb.Append("</tbody></table>");
                }
                sb.Append(html_footer);
                sb.Replace("[[COMMAND]]", c);
                sb.Replace("[[HELP]]", shared_interface.GetCommandHelp(c));
                sb.Replace("[[MINARGS]]", minargs.ToString());
                sb.Replace("[[WORKSPACE]]", workspace);
                sb.Replace("[[AREA]]", area);
                sb.Replace("[[SUBFOLDER]]", "");
                sb.Replace("[[RETURNROOT]]", "../");
                sb = DebugModeCreateWiki.MenuActive(sb, area);
                string target_file = "" + area + "" + workspace + "" + c + ".html";
                io.WriteFile(target_file, sb.ToString());
            }
        }
Пример #7
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]]", "../");
                }
            }
        }