Ejemplo n.º 1
0
        public void TestSetColSpan()
        {
            var cs    = new CellStyle(CellHorizontalAlignment.Left, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);
            var csr   = new CellStyle(CellHorizontalAlignment.Right, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);
            var csc   = new CellStyle(CellHorizontalAlignment.Center, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);
            var table = new TextTable(2, TableBordersStyle.CLASSIC, TableVisibleBorders.ALL, false, "");

            table.Columns.ElementAt(0).SetWidthRange(6, 10);
            table.Columns.ElementAt(1).SetWidthRange(2, 7);

            table.AddCell("abcd", cs);
            table.AddCell("123456", cs);
            table.AddCell("mno", cs, 2);
            table.AddCell("xyztu", csr, 2);
            table.AddCell("efgh", csc, 2);

            Assert.AreEqual(""
                            + "+------+------+\n"
                            + "|abcd  |123456|\n"
                            + "+-------------+\n"
                            + "|mno          |\n"
                            + "+-------------+\n"
                            + "|        xyztu|\n"
                            + "+-------------+\n"
                            + "|    efgh     |\n"
                            + "+-------------+", table.Render());
        }
Ejemplo n.º 2
0
        public void TestCenteredColSpan()
        {
            var cellStyle1 = new CellStyle(CellHorizontalAlignment.Left, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);
            var cellStyle2 = new CellStyle(CellHorizontalAlignment.Right, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);

            var table = new TextTable(4, TableBordersStyle.CLASSIC, TableVisibleBorders.ALL, false, string.Empty);

            table.Columns[0].SetWidthRange(3, 10);
            table.Columns[1].SetWidthRange(2, 7);
            table.Columns[2].SetWidthRange(3, 10);

            table.AddCell("abcd", cellStyle1);
            table.AddCell("123456", cellStyle1);
            table.AddCell("efgh", cellStyle1);
            table.AddCell("789012", cellStyle1);

            table.AddCell("ijkl", cellStyle1);
            table.AddCell("mno", cellStyle1, 2);
            table.AddCell("345678", cellStyle1);

            table.AddCell("mnop", cellStyle1);
            table.AddCell("901234", cellStyle1);
            table.AddCell("qrst", cellStyle1);
            table.AddCell("567890", cellStyle1);

            Assert.AreEqual(""
                            + "+----+------+----+------+\n"
                            + "|abcd|123456|efgh|789012|\n"
                            + "+----+-----------+------+\n"
                            + "|ijkl|mno        |345678|\n"
                            + "+----+-----------+------+\n"
                            + "|mnop|901234|qrst|567890|\n"
                            + "+----+------+----+------+", table.Render());
        }
        public void TestEmptyCell()
        {
            var cellStyle = new CellStyle(CellHorizontalAlignment.Left, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);
            var table     = new TextTable(1, TableBordersStyle.CLASSIC, TableVisibleBorders.ALL, false, "");

            table.AddCell("", cellStyle);
            Assert.AreEqual(""
                            + "++\n"
                            + "||\n"
                            + "++", table.Render());
        }
Ejemplo n.º 4
0
        public void TestWideIncompleteNullCell()
        {
            var cellStyle = new CellStyle(CellHorizontalAlignment.Left, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);
            var table     = new TextTable(7, TableBordersStyle.CLASSIC, TableVisibleBorders.ALL, false, string.Empty);

            table.AddCell(null, cellStyle, 3);

            Assert.AreEqual(""
                            + "+--+++++\n"
                            + "|  |||||\n"
                            + "+--+++++", table.Render());
        }
        public void TestTwoCellsHorizontal()
        {
            var cellStyle = new CellStyle(CellHorizontalAlignment.Left, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);
            var textTable = new TextTable(2, TableBordersStyle.CLASSIC, TableVisibleBorders.ALL, false, "");

            textTable.AddCell("abcdef", cellStyle);
            textTable.AddCell("123456", cellStyle);

            Assert.AreEqual(""
                            + "+------+------+\n"
                            + "|abcdef|123456|\n"
                            + "+------+------+", textTable.Render());
        }
Ejemplo n.º 6
0
        public void TestTooWideCell()
        {
            var cellStyle = new CellStyle(CellHorizontalAlignment.Left, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);
            var table     = new TextTable(3, TableBordersStyle.CLASSIC, TableVisibleBorders.ALL, false, "");

            table.AddCell("abc", cellStyle, 5);
            table.AddCell("defg", cellStyle, 5);
            Assert.AreEqual(""
                            + "+----+\n"
                            + "|abc |\n"
                            + "+----+\n"
                            + "|defg|\n"
                            + "+----+", table.Render());
        }
Ejemplo n.º 7
0
    private static void FormatAndWriteToConsole(IList <PackageLibYear>?libYearPackages)
    {
        if (libYearPackages != null)
        {
            var libYearTotal = libYearPackages.Sum(libYear => libYear.LibYear);

            var tableStyle = new CellStyle(CellHorizontalAlignment.Right);
            var table      = new TextTable(6, TableBordersStyle.DESIGN_FORMAL,
                                           TableVisibleBorders.SURROUND_HEADER_FOOTER_AND_COLUMNS);

            table.AddCell(CliOutput.ComputeLibYearCommandRunner_Table_Header_Package);
            table.AddCell(CliOutput.ComputeLibYearCommandRunner_Table_Header_Currently_Installed);
            table.AddCell(CliOutput.ComputeLibYearCommandRunner_Table_Header_Released_at);
            table.AddCell(CliOutput.ComputeLibYearCommandRunner_Table_Header_Latest_Available);
            table.AddCell(CliOutput.ComputeLibYearCommandRunner_Table_Header_Released_at);
            table.AddCell("Libyear");

            foreach (var libYearPackage in libYearPackages)
            {
                if (libYearPackage.ExceptionMessage == null)
                {
                    _ = libYearPackage.CurrentVersion ??
                        throw new NullReferenceException("libYearPackage has no CurrentVersion");
                    _ = libYearPackage.LatestVersion ??
                        throw new NullReferenceException("libYearPackage has no LatestVersion");

                    table.AddCell(libYearPackage.CurrentVersion.Name);
                    table.AddCell(libYearPackage.CurrentVersion.Version, tableStyle);
                    table.AddCell(libYearPackage.ReleaseDateCurrentVersion.ToString("s"), tableStyle);
                    table.AddCell(libYearPackage.LatestVersion.Version, tableStyle);
                    table.AddCell(libYearPackage.ReleaseDateLatestVersion.ToString("s"), tableStyle);
                    table.AddCell(libYearPackage.LibYear.ToString(CultureInfo.InvariantCulture.NumberFormat),
                                  tableStyle);
                    continue;
                }

                _ = libYearPackage.PackageUrl ??
                    throw new NullReferenceException("libYearPackage has no LatestVersion");

                table.AddCell(libYearPackage.PackageUrl.Name, tableStyle);
                table.AddCell(libYearPackage.ExceptionMessage, tableStyle, 5);
            }

            table.AddCell("Total", tableStyle, 5);
            table.AddCell(libYearTotal.ToString(CultureInfo.InvariantCulture.NumberFormat), tableStyle);

            Console.WriteLine(table.Render());
        }
    }
Ejemplo n.º 8
0
        public static void Main(string[] args)
        {
            // The header
            string[] headers = new string[] { "Atomic Number", "Abreviation", "Name", "Atomic Weight" };
            // The table
            TextTable tt = new TextTable(headers);

            // Adjust lengths and alignment
            tt.Header[0].CellAlignment = Align.Right;
            tt.Header[1].CellAlignment = Align.Center;
            tt.Header[2].CellAlignment = Align.Left;
            tt.Header[2].Alignment     = Align.Center;
            tt.Header[2].MaximumLength = 6;
            tt.Header[3].CellAlignment = Align.Right;
            // Print the data into the console!
            tt.Render(data);
        }
Ejemplo n.º 9
0
    private static void FormatAndWriteToConsole(Dictionary <string, string> agentsAndLocations)
    {
        var basicTable = new TextTable(2);

        basicTable.AddCell("Agent file");
        basicTable.AddCell("Agent path");

        foreach (var agentAndLocation in agentsAndLocations)
        {
            basicTable.AddCell(agentAndLocation.Key);
            basicTable.AddCell(agentAndLocation.Value);
        }

        Console.WriteLine(agentsAndLocations.Count == 0
            ? CliOutput.AgentsDetectCommandRunner_Run_No_detected_agents_found
            : basicTable.Render());
    }
