LanguageText değişiklikleri Redis Clear Cache
This commit is contained in:
parent
d0bfbbd811
commit
b085e8bd11
5 changed files with 91 additions and 10 deletions
|
|
@ -1,6 +1,8 @@
|
|||
using Erp.Languages.Entities;
|
||||
using Erp.Languages.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
|
@ -27,10 +29,12 @@ public class LanguageTextAppService : CrudAppService<
|
|||
{
|
||||
private readonly IRepository<LanguageText, Guid> _repositoryText;
|
||||
private readonly IRepository<LanguageKey, Guid> _repositoryKey;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public LanguageTextAppService(
|
||||
IRepository<LanguageText, Guid> repositoryText,
|
||||
IRepository<LanguageKey, Guid> repositoryKey
|
||||
IRepository<LanguageKey, Guid> repositoryKey,
|
||||
IConfiguration configuration
|
||||
)
|
||||
: base(repositoryText)
|
||||
{
|
||||
|
|
@ -38,6 +42,7 @@ public class LanguageTextAppService : CrudAppService<
|
|||
ObjectMapperContext = typeof(LanguagesApplicationModule);
|
||||
_repositoryText = repositoryText;
|
||||
_repositoryKey = repositoryKey;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public override async Task<LanguageTextDto> CreateAsync(LanguageTextCreateUpdateDto input)
|
||||
|
|
@ -124,6 +129,13 @@ public class LanguageTextAppService : CrudAppService<
|
|||
|
||||
return ObjectMapper.Map<List<LanguageText>, List<LanguageTextDto>>(item);
|
||||
}
|
||||
|
||||
public async Task ClearRedisCacheAsync()
|
||||
{
|
||||
var redis = ConnectionMultiplexer.Connect(_configuration["Redis:Configuration"]!);
|
||||
var db = redis.GetDatabase();
|
||||
await db.ExecuteAsync("FLUSHALL");
|
||||
}
|
||||
|
||||
protected virtual IQueryable<LanguageKey> ApplySorting(IQueryable<LanguageKey> query, LanguageTextTranslatedRequestDto input)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3007,6 +3007,12 @@
|
|||
"en": "Background Workers are being renewed.",
|
||||
"tr": "Arka Plan Çalışanları yenileniyor."
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "App.ClearRedisCache.Message",
|
||||
"en": "Redis cache is being cleared.",
|
||||
"tr": "Redis önbelleği temizleniyor."
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "LoginEndDate",
|
||||
|
|
|
|||
|
|
@ -1841,16 +1841,25 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency
|
|||
PagerOptionJson = DefaultPagerOptionJson,
|
||||
EditingOptionJson = DefaultEditingOptionJson(listFormName, 600, 400, true, true, true, true, false),
|
||||
EditingFormJson = JsonSerializer.Serialize(new List<EditingFormDto>() {
|
||||
new() { Order=1, ColCount=1, ColSpan=1, ItemType="group", Items=
|
||||
[
|
||||
new EditingFormItemDto { Order = 1, DataField = "CultureName", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
|
||||
new EditingFormItemDto { Order = 2, DataField = "ResourceName", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
|
||||
new EditingFormItemDto { Order = 3, DataField = "Key", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxAutocomplete, EditorOptions=EditorOptionValues.ShowClearButton },
|
||||
new EditingFormItemDto { Order = 4, DataField = "Value", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox },
|
||||
]
|
||||
}
|
||||
}),
|
||||
new() { Order=1, ColCount=1, ColSpan=1, ItemType="group", Items=
|
||||
[
|
||||
new EditingFormItemDto { Order = 1, DataField = "CultureName", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
|
||||
new EditingFormItemDto { Order = 2, DataField = "ResourceName", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
|
||||
new EditingFormItemDto { Order = 3, DataField = "Key", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxAutocomplete, EditorOptions=EditorOptionValues.ShowClearButton },
|
||||
new EditingFormItemDto { Order = 4, DataField = "Value", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox },
|
||||
]
|
||||
}}),
|
||||
InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson(),
|
||||
CommandColumnJson = JsonSerializer.Serialize(new CommandColumnDto[] {
|
||||
new() {
|
||||
ButtonPosition= UiCommandButtonPositionTypeEnum.Toolbar,
|
||||
Hint = "Clear Redis Cache",
|
||||
Text = "Clear Redis Cache",
|
||||
AuthName = listFormName,
|
||||
OnClick = "UiEvalService.ApiClearRedisCache();",
|
||||
IsVisible = true,
|
||||
},
|
||||
}),
|
||||
}, autoSave: true
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { Notification, toast } from '@/components/ui'
|
|||
import { generateBackgroundWorkers } from '@/services/background-worker.service'
|
||||
import { getLocalization } from '@/services/localization.service'
|
||||
import { store } from '@/store'
|
||||
import { clearRedisCache } from './languageText.service'
|
||||
|
||||
export abstract class UiEvalService {
|
||||
static Init = () => {
|
||||
|
|
@ -45,6 +46,44 @@ export abstract class UiEvalService {
|
|||
},
|
||||
)
|
||||
}
|
||||
|
||||
static ApiClearRedisCache = () => {
|
||||
// Get store state directly instead of using hook
|
||||
const state = store.getState()
|
||||
const { texts, config } = state.abpConfig
|
||||
|
||||
// Create translate function similar to useLocalization hook
|
||||
const translate = (
|
||||
localizationKey: string,
|
||||
params?: Record<string, string | number>,
|
||||
defaultResourceName?: string,
|
||||
): string => {
|
||||
if (!texts) {
|
||||
return localizationKey
|
||||
}
|
||||
return getLocalization(
|
||||
texts,
|
||||
defaultResourceName ?? config?.localization?.defaultResourceName,
|
||||
localizationKey,
|
||||
params,
|
||||
)
|
||||
}
|
||||
|
||||
const asyncCall = async () => {
|
||||
await clearRedisCache()
|
||||
}
|
||||
|
||||
asyncCall()
|
||||
|
||||
toast.push(
|
||||
<Notification type="success" duration={2000}>
|
||||
{translate('::App.ClearRedisCache.Message')}
|
||||
</Notification>,
|
||||
{
|
||||
placement: 'top-end',
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const _global = (window || global) as any
|
||||
|
|
|
|||
15
ui/src/services/languageText.service.ts
Normal file
15
ui/src/services/languageText.service.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { AxiosError } from 'axios'
|
||||
import apiService from './api.service'
|
||||
|
||||
export const clearRedisCache = async () => {
|
||||
try {
|
||||
return await apiService.fetchData<void, Record<string, string>>({
|
||||
method: 'POST',
|
||||
url: '/api/app/language-text/clear-redis-cache',
|
||||
})
|
||||
} catch (error) {
|
||||
if (error instanceof AxiosError) {
|
||||
return error.response?.data
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue