Public Demo güncellemeleri

This commit is contained in:
Sedat ÖZTÜRK 2026-08-15 19:46:14 +03:00
parent 853ad0240e
commit b517b7346e
2 changed files with 233 additions and 25 deletions

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Sozsoft.Platform.Entities; using Sozsoft.Platform.Entities;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using System.Text;
using Sozsoft.Platform.Data.Seeds; using Sozsoft.Platform.Data.Seeds;
using Sozsoft.Sender.Mail; using Sozsoft.Sender.Mail;
using Volo.Abp.Settings; using Volo.Abp.Settings;
@ -318,26 +317,181 @@ public class PublicAppService : PlatformAppService
var demo = ObjectMapper.Map<DemoDto, Demo>(input); var demo = ObjectMapper.Map<DemoDto, Demo>(input);
await _demoRepository.InsertAsync(demo); await _demoRepository.InsertAsync(demo);
var bodyBuilder = new StringBuilder(); await SendDemoCreatedEmailsAsync(input);
bodyBuilder.AppendLine($"Şirket: {input.OrganizationName}"); }
bodyBuilder.AppendLine($"Ad Soyad: {input.Name}");
bodyBuilder.AppendLine($"E-Posta: {input.Email}");
bodyBuilder.AppendLine($"Telefon: {input.PhoneNumber}");
bodyBuilder.AppendLine($"Adres: {input.Address}");
bodyBuilder.AppendLine($"Şube Sayısı: {input.NumberOfBranches}");
bodyBuilder.AppendLine($"Kullanıcı Sayısı: {input.NumberOfUsers}");
bodyBuilder.AppendLine($"Mesaj: {input.Message}");
var SenderName = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromDisplayName); private async Task SendDemoCreatedEmailsAsync(DemoDto input)
var SenderEmailAddress = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromAddress); {
// Demo talebi bildirimleri, uye bildirim ayarindaki adreslere gonderilir.
var recipients = ParseRecipients(
await _settingProvider.GetOrNullAsync(PlatformConsts.AbpSettings.SiteManagement.General.NewMemberNotificationEmails));
await _emailSender.QueueEmailAsync( if (recipients.Count == 0)
SenderEmailAddress ?? string.Empty, {
new KeyValuePair<string, string>(SenderName ?? string.Empty, SenderEmailAddress ?? string.Empty), Logger.LogWarning(
null, "Demo request email was not sent: {Setting} setting is empty.",
bodyBuilder.ToString(), PlatformConsts.AbpSettings.SiteManagement.General.NewMemberNotificationEmails);
subject: PlatformConsts.AppName + " : Demo Talebi");
return;
}
var senderName = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromDisplayName);
var senderEmail = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromAddress);
KeyValuePair<string, string>? sender = null;
if (!senderEmail.IsNullOrWhiteSpace())
{
sender = new KeyValuePair<string, string>(senderName ?? string.Empty, senderEmail);
}
var body = BuildDemoEmailBody(input);
var subject = $"{PlatformConsts.AppName} : {Translate("App.PublicDemo.MailTitle")}";
foreach (var recipient in recipients)
{
try
{
await _emailSender.SendEmailAsync(
recipient,
sender,
new { },
body,
subject,
null,
true);
}
catch (Exception ex)
{
Logger.LogError(ex, "Demo request email could not be sent to {Recipient}", recipient);
}
}
}
private string BuildDemoEmailBody(DemoDto input)
{
string Row(string label, string value, bool striped) => $@"
<tr>
<td {(striped ? @"bgcolor=""#f9fafb"" " : string.Empty)}style=""padding:10px 8px;{(striped ? "background-color:#f9fafb;" : string.Empty)}color:#6b7280;line-height:20px;width:40%;"">{Html(label)}</td>
<td {(striped ? @"bgcolor=""#f9fafb"" " : string.Empty)}style=""padding:10px 8px;{(striped ? "background-color:#f9fafb;" : string.Empty)}font-weight:700;color:#111827;line-height:20px;"">{Html(value)}</td>
</tr>";
var contactRows = string.Concat(
Row(Translate("App.PublicCommon.FullName"), input.Name, true),
Row(Translate("App.Listform.ListformField.Email"), input.Email, false),
Row(Translate("Abp.Identity.User.UserInformation.PhoneNumber"), FormatPhoneNumber(input.PhoneNumber), true));
var companyRows = string.Concat(
Row(Translate("App.Platform.Company"), input.OrganizationName, true),
Row(Translate("App.PublicCommon.BranchCount"), input.NumberOfBranches.ToString(), false),
Row(Translate("App.PublicCommon.UserCount"), input.NumberOfUsers.ToString(), true),
Row(Translate("App.Listform.ListformField.Address"), input.Address, false));
return $@"
<!doctype html>
<html>
<head>
<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />
<meta name=""viewport"" content=""width=device-width, initial-scale=1.0"" />
<meta name=""x-apple-disable-message-reformatting"" />
</head>
<body bgcolor=""#f3f4f6"" style=""margin:0;padding:0;background-color:#f3f4f6;font-family:Arial,Helvetica,sans-serif;color:#111827;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;"">
<div style=""display:none;font-size:1px;color:#f3f4f6;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden;"">
{Html(Translate("App.PublicDemo.MailIntro"))}
</div>
<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" bgcolor=""#f3f4f6"" style=""width:100%;background-color:#f3f4f6;border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt;"">
<tr>
<td align=""center"" style=""padding:24px 12px;"">
<table role=""presentation"" width=""720"" cellpadding=""0"" cellspacing=""0"" border=""0"" align=""center"" bgcolor=""#ffffff"" style=""width:100%;max-width:720px;background-color:#ffffff;border:1px solid #e5e7eb;border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt;"">
<tr>
<td bgcolor=""#f9fafb"" style=""padding:24px;background-color:#f9fafb;border-bottom:1px solid #e5e7eb;"">
<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width:100%;border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt;"">
<tr>
<td style=""width:46px;vertical-align:middle;"">
<table role=""presentation"" width=""40"" height=""40"" cellpadding=""0"" cellspacing=""0"" border=""0"" bgcolor=""#2563eb"" style=""width:40px;height:40px;background-color:#2563eb;border-collapse:collapse;"">
<tr>
<td align=""center"" valign=""middle"" style=""font-size:20px;line-height:40px;font-weight:800;color:#ffffff;"">&#9993;</td>
</tr>
</table>
</td>
<td style=""vertical-align:middle;"">
<table role=""presentation"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""border-collapse:collapse;"">
<tr>
<td style=""font-size:22px;line-height:28px;font-weight:800;color:#111827;"">{Html(Translate("App.PublicDemo.MailTitle"))}</td>
</tr>
<tr>
<td style=""padding-top:6px;color:#4b5563;font-size:14px;line-height:20px;"">{Html(Translate("App.PublicDemo.MailIntro"))}</td>
</tr>
</table>
</td>
<td align=""right"" style=""text-align:right;vertical-align:middle;"">
<table role=""presentation"" cellpadding=""0"" cellspacing=""0"" border=""0"" align=""right"" style=""border-collapse:collapse;"">
<tr>
<td align=""right"" style=""font-size:12px;line-height:16px;text-transform:uppercase;letter-spacing:.08em;color:#6b7280;"">Demo</td>
</tr>
<tr>
<td align=""right"" style=""padding-top:4px;font-size:14px;line-height:20px;font-weight:700;color:#111827;"">{FormatDate(Clock.Now)}</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style=""padding:24px;"">
<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width:100%;border-collapse:separate;border-spacing:0;mso-table-lspace:0pt;mso-table-rspace:0pt;"">
<tr>
<td width=""50%"" style=""vertical-align:top;padding:0 10px 20px 0;"">
<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" bgcolor=""#ffffff"" style=""width:100%;background-color:#ffffff;border:1px solid #e5e7eb;border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt;"">
<tr>
<td style=""padding:18px;"">
<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width:100%;border-collapse:collapse;"">
<tr>
<td colspan=""2"" style=""font-size:18px;line-height:24px;font-weight:800;color:#111827;padding-bottom:14px;"">{Html(Translate("App.PublicDemo.MailContactInfo"))}</td>
</tr>{contactRows}
</table>
</td>
</tr>
</table>
</td>
<td width=""50%"" style=""vertical-align:top;padding:0 0 20px 10px;"">
<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" bgcolor=""#ffffff"" style=""width:100%;background-color:#ffffff;border:1px solid #e5e7eb;border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt;"">
<tr>
<td style=""padding:18px;"">
<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width:100%;border-collapse:collapse;"">
<tr>
<td colspan=""2"" style=""font-size:18px;line-height:24px;font-weight:800;color:#111827;padding-bottom:14px;"">{Html(Translate("App.PublicDemo.MailCompanyInfo"))}</td>
</tr>{companyRows}
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" bgcolor=""#ffffff"" style=""width:100%;background-color:#ffffff;border:1px solid #e5e7eb;border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt;"">
<tr>
<td style=""padding:18px;"">
<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width:100%;border-collapse:collapse;"">
<tr>
<td style=""font-size:18px;line-height:24px;font-weight:800;color:#111827;padding-bottom:12px;"">{Html(Translate("App.Listform.ListformField.Message"))}</td>
</tr>
<tr>
<td style=""color:#374151;font-size:14px;line-height:22px;white-space:pre-wrap;"">{Html(input.Message)}</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>";
} }
public async Task<BlogPostAndCategoriesDto> GetPostListAsync(GetBlogPostsInput input) public async Task<BlogPostAndCategoriesDto> GetPostListAsync(GetBlogPostsInput input)
@ -585,13 +739,7 @@ public class PublicAppService : PlatformAppService
} }
var notificationEmails = await _settingProvider.GetOrNullAsync("App.SiteManagement.General.NewTenantNotificationEmails"); var notificationEmails = await _settingProvider.GetOrNullAsync("App.SiteManagement.General.NewTenantNotificationEmails");
if (!notificationEmails.IsNullOrWhiteSpace()) recipients.AddRange(ParseRecipients(notificationEmails));
{
recipients.AddRange(notificationEmails
.Split(new[] { ',', ';', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)
.Select(email => email.Trim())
.Where(email => !email.IsNullOrWhiteSpace()));
}
recipients = recipients recipients = recipients
.Distinct(StringComparer.OrdinalIgnoreCase) .Distinct(StringComparer.OrdinalIgnoreCase)
@ -876,6 +1024,24 @@ public class PublicAppService : PlatformAppService
return string.Format(new System.Globalization.CultureInfo("tr-TR"), "{0:C2}", value); return string.Format(new System.Globalization.CultureInfo("tr-TR"), "{0:C2}", value);
} }
/// <summary>
/// Virgul, noktali virgul veya satir sonu ile ayrilmis e-posta ayar degerini listeye cevirir.
/// </summary>
private static List<string> ParseRecipients(string? value)
{
if (value.IsNullOrWhiteSpace())
{
return [];
}
return value!
.Split([',', ';', '\n', '\r'], StringSplitOptions.RemoveEmptyEntries)
.Select(email => email.Trim())
.Where(email => !email.IsNullOrWhiteSpace())
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
}
private static string Html(string value) private static string Html(string value)
{ {
return WebUtility.HtmlEncode(value ?? string.Empty); return WebUtility.HtmlEncode(value ?? string.Empty);

View file

@ -25625,6 +25625,48 @@
"key": "App.ForumDashboard.NewCategoryCreated", "key": "App.ForumDashboard.NewCategoryCreated",
"en": "New category created", "en": "New category created",
"tr": "Yeni kategori oluşturuldu" "tr": "Yeni kategori oluşturuldu"
},
{
"resourceName": "Platform",
"key": "App.Validation.Required",
"en": "This field is required.",
"tr": "Bu alan zorunludur."
},
{
"resourceName": "Platform",
"key": "App.Validation.InvalidEmail",
"en": "Please enter a valid email address.",
"tr": "Geçerli bir e-posta adresi giriniz."
},
{
"resourceName": "Platform",
"key": "App.Errors.ServerUnreachable",
"en": "The server could not be reached. Please try again later.",
"tr": "Sunucuya ulaşılamadı. Lütfen daha sonra tekrar deneyin."
},
{
"resourceName": "Platform",
"key": "App.PublicDemo.MailTitle",
"en": "New Demo Request",
"tr": "Yeni Demo Talebi"
},
{
"resourceName": "Platform",
"key": "App.PublicDemo.MailIntro",
"en": "A new demo request has been submitted through the website.",
"tr": "Web sitesi üzerinden yeni bir demo talebi oluşturuldu."
},
{
"resourceName": "Platform",
"key": "App.PublicDemo.MailContactInfo",
"en": "Contact Information",
"tr": "İletişim Bilgileri"
},
{
"resourceName": "Platform",
"key": "App.PublicDemo.MailCompanyInfo",
"en": "Company Information",
"tr": "Firma Bilgileri"
} }
] ]
} }