Esempio n. 1
0
        public override string Execute(int consoleWidth)
        {
            output += _js.GetNodesStats();
            output += "<color><yellow>" + ConsoleTable.GetSplitline(consoleWidth);

            string[] _tableRow = _tableRow = new string[] { "Node-ID", "Node-Name", "Node-State", "MAC-Address", "IP-Address", "Jobs Init." };
            output += ConsoleTable.FormatStringArray(consoleWidth, _tableRow);
            output += ConsoleTable.GetSplitline(consoleWidth);
            output += "<color><white>";

            lock (_js.jsLock)
            {
                List <JobNode> _nodes = _js.LGetNodes();
                foreach (JobNode _temp in _nodes)
                {
                    _tableRow[0] = _temp.id.ToString();
                    _tableRow[1] = _temp.name;
                    _tableRow[2] = _js.NodeState(_temp.state);
                    _tableRow[3] = _temp.mac.ToString();
                    _tableRow[4] = _temp.ip.ToString();
                    _tableRow[5] = _temp.jobs.Count.ToString();
                    output      += ConsoleTable.FormatStringArray(consoleWidth, _tableRow);
                }
            }

            return(output);
        }
Esempio n. 2
0
        public override string Execute(int consoleWidth)
        {
            using (DataTable _table = _db.GetSummaryTable(GetSQLSubCommand("SummaryTable", true)))
            {
                DataColumnCollection _columns = _table.Columns;
                DataRowCollection    _rows    = _table.Rows;

                output += "<color><yellow>" + ConsoleTable.GetSplitline(consoleWidth);
                output += ConsoleTable.FormatStringArray(consoleWidth, DBCLIHelper.GetColumnNames(_columns));
                output += ConsoleTable.GetSplitline(consoleWidth) + "<color><white>";

                for (int i = 0; i < _rows.Count; i++)
                {
                    output += ConsoleTable.FormatStringArray(consoleWidth, DBCLIHelper.GetRowValues(_columns, _rows[i]));
                }

                return(output);
            }
        }
Esempio n. 3
0
        public override string Execute(int consoleWidth)
        {
            if (!OParUsed("t"))
            {
                using (DataTable _table = _db.ReadTables())
                {
                    DataColumnCollection _columns = _table.Columns;
                    DataRowCollection    _rows    = _table.Rows;

                    output += "<color><yellow>" + ConsoleTable.GetSplitline(consoleWidth);
                    output += ConsoleTable.FormatStringArray(consoleWidth, DBCLIHelper.GetColumnNames(_columns));
                    output += ConsoleTable.GetSplitline(consoleWidth) + "<color><white>";

                    for (int i = 0; i < _rows.Count; i++)
                    {
                        output += ConsoleTable.FormatStringArray(consoleWidth, DBCLIHelper.GetRowValues(_columns, _rows[i]));
                    }
                }
            }
            else
            {
                string _dataTable = (string)pars.GetPar("t").argValues[0];

                using (DataTable _table = _db.SelectAllFromTable(_dataTable + GetSQLSubCommand(_dataTable, false)))
                {
                    DataColumnCollection _columns = _table.Columns;
                    DataRowCollection    _rows    = _table.Rows;

                    output += "<color><yellow>" + ConsoleTable.GetSplitline(consoleWidth);
                    output += ConsoleTable.FormatStringArray(consoleWidth, DBCLIHelper.GetColumnNames(_columns));
                    output += ConsoleTable.GetSplitline(consoleWidth) + "<color><white>";

                    for (int i = 0; i < _rows.Count; i++)
                    {
                        output += ConsoleTable.FormatStringArray(consoleWidth, DBCLIHelper.GetRowValues(_columns, _rows[i]));
                    }
                }
            }

            return(output);
        }
Esempio n. 4
0
        public override string Execute(int consoleWidth)
        {
            output += _js.GetJobsStats();
            output += "<color><yellow>" + ConsoleTable.GetSplitline(consoleWidth);

            string[] _tableRow = null;

            if (!OParUsed("more"))
            {
                _tableRow = new string[] { "Node-ID", "Job-ID", "Job-Name", "Job-Type", "Job-State", "Time-Type", "Time-Value(s)", "Output-State" }
            }
            ;
            else
            {
                _tableRow = new string[] { "Node-ID", "Job-ID", "Job-Name", "Job-Type", "Job-State", "Time-Type", "Time-Value(s)", "Last-Started", "Last-Stopped", "Last-Delta", "Output-State" }
            };

            output += ConsoleTable.FormatStringArray(consoleWidth, _tableRow);
            output += ConsoleTable.GetSplitline(consoleWidth);
            output += "<color><white>";

            lock (_js.jsLock)
            {
                List <JobNode> _nodes = _js.LGetNodes();
                foreach (JobNode _temp in _nodes)
                {
                    foreach (Job _temp2 in _temp.jobs)
                    {
                        if (_temp2.state == 0 || _temp2.state == 1)
                        {
                            _tableRow[0] = _temp.id.ToString();
                            _tableRow[1] = _temp2.id.ToString();
                            _tableRow[2] = _temp2.name;
                            _tableRow[3] = _temp2.type.ToString();
                            _tableRow[4] = _js.JobState(_temp2.state);
                            _tableRow[5] = _temp2.time.type.ToString();
                            _tableRow[6] = _temp2.time.GetValues();

                            if (!OParUsed("more"))
                            {
                                _tableRow[7] = _temp2.outp.outState.ToString();
                            }
                            else
                            {
                                _tableRow[7]  = _temp2.tStart.ToString("HH:mm:ss");
                                _tableRow[8]  = _temp2.tStop.ToString("HH:mm:ss");
                                _tableRow[9]  = "+" + _temp2.tSpan.Seconds + "s" + _temp2.tSpan.Milliseconds + "ms";
                                _tableRow[10] = _temp2.outp.outState.ToString();
                            }
                        }
                        else
                        {
                            _tableRow[0] = _temp.id.ToString();
                            _tableRow[1] = _temp2.id.ToString();
                            _tableRow[2] = "-";
                            _tableRow[3] = "-";
                            _tableRow[4] = _js.JobState(_temp2.state);
                            _tableRow[5] = "-";
                            _tableRow[6] = "-";

                            if (!OParUsed("more"))
                            {
                                _tableRow[7] = "-";
                            }
                            else
                            {
                                _tableRow[7]  = "-";
                                _tableRow[8]  = "-";
                                _tableRow[9]  = "-";
                                _tableRow[10] = "-";
                            }
                        }

                        output += ConsoleTable.FormatStringArray(consoleWidth, _tableRow);
                    }
                }
                return(output);
            }
        }
    }
Esempio n. 5
0
        public override string Execute(int consoleWidth)
        {
            if (!OParUsed("id"))
            {
                output += "<color><yellow>Type 'help -id <COMMAND-ID>' to get more information about a command.\n";
                output += "<color><yellow>Available Commands:\n\n<color><white>";

                int      i2       = 0;
                string[] _buffer2 = new string[3] {
                    "", "", ""
                };
                for (int i = 0; i < _commands.Count; i++)
                {
                    _buffer2[i2] = "[" + i + "] " + _commands[i].command;

                    if (i2 == 2)
                    {
                        i2       = -1;
                        output  += ConsoleTable.FormatStringArray(consoleWidth, _buffer2);
                        _buffer2 = new string[3] {
                            "", "", ""
                        };
                    }

                    if (i == _commands.Count - 1)
                    {
                        output += ConsoleTable.FormatStringArray(consoleWidth, _buffer2);
                    }

                    i2++;
                }

                output += "\n";
            }
            else
            {
                int commandIndex = (int)pars.GetPar("id").argValues[0];

                try
                {
                    CommandOptions commandOptions = _commands[commandIndex];
                    Type           commandType    = commandOptions.commandType;
                    Command        tempCommand;

                    System.Reflection.ConstructorInfo cInfo = commandType.GetConstructor(new Type[1] {
                        typeof(object[])
                    });

                    if (cInfo == null)
                    {
                        cInfo       = commandType.GetConstructor(new Type[0]);
                        tempCommand = (Command)cInfo.Invoke(null);
                    }
                    else
                    {
                        tempCommand = (Command)cInfo.Invoke(new object[] { commandOptions.commandObjects });
                    }

                    output += "<color><yellow>COMMAND     <color><white>" + commandOptions.command + "<color><darkyellow> [" + commandIndex + "]\n";
                    output += "<color><yellow>DESCRIPTION <color><white>" + tempCommand.description + "\n";
                    output += "<color><yellow>USAGE       <color><white>" + GenUsageText(tempCommand, commandOptions) + "\n";
                    output += "<color><yellow>PARAMETER(S)\n";

                    if (!(tempCommand.rPar.Count == 0 && tempCommand.oPar.Count == 0))
                    {
                        if (tempCommand.rPar.Count != 0)
                        {
                            output += "\t<color><yellow>REQUIRED PARAMETER(S)\n\n";

                            foreach (ParOption _temp in tempCommand.rPar)
                            {
                                output += "\t<color><darkyellow>-" + _temp.par + " <color><white>";

                                if (_temp.multiargs)
                                {
                                    output += "<arg_1> <arg_2> ...";
                                }
                                else
                                if (!_temp.argEmpty)
                                {
                                    output += "<arg>";
                                }

                                output += "\n";
                                output += "\t<color><gray>" + _temp.description + "\n\n";
                            }
                        }

                        if (tempCommand.oPar.Count != 0)
                        {
                            output += "\t<color><yellow>OPTIONAL PARAMETER(S)\n\n";

                            foreach (ParOption _temp in tempCommand.oPar)
                            {
                                output += "\t<color><darkyellow>-" + _temp.par + " <color><white>";

                                if (_temp.multiargs)
                                {
                                    output += "<arg_1> <arg_2> ...";
                                }
                                else
                                if (!_temp.argEmpty)
                                {
                                    output += "<arg>";
                                }

                                output += "\n";
                                output += "\t<color><gray>" + _temp.description + "\n\n";
                            }
                        }
                    }
                    else
                    {
                        output += "\n\t<color><gray>(command does not use any parameters)\n";
                    }
                }
                catch (Exception)
                {
                    output = "<color><red>Command with the ID '" + commandIndex + "' does not exist!";
                }
            }

            return(output);
        }