MenuAddDialog eklendi
This commit is contained in:
parent
c5ad419a27
commit
5ddf2e97f7
22 changed files with 856 additions and 689 deletions
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -15,6 +14,8 @@ using Volo.Abp.PermissionManagement;
|
|||
using Volo.Abp.Uow;
|
||||
using static Sozsoft.Platform.PlatformConsts;
|
||||
using System.Data;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Sozsoft.Languages;
|
||||
|
||||
namespace Sozsoft.Platform.ListForms;
|
||||
|
||||
|
|
@ -30,7 +31,9 @@ public class ListFormWizardAppService(
|
|||
IIdentityRoleRepository roleRepository,
|
||||
IIdentityUserRepository userRepository,
|
||||
IPermissionGrantRepository permissionGrantRepository,
|
||||
ILookupNormalizer LookupNormalizer
|
||||
ILookupNormalizer LookupNormalizer,
|
||||
IConfiguration configuration,
|
||||
LanguageTextAppService languageTextAppService
|
||||
) : PlatformAppService(), IListFormWizardAppService
|
||||
{
|
||||
private readonly IRepository<ListForm, Guid> repoListForm = repoListForm;
|
||||
|
|
@ -45,17 +48,21 @@ public class ListFormWizardAppService(
|
|||
private readonly IIdentityUserRepository userRepository = userRepository;
|
||||
private readonly IPermissionGrantRepository permissionGrantRepository = permissionGrantRepository;
|
||||
private readonly ILookupNormalizer lookupNormalizer = LookupNormalizer;
|
||||
private readonly IConfiguration _configuration = configuration;
|
||||
private readonly LanguageTextAppService _languageTextAppService = languageTextAppService;
|
||||
private readonly string cultureNameDefault = PlatformConsts.DefaultLanguage;
|
||||
|
||||
[UnitOfWork]
|
||||
public async Task Create(ListFormWizardDto input)
|
||||
{
|
||||
var wizardName = input.WizardName.Trim();
|
||||
var titleLangKey = PlatformConsts.Wizard.WizardKeyTitle(wizardName);
|
||||
var nameLangKey = PlatformConsts.Wizard.WizardKey(wizardName);
|
||||
var descLangKey = PlatformConsts.Wizard.WizardKeyDesc(wizardName);
|
||||
var titleLangKey = WizardConsts.WizardKeyTitle(wizardName);
|
||||
var nameLangKey = WizardConsts.WizardKey(wizardName);
|
||||
var descLangKey = WizardConsts.WizardKeyDesc(wizardName);
|
||||
var code = WizardConsts.WizardKey(wizardName);
|
||||
|
||||
var code = PlatformConsts.Wizard.WizardKey(wizardName);
|
||||
// Clear Redis Cache
|
||||
await _languageTextAppService.ClearRedisCacheAsync();
|
||||
|
||||
//Dil - Language Keys
|
||||
await CreateLangKey(nameLangKey, input.LanguageTextMenuEn, input.LanguageTextMenuTr);
|
||||
|
|
@ -79,23 +86,23 @@ public class ListFormWizardAppService(
|
|||
var permRead = existingPerms.FirstOrDefault(a => a.Name == code) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, code, null, nameLangKey, true, MultiTenancySides.Both), autoSave: false);
|
||||
|
||||
var permCreate = existingPerms.FirstOrDefault(a => a.Name == PlatformConsts.Wizard.PermCreate(wizardName)) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, PlatformConsts.Wizard.PermCreate(wizardName), permRead.Name, PlatformConsts.Wizard.LangKeyCreate, true, MultiTenancySides.Both), autoSave: false);
|
||||
var permCreate = existingPerms.FirstOrDefault(a => a.Name == WizardConsts.PermCreate(wizardName)) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, WizardConsts.PermCreate(wizardName), permRead.Name, WizardConsts.LangKeyCreate, true, MultiTenancySides.Both), autoSave: false);
|
||||
|
||||
var permUpdate = existingPerms.FirstOrDefault(a => a.Name == PlatformConsts.Wizard.PermUpdate(wizardName)) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, PlatformConsts.Wizard.PermUpdate(wizardName), permRead.Name, PlatformConsts.Wizard.LangKeyUpdate, true, MultiTenancySides.Both), autoSave: false);
|
||||
var permUpdate = existingPerms.FirstOrDefault(a => a.Name == WizardConsts.PermUpdate(wizardName)) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, WizardConsts.PermUpdate(wizardName), permRead.Name, WizardConsts.LangKeyUpdate, true, MultiTenancySides.Both), autoSave: false);
|
||||
|
||||
var permDelete = existingPerms.FirstOrDefault(a => a.Name == PlatformConsts.Wizard.PermDelete(wizardName)) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, PlatformConsts.Wizard.PermDelete(wizardName), permRead.Name, PlatformConsts.Wizard.LangKeyDelete, true, MultiTenancySides.Both), autoSave: false);
|
||||
var permDelete = existingPerms.FirstOrDefault(a => a.Name == WizardConsts.PermDelete(wizardName)) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, WizardConsts.PermDelete(wizardName), permRead.Name, WizardConsts.LangKeyDelete, true, MultiTenancySides.Both), autoSave: false);
|
||||
|
||||
var permExport = existingPerms.FirstOrDefault(a => a.Name == PlatformConsts.Wizard.PermExport(wizardName)) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, PlatformConsts.Wizard.PermExport(wizardName), permRead.Name, PlatformConsts.Wizard.LangKeyExport, true, MultiTenancySides.Both), autoSave: false);
|
||||
var permExport = existingPerms.FirstOrDefault(a => a.Name == WizardConsts.PermExport(wizardName)) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, WizardConsts.PermExport(wizardName), permRead.Name, WizardConsts.LangKeyExport, true, MultiTenancySides.Both), autoSave: false);
|
||||
|
||||
var permImport = existingPerms.FirstOrDefault(a => a.Name == PlatformConsts.Wizard.PermImport(wizardName)) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, PlatformConsts.Wizard.PermImport(wizardName), permRead.Name, PlatformConsts.Wizard.LangKeyImport, true, MultiTenancySides.Both), autoSave: false);
|
||||
var permImport = existingPerms.FirstOrDefault(a => a.Name == WizardConsts.PermImport(wizardName)) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, WizardConsts.PermImport(wizardName), permRead.Name, WizardConsts.LangKeyImport, true, MultiTenancySides.Both), autoSave: false);
|
||||
|
||||
var permNote = existingPerms.FirstOrDefault(a => a.Name == PlatformConsts.Wizard.PermNote(wizardName)) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, PlatformConsts.Wizard.PermNote(wizardName), permRead.Name, PlatformConsts.Wizard.LangKeyNote, true, MultiTenancySides.Both), autoSave: false);
|
||||
var permNote = existingPerms.FirstOrDefault(a => a.Name == WizardConsts.PermNote(wizardName)) ??
|
||||
await repoPerm.InsertAsync(new PermissionDefinitionRecord(Guid.NewGuid(), groupName, WizardConsts.PermNote(wizardName), permRead.Name, WizardConsts.LangKeyNote, true, MultiTenancySides.Both), autoSave: false);
|
||||
|
||||
// Permission Grants - Bulk Insert
|
||||
var adminUserName = PlatformConsts.AbpIdentity.User.AdminEmailDefaultValue;
|
||||
|
|
@ -118,11 +125,11 @@ public class ListFormWizardAppService(
|
|||
var menuParent = await AsyncExecuter.FirstOrDefaultAsync(menuQueryable.Where(a => a.Code == input.MenuParentCode));
|
||||
if (menuParent == null)
|
||||
{
|
||||
await CreateLangKey(PlatformConsts.Wizard.WizardKeyParent(wizardName), input.LanguageTextMenuParentEn, input.LanguageTextMenuParentTr);
|
||||
await CreateLangKey(WizardConsts.WizardKeyParent(wizardName), input.LanguageTextMenuParentEn, input.LanguageTextMenuParentTr);
|
||||
menuParent = await repoMenu.InsertAsync(new Menu
|
||||
{
|
||||
Code = input.MenuParentCode,
|
||||
DisplayName = PlatformConsts.Wizard.WizardKeyParent(wizardName),
|
||||
DisplayName = WizardConsts.WizardKeyParent(wizardName),
|
||||
IsDisabled = false,
|
||||
}, autoSave: false);
|
||||
}
|
||||
|
|
@ -135,11 +142,11 @@ public class ListFormWizardAppService(
|
|||
DisplayName = nameLangKey,
|
||||
IsDisabled = false,
|
||||
ParentCode = menuParent.Code,
|
||||
Icon = input.MenuIcon ?? PlatformConsts.Wizard.MenuIcon,
|
||||
Icon = input.MenuIcon ?? WizardConsts.MenuIcon,
|
||||
Target = null,
|
||||
ElementId = null,
|
||||
CssClass = null,
|
||||
Url = PlatformConsts.Wizard.MenuUrl(code),
|
||||
Url = WizardConsts.MenuUrl(code),
|
||||
RequiredPermissionName = permRead.Name
|
||||
}, autoSave: false);
|
||||
|
||||
|
|
@ -186,10 +193,10 @@ public class ListFormWizardAppService(
|
|||
{
|
||||
ListFormType = ListFormTypeEnum.List,
|
||||
PageSize = 10,
|
||||
ExportJson = Wizard.DefaultExportJson,
|
||||
ExportJson = WizardConsts.DefaultExportJson,
|
||||
IsSubForm = false,
|
||||
ShowNote = true,
|
||||
LayoutJson = Wizard.DefaultLayoutJson(),
|
||||
LayoutJson = WizardConsts.DefaultLayoutJson(),
|
||||
CultureName = LanguageCodes.En,
|
||||
ListFormCode = input.ListFormCode,
|
||||
Name = nameLangKey,
|
||||
|
|
@ -203,19 +210,20 @@ public class ListFormWizardAppService(
|
|||
SelectCommand = input.SelectCommand,
|
||||
KeyFieldName = input.KeyFieldName,
|
||||
KeyFieldDbSourceType = input.KeyFieldDbSourceType,
|
||||
DefaultFilter = Wizard.DefaultFilterJson,
|
||||
DefaultFilter = WizardConsts.DefaultFilterJson,
|
||||
SortMode = GridOptions.SortModeSingle,
|
||||
FilterRowJson = Wizard.DefaultFilterRowJson,
|
||||
HeaderFilterJson = Wizard.DefaultHeaderFilterJson,
|
||||
SearchPanelJson = Wizard.DefaultSearchPanelJson,
|
||||
FilterRowJson = WizardConsts.DefaultFilterRowJson,
|
||||
HeaderFilterJson = WizardConsts.DefaultHeaderFilterJson,
|
||||
SearchPanelJson = WizardConsts.DefaultSearchPanelJson,
|
||||
GroupPanelJson = JsonSerializer.Serialize(new { Visible = false }),
|
||||
SelectionJson = Wizard.DefaultSelectionSingleJson,
|
||||
ColumnOptionJson = Wizard.DefaultColumnOptionJson(),
|
||||
PermissionJson = Wizard.DefaultPermissionJson(code),
|
||||
DeleteCommand = Wizard.DefaultDeleteCommand(nameof(TableNameEnum.Country)),
|
||||
DeleteFieldsDefaultValueJson = Wizard.DefaultDeleteFieldsDefaultValueJson(input.KeyFieldDbSourceType),
|
||||
PagerOptionJson = Wizard.DefaultPagerOptionJson,
|
||||
EditingOptionJson = Wizard.DefaultEditingOptionJson(titleLangKey, 600, 500, input.AllowDeleting, input.AllowAdding, input.AllowEditing, input.ConfirmDelete, false, input.AllowDetail),
|
||||
SelectionJson = WizardConsts.DefaultSelectionSingleJson,
|
||||
ColumnOptionJson = WizardConsts.DefaultColumnOptionJson(),
|
||||
PermissionJson = WizardConsts.DefaultPermissionJson(code),
|
||||
DeleteCommand = WizardConsts.DefaultDeleteCommand(input.SelectCommand),
|
||||
DeleteFieldsDefaultValueJson = WizardConsts.DefaultDeleteFieldsDefaultValueJson(input.KeyFieldDbSourceType),
|
||||
InsertFieldsDefaultValueJson = WizardConsts.DefaultInsertFieldsDefaultValueJson(input.KeyFieldDbSourceType),
|
||||
PagerOptionJson = WizardConsts.DefaultPagerOptionJson,
|
||||
EditingOptionJson = WizardConsts.DefaultEditingOptionJson(titleLangKey, 600, 500, input.AllowDeleting, input.AllowAdding, input.AllowEditing, input.ConfirmDelete, false, input.AllowDetail),
|
||||
EditingFormJson = editingFormDtos.Count > 0 ? JsonSerializer.Serialize(editingFormDtos) : null,
|
||||
}, autoSave: true);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Sozsoft.Languages.Entities;
|
||||
using Sozsoft.Platform.Entities;
|
||||
using Sozsoft.Platform.Enums;
|
||||
using Sozsoft.Settings.Entities;
|
||||
|
|
@ -12,14 +10,11 @@ using Microsoft.Extensions.Configuration;
|
|||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using Volo.Abp.PermissionManagement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EFCore.BulkExtensions;
|
||||
using System.Collections.Generic;
|
||||
using Sozsoft.Platform.Public;
|
||||
using static Sozsoft.Settings.SettingsConsts;
|
||||
using Sozsoft.Platform.Extensions;
|
||||
|
||||
namespace Sozsoft.Platform.Data.Seeds;
|
||||
|
||||
|
|
@ -104,65 +99,36 @@ public class ContactTitleSeedDto
|
|||
public string Abbreviation { get; set; }
|
||||
}
|
||||
|
||||
public class RouteSeedDto
|
||||
{
|
||||
public string Key { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string ComponentPath { get; set; }
|
||||
public string RouteType { get; set; }
|
||||
public string[] Authority { get; set; }
|
||||
}
|
||||
|
||||
public class HostSeederDto
|
||||
{
|
||||
public List<AiBotSeedDto> AiBots { get; set; }
|
||||
public List<Language> Languages { get; set; }
|
||||
public List<LanguageTextsSeedDto> LanguageTexts { get; set; }
|
||||
public List<LanguageTextsSeedDto> LanguageFieldTitles { get; set; }
|
||||
public List<DataSource> DataSources { get; set; }
|
||||
public List<SettingDefinition> Settings { get; set; }
|
||||
public List<BackgroundWorkerSeedDto> BackgroundWorkers { get; set; }
|
||||
public List<NotificationRuleSeedDto> NotificationRules { get; set; }
|
||||
public List<MenuSeedDto> Menus { get; set; }
|
||||
public List<PermissionGroupDefinitionRecordSeedDto> PermissionGroupDefinitionRecords { get; set; }
|
||||
public List<PermissionDefinitionRecordSeedDto> PermissionDefinitionRecords { get; set; }
|
||||
public List<CurrencySeedDto> Currencies { get; set; }
|
||||
public List<ContactTitleSeedDto> ContactTitles { get; set; }
|
||||
public List<RouteSeedDto> Routes { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
public class HostDataSeeder : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private readonly IRepository<AiBot, Guid> _aiBotRepository;
|
||||
private readonly IRepository<Language, Guid> _languages;
|
||||
private readonly IRepository<LanguageKey, Guid> _languageKey;
|
||||
private readonly IRepository<LanguageText, Guid> _languagesText;
|
||||
private readonly IRepository<DataSource, Guid> _dataSources;
|
||||
private readonly IRepository<SettingDefinition, Guid> _settings;
|
||||
private readonly IRepository<BackgroundWorker, Guid> _backgroundWorkerRepository;
|
||||
private readonly IRepository<Menu, Guid> _menuRepository;
|
||||
private readonly IRepository<PermissionGroupDefinitionRecord, Guid> _permissionGroupRepository;
|
||||
private readonly IRepository<PermissionDefinitionRecord, Guid> _permissionRepository;
|
||||
private readonly IRepository<Currency, string> _currencyRepository;
|
||||
private readonly IRepository<CountryGroup, string> _countryGroupRepository;
|
||||
private readonly IRepository<Country, string> _countryRepository;
|
||||
private readonly IRepository<City, Guid> _cityRepository;
|
||||
private readonly IRepository<District, Guid> _districtRepository;
|
||||
private readonly IRepository<ContactTitle, Guid> _contactTitleRepository;
|
||||
private readonly IRepository<Route, Guid> _routeRepository;
|
||||
|
||||
public HostDataSeeder(
|
||||
IRepository<AiBot, Guid> aiBotRepository,
|
||||
IRepository<Language, Guid> languages,
|
||||
IRepository<LanguageKey, Guid> languageKey,
|
||||
IRepository<LanguageText, Guid> languagesText,
|
||||
IRepository<DataSource, Guid> dataSource,
|
||||
IRepository<SettingDefinition, Guid> settings,
|
||||
IRepository<BackgroundWorker, Guid> backgroundWorkerRepository,
|
||||
IRepository<Menu, Guid> menuRepository,
|
||||
IRepository<PermissionGroupDefinitionRecord, Guid> permissionGroupRepository,
|
||||
IRepository<PermissionDefinitionRecord, Guid> permissionRepository,
|
||||
IRepository<Currency, string> currencyRepository,
|
||||
IRepository<CountryGroup, string> countryGroupRepository,
|
||||
IRepository<Country, string> countryRepository,
|
||||
|
|
@ -172,23 +138,16 @@ public class HostDataSeeder : IDataSeedContributor, ITransientDependency
|
|||
IRepository<Route, Guid> routeRepository
|
||||
)
|
||||
{
|
||||
_languages = languages;
|
||||
_languageKey = languageKey;
|
||||
_languagesText = languagesText;
|
||||
_aiBotRepository = aiBotRepository;
|
||||
_dataSources = dataSource;
|
||||
_settings = settings;
|
||||
_backgroundWorkerRepository = backgroundWorkerRepository;
|
||||
_menuRepository = menuRepository;
|
||||
_permissionGroupRepository = permissionGroupRepository;
|
||||
_permissionRepository = permissionRepository;
|
||||
_currencyRepository = currencyRepository;
|
||||
_countryGroupRepository = countryGroupRepository;
|
||||
_countryRepository = countryRepository;
|
||||
_cityRepository = cityRepository;
|
||||
_districtRepository = districtRepository;
|
||||
_contactTitleRepository = contactTitleRepository;
|
||||
_aiBotRepository = aiBotRepository;
|
||||
_routeRepository = routeRepository;
|
||||
}
|
||||
|
||||
private static IConfigurationRoot BuildConfiguration()
|
||||
|
|
@ -436,22 +395,14 @@ public class HostDataSeeder : IDataSeedContributor, ITransientDependency
|
|||
{
|
||||
var settings = await _settings.GetListAsync();
|
||||
var dataSources = await _dataSources.GetListAsync();
|
||||
var languages = await _languages.GetListAsync();
|
||||
var keys = await _languageKey.GetListAsync();
|
||||
var texts = await _languagesText.GetListAsync();
|
||||
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile(Path.Combine("Seeds", "HostData.json"))
|
||||
.AddJsonFile(Path.Combine("Seeds", $"HostData.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? ""}.json"), true)
|
||||
.AddJsonFile(Path.Combine("Seeds", "LanguagesData.json"))
|
||||
.AddJsonFile(Path.Combine("Seeds", "MenusData.json"))
|
||||
.AddJsonFile(Path.Combine("Seeds", "PermissionsData.json"))
|
||||
.Build();
|
||||
var items = configuration.Get<HostSeederDto>();
|
||||
|
||||
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
|
||||
|
||||
foreach (var item in items.Settings)
|
||||
{
|
||||
if (!settings.Any(a => a.Code == item.Code))
|
||||
|
|
@ -487,101 +438,6 @@ public class HostDataSeeder : IDataSeedContributor, ITransientDependency
|
|||
});
|
||||
}
|
||||
|
||||
foreach (var item in items.Languages)
|
||||
{
|
||||
if (!languages.Any(a => a.CultureName == item.CultureName))
|
||||
{
|
||||
await _languages.InsertAsync(new()
|
||||
{
|
||||
CultureName = item.CultureName,
|
||||
UiCultureName = item.UiCultureName,
|
||||
DisplayName = item.DisplayName,
|
||||
IsEnabled = item.IsEnabled,
|
||||
TwoLetterISOLanguageName = new CultureInfo(item.CultureName).TwoLetterISOLanguageName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.LanguageTexts)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!keys.Any(a => a.Key == item.Key))
|
||||
{
|
||||
await _languageKey.InsertAsync(new()
|
||||
{
|
||||
Key = item.Key,
|
||||
ResourceName = item.ResourceName,
|
||||
});
|
||||
}
|
||||
if (!texts.Any(a => a.CultureName == "en" && a.Key == item.Key))
|
||||
{
|
||||
await _languagesText.InsertAsync(new()
|
||||
{
|
||||
CultureName = "en",
|
||||
Key = item.Key,
|
||||
Value = item.En,
|
||||
ResourceName = item.ResourceName,
|
||||
});
|
||||
}
|
||||
if (!texts.Any(a => a.CultureName == "tr" && a.Key == item.Key))
|
||||
{
|
||||
|
||||
await _languagesText.InsertAsync(new()
|
||||
{
|
||||
CultureName = "tr",
|
||||
Key = item.Key,
|
||||
Value = item.Tr,
|
||||
ResourceName = item.ResourceName,
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Hata veren Kod:' ResourceName='{item.ResourceName}', Key='{item.Key}' Message='{ex.Message}'");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.LanguageFieldTitles)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!keys.Any(a => a.Key == item.Key))
|
||||
{
|
||||
await _languageKey.InsertAsync(new()
|
||||
{
|
||||
Key = item.Key,
|
||||
ResourceName = item.ResourceName,
|
||||
});
|
||||
}
|
||||
if (!texts.Any(a => a.CultureName == "en" && a.Key == item.Key))
|
||||
{
|
||||
await _languagesText.InsertAsync(new()
|
||||
{
|
||||
CultureName = "en",
|
||||
Key = item.Key,
|
||||
Value = item.En,
|
||||
ResourceName = item.ResourceName,
|
||||
});
|
||||
}
|
||||
if (!texts.Any(a => a.CultureName == "tr" && a.Key == item.Key))
|
||||
{
|
||||
|
||||
await _languagesText.InsertAsync(new()
|
||||
{
|
||||
CultureName = "tr",
|
||||
Key = item.Key,
|
||||
Value = item.Tr,
|
||||
ResourceName = item.ResourceName,
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Hata veren Kod:' ResourceName='{item.ResourceName}', Key='{item.Key}' Message='{ex.Message}'");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.BackgroundWorkers)
|
||||
{
|
||||
if (!await _backgroundWorkerRepository.AnyAsync(x => x.Name == item.Name))
|
||||
|
|
@ -597,63 +453,6 @@ public class HostDataSeeder : IDataSeedContributor, ITransientDependency
|
|||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.Menus)
|
||||
{
|
||||
var exists = await _menuRepository.AnyAsync(x => x.Code == item.Code);
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
await _menuRepository.InsertAsync(new Menu
|
||||
{
|
||||
ParentCode = string.IsNullOrWhiteSpace(item.ParentCode) ? null : item.ParentCode,
|
||||
Code = item.Code,
|
||||
DisplayName = item.DisplayName,
|
||||
Order = item.Order,
|
||||
Url = item.Url,
|
||||
Icon = item.Icon,
|
||||
RequiredPermissionName = item.RequiredPermissionName,
|
||||
IsDisabled = item.IsDisabled,
|
||||
ShortName = item.ShortName
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.PermissionGroupDefinitionRecords)
|
||||
{
|
||||
var exists = await _permissionGroupRepository.AnyAsync(x => x.Name == item.Name);
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
await _permissionGroupRepository.InsertAsync(new PermissionGroupDefinitionRecord
|
||||
{
|
||||
Name = item.Name,
|
||||
DisplayName = item.DisplayName
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.PermissionDefinitionRecords)
|
||||
{
|
||||
var exists = await _permissionRepository.AnyAsync(x => x.Name == item.Name);
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
var perm = new PermissionDefinitionRecord
|
||||
{
|
||||
GroupName = item.GroupName,
|
||||
Name = item.Name,
|
||||
ParentName = string.IsNullOrWhiteSpace(item.ParentName) ? null : item.ParentName,
|
||||
DisplayName = item.DisplayName,
|
||||
IsEnabled = item.IsEnabled,
|
||||
MultiTenancySide = (MultiTenancySides)item.MultiTenancySide,
|
||||
};
|
||||
|
||||
perm.SetMenuGroup(item.MenuGroup);
|
||||
|
||||
await _permissionRepository.InsertAsync(perm);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.Currencies)
|
||||
{
|
||||
var exists = await _currencyRepository.AnyAsync(x => x.Id == item.Id);
|
||||
|
|
@ -699,22 +498,6 @@ public class HostDataSeeder : IDataSeedContributor, ITransientDependency
|
|||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.Routes)
|
||||
{
|
||||
var exists = await _routeRepository.AnyAsync(x => x.Key == item.Key);
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
await _routeRepository.InsertAsync(new Route(
|
||||
item.Key,
|
||||
item.Path,
|
||||
item.ComponentPath,
|
||||
item.RouteType,
|
||||
item.Authority ?? []
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
await SeedCountyGroupsAsync();
|
||||
|
||||
await SeedCountriesAsync();
|
||||
|
|
|
|||
144
api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguageDataSeeder.cs
Normal file
144
api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguageDataSeeder.cs
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Sozsoft.Languages.Entities;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
|
||||
namespace Sozsoft.Platform.Data.Seeds;
|
||||
|
||||
public class LanguageSeederDto
|
||||
{
|
||||
public List<Language> Languages { get; set; }
|
||||
public List<LanguageTextsSeedDto> LanguageTexts { get; set; }
|
||||
public List<LanguageTextsSeedDto> LanguageFieldTitles { get; set; }
|
||||
}
|
||||
|
||||
public class LanguageDataSeeder : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private readonly IRepository<Language, Guid> _languages;
|
||||
private readonly IRepository<LanguageKey, Guid> _languageKey;
|
||||
private readonly IRepository<LanguageText, Guid> _languagesText;
|
||||
|
||||
public LanguageDataSeeder(
|
||||
IRepository<Language, Guid> languages,
|
||||
IRepository<LanguageKey, Guid> languageKey,
|
||||
IRepository<LanguageText, Guid> languagesText)
|
||||
{
|
||||
_languages = languages;
|
||||
_languageKey = languageKey;
|
||||
_languagesText = languagesText;
|
||||
}
|
||||
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
var languages = await _languages.GetListAsync();
|
||||
var keys = await _languageKey.GetListAsync();
|
||||
var texts = await _languagesText.GetListAsync();
|
||||
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile(Path.Combine("Seeds", "LanguagesData.json"))
|
||||
.Build();
|
||||
|
||||
var items = configuration.Get<LanguageSeederDto>();
|
||||
|
||||
foreach (var item in items.Languages)
|
||||
{
|
||||
if (!languages.Any(a => a.CultureName == item.CultureName))
|
||||
{
|
||||
await _languages.InsertAsync(new()
|
||||
{
|
||||
CultureName = item.CultureName,
|
||||
UiCultureName = item.UiCultureName,
|
||||
DisplayName = item.DisplayName,
|
||||
IsEnabled = item.IsEnabled,
|
||||
TwoLetterISOLanguageName = new CultureInfo(item.CultureName).TwoLetterISOLanguageName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.LanguageTexts)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!keys.Any(a => a.Key == item.Key))
|
||||
{
|
||||
await _languageKey.InsertAsync(new()
|
||||
{
|
||||
Key = item.Key,
|
||||
ResourceName = item.ResourceName,
|
||||
});
|
||||
}
|
||||
if (!texts.Any(a => a.CultureName == "en" && a.Key == item.Key))
|
||||
{
|
||||
await _languagesText.InsertAsync(new()
|
||||
{
|
||||
CultureName = "en",
|
||||
Key = item.Key,
|
||||
Value = item.En,
|
||||
ResourceName = item.ResourceName,
|
||||
});
|
||||
}
|
||||
if (!texts.Any(a => a.CultureName == "tr" && a.Key == item.Key))
|
||||
{
|
||||
await _languagesText.InsertAsync(new()
|
||||
{
|
||||
CultureName = "tr",
|
||||
Key = item.Key,
|
||||
Value = item.Tr,
|
||||
ResourceName = item.ResourceName,
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Hata veren Kod:' ResourceName='{item.ResourceName}', Key='{item.Key}' Message='{ex.Message}'");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.LanguageFieldTitles)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!keys.Any(a => a.Key == item.Key))
|
||||
{
|
||||
await _languageKey.InsertAsync(new()
|
||||
{
|
||||
Key = item.Key,
|
||||
ResourceName = item.ResourceName,
|
||||
});
|
||||
}
|
||||
if (!texts.Any(a => a.CultureName == "en" && a.Key == item.Key))
|
||||
{
|
||||
await _languagesText.InsertAsync(new()
|
||||
{
|
||||
CultureName = "en",
|
||||
Key = item.Key,
|
||||
Value = item.En,
|
||||
ResourceName = item.ResourceName,
|
||||
});
|
||||
}
|
||||
if (!texts.Any(a => a.CultureName == "tr" && a.Key == item.Key))
|
||||
{
|
||||
await _languagesText.InsertAsync(new()
|
||||
{
|
||||
CultureName = "tr",
|
||||
Key = item.Key,
|
||||
Value = item.Tr,
|
||||
ResourceName = item.ResourceName,
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Hata veren Kod:' ResourceName='{item.ResourceName}', Key='{item.Key}' Message='{ex.Message}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15908,6 +15908,12 @@
|
|||
"en": "Rename",
|
||||
"tr": "Yeniden Adlandır"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.Wizard.Step1.ShortNameHint",
|
||||
"en": "Auto-derived, editable",
|
||||
"tr": "Otomatik oluşturulur, düzenlenebilir"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.Wizard.Step1.Delete",
|
||||
|
|
@ -16100,6 +16106,12 @@
|
|||
"en": "Editor Options",
|
||||
"tr": "Editör Seçenekleri"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.Wizard.Step3.Required",
|
||||
"en": "Required",
|
||||
"tr": "Zorunlu"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.Wizard.Step3.EditorScript",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ using Volo.Abp.Identity;
|
|||
using AbpIdentity = Sozsoft.Platform.Data.Seeds.SeedConsts.AbpIdentity;
|
||||
using AppCodes = Sozsoft.Platform.Data.Seeds.SeedConsts.AppCodes;
|
||||
using static Sozsoft.Platform.PlatformConsts;
|
||||
using static Sozsoft.Platform.PlatformSeeder.SeederDefaults;
|
||||
using static Sozsoft.Platform.PlatformSeeder.ListFormSeeder_DefaultJsons;
|
||||
|
||||
namespace Sozsoft.Platform.Data.Seeds;
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep
|
|||
{
|
||||
var configurationSection = _configuration.GetSection("OpenIddict:Applications");
|
||||
var swaggerRootUrl = configurationSection["Platform_Swagger:RootUrl"]?.TrimEnd('/');
|
||||
var utils = new SeederUtils(_listFormRepository, _listFormFieldRepository);
|
||||
var utils = new ListFormSeeder_Utils(_listFormRepository, _listFormFieldRepository);
|
||||
var listFormName = String.Empty;
|
||||
|
||||
#region Permission Group
|
||||
|
|
@ -5012,7 +5012,7 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep
|
|||
Name = listFormName,
|
||||
Title = listFormName,
|
||||
DataSourceCode = SeedConsts.DataSources.DefaultCode,
|
||||
IsTenant = true,
|
||||
IsTenant = false,
|
||||
IsBranch = false,
|
||||
IsOrganizationUnit = false,
|
||||
Description = listFormName,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using static Sozsoft.Platform.PlatformConsts;
|
|||
|
||||
namespace Sozsoft.Platform.PlatformSeeder;
|
||||
|
||||
public static class SeederDefaults
|
||||
public static class ListFormSeeder_DefaultJsons
|
||||
{
|
||||
public static string DefaultDeleteCommand(string tableName)
|
||||
{
|
||||
|
|
@ -16,7 +16,7 @@ using Volo.Abp.Identity;
|
|||
using Volo.Abp.TenantManagement;
|
||||
using AppCodes = Sozsoft.Platform.Data.Seeds.SeedConsts.AppCodes;
|
||||
using static Sozsoft.Platform.PlatformConsts;
|
||||
using static Sozsoft.Platform.PlatformSeeder.SeederDefaults;
|
||||
using static Sozsoft.Platform.PlatformSeeder.ListFormSeeder_DefaultJsons;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Sozsoft.Platform.Localization;
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency
|
|||
{
|
||||
var configurationSection = _configuration.GetSection("OpenIddict:Applications");
|
||||
var swaggerRootUrl = configurationSection["Platform_Swagger:RootUrl"]?.TrimEnd('/');
|
||||
var utils = new SeederUtils(_listFormRepository, _listFormFieldRepository);
|
||||
var utils = new ListFormSeeder_Utils(_listFormRepository, _listFormFieldRepository);
|
||||
var listFormName = String.Empty;
|
||||
|
||||
#region Tenant
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ using Volo.Abp.Domain.Repositories;
|
|||
|
||||
namespace Sozsoft.Platform.Data.Seeds;
|
||||
|
||||
public class SeederUtils
|
||||
public class ListFormSeeder_Utils
|
||||
{
|
||||
private readonly IRepository<ListForm, Guid> _listFormRepository;
|
||||
private readonly IRepository<ListFormField, Guid> _listFormFieldRepository;
|
||||
|
||||
public SeederUtils(
|
||||
public ListFormSeeder_Utils(
|
||||
IRepository<ListForm, Guid> listFormRepository,
|
||||
IRepository<ListFormField, Guid> listFormFieldRepository)
|
||||
{
|
||||
88
api/src/Sozsoft.Platform.DbMigrator/Seeds/MenuDataSeeder.cs
Normal file
88
api/src/Sozsoft.Platform.DbMigrator/Seeds/MenuDataSeeder.cs
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Sozsoft.Platform.Entities;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
|
||||
namespace Sozsoft.Platform.Data.Seeds;
|
||||
|
||||
public class RouteSeedDto
|
||||
{
|
||||
public string Key { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string ComponentPath { get; set; }
|
||||
public string RouteType { get; set; }
|
||||
public string[] Authority { get; set; }
|
||||
}
|
||||
|
||||
public class MenuSeederDto
|
||||
{
|
||||
public List<RouteSeedDto> Routes { get; set; }
|
||||
public List<MenuSeedDto> Menus { get; set; }
|
||||
}
|
||||
|
||||
public class MenuDataSeeder : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private readonly IRepository<Route, Guid> _routeRepository;
|
||||
private readonly IRepository<Menu, Guid> _menuRepository;
|
||||
|
||||
public MenuDataSeeder(
|
||||
IRepository<Route, Guid> routeRepository,
|
||||
IRepository<Menu, Guid> menuRepository
|
||||
)
|
||||
{
|
||||
_routeRepository = routeRepository;
|
||||
_menuRepository = menuRepository;
|
||||
}
|
||||
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile(Path.Combine("Seeds", "MenusData.json"))
|
||||
.Build();
|
||||
|
||||
var items = configuration.Get<MenuSeederDto>();
|
||||
|
||||
foreach (var item in items.Routes)
|
||||
{
|
||||
var exists = await _routeRepository.AnyAsync(x => x.Key == item.Key);
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
await _routeRepository.InsertAsync(new Route(
|
||||
item.Key,
|
||||
item.Path,
|
||||
item.ComponentPath,
|
||||
item.RouteType,
|
||||
item.Authority ?? []
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.Menus)
|
||||
{
|
||||
var exists = await _menuRepository.AnyAsync(x => x.Code == item.Code);
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
await _menuRepository.InsertAsync(new Menu
|
||||
{
|
||||
ParentCode = string.IsNullOrWhiteSpace(item.ParentCode) ? null : item.ParentCode,
|
||||
Code = item.Code,
|
||||
DisplayName = item.DisplayName,
|
||||
Order = item.Order,
|
||||
Url = item.Url,
|
||||
Icon = item.Icon,
|
||||
RequiredPermissionName = item.RequiredPermissionName,
|
||||
IsDisabled = item.IsDisabled,
|
||||
ShortName = item.ShortName
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using Volo.Abp.PermissionManagement;
|
||||
using Sozsoft.Platform.Extensions;
|
||||
|
||||
namespace Sozsoft.Platform.Data.Seeds;
|
||||
|
||||
public class PermissionSeederDto
|
||||
{
|
||||
public List<PermissionGroupDefinitionRecordSeedDto> PermissionGroupDefinitionRecords { get; set; }
|
||||
public List<PermissionDefinitionRecordSeedDto> PermissionDefinitionRecords { get; set; }
|
||||
}
|
||||
|
||||
public class PermissionDataSeeder : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private readonly IRepository<PermissionGroupDefinitionRecord, Guid> _permissionGroupRepository;
|
||||
private readonly IRepository<PermissionDefinitionRecord, Guid> _permissionRepository;
|
||||
|
||||
public PermissionDataSeeder(
|
||||
IRepository<PermissionGroupDefinitionRecord, Guid> permissionGroupRepository,
|
||||
IRepository<PermissionDefinitionRecord, Guid> permissionRepository)
|
||||
{
|
||||
_permissionGroupRepository = permissionGroupRepository;
|
||||
_permissionRepository = permissionRepository;
|
||||
}
|
||||
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile(Path.Combine("Seeds", "PermissionsData.json"))
|
||||
.Build();
|
||||
|
||||
var items = configuration.Get<PermissionSeederDto>();
|
||||
|
||||
foreach (var item in items.PermissionGroupDefinitionRecords)
|
||||
{
|
||||
var exists = await _permissionGroupRepository.AnyAsync(x => x.Name == item.Name);
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
await _permissionGroupRepository.InsertAsync(new PermissionGroupDefinitionRecord
|
||||
{
|
||||
Name = item.Name,
|
||||
DisplayName = item.DisplayName
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in items.PermissionDefinitionRecords)
|
||||
{
|
||||
var exists = await _permissionRepository.AnyAsync(x => x.Name == item.Name);
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
var perm = new PermissionDefinitionRecord
|
||||
{
|
||||
GroupName = item.GroupName,
|
||||
Name = item.Name,
|
||||
ParentName = string.IsNullOrWhiteSpace(item.ParentName) ? null : item.ParentName,
|
||||
DisplayName = item.DisplayName,
|
||||
IsEnabled = item.IsEnabled,
|
||||
MultiTenancySide = (MultiTenancySides)item.MultiTenancySide,
|
||||
};
|
||||
|
||||
perm.SetMenuGroup(item.MenuGroup);
|
||||
|
||||
await _permissionRepository.InsertAsync(perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text.Json;
|
||||
using Sozsoft.Languages.Languages;
|
||||
using Sozsoft.Platform.Enums;
|
||||
using Volo.Abp.Reflection;
|
||||
|
|
@ -407,135 +405,6 @@ public static class PlatformConsts
|
|||
}
|
||||
}
|
||||
|
||||
public static class Wizard
|
||||
{
|
||||
public static string WizardKey(string code) => $"{Prefix.App}.Wizard.{code}";
|
||||
public static string WizardKeyTitle(string code) => $"{WizardKey(code)}.Title";
|
||||
public static string WizardKeyDesc(string code) => $"{WizardKey(code)}.Desc";
|
||||
public static string WizardKeyParent(string code) => $"{WizardKey(code)}.Parent";
|
||||
|
||||
public static string PermCreate(string code) => $"{WizardKey(code)}.Create";
|
||||
public static string PermUpdate(string code) => $"{WizardKey(code)}.Update";
|
||||
public static string PermDelete(string code) => $"{WizardKey(code)}.Delete";
|
||||
public static string PermExport(string code) => $"{WizardKey(code)}.Export";
|
||||
public static string PermImport(string code) => $"{WizardKey(code)}.Import";
|
||||
public static string PermNote(string code) => $"{WizardKey(code)}.Note";
|
||||
public static string LangKeyCreate => "Create";
|
||||
public static string LangKeyUpdate => "Update";
|
||||
public static string LangKeyDelete => "Delete";
|
||||
public static string LangKeyExport => "Export";
|
||||
public static string LangKeyImport => "Import";
|
||||
public static string LangKeyNote => "Note";
|
||||
|
||||
public static string MenuUrl(string code) => $"/admin/list/{code}";
|
||||
public static string MenuIcon => "FcList";
|
||||
|
||||
public static readonly string DefaultExportJson = JsonSerializer.Serialize(new
|
||||
{
|
||||
Enabled = true,
|
||||
AllowExportSelectedData = false,
|
||||
PrintingEnabled = true,
|
||||
BackgroundColor = "#FFFFFF",
|
||||
Margin = 10
|
||||
});
|
||||
|
||||
public static string DefaultLayoutJson(string DefaultLayout = "grid") => JsonSerializer.Serialize(new
|
||||
{
|
||||
Grid = true,
|
||||
Pivot = true,
|
||||
Chart = true,
|
||||
Tree = true,
|
||||
Gantt = true,
|
||||
Scheduler = true,
|
||||
DefaultLayout = DefaultLayout,
|
||||
});
|
||||
|
||||
public static readonly string DefaultFilterJson = "\"IsDeleted\" = 'false'";
|
||||
public static readonly string DefaultFilterRowJson = JsonSerializer.Serialize(new { Visible = true });
|
||||
public static readonly string DefaultHeaderFilterJson = JsonSerializer.Serialize(new { Visible = true });
|
||||
public static readonly string DefaultSearchPanelJson = JsonSerializer.Serialize(new { Visible = true });
|
||||
public static readonly string DefaultGroupPanelJson = JsonSerializer.Serialize(new { Visible = true });
|
||||
|
||||
public static readonly string DefaultSelectionSingleJson = JsonSerializer.Serialize(new
|
||||
{
|
||||
Mode = GridOptions.SelectionModeNone,
|
||||
AllowSelectAll = false
|
||||
});
|
||||
|
||||
public static string DefaultColumnOptionJson(bool FocusedRowEnabled = true) => JsonSerializer.Serialize(new
|
||||
{
|
||||
ColumnFixingEnabled = true,
|
||||
ColumnAutoWidth = true,
|
||||
ColumnChooserEnabled = true,
|
||||
AllowColumnResizing = true,
|
||||
AllowColumnReordering = true,
|
||||
ColumnResizingMode = "widget",
|
||||
FocusedRowEnabled = FocusedRowEnabled,
|
||||
});
|
||||
|
||||
public static string DefaultPermissionJson(string permissionName)
|
||||
{
|
||||
return JsonSerializer.Serialize(new
|
||||
{
|
||||
C = permissionName + ".Create",
|
||||
R = permissionName,
|
||||
U = permissionName + ".Update",
|
||||
D = permissionName + ".Delete",
|
||||
E = permissionName + ".Export",
|
||||
I = permissionName + ".Import",
|
||||
N = permissionName + ".Note",
|
||||
});
|
||||
}
|
||||
|
||||
public static string DefaultDeleteCommand(string tableName)
|
||||
{
|
||||
return $"UPDATE \"{TableNameResolver.GetFullTableName(tableName)}\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id";
|
||||
}
|
||||
|
||||
public static string DefaultDeleteFieldsDefaultValueJson(DbType dbType = DbType.Guid)
|
||||
{
|
||||
return JsonSerializer.Serialize(new[]
|
||||
{
|
||||
new { FieldName = "DeleterId", FieldDbType = DbType.Guid, Value = "@USERID", CustomValueType = FieldCustomValueTypeEnum.CustomKey },
|
||||
new { FieldName = "Id", FieldDbType = dbType, Value = "@ID", CustomValueType = FieldCustomValueTypeEnum.CustomKey }
|
||||
});
|
||||
}
|
||||
|
||||
public static readonly string DefaultPagerOptionJson = JsonSerializer.Serialize(new
|
||||
{
|
||||
Visible = true,
|
||||
AllowedPageSizes = "10,20,50,100",
|
||||
ShowPageSizeSelector = true,
|
||||
ShowNavigationButtons = true,
|
||||
ShowInfo = false,
|
||||
InfoText = "Page {0} of {1} ({2} items)",
|
||||
DisplayMode = GridColumnOptions.PagerDisplayModeAdaptive,
|
||||
ScrollingMode = GridColumnOptions.ScrollingModeStandard,
|
||||
LoadPanelEnabled = "auto",
|
||||
LoadPanelText = "Loading..."
|
||||
});
|
||||
|
||||
public static string DefaultEditingOptionJson(
|
||||
string Title,
|
||||
int Width,
|
||||
int Height,
|
||||
bool AllowDeleting,
|
||||
bool AllowAdding,
|
||||
bool AllowEditing,
|
||||
bool ConfirmDelete,
|
||||
bool SendOnlyChangedFormValuesUpdate,
|
||||
bool AllowDetail = false) => JsonSerializer.Serialize(new
|
||||
{
|
||||
Popup = new { Title = Title, Width = Width, Height = Height },
|
||||
AllowDeleting = AllowDeleting,
|
||||
AllowAdding = AllowAdding,
|
||||
AllowEditing = AllowEditing,
|
||||
ConfirmDelete = ConfirmDelete,
|
||||
SendOnlyChangedFormValuesUpdate = SendOnlyChangedFormValuesUpdate,
|
||||
AllowDetail = AllowDetail
|
||||
});
|
||||
}
|
||||
|
||||
public static class AppErrorCodes
|
||||
{
|
||||
public const string NoAuth = "Error:0001";
|
||||
|
|
|
|||
144
api/src/Sozsoft.Platform.Domain.Shared/WizardConsts.cs
Normal file
144
api/src/Sozsoft.Platform.Domain.Shared/WizardConsts.cs
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
using System.Data;
|
||||
using System.Text.Json;
|
||||
using Sozsoft.Platform.Enums;
|
||||
using static Sozsoft.Platform.PlatformConsts;
|
||||
|
||||
public static class WizardConsts
|
||||
{
|
||||
public static string WizardKey(string code) => $"{Prefix.App}.Wizard.{code}";
|
||||
public static string WizardKeyTitle(string code) => $"{WizardKey(code)}.Title";
|
||||
public static string WizardKeyDesc(string code) => $"{WizardKey(code)}.Desc";
|
||||
public static string WizardKeyParent(string code) => $"{WizardKey(code)}.Parent";
|
||||
|
||||
public static string PermCreate(string code) => $"{WizardKey(code)}.Create";
|
||||
public static string PermUpdate(string code) => $"{WizardKey(code)}.Update";
|
||||
public static string PermDelete(string code) => $"{WizardKey(code)}.Delete";
|
||||
public static string PermExport(string code) => $"{WizardKey(code)}.Export";
|
||||
public static string PermImport(string code) => $"{WizardKey(code)}.Import";
|
||||
public static string PermNote(string code) => $"{WizardKey(code)}.Note";
|
||||
public static string LangKeyCreate => "Create";
|
||||
public static string LangKeyUpdate => "Update";
|
||||
public static string LangKeyDelete => "Delete";
|
||||
public static string LangKeyExport => "Export";
|
||||
public static string LangKeyImport => "Import";
|
||||
public static string LangKeyNote => "Note";
|
||||
|
||||
public static string MenuUrl(string code) => $"/admin/list/{code}";
|
||||
public static string MenuIcon => "FcList";
|
||||
|
||||
public static readonly string DefaultExportJson = JsonSerializer.Serialize(new
|
||||
{
|
||||
Enabled = true,
|
||||
AllowExportSelectedData = false,
|
||||
PrintingEnabled = true,
|
||||
BackgroundColor = "#FFFFFF",
|
||||
Margin = 10
|
||||
});
|
||||
|
||||
public static string DefaultLayoutJson(string DefaultLayout = "grid") => JsonSerializer.Serialize(new
|
||||
{
|
||||
Grid = true,
|
||||
Pivot = true,
|
||||
Chart = true,
|
||||
Tree = true,
|
||||
Gantt = true,
|
||||
Scheduler = true,
|
||||
DefaultLayout = DefaultLayout,
|
||||
});
|
||||
|
||||
public static readonly string DefaultFilterJson = "\"IsDeleted\" = 'false'";
|
||||
public static readonly string DefaultFilterRowJson = JsonSerializer.Serialize(new { Visible = true });
|
||||
public static readonly string DefaultHeaderFilterJson = JsonSerializer.Serialize(new { Visible = true });
|
||||
public static readonly string DefaultSearchPanelJson = JsonSerializer.Serialize(new { Visible = true });
|
||||
public static readonly string DefaultGroupPanelJson = JsonSerializer.Serialize(new { Visible = true });
|
||||
|
||||
public static readonly string DefaultSelectionSingleJson = JsonSerializer.Serialize(new
|
||||
{
|
||||
Mode = GridOptions.SelectionModeNone,
|
||||
AllowSelectAll = false
|
||||
});
|
||||
|
||||
public static string DefaultColumnOptionJson(bool FocusedRowEnabled = true) => JsonSerializer.Serialize(new
|
||||
{
|
||||
ColumnFixingEnabled = true,
|
||||
ColumnAutoWidth = true,
|
||||
ColumnChooserEnabled = true,
|
||||
AllowColumnResizing = true,
|
||||
AllowColumnReordering = true,
|
||||
ColumnResizingMode = "widget",
|
||||
FocusedRowEnabled = FocusedRowEnabled,
|
||||
});
|
||||
|
||||
public static string DefaultPermissionJson(string permissionName)
|
||||
{
|
||||
return JsonSerializer.Serialize(new
|
||||
{
|
||||
C = permissionName + ".Create",
|
||||
R = permissionName,
|
||||
U = permissionName + ".Update",
|
||||
D = permissionName + ".Delete",
|
||||
E = permissionName + ".Export",
|
||||
I = permissionName + ".Import",
|
||||
N = permissionName + ".Note",
|
||||
});
|
||||
}
|
||||
|
||||
public static string DefaultDeleteCommand(string tableName)
|
||||
{
|
||||
return $"UPDATE \"{tableName}\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id";
|
||||
}
|
||||
|
||||
public static string DefaultInsertFieldsDefaultValueJson(DbType dbType = DbType.Guid)
|
||||
{
|
||||
return JsonSerializer.Serialize(new[]
|
||||
{
|
||||
new { FieldName = "CreationTime", FieldDbType = DbType.DateTime, Value = "@NOW", CustomValueType = FieldCustomValueTypeEnum.CustomKey },
|
||||
new { FieldName = "CreatorId", FieldDbType = DbType.Guid, Value = "@USERID", CustomValueType = FieldCustomValueTypeEnum.CustomKey },
|
||||
new { FieldName = "IsDeleted", FieldDbType = DbType.Boolean, Value = "false", CustomValueType = FieldCustomValueTypeEnum.Value },
|
||||
new { FieldName = "Id", FieldDbType = dbType, Value = "@NEWID", CustomValueType = FieldCustomValueTypeEnum.CustomKey }
|
||||
});
|
||||
}
|
||||
|
||||
public static string DefaultDeleteFieldsDefaultValueJson(DbType dbType = DbType.Guid)
|
||||
{
|
||||
return JsonSerializer.Serialize(new[]
|
||||
{
|
||||
new { FieldName = "DeleterId", FieldDbType = DbType.Guid, Value = "@USERID", CustomValueType = FieldCustomValueTypeEnum.CustomKey },
|
||||
new { FieldName = "Id", FieldDbType = dbType, Value = "@ID", CustomValueType = FieldCustomValueTypeEnum.CustomKey }
|
||||
});
|
||||
}
|
||||
|
||||
public static readonly string DefaultPagerOptionJson = JsonSerializer.Serialize(new
|
||||
{
|
||||
Visible = true,
|
||||
AllowedPageSizes = "10,20,50,100",
|
||||
ShowPageSizeSelector = true,
|
||||
ShowNavigationButtons = true,
|
||||
ShowInfo = false,
|
||||
InfoText = "Page {0} of {1} ({2} items)",
|
||||
DisplayMode = GridColumnOptions.PagerDisplayModeAdaptive,
|
||||
ScrollingMode = GridColumnOptions.ScrollingModeStandard,
|
||||
LoadPanelEnabled = "auto",
|
||||
LoadPanelText = "Loading..."
|
||||
});
|
||||
|
||||
public static string DefaultEditingOptionJson(
|
||||
string Title,
|
||||
int Width,
|
||||
int Height,
|
||||
bool AllowDeleting,
|
||||
bool AllowAdding,
|
||||
bool AllowEditing,
|
||||
bool ConfirmDelete,
|
||||
bool SendOnlyChangedFormValuesUpdate,
|
||||
bool AllowDetail = false) => JsonSerializer.Serialize(new
|
||||
{
|
||||
Popup = new { Title = Title, Width = Width, Height = Height },
|
||||
AllowDeleting = AllowDeleting,
|
||||
AllowAdding = AllowAdding,
|
||||
AllowEditing = AllowEditing,
|
||||
ConfirmDelete = ConfirmDelete,
|
||||
SendOnlyChangedFormValuesUpdate = SendOnlyChangedFormValuesUpdate,
|
||||
AllowDetail = AllowDetail
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
IF OBJECT_ID(N'[dbo].[Adm_T_Behavior]', 'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE [dbo].[Adm_T_Behavior](
|
||||
[Id] [nvarchar](128) NOT NULL,
|
||||
[TenantId] [uniqueidentifier] NULL,
|
||||
[Name] [nvarchar](128) NOT NULL,
|
||||
[CreationTime] [datetime2](7) NOT NULL,
|
||||
[CreatorId] [uniqueidentifier] NULL,
|
||||
[LastModificationTime] [datetime2](7) NULL,
|
||||
[LastModifierId] [uniqueidentifier] NULL,
|
||||
[IsDeleted] [bit] NOT NULL,
|
||||
[DeleterId] [uniqueidentifier] NULL,
|
||||
[DeletionTime] [datetime2](7) NULL,
|
||||
CONSTRAINT [PK_Adm_T_Behavior] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.default_constraints dc
|
||||
JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
|
||||
WHERE dc.parent_object_id = OBJECT_ID(N'[dbo].[Adm_T_Behavior]')
|
||||
AND c.name = N'IsDeleted'
|
||||
)
|
||||
BEGIN
|
||||
ALTER TABLE [dbo].[Adm_T_Behavior] ADD DEFAULT (CONVERT([bit],(0))) FOR [IsDeleted]
|
||||
END
|
||||
GO
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Sozsoft.Platform.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.EntityFrameworkCore;
|
||||
|
||||
namespace Sozsoft.Platform.Data.Seeds;
|
||||
|
||||
/// <summary>
|
||||
/// Sql tables seeder for creating or updating database tables based on the current entity definitions. This seeder ensures that the database schema is in sync with the application's data model, allowing for smooth migrations and updates without manual intervention.
|
||||
/// </summary>
|
||||
public class SqlTablesSeeder : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private readonly IDbContextProvider<PlatformDbContext> _dbContextProvider;
|
||||
private readonly ILogger<SqlTablesSeeder> _logger;
|
||||
|
||||
public SqlTablesSeeder(
|
||||
IDbContextProvider<PlatformDbContext> dbContextProvider,
|
||||
ILogger<SqlTablesSeeder> logger)
|
||||
{
|
||||
_dbContextProvider = dbContextProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
var assemblyLocation = Path.GetDirectoryName(typeof(SqlTablesSeeder).Assembly.Location)!;
|
||||
var sqlFilePath = Path.Combine(assemblyLocation, "Seeds", "SqlTables.sql");
|
||||
|
||||
if (!File.Exists(sqlFilePath))
|
||||
{
|
||||
_logger.LogWarning("SqlTables.sql file not found at {Path}. Skipping SQL table seeding.", sqlFilePath);
|
||||
return;
|
||||
}
|
||||
|
||||
var sqlContent = await File.ReadAllTextAsync(sqlFilePath);
|
||||
|
||||
// Split by GO statements (SQL Server batch separator)
|
||||
var batches = Regex.Split(sqlContent, @"^\s*GO\s*$", RegexOptions.Multiline | RegexOptions.IgnoreCase);
|
||||
|
||||
var dbContext = await _dbContextProvider.GetDbContextAsync();
|
||||
|
||||
_logger.LogInformation("Starting database script seeding...");
|
||||
|
||||
foreach (var batch in batches)
|
||||
{
|
||||
var sql = batch.Trim();
|
||||
if (string.IsNullOrWhiteSpace(sql))
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
await dbContext.Database.ExecuteSqlRawAsync(sql);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning("SQL batch skipped (may already exist): {Message}", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("Database script seeding completed successfully.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4,20 +4,241 @@ using System.Text.Json;
|
|||
using System.Threading.Tasks;
|
||||
using Sozsoft.Platform.Entities;
|
||||
using Sozsoft.Platform.Forum;
|
||||
using Sozsoft.Platform.Seeds;
|
||||
using Sozsoft.Platform.Public;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Timing;
|
||||
using Volo.Abp;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Sozsoft.Platform.Data.Seeds;
|
||||
|
||||
public class TenantSeederDto
|
||||
{
|
||||
//Saas
|
||||
public List<GlobalSearchSeedDto> GlobalSearch { get; set; }
|
||||
public List<CustomEndpointSeedDto> CustomEndpoints { get; set; }
|
||||
public List<CustomComponentSeedDto> CustomComponents { get; set; }
|
||||
|
||||
//Tanımlamalar
|
||||
public List<SectorSeedDto> Sectors { get; set; }
|
||||
public List<WorkHourSeedDto> WorkHours { get; set; }
|
||||
public List<UomCategorySeedDto> UomCategories { get; set; }
|
||||
public List<UomSeedDto> Uoms { get; set; }
|
||||
public List<SkillTypeSeedDto> SkillTypes { get; set; }
|
||||
public List<SkillSeedDto> Skills { get; set; }
|
||||
public List<SkillLevelSeedDto> SkillLevels { get; set; }
|
||||
|
||||
public List<AboutSeedDto> Abouts { get; set; }
|
||||
public List<ServiceSeedDto> Services { get; set; }
|
||||
public List<PaymentMethodSeedDto> PaymentMethods { get; set; }
|
||||
public List<InstallmentOptionSeedDto> InstallmentOptions { get; set; }
|
||||
public List<BlogCategorySeedDto> BlogCategories { get; set; }
|
||||
public List<BlogPostSeedDto> BlogPosts { get; set; }
|
||||
public List<ProductSeedDto> Products { get; set; }
|
||||
public List<ContactSeedDto> Contacts { get; set; }
|
||||
|
||||
//Report Templates
|
||||
public List<ReportCategorySeedDto> ReportCategories { get; set; }
|
||||
public List<ReportTemplateSeedDto> ReportTemplates { get; set; }
|
||||
|
||||
public List<ForumCategorySeedDto> ForumCategories { get; set; }
|
||||
}
|
||||
|
||||
public class GlobalSearchSeedDto
|
||||
{
|
||||
public string System { get; set; }
|
||||
public string Group { get; set; }
|
||||
public string Term { get; set; }
|
||||
public string Weight { get; set; }
|
||||
public string Url { get; set; }
|
||||
}
|
||||
|
||||
public class SectorSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class UomCategorySeedDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class UomSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Type { get; set; }
|
||||
public decimal Ratio { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public decimal Rounding { get; set; }
|
||||
public string UomCategoryName { get; set; }
|
||||
}
|
||||
|
||||
public class SkillTypeSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class SkillSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string SkillTypeName { get; set; }
|
||||
}
|
||||
|
||||
public class SkillLevelSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Progress { get; set; }
|
||||
public bool IsDefault { get; set; }
|
||||
public string SkillTypeName { get; set; }
|
||||
}
|
||||
|
||||
public class BlogCategorySeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int DisplayOrder { get; set; }
|
||||
public int PostCount { get; set; }
|
||||
}
|
||||
|
||||
public class BlogPostSeedDto
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string ContentTr { get; set; }
|
||||
public string ContentEn { get; set; }
|
||||
public string ReadTime { get; set; }
|
||||
public string Summary { get; set; }
|
||||
public string CoverImage { get; set; }
|
||||
public string CategoryName { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public bool IsPublished { get; set; }
|
||||
public DateTime PublishedAt { get; set; }
|
||||
}
|
||||
|
||||
public class ForumCategorySeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Icon { get; set; }
|
||||
public int DisplayOrder { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
}
|
||||
|
||||
public class CustomEndpointSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string Method { get; set; }
|
||||
public string DataSourceCode { get; set; }
|
||||
public string Sql { get; set; }
|
||||
public List<CustomEndpointParameter> ParametersJson { get; set; }
|
||||
public List<CustomEndpointPermission> PermissionsJson { get; set; }
|
||||
}
|
||||
|
||||
public class PaymentMethodSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public decimal Commission { get; set; }
|
||||
public string Logo { get; set; }
|
||||
}
|
||||
|
||||
public class InstallmentOptionSeedDto
|
||||
{
|
||||
public int Installment { get; set; }
|
||||
public string Name { get; set; }
|
||||
public decimal Commission { get; set; }
|
||||
}
|
||||
|
||||
public class CustomComponentSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Code { get; set; }
|
||||
public string Props { get; set; }
|
||||
public string Description { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public List<string> Dependencies { get; set; } = new();
|
||||
}
|
||||
|
||||
public class ReportTemplateSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string CategoryName { get; set; }
|
||||
public string HtmlContent { get; set; }
|
||||
public string Status { get; set; }
|
||||
}
|
||||
|
||||
public class ReportCategorySeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Icon { get; set; }
|
||||
}
|
||||
|
||||
public class ServiceSeedDto
|
||||
{
|
||||
public string Icon { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string[] Features { get; set; }
|
||||
}
|
||||
|
||||
public class AboutSeedDto
|
||||
{
|
||||
public List<StatDto> Stats { get; set; }
|
||||
public List<string> Descriptions { get; set; }
|
||||
public List<SectionDto> Sections { get; set; }
|
||||
}
|
||||
|
||||
public class WorkHourSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public DateTime StartTime { get; set; }
|
||||
public DateTime EndTime { get; set; }
|
||||
public bool? IsFixed { get; set; }
|
||||
public bool? Monday { get; set; }
|
||||
public bool? Tuesday { get; set; }
|
||||
public bool? Wednesday { get; set; }
|
||||
public bool? Thursday { get; set; }
|
||||
public bool? Friday { get; set; }
|
||||
public bool? Saturday { get; set; }
|
||||
public bool? Sunday { get; set; }
|
||||
}
|
||||
|
||||
public class ContactSeedDto
|
||||
{
|
||||
public string Address { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Location { get; set; }
|
||||
public long TaxNumber { get; set; }
|
||||
public BankDto Bank { get; set; }
|
||||
public WorkHoursDto WorkHour { get; set; }
|
||||
public MapDto Map { get; set; }
|
||||
}
|
||||
|
||||
public class ProductSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Category { get; set; }
|
||||
public int Order { get; set; }
|
||||
public decimal? MonthlyPrice { get; set; }
|
||||
public decimal? YearlyPrice { get; set; }
|
||||
public bool IsQuantityBased { get; set; }
|
||||
public string ImageUrl { get; set; }
|
||||
}
|
||||
|
||||
public class TenantDataSeeder : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private readonly IClock _clock;
|
||||
|
|
@ -104,25 +325,14 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency
|
|||
_organizationUnitManager = organizationUnitManager;
|
||||
}
|
||||
|
||||
private static IConfigurationRoot BuildConfiguration()
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? ""}.json", true);
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
var assemblyLocation = Path.GetDirectoryName(typeof(TenantDataSeeder).Assembly.Location)!;
|
||||
var basePath = Path.Combine(assemblyLocation, "Tenants", "Seeds");
|
||||
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(basePath)
|
||||
.AddJsonFile("TenantData.json", optional: false, reloadOnChange: false)
|
||||
.AddJsonFile($"TenantData.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? ""}.json", optional: true)
|
||||
.SetBasePath(assemblyLocation)
|
||||
.AddJsonFile(Path.Combine("Seeds", "TenantData.json"), optional: false, reloadOnChange: false)
|
||||
.AddJsonFile(Path.Combine("Seeds", $"TenantData.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? ""}.json"), optional: true)
|
||||
.Build();
|
||||
|
||||
var items = configuration.Get<TenantSeederDto>();
|
||||
|
|
@ -8,19 +8,23 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Tenants\Seeds\TenantData.json" />
|
||||
<Content Include="Tenants\Seeds\TenantData.json">
|
||||
<None Remove="Seeds\TenantData.json" />
|
||||
<Content Include="Seeds\TenantData.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Tenants\Seeds\TenantData.Dev.json">
|
||||
<Content Include="Seeds\TenantData.Dev.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Tenants\Seeds\TenantData.Production.json">
|
||||
<Content Include="Seeds\TenantData.Production.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Seeds\SqlTables.sql">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Sozsoft.Platform.EntityFrameworkCore;
|
||||
using Sozsoft.Platform.Enums;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.EntityFrameworkCore;
|
||||
|
||||
namespace Sozsoft.Platform.Data.Seeds;
|
||||
|
||||
/// <summary>
|
||||
/// Database view seeder for creating or updating database views
|
||||
/// </summary>
|
||||
public class DatabaseViewSeeder : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private readonly IDbContextProvider<PlatformDbContext> _dbContextProvider;
|
||||
private readonly ILogger<DatabaseViewSeeder> _logger;
|
||||
|
||||
public DatabaseViewSeeder(
|
||||
IDbContextProvider<PlatformDbContext> dbContextProvider,
|
||||
ILogger<DatabaseViewSeeder> logger)
|
||||
{
|
||||
_dbContextProvider = dbContextProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dbContext = await _dbContextProvider.GetDbContextAsync();
|
||||
|
||||
_logger.LogInformation("Starting database view seeding...");
|
||||
|
||||
_logger.LogInformation("Database view seeding completed successfully.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error occurred while seeding database views.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,229 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sozsoft.Platform.Entities;
|
||||
using Sozsoft.Platform.Public;
|
||||
|
||||
namespace Sozsoft.Platform.Seeds;
|
||||
|
||||
public class TenantSeederDto
|
||||
{
|
||||
//Saas
|
||||
public List<GlobalSearchSeedDto> GlobalSearch { get; set; }
|
||||
public List<CustomEndpointSeedDto> CustomEndpoints { get; set; }
|
||||
public List<CustomComponentSeedDto> CustomComponents { get; set; }
|
||||
|
||||
//Tanımlamalar
|
||||
public List<SectorSeedDto> Sectors { get; set; }
|
||||
public List<WorkHourSeedDto> WorkHours { get; set; }
|
||||
public List<UomCategorySeedDto> UomCategories { get; set; }
|
||||
public List<UomSeedDto> Uoms { get; set; }
|
||||
public List<SkillTypeSeedDto> SkillTypes { get; set; }
|
||||
public List<SkillSeedDto> Skills { get; set; }
|
||||
public List<SkillLevelSeedDto> SkillLevels { get; set; }
|
||||
|
||||
public List<AboutSeedDto> Abouts { get; set; }
|
||||
public List<ServiceSeedDto> Services { get; set; }
|
||||
public List<PaymentMethodSeedDto> PaymentMethods { get; set; }
|
||||
public List<InstallmentOptionSeedDto> InstallmentOptions { get; set; }
|
||||
public List<BlogCategorySeedDto> BlogCategories { get; set; }
|
||||
public List<BlogPostSeedDto> BlogPosts { get; set; }
|
||||
public List<ProductSeedDto> Products { get; set; }
|
||||
public List<ContactSeedDto> Contacts { get; set; }
|
||||
|
||||
//Report Templates
|
||||
public List<ReportCategorySeedDto> ReportCategories { get; set; }
|
||||
public List<ReportTemplateSeedDto> ReportTemplates { get; set; }
|
||||
|
||||
public List<ForumCategorySeedDto> ForumCategories { get; set; }
|
||||
}
|
||||
|
||||
public class GlobalSearchSeedDto
|
||||
{
|
||||
public string System { get; set; }
|
||||
public string Group { get; set; }
|
||||
public string Term { get; set; }
|
||||
public string Weight { get; set; }
|
||||
public string Url { get; set; }
|
||||
}
|
||||
|
||||
public class SectorSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class UomCategorySeedDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class UomSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Type { get; set; }
|
||||
public decimal Ratio { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public decimal Rounding { get; set; }
|
||||
public string UomCategoryName { get; set; }
|
||||
}
|
||||
|
||||
public class SkillTypeSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class SkillSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string SkillTypeName { get; set; }
|
||||
}
|
||||
|
||||
public class SkillLevelSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Progress { get; set; }
|
||||
public bool IsDefault { get; set; }
|
||||
public string SkillTypeName { get; set; }
|
||||
}
|
||||
|
||||
public class BlogCategorySeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int DisplayOrder { get; set; }
|
||||
public int PostCount { get; set; }
|
||||
}
|
||||
|
||||
public class BlogPostSeedDto
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string ContentTr { get; set; }
|
||||
public string ContentEn { get; set; }
|
||||
public string ReadTime { get; set; }
|
||||
public string Summary { get; set; }
|
||||
public string CoverImage { get; set; }
|
||||
public string CategoryName { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public bool IsPublished { get; set; }
|
||||
public DateTime PublishedAt { get; set; }
|
||||
}
|
||||
|
||||
public class ForumCategorySeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Icon { get; set; }
|
||||
public int DisplayOrder { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
}
|
||||
|
||||
public class CustomEndpointSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string Method { get; set; }
|
||||
public string DataSourceCode { get; set; }
|
||||
public string Sql { get; set; }
|
||||
public List<CustomEndpointParameter> ParametersJson { get; set; }
|
||||
public List<CustomEndpointPermission> PermissionsJson { get; set; }
|
||||
}
|
||||
|
||||
public class PaymentMethodSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public decimal Commission { get; set; }
|
||||
public string Logo { get; set; }
|
||||
}
|
||||
|
||||
public class InstallmentOptionSeedDto
|
||||
{
|
||||
public int Installment { get; set; }
|
||||
public string Name { get; set; }
|
||||
public decimal Commission { get; set; }
|
||||
}
|
||||
|
||||
public class CustomComponentSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Code { get; set; }
|
||||
public string Props { get; set; }
|
||||
public string Description { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public List<string> Dependencies { get; set; } = new();
|
||||
}
|
||||
|
||||
public class ReportTemplateSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string CategoryName { get; set; }
|
||||
public string HtmlContent { get; set; }
|
||||
public string Status { get; set; }
|
||||
}
|
||||
|
||||
public class ReportCategorySeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Icon { get; set; }
|
||||
}
|
||||
|
||||
public class ServiceSeedDto
|
||||
{
|
||||
public string Icon { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string[] Features { get; set; }
|
||||
}
|
||||
|
||||
public class AboutSeedDto
|
||||
{
|
||||
public List<StatDto> Stats { get; set; }
|
||||
public List<string> Descriptions { get; set; }
|
||||
public List<SectionDto> Sections { get; set; }
|
||||
}
|
||||
|
||||
public class WorkHourSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public DateTime StartTime { get; set; }
|
||||
public DateTime EndTime { get; set; }
|
||||
public bool? IsFixed { get; set; }
|
||||
public bool? Monday { get; set; }
|
||||
public bool? Tuesday { get; set; }
|
||||
public bool? Wednesday { get; set; }
|
||||
public bool? Thursday { get; set; }
|
||||
public bool? Friday { get; set; }
|
||||
public bool? Saturday { get; set; }
|
||||
public bool? Sunday { get; set; }
|
||||
}
|
||||
|
||||
public class ContactSeedDto
|
||||
{
|
||||
public string Address { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Location { get; set; }
|
||||
public long TaxNumber { get; set; }
|
||||
public BankDto Bank { get; set; }
|
||||
public WorkHoursDto WorkHour { get; set; }
|
||||
public MapDto Map { get; set; }
|
||||
}
|
||||
|
||||
public class ProductSeedDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Category { get; set; }
|
||||
public int Order { get; set; }
|
||||
public decimal? MonthlyPrice { get; set; }
|
||||
public decimal? YearlyPrice { get; set; }
|
||||
public bool IsQuantityBased { get; set; }
|
||||
public string ImageUrl { get; set; }
|
||||
}
|
||||
Loading…
Reference in a new issue