Seeder düzenlemesi ve interpolate
This commit is contained in:
parent
444261ba39
commit
ea3e847490
4 changed files with 21 additions and 11 deletions
|
|
@ -18,6 +18,7 @@ using Microsoft.Extensions.Hosting;
|
|||
using Sozsoft.Languages;
|
||||
using Sozsoft.Platform.DynamicData;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Sozsoft.Platform.ListForms;
|
||||
|
||||
|
|
@ -34,7 +35,8 @@ public class ListFormWizardAppService(
|
|||
IPermissionGrantRepository permissionGrantRepository,
|
||||
IHostEnvironment hostEnvironment,
|
||||
LanguageTextAppService languageTextAppService,
|
||||
IDynamicDataManager dynamicDataManager
|
||||
IDynamicDataManager dynamicDataManager,
|
||||
ILogger<ListFormWizardAppService> logger
|
||||
) : PlatformAppService(), IListFormWizardAppService
|
||||
{
|
||||
private readonly IRepository<ListForm, Guid> repoListForm = repoListForm;
|
||||
|
|
@ -49,6 +51,7 @@ public class ListFormWizardAppService(
|
|||
private readonly IHostEnvironment _hostEnvironment = hostEnvironment;
|
||||
private readonly LanguageTextAppService _languageTextAppService = languageTextAppService;
|
||||
private readonly IDynamicDataManager _dynamicDataManager = dynamicDataManager;
|
||||
private readonly ILogger<ListFormWizardAppService> logger = logger;
|
||||
private readonly string cultureNameDefault = PlatformConsts.DefaultLanguage;
|
||||
|
||||
[UnitOfWork]
|
||||
|
|
@ -346,12 +349,12 @@ public class ListFormWizardAppService(
|
|||
var filePath = Path.Combine(outputPath, $"{timestamp}_{safeWizardName}.json");
|
||||
await File.WriteAllTextAsync(filePath, json);
|
||||
|
||||
Console.WriteLine($"[WizardSeed] Seed dosyası kaydedildi: {filePath}");
|
||||
logger.LogInformation($"Seed dosyası kaydedildi: {filePath}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Dosya kaydetme hatası wizard işlemini engellemez
|
||||
Console.WriteLine($"[WizardSeed] Seed dosyası kaydedilemedi: {ex.Message}");
|
||||
logger.LogError(ex, $"Seed dosyası kaydedilemedi: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,8 +47,15 @@ const interpolate = (text: string, params: Record<string, string | number>) => {
|
|||
if (!params || typeof params !== 'object') return text
|
||||
|
||||
return Object.entries(params).reduce((acc, [key, value]) => {
|
||||
const pattern = new RegExp(`{{\\s*${key}\\s*}}`, 'g')
|
||||
return acc.replace(pattern, String(value))
|
||||
if (/^\d+$/.test(key)) {
|
||||
// Positional ABP-style: {0}, {1}, etc.
|
||||
const pattern = new RegExp(`\\{${key}\\}`, 'g')
|
||||
return acc.replace(pattern, String(value))
|
||||
} else {
|
||||
// Named: {{ key }}
|
||||
const pattern = new RegExp(`{{\\s*${key}\\s*}}`, 'g')
|
||||
return acc.replace(pattern, String(value))
|
||||
}
|
||||
}, text)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ interface LogEntry {
|
|||
function buildLogSteps(
|
||||
values: ListFormWizardDto,
|
||||
groups: WizardGroup[],
|
||||
translate: (key: string) => string,
|
||||
translate: (key: string, params?: Record<string, string | number>) => string,
|
||||
): Omit<LogEntry, 'status'>[] {
|
||||
const totalFields = groups.reduce((acc, g) => acc + g.items.length, 0)
|
||||
return [
|
||||
{ id: 1, label: translate('::ListForms.Wizard.Step4.Log.ValidatingConfig') },
|
||||
{
|
||||
id: 2,
|
||||
label: `${translate('::ListForms.Wizard.Step4.Log.CreatingMenu')}: ${values.menuCode}`,
|
||||
label: translate('::ListForms.Wizard.Step4.Log.CreatingMenu', { 0: values.menuCode }),
|
||||
detail: `Parent: ${values.menuParentCode}`,
|
||||
},
|
||||
{
|
||||
|
|
@ -57,14 +57,14 @@ function buildLogSteps(
|
|||
label: translate('::ListForms.Wizard.Step4.Log.SavingLanguageTexts'),
|
||||
detail: `EN: ${values.languageTextMenuEn} / TR: ${values.languageTextMenuTr}`,
|
||||
},
|
||||
{ id: 4, label: `${translate('::ListForms.Wizard.Step4.Log.ConfiguringPermission')}: ${values.permissionGroupName}` },
|
||||
{ id: 5, label: `${translate('::ListForms.Wizard.Step4.Log.ConnectingDataSource')}: ${values.dataSourceCode}` },
|
||||
{ id: 4, label: translate('::ListForms.Wizard.Step4.Log.ConfiguringPermission', { 0: values.permissionGroupName }) },
|
||||
{ id: 5, label: translate('::ListForms.Wizard.Step4.Log.ConnectingDataSource', { 0: values.dataSourceCode }) },
|
||||
{
|
||||
id: 6,
|
||||
label: `${translate('::ListForms.Wizard.Step4.Log.CreatingListForm')}: ${values.listFormCode}`,
|
||||
label: translate('::ListForms.Wizard.Step4.Log.CreatingListForm', { 0: values.listFormCode }),
|
||||
detail: `Key: ${values.keyFieldName}`,
|
||||
},
|
||||
{ id: 7, label: `${translate('::ListForms.Wizard.Step4.Log.SavingFormGroups')} (${groups.length} ${translate('::ListForms.Wizard.Step4.StatGroup')}, ${totalFields} ${translate('::ListForms.Wizard.Step4.StatField')})` },
|
||||
{ id: 7, label: translate('::ListForms.Wizard.Step4.Log.SavingFormGroups', { 0: groups.length, 1: totalFields }) },
|
||||
{ id: 8, label: translate('::ListForms.Wizard.Step4.Log.Deploying') },
|
||||
{ id: 9, label: translate('::ListForms.Wizard.Step4.Log.Completed') },
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue