src/ZKEACMS.Article/Service/ArticleTypeWidgetService.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using System;
using Easy;
using Easy.Extend;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using ZKEACMS.Article.Models;
using ZKEACMS.Article.ViewModel;
using ZKEACMS.Widget;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Collections.Concurrent;
using Easy.Cache;
namespace ZKEACMS.Article.Service
{
public class ArticleTypeWidgetService : WidgetService<ArticleTypeWidget>
{
private const string ArticleTypeWidgetRelatedPageUrls = "ArticleTypeWidgetRelatedPageUrls";
private readonly ConcurrentDictionary<string, object> _allRelatedUrlCache;
private readonly IArticleTypeService _articleTypeService;
public ArticleTypeWidgetService(IWidgetBasePartService widgetService,
IArticleTypeService articleTypeService,
IApplicationContext applicationContext,
ICacheManager<ConcurrentDictionary<string, object>> cacheManager,
CMSDbContext dbContext)
: base(widgetService, applicationContext, dbContext)
{
_articleTypeService = articleTypeService;
_allRelatedUrlCache = cacheManager.GetOrAdd(ArticleTypeWidgetRelatedPageUrls, new ConcurrentDictionary<string, object>());
}
private void DismissRelatedPageUrls()
{
_allRelatedUrlCache.TryRemove(ArticleTypeWidgetRelatedPageUrls, out var urls);
}
public override void AddWidget(WidgetBase widget)
{
base.AddWidget(widget);
DismissRelatedPageUrls();
}
public override void DeleteWidget(string widgetId)
{
base.DeleteWidget(widgetId);
DismissRelatedPageUrls();
}
public override object Display(WidgetDisplayContext widgetDisplayContext)
{
ArticleTypeWidget currentWidget = widgetDisplayContext.Widget as ArticleTypeWidget;
var types = _articleTypeService.Get(m => m.ParentID == currentWidget.ArticleTypeID);
var actionContext = widgetDisplayContext.ActionContext;
int ac = actionContext.RouteData.GetCategory();
ArticleType articleType = null;
if (ac > 0)
{
articleType = _articleTypeService.Get(ac);
后面还有 33 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。