Example #1
0
    void Start()
    {
        terminalController = GetComponent <TerminalController>();
        commandDB          = GetComponent <CommandDB>();

        ResetHintColor();
    }
Example #2
0
    //public CommandDB.UserMode currentUserMode;
    //PCController pcController;
    void Awake()
    {
        //pcController = GetComponent<TerminalController>().GetCurrentPc();

        commandDB = GetComponent <CommandDB>();
        //commandDB.userMode = CommandDB.UserMode.Guest;
        //currentUserMode = CommandDB.UserMode.Guest;
        //commands = commandDB.GetCommands();
    }
Example #3
0
        public CommandModule()
            : base("/command/mgmt")
        {
            this.RequiresAuthentication();

            Get["/"] = x => {
                dynamic vmod = new ExpandoObject();
                vmod.list = CommandDB.GetAll();
                return(View["page-command-mgmt", vmod]);
            };

            Post["/"] = x => {
                string command       = this.Request.Form.Command;
                string layout        = this.Request.Form.CommandLayout;
                string notes         = this.Request.Form.Notes;
                string inputid       = this.Request.Form.InputID;
                string inputlocation = this.Request.Url;
                CommandDB.Create(inputid, command, layout, inputlocation, notes);
                return(Response.AsRedirect("/command/mgmt"));
            };

            Post["/launch/{guid}"] = x => {
                string guid   = x.guid;
                string result = CommandDB.LaunchAndGetOutput(guid);
                return(Response.AsJson(result));
            };

            Post["/delete/{guid}"] = x => {
                string guid = x.guid;
                CommandDB.Delete(guid);
                return(Response.AsJson(true));
            };

            Get["/ex/{inputid}"] = x => {
                string inputid = x.inputid;
                var    r       = CommandDB.LaunchAndGetOutputUsingNewValue(inputid);
                return(Response.AsJson(r));
            };

            Get["/ex/{inputid}/{value}"] = x => {
                string inputid = x.inputid;
                string value   = x.value;
                var    r       = CommandDB.LaunchAndGetOutputUsingNewValue(inputid, value);
                return(Response.AsJson(r));
            };
        }
Example #4
0
        public CCTableModule()
            : base("/cctable")
        {
            this.RequiresAuthentication();

            Get["/"] = x => {
                dynamic vmod = new ExpandoObject();
                vmod.list = CCTableRepository.GetAll();
                return(View["_page-cctable", vmod]);
            };

            Post["/"] = x => {
                string tbl = (string)this.Request.Form.Alias;
                if (tbl != "")
                {
                    CCTableRepository.CreateTable(tbl);
                }
                return(Response.AsRedirect("/cctable"));
            };

            Post["/row"] = x => {
                string table        = (string)this.Request.Form.TableGuid;
                string tableName    = (string)this.Request.Form.TableName;
                string label        = (string)this.Request.Form.Label;
                string inputType    = (string)this.Request.Form.InputType.Value;
                string inputValue   = (string)this.Request.Form.InputLabel;
                string inputCommand = (string)this.Request.Form.InputCommand;
                string notes        = (string)this.Request.Form.Notes;
                CCTableRepository.CreateRow(table, tableName, label, inputType, inputValue, inputCommand, notes);

                string command       = this.Request.Form.CCTableCommand;
                string inputid       = "New" + tableName.UppercaseAllFirstLetters().RemoveWhiteSpace() + label.UppercaseAllFirstLetters().RemoveWhiteSpace();
                string inputlocation = "CCTable" + this.Request.Form.TableName;
                CommandDB.Create(inputid, command, command, inputlocation, notes);

                return(Response.AsRedirect("/cctable"));
            };

            Get["/delete/table/{guid}"] = x => {
                string guid = x.guid;
                CCTableRepository.DeleteTable(guid);
                return(Response.AsJson("CCTable deleted"));
            };
        }
Example #5
0
 void Awake()
 {
     commandDB = GetComponent <CommandDB>();
 }
Example #6
0
        public List <string> GetActionStatus(string[] param)
        {
            CommandDB commandDB = Global.UIElement.GetTerminalWindow().GetComponent <CommandDB>();


            if (param.Length == 2)
            {
                if (param[1] == "-all")
                {
                    List <string> responce = new List <string>();

                    foreach (KeyValuePair <string, ICommandAction> entry in commandDB.GetCommands())
                    {
                        responce.Add(entry.Key + " - " + entry.Value.GetDescription());

                        if (entry.Value.GetParams() != null)
                        {
                            List <string> flags = new List <string>(entry.Value.GetParams().Keys);
                            responce.Add(entry.Key + " ( " + string.Join(", ", flags) + " )");

                            foreach (KeyValuePair <string, string> flagData in entry.Value.GetParams())
                            {
                                responce.Add(flagData.Key + " " + flagData.Value);
                            }
                        }

                        responce.Add("");
                    }

                    return(responce);
                }
                else if (param[1] == "-f")
                {
                    List <string> responce = new List <string>();

                    foreach (KeyValuePair <string, ICommandAction> entry in commandDB.GetCommands())
                    {
                        if (entry.Value.GetParams() != null)
                        {
                            List <string> flags = new List <string>(entry.Value.GetParams().Keys);
                            responce.Add(entry.Key + " ( " + string.Join(", ", flags) + " )");
                        }
                        else
                        {
                            responce.Add(entry.Key + "( No flags )");
                        }

                        responce.Add("");
                    }

                    return(responce);
                }
            }
            else if (param.Length == 1)
            {
                return(new List <string>(commandDB.GetCommands().Keys));
            }
            else if (param.Length == 3)
            {
                if (param[1] == "-s")
                {
                    CommandDB commandDb = Global.Component.GetCommandDB();

                    Dictionary <string, ICommandAction> commands = commandDb.GetCommands();

                    if (commands.ContainsKey(param[2]))
                    {
                        return(new List <string>()
                        {
                            param[2] + ": " + commands[param[2]].GetDescription()
                        });
                    }
                    else
                    {
                        return(new List <string> {
                            "Command not found"
                        });
                    }
                }

                if (param[1] == "-sf")
                {
                    CommandDB commandDb = Global.Component.GetCommandDB();

                    Dictionary <string, ICommandAction> commands = commandDb.GetCommands();

                    if (commands.ContainsKey(param[2]))
                    {
                        List <string> resp = new List <string>()
                        {
                            param[2] + ": " + commands[param[2]].GetDescription()
                        };

                        List <string> temp = new List <string>();

                        foreach (var item in commands[param[2]].GetParams())
                        {
                            temp.Add(item.Key + " " + item.Value);
                        }

                        resp.AddRange(temp);

                        return(resp);
                    }
                    else
                    {
                        return(new List <string> {
                            "Command not found"
                        });
                    }
                }
            }

            return(null);
        }