src/ZKEACMS/Layout/LayoutService.cs

(开头部分) 9KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Easy.Extend;
using Easy.RepositoryPattern;
using ZKEACMS.DataArchived;
using ZKEACMS.Page;
using ZKEACMS.Widget;
using ZKEACMS.Zone;
using Easy;
using ZKEACMS.Layout;
using Microsoft.EntityFrameworkCore;
using System.Collections.Concurrent;
using Easy.Cache;

namespace ZKEACMS.Layout
{
    public class LayoutService : ServiceBase<LayoutEntity, CMSDbContext>, ILayoutService
    {
        private readonly IZoneService _zoneService;
        private readonly ILayoutHtmlService _layoutHtmlService;
        private readonly IWidgetActivator _widgetActivator;
        private readonly IWidgetBasePartService _widgetService;
        private readonly ConcurrentDictionary<string, object> _cache;
        private const string LayoutCacheKey = "LayoutCacheKey";
        public LayoutService(IDataArchivedService dataArchivedService,
            IZoneService zoneService,
            IWidgetBasePartService widgetService,
            IApplicationContext applicationContext,
            ILayoutHtmlService layoutHtmlService,
            IWidgetActivator widgetActivator,
            ICacheManager<ConcurrentDictionary<string, object>> cacheManager,
            CMSDbContext dbContext)
            : base(applicationContext, dbContext)
        {
            _zoneService = zoneService;
            _widgetService = widgetService;
            _layoutHtmlService = layoutHtmlService;
            _widgetActivator = widgetActivator;
            _cache = cacheManager.GetOrAdd("LayoutCacheKey", key => new ConcurrentDictionary<string, object>());
        }

        public override DbSet<LayoutEntity> CurrentDbSet => DbContext.Layout;

        public override IQueryable<LayoutEntity> Get()
        {
            return CurrentDbSet.AsNoTracking();
        }
        public override ServiceResult<LayoutEntity> Add(LayoutEntity item)
        {
            item.ID = Guid.NewGuid().ToString("N");
            var result = base.Add(item);
            if (result.HasViolation)
            {
                return result;
后面还有 198 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。