public async Task GetProcesses(CommandContext ctx) { if (!Bot.Config.ProcessesEnabled) { Logger.Log( $"Processes requested by {ctx.User.Username}#{ctx.User.Discriminator}, but it was toggled off.", ctx, LogLevel.Info); await ctx.Message.CreateReactionAsync(DiscordEmoji.FromUnicode("🔕")); return; } Logger.Log($"Processes requested by {ctx.User.Username}#{ctx.User.Discriminator}", ctx, LogLevel.Info); var procs = Process.GetProcesses().Where(x => x.SessionId == Process.GetCurrentProcess().SessionId) .OrderByDescending(x => x.PrivateMemorySize64) .ToList(); var table = new ConsoleTable("Name", "Memory", "Uptime"); foreach (var process in procs.Take(15)) { try { table.AddRow($"{process.ProcessName}", $"{process.PrivateMemorySize64 / 1000000}MB", $"{DateTime.Now - process.StartTime:h'h 'm'm 's's'}"); } catch (Exception) { table.AddRow($"{process.ProcessName}", $"{process.PrivateMemorySize64 / 1000000}MB", "Not available!"); } } var response = table.Configure(x => x.NumberAlignment = Alignment.Right).ToMinimalString(); await ctx.RespondAsync($"```{response}```"); }
protected static void ProcessCvsAndSaveToDbAndConsoleDisplayResults(IAddressService addressService) { System.Console.WriteLine("Twiddle your fingers whilst this is working at the back..."); var csvRecords = CsvFileReader.Read(CsvFilePathImport); CustomValidator.ValidateJsonCsvAddressesReaderDtos(csvRecords); addressService.UploadAddressesToDb(csvRecords); var table = new ConsoleTable("AddressId ", "Name", "Surname", "Company", "Street", "City", "County ", "Postcode", "Phone ", "Email", "Updated "); var rawEntityDataStraightFromContext = addressService.FindAddressesForDemoPurposes(); foreach (var data in rawEntityDataStraightFromContext) { table.AddRow(data.AddressId, data.Name, data.Surname, data.Company, data.Street, data.City, data.County, data.Postcode, data.Phone, data.Email, data.Updated); } table.Configure(o => o.NumberAlignment = Alignment.Left); table.Write(); ClearScreenAfterInteraction("There you go! You do not have to query your database. Press any key to clear screen and use other options..."); }
public async Task ProcessesTask(CommandContext ctx) { Logger.Log($"Processes requested by {ctx.User.Username} in #{ctx.Channel.Name} ({ctx.Guild.Name})", LogLevel.Info); var table = new ConsoleTable("Name", "RAM", "Uptime"); Process.GetProcesses() .Where(x => x.SessionId == Process.GetCurrentProcess().SessionId) .OrderByDescending(p => p.PrivateMemorySize64) .Take(15) .ToList() .ForEach(process => { try { table.AddRow($"{process.ProcessName}", $"{process.PrivateMemorySize64 / 1_000_000}MB", $"{DateTime.Now - process.StartTime:h'h 'm'm 's's'}"); } catch { table.AddRow($"{process.ProcessName}", $"{process.PrivateMemorySize64 / 1_000_000}MB", "Not available"); } }); var tableString = table.Configure(x => x.NumberAlignment = Alignment.Right).ToMinimalString(); StalkbotClient.UpdateLastMessage(await ctx.RespondAsync($"```{tableString}```")); }
static int Columns(string file, string name) { if (!File.Exists(file)) { Error("File not found: " + file); return(1); } using var csvz = CsvZipPackage.Open(file); var entry = csvz.FindEntry(name); var cols = entry.GetColumnSchema(); var table = new ConsoleTable("Column", "Ordinal", "Type", "Nullable"); table.Configure(o => o.NumberAlignment = Alignment.Right); foreach (var col in cols.OrderBy(c => c.ColumnOrdinal)) { table.AddRow(col.ColumnName, col.ColumnOrdinal, col.DataTypeName, col.AllowDBNull); } table.Write(Format.Minimal); return(0); }
static void Analyze(List <CompileTimeInfoContainer> container) { var ex = container .SelectMany(m => m.infos) .Where(m => m.compileGroupName == "Source") .GroupBy(m => m.name) .OrderByDescending(m => m.Aggregate(0.0f, (m, n) => m + n.durationMilliSeconds)) .Select(m => { var file = Path.GetFileName(m.Key); var totalSecounds = MathF.Ceiling(m.Aggregate(0.0f, (n, o) => n + o.durationMilliSeconds) / 10000) / 100; return(file, m.Count(), totalSecounds); }); var table = new ConsoleTable("File", "Count", "Secounds"); var e = ex.Select(m => { table.AddRow(m.file, m.Item2, m.totalSecounds); return(0); }).ToList(); table .Configure(m => m.EnableCount = true) .Configure(m => m.NumberAlignment = Alignment.Right) .Write(Format.Minimal); var totalExecute = MathF.Ceiling(container .SelectMany(m => m.infos) .Where(n => n.compileGroupName == "Total ExecuteCompiler") .Aggregate(0.0f, (o, p) => o + p.durationMilliSeconds) / 10000) / 100; Console.WriteLine($"Total ExecuteCompiler: {totalExecute}"); }
public string GetShopItemsOutput() { var table = new ConsoleTable("name", "sellIn", "quality"); table.Configure(options => options.EnableCount = false); _shop.Items.ForEach(item => { table.AddRow(item.Name, item.SellIn, item.Quality); }); return(table.ToMinimalString()); }
static async Task Main(string[] args) { var config = new ConfigurationBuilder() .SetBasePath(Environment.CurrentDirectory) .AddJsonFile("appsettings.json", false) .Build(); var files = Directory.EnumerateFiles(config["inputDir"]); var outputDir = Directory.CreateDirectory(config["outputDir"]); var workQueue = new ConcurrentQueue <string>(); foreach (var value in files) { workQueue.Enqueue(value); } var tasks = new List <Task>(); var results = new ConcurrentBag <TranscriptionResult>(); var timer = new Stopwatch(); timer.Start(); foreach (var value in Enumerable.Range(0, int.Parse(config["workers"]))) { tasks.Add(Worker.Work(workQueue, config, results)); } await Task.WhenAll(tasks); timer.Stop(); if (bool.Parse(config["demoMode"])) { var totalFilesize = 0d; var totalDuration = TimeSpan.Zero; var totalLatency = timer.ElapsedMilliseconds; var table = new ConsoleTable("File", "Size (MB)", "Duration", "Latency (ms)", "Realtime Factor"); foreach (var result in results) { table.AddRow(result.Filename, Math.Round(result.FilesizeInMegabytes, 2), result.AudioDuration.ToString("g"), result.Latency, Math.Round(result.RealtimeSpeedup, 0)); totalFilesize += result.FilesizeInMegabytes; totalDuration = totalDuration.Add(result.AudioDuration); } var totalSpeedup = Math.Round(totalDuration.TotalMilliseconds / totalLatency, 0); table.AddRow($"TOTAL ({results.Count} files)", Math.Round(totalFilesize, 2), totalDuration.ToString("g"), totalLatency, totalSpeedup); table.Configure(o => o.EnableCount = false); Console.WriteLine(TextConstants.TranscriptionComplete); table.Write(); } }
public override async Task Execute() { using var identifier = Prompt.GetPasswordAsSecureString("Identifier:", ConsoleColor.Yellow); using var passphrase = Prompt.GetPasswordAsSecureString("Passphrase:", ConsoleColor.Yellow); try { var session = _walletService.SessionAddOrUpdate(new Session(identifier, passphrase)); await Spinner.StartAsync("Looking up history ...", spinner => { var request = _walletService.History(session.SessionId); if (!request.Success) { _console.ForegroundColor = ConsoleColor.Red; _console.WriteLine("\nWallet history request failed."); if (request.NonSuccessMessage != null) { _console.WriteLine($"{request.NonSuccessMessage}"); } _console.ForegroundColor = ConsoleColor.White; return(Task.CompletedTask); } if (!request.Result.Any()) { NoTxn(); return(Task.CompletedTask); } var table = new ConsoleTable("DateTime", "Memo", "MoneyOut", "Fee", "MoneyIn", "Reward", "Balance"); foreach (var sheet in request.Result) { table.AddRow(sheet.Date, sheet.Memo, sheet.MoneyOut, sheet.Fee, sheet.MoneyIn, sheet.Reward, sheet.Balance); } table.Configure(o => o.NumberAlignment = Alignment.Right); _console.WriteLine($"\n{table.ToString()}"); return(Task.CompletedTask); }); } catch (Exception ex) { NoTxn(ex); } }
void IOutput.Write(IEnumerable <string> header, IEnumerable <IEnumerable <string> > rows) { var table = new ConsoleTable(header.ToArray()); table.Configure(_tableConfiguration); foreach (var row in rows) { table.AddRow(row.ToArray()); } table.Write(); }
// Zoznam hracov public static void PlayersList() { using (var client = new Client()) { var players = (List <Items.Player>)client.GetListAsync(new Uri(serverUri, "players/all"), typeof(List <Items.Player>)).Result; var table = new ConsoleTable("Nickname", "Game"); foreach (var p in players) { table.AddRow(p.Nickname, p.GameId); } table.Configure(o => o.EnableCount = false); table.Write(Format.Alternative); } }
// Zobraz profil hraca public static void Profile() { // Vytvor spojenie using (var client = new Client()) { myPlayer = client.GetPlayerAsync(new Uri(serverUri, "players/player"), myPlayer).Result; var table = new ConsoleTable("Nickname", "Game", "Wallet [$]", "State"); if (myPlayer != null) { table.AddRow(myPlayer.Nickname, myPlayer.GameId, myPlayer.Wallet, myPlayer.State); table.Configure(o => { o.NumberAlignment = Alignment.Right; o.EnableCount = false; }); table.Write(Format.Alternative); } } }
public override string ToString() { var table = new ConsoleTable("R.Br", "M_Rd", "N_Rd", "x", "Fc", "zc", "Fs1", "zs1", "Fs2", "zs2"); List <object[]> rows = new List <object[]>(); List.ForEach(x => { table.Rows.Add(new object[] { List.IndexOf(x), x.M_Rd.Round(2), x.N_Rd.Round(2), x.x.Round(2), x.F_c.Round(2), x.z_c.Round(2), x.F_s1.Round(2), x.z_s1.Round(2), x.F_s2.Round(2), x.z_s2.Round(2) }); }); var s = table .Configure(o => o.NumberAlignment = Alignment.Right) .ToMarkDownString(); return(s); }
static int Tables(string file) { if (!File.Exists(file)) { Error("File not found: " + file); return(1); } using var csvz = CsvZipPackage.Open(file); var table = new ConsoleTable("Table", "Size", "Rows", "Columns"); table.Configure(o => o.NumberAlignment = Alignment.Right); foreach (var entry in csvz.Entries) { table.AddRow(entry.Name, entry.Length, entry.RowCount, entry.ColumnCount); } table.Write(Format.Minimal); return(0); }