/// <summary> /// Export employees table to html file /// </summary> private static void ExportEmployeeListToHtml() { string html = AnsiConsole.ExportHtml(); string directory = $"../Employes-{DateTime.Now.Year}/index.html"; Directory.CreateDirectory(directory.Replace("/index.html", "")); File.WriteAllText(directory, html); File.AppendAllText(directory, $"Generado por el sistema {DateTime.Now}"); Console.ForegroundColor = Color.Green; Console.WriteLine("Guardado Exitosamente"); Console.ForegroundColor = Color.White; }
public override bool Execute(LamarServicesInput input) { if (input.FileFlag.IsNotEmpty()) { AnsiConsole.Record(); } AnsiConsole.Render(new FigletText("Lamar") { Color = Color.Blue }); using (var host = input.BuildHost()) { var container = (IContainer)host.Services; // TODO -- check for the interactive mode here. var configurations = input.Query(container) .GroupBy(x => x.ServiceType.ResolveServiceType().Assembly) .OrderBy(x => x.Key.FullName) .ToArray(); var display = input.BuildPlansFlag ? WhatDoIHaveDisplay.BuildPlan : WhatDoIHaveDisplay.Summary; WriteSummaries(input, configurations, display, container); if (input.FileFlag.IsNotEmpty()) { var fullPath = input.FileFlag.ToFullPath(); Console.WriteLine("Writing the query results to " + fullPath); var extension = Path.GetExtension(fullPath); if (extension.EndsWith("htm", StringComparison.OrdinalIgnoreCase) || extension.EndsWith("html", StringComparison.OrdinalIgnoreCase)) { File.WriteAllText(fullPath, AnsiConsole.ExportHtml()); } else { File.WriteAllText(fullPath, AnsiConsole.ExportText()); } } } return(true); }
static async Task Main(string[] args) { string name, surname; int birthday; List <Person> personsList = new List <Person> (); do { Console.WriteLine("1- Para agregar persona\n2- Para mostrar información"); var option = int.Parse(Console.ReadLine()); switch (option) { case 1: name = AnsiConsole.Ask <string> ("Cual es tu [blue]nombre[/]?"); surname = AnsiConsole.Ask <string> ("Cual es tu [blue]apellido[/]?"); birthday = AnsiConsole.Ask <int> ("Cual es tu [green]año de nacimiento[/]?"); Person persona = new Person(name, surname, birthday); personsList.Add(persona); AnsiConsole.Status() .Start("Guardando...", ctx => { Thread.Sleep(1000); // Update the status and spinner ctx.Status("Finalizado"); ctx.Spinner(Spinner.Known.Star); ctx.SpinnerStyle(Style.Parse("green")); Thread.Sleep(1000); }); Console.Clear(); break; case 2: var saveTable = AnsiConsole.Confirm("Guardar tabla?"); AnsiConsole.Record(); Table table = new Table(); table.AddColumn("Nombre"); table.AddColumn("Apellido"); table.AddColumn("Edad"); table.AddColumn("Pais"); table.AddColumn("Ciudad"); table.AddColumn("Idioma"); table.AddColumn("Cordenadas"); foreach (var item in personsList) { table.AddRow(item.Name, item.Surname, item.Birthday.ToString(), item.Country, item.City, item.Language, item.Cordinates); } var title = new TableTitle("Empleado", Style.WithDecoration(Decoration.Bold)); table.Title = title; table.Border(TableBorder.Rounded); table.BorderColor <Table> (Color.Blue); AnsiConsole.Render(table); if (saveTable) { string html = AnsiConsole.ExportHtml(); Directory.CreateDirectory("../Employes"); File.WriteAllText("../Employes/index.html", html); Console.ForegroundColor = Color.Green; Console.WriteLine("Guardado Exitosamente"); Console.ForegroundColor = Color.White; } break; default: break; } } while (true); }