33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using System.Threading.Tasks;
|
|
using Volo.Abp.Domain.Services;
|
|
using Volo.Abp.TextTemplating;
|
|
using Volo.Abp.TextTemplating.Razor;
|
|
|
|
namespace Sozsoft.Platform.BackgroundWorkers;
|
|
|
|
public class PlatformTemplateManager : DomainService
|
|
{
|
|
private readonly ITemplateDefinitionManager templateDefinitionManager;
|
|
|
|
public PlatformTemplateManager(ITemplateDefinitionManager templateDefinitionManager)
|
|
{
|
|
this.templateDefinitionManager = templateDefinitionManager;
|
|
}
|
|
|
|
public async Task AddOrUpdateTemplateAsync(string name, string template)
|
|
{
|
|
var templateDefinition = await templateDefinitionManager.GetOrNullAsync(name);
|
|
if (templateDefinition == null)
|
|
{
|
|
templateDefinition = new TemplateDefinition(name)
|
|
.WithRazorEngine()
|
|
.WithProperty(PropertyTemplateContentContributor.PropertyContentPropertyName, template);
|
|
PlatformTemplateDynamicStore.TemplateDefinitions.Add(name, templateDefinition);
|
|
}
|
|
else
|
|
{
|
|
templateDefinition.WithProperty(PropertyTemplateContentContributor.PropertyContentPropertyName, template);
|
|
}
|
|
}
|
|
}
|
|
|