Ejemplo n.º 10
0
        public override TaskResult StartTask()
        {
            var data = new List <string[]>()
            {
                new string[] { "Darth", "Vader", "Sith", "Empire" },
                new string[] { "Luke", "Skywalker", "Jedi", "Rebellion" },
                new string[] { "Leia", "Organa", "Princess", "Rebellion" },
            };

            var data2 = new List <Bag>()
            {
                new Bag()
                {
                    Name = "X-Wing", Length = 105, Decription = "Cool Starfighter"
                },
                new Bag()
                {
                    Name = "TIE Fighter", Length = 162, Decription = "Freaky fast and meneuverable fighter"
                },
                new Bag()
                {
                    Name = "Millenium Falcon", Length = 783, Decription = "THe ship that made the Kessel Run in less than 12 parsecs"
                },
            };

            var table = new TextTable()
                        .AddColumn("Col1", 12)
                        .AddColumn("col2", 4, AlignmentType.Center)
                        .AddColumn("col3", 12, AlignmentType.Right)
            ;

            var table2 = new TextTable()
                         .AddColumn("Col1", 12)
                         .AddColumn("col2", 4, AlignmentType.Center)
                         .AddColumn("col3", 12, AlignmentType.Right)
            ;

            Console.WriteLine(table.Render(data));
            Console.WriteLine(table2.Render(data2));
            Console.WriteLine(new TextTable().Render(data2));
            Console.WriteLine(new TextTable().Render(data2.Select(o => new { Vehicle = o.Name, LOA = o.Length, CatchPhrase = o.Decription })));
            Console.WriteLine(new TextTable().Render(data2.Select(o => new { Vehicle = o.Name, Catch_Phrase = o.Decription })));

            return(TaskResult.Complete());
        }
        public void TestAutomaticWidth()
        {
            var cellStyle = new CellStyle(CellHorizontalAlignment.Left, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);
            var textTable = new TextTable(2, TableBordersStyle.CLASSIC, TableVisibleBorders.ALL, false, "");

            textTable.AddCell("abcdef", cellStyle);
            textTable.AddCell("123456", cellStyle);
            textTable.AddCell("mno", cellStyle);
            textTable.AddCell("45689", cellStyle);
            textTable.AddCell("xyztuvw", cellStyle);
            textTable.AddCell("01234567", cellStyle);

            Assert.AreEqual(""
                            + "+-------+--------+\n"
                            + "|abcdef |123456  |\n"
                            + "+-------+--------+\n"
                            + "|mno    |45689   |\n"
                            + "+-------+--------+\n"
                            + "|xyztuvw|01234567|\n"
                            + "+-------+--------+", textTable.Render());
        }
        public void TestMissingCell()
        {
            var cellStyle = new CellStyle(CellHorizontalAlignment.Left, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);
            var table     = new TextTable(2, TableBordersStyle.CLASSIC, TableVisibleBorders.ALL, false, "");

            table.Columns[0].SetWidthRange(6, 10);
            table.Columns[1].SetWidthRange(2, 7);

            table.AddCell("abcd", cellStyle);
            table.AddCell("123456", cellStyle);
            table.AddCell("mno", cellStyle);
            table.AddCell("45689", cellStyle);
            table.AddCell("xyztu", cellStyle);

            Assert.AreEqual(""
                            + "+------+------+\n"
                            + "|abcd  |123456|\n"
                            + "+------+------+\n"
                            + "|mno   |45689 |\n"
                            + "+------+------+\n"
                            + "|xyztu |      |\n"
                            + "+------+------+", table.Render());
        }
Ejemplo n.º 13
0
        public void TestSetColSpanWide()
        {
            var cellStyle1 = new CellStyle(CellHorizontalAlignment.Left, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);
            var cellStyle2 = new CellStyle(CellHorizontalAlignment.Right, CellTextTrimmingStyle.Crop, CellNullStyle.EmptyString);
            var textTable  = new TextTable(2, TableBordersStyle.CLASSIC_WIDE, TableVisibleBorders.ALL, false, "");

            textTable.Columns[0].SetWidthRange(6, 10);
            textTable.Columns[1].SetWidthRange(2, 7);

            textTable.AddCell("abcd", cellStyle1);
            textTable.AddCell("123456", cellStyle1);
            textTable.AddCell("mno", cellStyle1, 2);
            textTable.AddCell("xyztu", cellStyle2, 2);

            Assert.AreEqual(""
                            + "+--------+--------+\n"
                            + "| abcd   | 123456 |\n"
                            + "+-----------------+\n"
                            + "| mno             |\n"
                            + "+-----------------+\n"
                            + "|           xyztu |\n"
                            + "+-----------------+", textTable.Render());
        }
        public void TestEmpty()
        {
            var table = new TextTable(10, TableBordersStyle.CLASSIC, TableVisibleBorders.ALL, false, string.Empty);

            Assert.AreEqual("", table.Render());
        }
Ejemplo n.º 15
0
        static void Main()
        {
            // 1. BASIC TABLE EXAMPLE
            var basicTable = new TextTable(3);

            basicTable.AddCell("Artist");
            basicTable.AddCell("Album");
            basicTable.AddCell("Year");
            basicTable.AddCell("Jamiroquai");
            basicTable.AddCell("Emergency on Planet Earth");
            basicTable.AddCell("1993");
            basicTable.AddCell("Jamiroquai");
            basicTable.AddCell("The Return of the Space Cowboy");
            basicTable.AddCell("1994");
            Console.WriteLine(basicTable.Render());

            // +----------+-------------------------------+-----+
            // |Artist    |Album                         |Year|
            // +----------+-------------------------------+-----+
            // |Jamiroquai|Emergency on Planet Earth     |1993|
            // |Jamiroquai|The Return of the Space Cowboy|1994|
            // +----------+-------------------------------+-----+


            // 2. ADVANCED TABLE EXAMPLE
            var numberStyleAdvancedTable = new CellStyle(CellHorizontalAlignment.Right);
            var advancedTable            = new TextTable(3, TableBordersStyle.DESIGN_FORMAL, TableVisibleBorders.SURROUND_HEADER_FOOTER_AND_COLUMNS);

            advancedTable.SetColumnWidthRange(0, 6, 14);
            advancedTable.SetColumnWidthRange(1, 4, 12);
            advancedTable.SetColumnWidthRange(2, 4, 12);

            advancedTable.AddCell("Region");
            advancedTable.AddCell("Orders", numberStyleAdvancedTable);
            advancedTable.AddCell("Sales", numberStyleAdvancedTable);

            advancedTable.AddCell("North");
            advancedTable.AddCell("6,345", numberStyleAdvancedTable);
            advancedTable.AddCell("$87.230", numberStyleAdvancedTable);

            advancedTable.AddCell("Center");
            advancedTable.AddCell("837", numberStyleAdvancedTable);
            advancedTable.AddCell("$12.855", numberStyleAdvancedTable);

            advancedTable.AddCell("South");
            advancedTable.AddCell("5,344", numberStyleAdvancedTable);
            advancedTable.AddCell("$72.561", numberStyleAdvancedTable);

            advancedTable.AddCell("Total", numberStyleAdvancedTable, 2);
            advancedTable.AddCell("$172.646", numberStyleAdvancedTable);

            Console.WriteLine(advancedTable.Render());

            // ======================
            // Region Orders    Sales
            // ------ ------ --------
            // North   6,345  $87.230
            // Center    837  $12.855
            // South   5,344  $72.561
            // ------ ------ --------
            //         Total $172.646
            // ======================


            // 3. FANCY TABLE EXAMPLE
            var numberStyleFancyTable = new CellStyle(CellHorizontalAlignment.Right);
            var fancyTable            = new TextTable(3, TableBordersStyle.DESIGN_PAPYRUS, TableVisibleBorders.SURROUND_HEADER_FOOTER_AND_COLUMNS);

            fancyTable.AddCell("Region");
            fancyTable.AddCell("Orders", numberStyleFancyTable);
            fancyTable.AddCell("Sales", numberStyleFancyTable);

            fancyTable.AddCell("North");
            fancyTable.AddCell("6,345", numberStyleFancyTable);
            fancyTable.AddCell("$87.230", numberStyleFancyTable);

            fancyTable.AddCell("Center");
            fancyTable.AddCell("837", numberStyleFancyTable);
            fancyTable.AddCell("$12.855", numberStyleFancyTable);

            fancyTable.AddCell("South");
            fancyTable.AddCell("5,344", numberStyleFancyTable);
            fancyTable.AddCell("$72.561", numberStyleFancyTable);

            fancyTable.AddCell("Total", numberStyleFancyTable, 2);
            fancyTable.AddCell("$172.646", numberStyleFancyTable);

            Console.WriteLine(fancyTable.Render());

            // o~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~o
            //  )  Region  Orders     Sales  (
            //  )  ~~~~~~  ~~~~~~  ~~~~~~~~  (
            //  )  North    6,345   $87.230  (
            //  )  Center     837   $12.855  (
            //  )  South    5,344   $72.561  (
            //  )  ~~~~~~  ~~~~~~  ~~~~~~~~  (
            //  )           Total  $172.646  (
            // o~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~o


            // 4. UNICODE TABLE EXAMPLE
            var numberStyleUnicodeTable = new CellStyle(CellHorizontalAlignment.Right);
            var unicodeTable            = new TextTable(3, TableBordersStyle.UNICODE_BOX_DOUBLE_BORDER_WIDE, TableVisibleBorders.SURROUND_HEADER_FOOTER_AND_COLUMNS, true);

            unicodeTable.AddCell("Region");
            unicodeTable.AddCell("Orders", numberStyleUnicodeTable);
            unicodeTable.AddCell("Sales", numberStyleUnicodeTable);

            unicodeTable.AddCell("North");
            unicodeTable.AddCell("6,345", numberStyleUnicodeTable);
            unicodeTable.AddCell("$87.230", numberStyleUnicodeTable);

            unicodeTable.AddCell("Center");
            unicodeTable.AddCell("837", numberStyleUnicodeTable);
            unicodeTable.AddCell("$12.855", numberStyleUnicodeTable);

            unicodeTable.AddCell("South");
            unicodeTable.AddCell("5,344", numberStyleUnicodeTable);
            unicodeTable.AddCell("$72.561", numberStyleUnicodeTable);

            unicodeTable.AddCell("Total", numberStyleUnicodeTable, 2);
            unicodeTable.AddCell("$172.646", numberStyleUnicodeTable);

            var unicodeTableStringArray = unicodeTable.RenderAsStringArray();
            var sb = new StringBuilder("<html><body><pre>");

            foreach (string line in unicodeTableStringArray)
            {
                sb.Append(line);
                sb.Append("<br>");
            }
            sb.Append("</pre></html>");

            File.WriteAllText("unicode.html", sb.ToString(), Encoding.UTF8);

            // unicode.html
            // ╔════════╤════════╤══════════╗
            // ║ Region │ Orders │    Sales ║
            // ╟────────┼────────┼──────────╢
            // ║ North  │  6,345 │  $87.230 ║
            // ║ Center │    837 │  $12.855 ║
            // ║ South  │  5,344 │  $72.561 ║
            // ╟────────┴────────┼──────────╢
            // ║           Total │ $172.646 ║
            // ╚═════════════════╧══════════╝
        }
Ejemplo n.º 16
0
 public async Task ExecuteAllActiveWebhooksAsync(DPSReportJSON reportJSON)
 {
     if (reportJSON.Encounter.BossId.Equals(1)) // WvW
     {
         var extraJSONFightName = (reportJSON.ExtraJSON is null) ? reportJSON.Encounter.Boss : reportJSON.ExtraJSON.FightName;
         var extraJSON          = (reportJSON.ExtraJSON is null) ? string.Empty : $"Recorded by: {reportJSON.ExtraJSON.RecordedBy}\nDuration: {reportJSON.ExtraJSON.Duration}\nElite Insights version: {reportJSON.ExtraJSON.EliteInsightsVersion}";
         var icon     = string.Empty;
         var bossData = Bosses.GetBossDataFromId(1);
         if (!(bossData is null))
         {
             icon = bossData.Icon;
         }
         var colour = 16752238;
         var discordContentEmbedThumbnail = new DiscordAPIJSONContentEmbedThumbnail()
         {
             Url = icon
         };
         var timestampDateTime = DateTime.UtcNow;
         if (!(reportJSON.ExtraJSON is null))
         {
             timestampDateTime = reportJSON.ExtraJSON.TimeStart;
         }
         var timestamp           = timestampDateTime.ToString("o");
         var discordContentEmbed = new DiscordAPIJSONContentEmbed()
         {
             Title       = extraJSONFightName,
             Url         = reportJSON.Permalink,
             Description = $"{extraJSON}\narcdps version: {reportJSON.EVTC.Type}{reportJSON.EVTC.Version}",
             Colour      = colour,
             TimeStamp   = timestamp,
             Thumbnail   = discordContentEmbedThumbnail
         };
         // fields
         if (!(reportJSON.ExtraJSON is null))
         {
             // squad summary
             var squadPlayers = reportJSON.ExtraJSON.Players
                                .Where(x => !x.FriendNPC && !x.NotInSquad)
                                .Count();
             var squadDamage = reportJSON.ExtraJSON.Players
                               .Where(x => !x.FriendNPC && !x.NotInSquad)
                               .Select(x => x.DpsTargets.Sum(y => y.Sum(z => z.Damage)))
                               .Sum();
             var squadDps = reportJSON.ExtraJSON.Players
                            .Where(x => !x.FriendNPC && !x.NotInSquad)
                            .Select(x => x.DpsTargets.Sum(y => y.Sum(z => z.DPS)))
                            .Sum();
             var squadDowns = reportJSON.ExtraJSON.Players
                              .Where(x => !x.FriendNPC && !x.NotInSquad)
                              .Select(x => x.Defenses.First().DownCount)
                              .Sum();
             var squadDeaths = reportJSON.ExtraJSON.Players
                               .Where(x => !x.FriendNPC && !x.NotInSquad)
                               .Select(x => x.Defenses.First().DeadCount)
                               .Sum();
             var squadSummary = new TextTable(5, tableStyle, tableBorders);
             squadSummary.SetColumnWidthRange(0, 3, 3);
             squadSummary.SetColumnWidthRange(1, 10, 10);
             squadSummary.SetColumnWidthRange(2, 10, 10);
             squadSummary.SetColumnWidthRange(3, 8, 8);
             squadSummary.SetColumnWidthRange(4, 8, 8);
             squadSummary.AddCell("#", tableCellCenterAlign);
             squadSummary.AddCell("DMG", tableCellCenterAlign);
             squadSummary.AddCell("DPS", tableCellCenterAlign);
             squadSummary.AddCell("Downs", tableCellCenterAlign);
             squadSummary.AddCell("Deaths", tableCellCenterAlign);
             squadSummary.AddCell($"{squadPlayers}", tableCellCenterAlign);
             squadSummary.AddCell($"{squadDamage.ParseAsK()}", tableCellCenterAlign);
             squadSummary.AddCell($"{squadDps.ParseAsK()}", tableCellCenterAlign);
             squadSummary.AddCell($"{squadDowns}", tableCellCenterAlign);
             squadSummary.AddCell($"{squadDeaths}", tableCellCenterAlign);
             var squadField = new DiscordAPIJSONContentEmbedField()
             {
                 Name  = "Squad summary:",
                 Value = $"```{squadSummary.Render()}```"
             };
             // enemy summary field
             var enemyField = new DiscordAPIJSONContentEmbedField()
             {
                 Name  = "Enemy summary:",
                 Value = $"```Summary could not have been generated.\nToggle detailed WvW to enable this feature.```"
             };
             if (reportJSON.ExtraJSON.Targets.Count > 1)
             {
                 var enemyPlayers = reportJSON.ExtraJSON.Targets
                                    .Count() - 1;
                 var enemyDamage = reportJSON.ExtraJSON.Targets
                                   .Where(x => !x.IsFake)
                                   .Select(x => x.DpsAll.First().Damage)
                                   .Sum();
                 var enemyDps = reportJSON.ExtraJSON.Targets
                                .Where(x => !x.IsFake)
                                .Select(x => x.DpsAll.First().DPS)
                                .Sum();
                 var enemyDowns = reportJSON.ExtraJSON.Players
                                  .Where(x => !x.FriendNPC && !x.NotInSquad)
                                  .Select(x => x.StatsTargets.Select(y => y.First().Downed).Sum())
                                  .Sum();
                 var enemyDeaths = reportJSON.ExtraJSON.Players
                                   .Where(x => !x.FriendNPC && !x.NotInSquad)
                                   .Select(x => x.StatsTargets.Select(y => y.First().Killed).Sum())
                                   .Sum();
                 var enemySummary = new TextTable(5, tableStyle, tableBorders);
                 enemySummary.SetColumnWidthRange(0, 3, 3);
                 enemySummary.SetColumnWidthRange(1, 10, 10);
                 enemySummary.SetColumnWidthRange(2, 10, 10);
                 enemySummary.SetColumnWidthRange(3, 8, 8);
                 enemySummary.SetColumnWidthRange(4, 8, 8);
                 enemySummary.AddCell("#", tableCellCenterAlign);
                 enemySummary.AddCell("DMG", tableCellCenterAlign);
                 enemySummary.AddCell("DPS", tableCellCenterAlign);
                 enemySummary.AddCell("Downs", tableCellCenterAlign);
                 enemySummary.AddCell("Deaths", tableCellCenterAlign);
                 enemySummary.AddCell($"{enemyPlayers}", tableCellCenterAlign);
                 enemySummary.AddCell($"{enemyDamage.ParseAsK()}", tableCellCenterAlign);
                 enemySummary.AddCell($"{enemyDps.ParseAsK()}", tableCellCenterAlign);
                 enemySummary.AddCell($"{enemyDowns}", tableCellCenterAlign);
                 enemySummary.AddCell($"{enemyDeaths}", tableCellCenterAlign);
                 enemyField = new DiscordAPIJSONContentEmbedField()
                 {
                     Name  = "Enemy summary:",
                     Value = $"```{enemySummary.Render()}```"
                 };
             }
             // damage summary
             var damageStats = reportJSON.ExtraJSON.Players
                               .Where(x => !x.FriendNPC && !x.NotInSquad)
                               .Where(x => x.DpsTargets.Sum(y => y.First().Damage) > 0)
                               .OrderByDescending(x => x.DpsTargets.Sum(y => y.First().Damage))
                               .Take(10)
                               .ToList();
             var damageSummary = new TextTable(4, tableStyle, tableBorders);
             damageSummary.SetColumnWidthRange(0, 3, 3);
             damageSummary.SetColumnWidthRange(1, 25, 25);
             damageSummary.SetColumnWidthRange(2, 7, 7);
             damageSummary.SetColumnWidthRange(3, 6, 6);
             damageSummary.AddCell("#", tableCellCenterAlign);
             damageSummary.AddCell("Name");
             damageSummary.AddCell("DMG", tableCellRightAlign);
             damageSummary.AddCell("DPS", tableCellRightAlign);
             var rank = 0;
             foreach (var player in damageStats)
             {
                 rank++;
                 damageSummary.AddCell($"{rank}", tableCellCenterAlign);
                 damageSummary.AddCell($"{player.Name} ({player.ProfessionShort})");
                 damageSummary.AddCell($"{player.DpsTargets.Sum(y => y.First().Damage).ParseAsK()}", tableCellRightAlign);
                 damageSummary.AddCell($"{player.DpsTargets.Sum(y => y.First().DPS).ParseAsK()}", tableCellRightAlign);
             }
             var damageField = new DiscordAPIJSONContentEmbedField()
             {
                 Name  = "Damage summary:",
                 Value = $"```{damageSummary.Render()}```"
             };
             // cleanses summary
             var cleansesStats = reportJSON.ExtraJSON.Players
                                 .Where(x => !x.FriendNPC && !x.NotInSquad)
                                 .Where(x => x.Support.First().CondiCleanseTotal > 0)
                                 .OrderByDescending(x => x.Support.First().CondiCleanseTotal)
                                 .Take(10)
                                 .ToList();
             var cleansesSummary = new TextTable(3, tableStyle, tableBorders);
             cleansesSummary.SetColumnWidthRange(0, 3, 3);
             cleansesSummary.SetColumnWidthRange(1, 27, 27);
             cleansesSummary.SetColumnWidthRange(2, 12, 12);
             cleansesSummary.AddCell("#", tableCellCenterAlign);
             cleansesSummary.AddCell("Name");
             cleansesSummary.AddCell("Cleanses", tableCellRightAlign);
             rank = 0;
             foreach (var player in cleansesStats)
             {
                 rank++;
                 cleansesSummary.AddCell($"{rank}", tableCellCenterAlign);
                 cleansesSummary.AddCell($"{player.Name} ({player.ProfessionShort})");
                 cleansesSummary.AddCell($"{player.Support.First().CondiCleanseTotal}", tableCellRightAlign);
             }
             var cleansesField = new DiscordAPIJSONContentEmbedField()
             {
                 Name  = "Cleanses summary:",
                 Value = $"```{cleansesSummary.Render()}```"
             };
             // boon strips summary
             var boonStripsStats = reportJSON.ExtraJSON.Players
                                   .Where(x => !x.FriendNPC && !x.NotInSquad)
                                   .Where(x => x.Support.First().BoonStrips > 0)
                                   .OrderByDescending(x => x.Support.First().BoonStrips)
                                   .Take(10)
                                   .ToList();
             var boonStripsSummary = new TextTable(3, tableStyle, tableBorders);
             boonStripsSummary.SetColumnWidthRange(0, 3, 3);
             boonStripsSummary.SetColumnWidthRange(1, 27, 27);
             boonStripsSummary.SetColumnWidthRange(2, 12, 12);
             boonStripsSummary.AddCell("#", tableCellCenterAlign);
             boonStripsSummary.AddCell("Name");
             boonStripsSummary.AddCell("Strips", tableCellRightAlign);
             rank = 0;
             foreach (var player in boonStripsStats)
             {
                 rank++;
                 boonStripsSummary.AddCell($"{rank}", tableCellCenterAlign);
                 boonStripsSummary.AddCell($"{player.Name} ({player.ProfessionShort})");
                 boonStripsSummary.AddCell($"{player.Support.First().BoonStrips}", tableCellRightAlign);
             }
             var boonStripsField = new DiscordAPIJSONContentEmbedField()
             {
                 Name  = "Boon strips summary:",
                 Value = $"```{boonStripsSummary.Render()}```"
             };
             // add the fields
             discordContentEmbed.Fields = new List <DiscordAPIJSONContentEmbedField>()
             {
                 squadField,
                 enemyField,
                 damageField,
                 cleansesField,
                 boonStripsField
             };
         }
         // post to discord
         var discordContentWvW = new DiscordAPIJSONContent()
         {
             Embeds = new List <DiscordAPIJSONContentEmbed>()
             {
                 discordContentEmbed
             }
         };
         try
         {
             var jsonContentWvW = JsonConvert.SerializeObject(discordContentWvW);
             foreach (var key in allWebhooks.Keys)
             {
                 var webhook = allWebhooks[key];
                 if (!webhook.Active ||
                     (webhook.SuccessFailToggle.Equals(DiscordWebhookDataSuccessToggle.OnSuccessOnly) && !(reportJSON.Encounter.Success ?? false)) ||
                     (webhook.SuccessFailToggle.Equals(DiscordWebhookDataSuccessToggle.OnFailOnly) && (reportJSON.Encounter.Success ?? false)) ||
                     (webhook.BossesDisable.Contains(reportJSON.Encounter.BossId)) ||
                     (!webhook.Team.IsSatisfied(reportJSON.ExtraJSON)))
                 {
                     continue;
                 }
                 var uri = new Uri(webhook.URL);
                 using var content  = new StringContent(jsonContentWvW, Encoding.UTF8, "application/json");
                 using var response = await mainLink.HttpClientController.PostAsync(uri, content);
             }
             if (allWebhooks.Count > 0)
             {
                 mainLink.AddToText(">:> All active webhooks successfully executed.");
             }
         }
         catch
         {
             mainLink.AddToText(">:> Unable to execute active webhooks.");
         }
     }
     else // not WvW
     {
         var bossName      = $"{reportJSON.Encounter.Boss}{(reportJSON.ChallengeMode ? " CM" : string.Empty)}";
         var successString = (reportJSON.Encounter.Success ?? false) ? ":white_check_mark:" : "❌";
         var extraJSON     = (reportJSON.ExtraJSON is null) ? string.Empty : $"Recorded by: {reportJSON.ExtraJSON.RecordedBy}\nDuration: {reportJSON.ExtraJSON.Duration}\nElite Insights version: {reportJSON.ExtraJSON.EliteInsightsVersion}\n";
         var icon          = string.Empty;
         var bossData      = Bosses.GetBossDataFromId(reportJSON.Encounter.BossId);
         if (!(bossData is null))
         {
             bossName = $"{bossData.Name}{(reportJSON.ChallengeMode ? " CM" : string.Empty)}";
             icon     = bossData.Icon;
         }
         var colour = (reportJSON.Encounter.Success ?? false) ? 32768 : 16711680;
         var discordContentEmbedThumbnail = new DiscordAPIJSONContentEmbedThumbnail()
         {
             Url = icon
         };
         var timestampDateTime = DateTime.UtcNow;
         if (!(reportJSON.ExtraJSON is null))
         {
             timestampDateTime = reportJSON.ExtraJSON.TimeStart;
         }
         var timestamp           = timestampDateTime.ToString("o");
         var discordContentEmbed = new DiscordAPIJSONContentEmbed()
         {
             Title       = bossName,
             Url         = reportJSON.Permalink,
             Description = $"{extraJSON}Result: {successString}\narcdps version: {reportJSON.EVTC.Type}{reportJSON.EVTC.Version}",
             Colour      = colour,
             TimeStamp   = timestamp,
             Thumbnail   = discordContentEmbedThumbnail
         };
         var discordContentWithoutPlayers = new DiscordAPIJSONContent()
         {
             Embeds = new List <DiscordAPIJSONContentEmbed>()
             {
                 discordContentEmbed
             }
         };
         var discordContentEmbedForPlayers = new DiscordAPIJSONContentEmbed()
         {
             Title       = bossName,
             Url         = reportJSON.Permalink,
             Description = $"{extraJSON}Result: {successString}\narcdps version: {reportJSON.EVTC.Type}{reportJSON.EVTC.Version}",
             Colour      = colour,
             TimeStamp   = timestamp,
             Thumbnail   = discordContentEmbedThumbnail
         };
         if (reportJSON.Players.Values.Count <= 10)
         {
             var fields = new List <DiscordAPIJSONContentEmbedField>();
             if (reportJSON.ExtraJSON is null)
             {
                 foreach (var player in reportJSON.Players.Values)
                 {
                     fields.Add(new DiscordAPIJSONContentEmbedField()
                     {
                         Name = player.CharacterName, Value = $"```\n{player.DisplayName}\n\n{Players.ResolveSpecName(player.Profession, player.EliteSpec)}\n```", Inline = true
                     });
                 }
             }
             else
             {
                 // player list
                 var playerNames = new TextTable(2, tableStyle, tableBorders);
                 playerNames.SetColumnWidthRange(0, 21, 21);
                 playerNames.SetColumnWidthRange(1, 20, 20);
                 playerNames.AddCell("Character");
                 playerNames.AddCell("Account name");
                 foreach (var player in reportJSON.ExtraJSON.Players.Where(x => !x.FriendNPC).OrderBy(x => x.Name))
                 {
                     playerNames.AddCell($"{player.Name}");
                     playerNames.AddCell($"{player.Account}");
                 }
                 fields.Add(new DiscordAPIJSONContentEmbedField()
                 {
                     Name  = "Players in squad/group:",
                     Value = $"```{playerNames.Render()}```"
                 });
                 var numberOfRealTargers = reportJSON.ExtraJSON.Targets
                                           .Where(x => !x.IsFake)
                                           .Count();
                 // damage summary
                 var damageStats = reportJSON.ExtraJSON.Players
                                   .Where(x => !x.FriendNPC)
                                   .Select(x => new
                 {
                     Player = x,
                     DPS    = numberOfRealTargers > 0 ? reportJSON.ExtraJSON.PlayerTargetDPS[x] : x.DpsAll.First().DPS
                 })
                                   .OrderByDescending(x => x.DPS)
                                   .Take(10)
                                   .ToList();
                 var dpsTargetSummary = new TextTable(3, tableStyle, TableVisibleBorders.HEADER_AND_FOOTER);
                 dpsTargetSummary.SetColumnWidthRange(0, 5, 5);
                 dpsTargetSummary.SetColumnWidthRange(1, 27, 27);
                 dpsTargetSummary.SetColumnWidthRange(2, 8, 8);
                 dpsTargetSummary.AddCell("#", tableCellCenterAlign);
                 dpsTargetSummary.AddCell("Name");
                 dpsTargetSummary.AddCell("DPS", tableCellRightAlign);
                 var rank = 0;
                 foreach (var player in damageStats)
                 {
                     rank++;
                     dpsTargetSummary.AddCell($"{rank}", tableCellCenterAlign);
                     dpsTargetSummary.AddCell($"{player.Player.Name} ({player.Player.ProfessionShort})");
                     dpsTargetSummary.AddCell($"{player.DPS.ParseAsK()}", tableCellRightAlign);
                 }
                 dpsTargetSummary.AddCell(string.Empty);
                 dpsTargetSummary.AddCell("Total");
                 var totalDPS = damageStats
                                .Select(x => x.DPS)
                                .Sum();
                 dpsTargetSummary.AddCell($"{totalDPS.ParseAsK()}", tableCellRightAlign);
                 fields.Add(new DiscordAPIJSONContentEmbedField()
                 {
                     Name  = "DPS target summary:",
                     Value = $"```{dpsTargetSummary.Render()}```"
                 });
             }
             discordContentEmbedForPlayers.Fields = fields;
         }
         var discordContentWithPlayers = new DiscordAPIJSONContent()
         {
             Embeds = new List <DiscordAPIJSONContentEmbed>()
             {
                 discordContentEmbedForPlayers
             }
         };
         try
         {
             var jsonContentWithoutPlayers = JsonConvert.SerializeObject(discordContentWithoutPlayers);
             var jsonContentWithPlayers    = JsonConvert.SerializeObject(discordContentWithPlayers);
             foreach (var key in allWebhooks.Keys)
             {
                 var webhook = allWebhooks[key];
                 if (!webhook.Active ||
                     (webhook.SuccessFailToggle.Equals(DiscordWebhookDataSuccessToggle.OnSuccessOnly) && !(reportJSON.Encounter.Success ?? false)) ||
                     (webhook.SuccessFailToggle.Equals(DiscordWebhookDataSuccessToggle.OnFailOnly) && (reportJSON.Encounter.Success ?? false)) ||
                     (webhook.BossesDisable.Contains(reportJSON.Encounter.BossId)) ||
                     (!webhook.Team.IsSatisfied(reportJSON.ExtraJSON)))
                 {
                     continue;
                 }
                 var uri = new Uri(webhook.URL);
                 if (webhook.ShowPlayers)
                 {
                     using var content = new StringContent(jsonContentWithPlayers, Encoding.UTF8, "application/json");
                     using (await mainLink.HttpClientController.PostAsync(uri, content)) { }
                 }
                 else
                 {
                     using var content = new StringContent(jsonContentWithoutPlayers, Encoding.UTF8, "application/json");
                     using (await mainLink.HttpClientController.PostAsync(uri, content)) { }
                 }
             }
             if (allWebhooks.Count > 0)
             {
                 mainLink.AddToText(">:> All active webhooks successfully executed.");
             }
         }
         catch
         {
             mainLink.AddToText(">:> Unable to execute active webhooks.");
         }
     }
 }