Browse Source

Used `LastModificationTime` instead of GUID

pull/13657/head
malik masis 4 years ago
parent
commit
24696bb4c0
  1. 9
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/GlobalResources/GlobalResourceDto.cs
  2. 7
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/GlobalResources/Handlers/GlobalResourceEventHandler.cs
  3. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/GlobalResources/Style/Default.cshtml
  4. 6
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/GlobalResources/Style/GlobalStyleModel.cs
  5. 24
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/GlobalResources/Style/GlobalStyleViewComponent.cs

9
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/GlobalResources/GlobalResourceDto.cs

@ -1,8 +1,13 @@
namespace Volo.CmsKit.Public.GlobalResources; using System;
namespace Volo.CmsKit.Public.GlobalResources;
[Serializable]
public class GlobalResourceDto public class GlobalResourceDto
{ {
public string Name { get; set; } public string Name { get; set; }
public string Value { get; set; } public string Value { get; set; }
public DateTime? LastModificationTime { get; set; }
} }

7
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/GlobalResources/Handlers/GlobalResourceEventHandler.cs

@ -5,11 +5,10 @@ using Volo.Abp.Domain.Entities.Events;
using Volo.Abp.EventBus; using Volo.Abp.EventBus;
using Volo.Abp.ObjectMapping; using Volo.Abp.ObjectMapping;
using Volo.CmsKit.GlobalResources; using Volo.CmsKit.GlobalResources;
using Volo.CmsKit.Public.GlobalResources;
namespace Volo.CmsKit.Public.GlobalResources.Handlers; namespace Volo.CmsKit.Public.GlobalResources.Handlers;
public class GlobalResourceEventHandler: public class GlobalResourceEventHandler :
ILocalEventHandler<EntityUpdatedEventData<GlobalResource>>, ILocalEventHandler<EntityUpdatedEventData<GlobalResource>>,
ITransientDependency ITransientDependency
{ {
@ -23,11 +22,11 @@ public class GlobalResourceEventHandler:
ObjectMapper = objectMapper; ObjectMapper = objectMapper;
_resourceCache = resourceCache; _resourceCache = resourceCache;
} }
public async Task HandleEventAsync(EntityUpdatedEventData<GlobalResource> eventData) public async Task HandleEventAsync(EntityUpdatedEventData<GlobalResource> eventData)
{ {
await _resourceCache.SetAsync( await _resourceCache.SetAsync(
eventData.Entity.Name, eventData.Entity.Name,
ObjectMapper.Map<GlobalResource, GlobalResourceDto>(eventData.Entity)); ObjectMapper.Map<GlobalResource, GlobalResourceDto>(eventData.Entity));
} }
} }

4
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/GlobalResources/Style/Default.cshtml

@ -1 +1,3 @@
<link rel="stylesheet" href="@("/cms-kit/global-resources/style?v=" + Guid.NewGuid())"/> @model Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.GlobalResources.Style.GlobalStyleModel
<link rel="stylesheet" href="@("/cms-kit/global-resources/style?v=" + Model.LastModificationTimeTimestamp)"/>

6
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/GlobalResources/Style/GlobalStyleModel.cs

@ -0,0 +1,6 @@
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.GlobalResources.Style;
public class GlobalStyleModel
{
public long LastModificationTimeTimestamp { get; set; }
}

24
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/GlobalResources/Style/GlobalStyleViewComponent.cs

@ -1,13 +1,33 @@
using System.Threading.Tasks; using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
using Volo.CmsKit.Public.GlobalResources;
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.GlobalResources.Style; namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.GlobalResources.Style;
public class GlobalStyleViewComponent : AbpViewComponent public class GlobalStyleViewComponent : AbpViewComponent
{ {
protected IGlobalResourcePublicAppService GlobalResourcePublicAppService { get; }
public GlobalStyleViewComponent(IGlobalResourcePublicAppService globalResourcePublicAppService)
{
GlobalResourcePublicAppService = globalResourcePublicAppService;
}
[BindProperty(SupportsGet = true)]
public DateTime? LastModificationTime { get; set; }
public async Task<IViewComponentResult> InvokeAsync() public async Task<IViewComponentResult> InvokeAsync()
{ {
return View("~/Pages/CmsKit/Shared/Components/GlobalResources/Style/Default.cshtml"); var lastModificationTime = (await GlobalResourcePublicAppService.GetGlobalStyleAsync())?.LastModificationTime;
var lastModificationTimeTimestamp = (long)(lastModificationTime.HasValue ? lastModificationTime.Value .Subtract(DateTime.UnixEpoch).TotalSeconds: 0);
return View("~/Pages/CmsKit/Shared/Components/GlobalResources/Style/Default.cshtml",
new GlobalStyleModel()
{
LastModificationTimeTimestamp = lastModificationTimeTimestamp
});
} }
} }
Loading…
Cancel
Save