private void CreateHtmlTable() { btn_save2file.Enabled = false; StringBuilder sb = new StringBuilder(); using (Html.Table table = new Html.Table(sb, id: AccountLogin.CurrentSteamID + "-GroupsIDS")) { table.StartBody(); using (var tr = table.AddRow()) { tr.AddCell("GROUP ID3"); tr.AddCell("GROUP ID64"); tr.AddCell("GROUP NAME"); } foreach (KeyValuePair <ulong, string> group in AccountLogin.ClanDictionary) { using (var tr = table.AddRow()) { tr.AddCell(Extensions.AllToSteamId3(group.Key).Substring(1).ToString()); // id3 tr.AddCell("<a target='_blank' rel='noopener noreferrer' href=https://steamcommunity.com/gid/" + (group.Key).ToString() + ">" + (group.Key).ToString() + "</a>"); //id64 tr.AddCell(group.Value); // name } } table.EndBody(); } File.WriteAllText(Program.ExecutablePath + @"\" + AccountLogin.CurrentSteamID + "-GroupsIDS.html", sb.ToString()); btn_save2file.Enabled = true; Process.Start(Program.ExecutablePath + @"\" + AccountLogin.CurrentSteamID + "-GroupsIDS.html"); }
private string MakeMailMessage(List <List <KiwiWebData> > listOfListOfResults) { if (listOfListOfResults.Count == 0) { return(""); } StringBuilder sb = new StringBuilder(); foreach (List <KiwiWebData> listOfResults in listOfListOfResults) { using (Html.Table table = new Html.Table(sb, id: "kiwiWebTable")) { table.StartBody(); using (var tr = table.AddRow()) { tr.AddCell("Price"); tr.AddCell("lengthOfStay"); tr.AddCell("Airlines to destination"); tr.AddCell("Airlines from destination"); tr.AddCell("Duration to destination"); tr.AddCell("Duration from destination"); tr.AddCell("Departure date"); tr.AddCell("Return date"); tr.AddCell("Departure time"); tr.AddCell("Return time"); tr.AddCell("Booking link"); } foreach (KiwiWebData data in listOfResults) { using (var tr = table.AddRow()) { tr.AddCell(data.price.ToString()); tr.AddCell(data.lengthOfStay); tr.AddCell(data.airlinesToDestination); tr.AddCell(data.airlinesFromDestination); tr.AddCell(data.durationToDestination); tr.AddCell(data.durationFromDestination); tr.AddCell(data.departureDate); tr.AddCell(data.returnDate); tr.AddCell(data.departureTime); tr.AddCell(data.returnTime); tr.AddCell(data.bookingLink); } } table.EndBody(); } sb.Append("</br>"); } return(sb.ToString()); }
private string CreateHTMLEmailContent() { try { string tableTop = @"<html><head><style>table,th,td{border:1px solid black;border-collapse: collapse;}th,td {padding: 15px;} table.center {margin-left: auto ; margin-right: auto;}</style></head><body>"; string tableBottom = @"</body></html>"; var result = GetTop10Crashes("").Result; var topCrashes = result as OkObjectResult; if (topCrashes == null) { return(null); } var tp = topCrashes.Value as IEnumerable <TopCrash>; if (tp == null) { return(null); } StringBuilder sb = new StringBuilder(); using (Html.Table table = new Html.Table(sb, id: "some-id")) { table.StartHead(); using (var thead = table.AddRow()) { //thead.AddCell ("Project"); thead.AddCell("Method"); thead.AddCell("Count"); } table.EndHead(); table.StartBody(); foreach (var cr in tp) { using (var tr = table.AddRow(classAttributes: "someattributes")) { tr.AddCell(cr.Method); tr.AddCell(cr.Count.ToString()); // string version = crash.App.Replace ("HPSmart.", ""); // string atag = "<a href = https://smartex-stage.azurewebsites.net/crashes/summary/" + crash.Lochash + "/" + version + ">" + crash.Loc + "</a>"; // tr.AddCell (atag); //tr.AddCell (crash.Count.ToString ()); } } table.EndBody(); var output = tableTop; output += "<p>Hi team,</p>"; output += "<p> These are the top crashes reported. For more details visit <a href=\"https://crashbox.z5.web.core.windows.net/\">website</a> .This is an auto-generated email from a webjob. If any questions,please contact <a href=\"mailto:[email protected]\">CrashBox</a>.</p>"; output += "<h4> Top Crashes </h4>"; output = output + sb.ToString() + tableBottom; //var tbl = sb.ToString(); return(output); } } catch (System.Exception ex) { // _logger.LogError(ex.Message); Console.WriteLine(ex.Message); return("null"); } }
private string MakeMailMessage(List <List <PelikanData> > listOfListOfResults) { if (listOfListOfResults.Count == 0) { return(""); } StringBuilder sb = new StringBuilder(); foreach (List <PelikanData> listOfResults in listOfListOfResults) { using (Html.Table table = new Html.Table(sb, id: "kiwiWebTable")) { table.StartBody(); using (var tr = table.AddRow()) { tr.AddCell("Price"); tr.AddCell("Tolerance"); tr.AddCell("departureDay"); tr.AddCell("Departure City"); tr.AddCell("Departure airport"); tr.AddCell("Departure date"); tr.AddCell("Departure time"); tr.AddCell("Duration to destination"); tr.AddCell("Destination City"); tr.AddCell("Destination airport"); tr.AddCell("Destination time"); } foreach (PelikanData data in listOfResults) { using (var tr = table.AddRow()) { tr.AddCell(data.price.ToString(), "", "", "4"); foreach (PelikanSubData subData in data.listPelikanSubData) { using (var tr2 = table.AddRow()) { tr2.AddCell(data.price.ToString(), "", "", ""); tr2.AddCell(subData.Tolerance); tr2.AddCell(subData.departureDay); tr2.AddCell(subData.departureCity); tr2.AddCell(subData.departureAirport); tr2.AddCell(subData.departureDate); tr2.AddCell(subData.departureTime); tr2.AddCell(subData.durationToDestination); tr2.AddCell(subData.destinationCity); tr2.AddCell(subData.destinationAirport); tr2.AddCell(subData.destinationTime); } } } } table.EndBody(); } sb.Append("</br>"); } return(sb.ToString()); }
private string MakeMailMessage(List <KiwiRespond> listResponds) { if (listResponds.Count == 0) { return(""); } StringBuilder sb = new StringBuilder(); foreach (KiwiRespond respond in listResponds) { using (Html.Table table = new Html.Table(sb, id: "kiwiTabule")) { table.StartBody(); using (var tr = table.AddRow()) { tr.AddCell("Price"); tr.AddCell("Currency"); tr.AddCell("From"); tr.AddCell("To"); tr.AddCell("Flight duration"); tr.AddCell("Return flight duration"); tr.AddCell("Bags price"); tr.AddCell("Bag hand limit"); tr.AddCell("Bag hold limit"); tr.AddCell("Deep_link"); } foreach (Data data in respond.data) { using (var tr = table.AddRow()) { tr.AddCell("Destination: " + data.countryTo.name + " : " + data.cityTo, "", "", "6"); } using (var tr = table.AddRow()) { tr.AddCell(data.price.ToString()); tr.AddCell(respond.currency); tr.AddCell(data.flyFrom); tr.AddCell(data.flyTo); tr.AddCell(data.fly_duration); tr.AddCell(data.return_duration); tr.AddCell(data.bags_price.__invalid_name__1.ToString()); tr.AddCell("Hand weight: " + data.baglimit.hand_weight.ToString()); tr.AddCell("Hold weight: " + data.baglimit.hold_weight.ToString()); tr.AddCell(data.deep_link); } using (var tr = table.AddRow()) { foreach (List <string> routes in data.routes) { string oneRoute = ""; foreach (string route in routes) { oneRoute += route + "-"; } tr.AddCell("Route: " + oneRoute); } tr.AddCell("Personal weight: " + data.baggage?.personal_item?.weight.ToString()); tr.AddCell("Personal price: " + data.baggage?.personal_item?.price.ToString()); tr.AddCell("Hand weight: " + data.baggage.hand.weight.ToString()); tr.AddCell("Hand price: " + data.baggage.hand.price.ToString()); foreach (Hold hold in data.baggage.hold) { tr.AddCell("Hold weight: " + hold.weight); tr.AddCell("Hold price: " + hold.price); } } using (var tr = table.AddRow()) { tr.AddCell("Routes", "", "", "4"); } foreach (Route route in data.route) { using (var tr = table.AddRow()) { tr.AddCell("Route Price: " + route.price.ToString()); tr.AddCell(respond.currency); tr.AddCell("Route from: " + route.cityFrom + " - " + route.flyFrom); tr.AddCell("Route to: " + route.cityTo + " - " + route.flyTo); DateTime time = DateTime.UnixEpoch.AddSeconds(route.dTime); tr.AddCell("Departure time: " + time.ToString()); //time = DateTime.UnixEpoch.AddSeconds(route.dTimeUTC); //tr.AddCell("Departure timeUtc: " + time.ToString()); time = DateTime.UnixEpoch.AddSeconds(route.aTime); tr.AddCell("Arrival time: " + time.ToString()); //time = DateTime.UnixEpoch.AddSeconds(route.aTimeUTC); //tr.AddCell("Arrival timeUtc: " + time.ToString()); } } using (var tr = table.AddRow()) { tr.AddCell("°°°°"); } } table.EndBody(); } } return(sb.ToString()); }