public async Task <List <WebMailHeader> > WebGetMailHeaders(long id, string token)
        {
            var mailHeaders = (await APIHelper.ESIAPI.GetMailHeaders(Reason, id, token, 0, null))?.Result;

            if (mailHeaders == null)
            {
                return(null);
            }
            var list = new List <WebMailHeader>();

            foreach (var h in mailHeaders)
            {
                var from = await APIHelper.ESIAPI.GetCharacterData(Reason, h.@from);

                var rcp = await MailModule.GetRecepientNames(Reason, h.recipients, id, token);

                list.Add(new WebMailHeader
                {
                    MailId   = h.mail_id,
                    FromName = from?.name ?? LM.Get("Unknown"),
                    ToName   = rcp.Length > 0 ? rcp : LM.Get("Unknown"),
                    Subject  = h.subject,
                    Date     = h.Date
                });
            }

            return(list);
        }
示例#2
0
        private async Task <string> GenerateMailHtml(string token, long inspectCharId, string authCode, int page)
        {
            var mailHeaders = (await APIHelper.ESIAPI.GetMailHeaders(Reason, inspectCharId.ToString(), token, 0, null))?.Result;
            //var totalCount = mailHeaders.Count;
            var startIndex = (page - 1) * Settings.HRMModule.TableEntriesPerPage;

            mailHeaders = mailHeaders.Count == 0 ? mailHeaders : mailHeaders.GetRange(startIndex, mailHeaders.Count > startIndex + Settings.HRMModule.TableEntriesPerPage ? Settings.HRMModule.TableEntriesPerPage : (mailHeaders.Count - startIndex));

            var sb = new StringBuilder();

            sb.AppendLine("<thead>");
            sb.AppendLine("<tr>");
            sb.AppendLine($"<th scope=\"col-md-auto\">#</th>");
            sb.AppendLine($"<th scope=\"col-md-auto\">{LM.Get("mailSubjectHeader")}</th>");
            sb.AppendLine($"<th scope=\"col-md-auto\">{LM.Get("mailFromHeader")}</th>");
            sb.AppendLine($"<th scope=\"col-md-auto\">{LM.Get("mailToHeader")}</th>");
            sb.AppendLine($"<th scope=\"col\">{LM.Get("mailDateHeader")}</th>");
            sb.AppendLine("</tr>");
            sb.AppendLine("</thead>");
            sb.AppendLine("<tbody>");
            var counter = startIndex + 1;

            foreach (var entry in mailHeaders)
            {
                var from = await APIHelper.ESIAPI.GetCharacterData(Reason, entry.@from);

                var mailBodyUrl = WebServerModule.GetHRM_AjaxMailURL(entry.mail_id, inspectCharId, authCode);

                var rcp = await MailModule.GetRecepientNames(Reason, entry.recipients, inspectCharId, token);

                sb.AppendLine("<tr>");
                sb.AppendLine($"  <th scope=\"row\">{counter++}</th>");
                sb.AppendLine($"  <td><a href=\"#\" onclick=\"openMailDialog('{mailBodyUrl}')\">{entry.subject}</td>");
                sb.AppendLine($"  <td>{from?.name ?? LM.Get("Unknown")}</td>");
                sb.AppendLine($"  <td>{(rcp.Length > 0 ? rcp : LM.Get("Unknown"))}</td>");
                sb.AppendLine($"  <td>{entry.Date.ToShortDateString()}</td>");
                sb.AppendLine("</tr>");
            }
            sb.AppendLine("</tbody>");
            return(sb.ToString());
        }