コード例 #1
0
ファイル: UsageBackend.cs プロジェクト: kieran23101/2sxc
        public IEnumerable <ViewDto> ViewUsage(IInstanceContext context, int appId, Guid guid,
                                               Func <List <IView>, List <BlockConfiguration>, IEnumerable <ViewDto> > finalBuilder)
        {
            var wrapLog = Log.Call <IEnumerable <ViewDto> >($"{appId}, {guid}");

            // extra security to only allow zone change if host user
            var permCheck = new MultiPermissionsApp().Init(context, GetApp(appId, null), Log);

            if (!permCheck.EnsureAll(GrantSets.ReadSomething, out var error))
            {
                throw HttpException.PermissionDenied(error);
            }

            var cms = new CmsRuntime(appId, Log, true);
            // treat view as a list - in case future code will want to analyze many views together
            var views = new List <IView> {
                cms.Views.Get(guid)
            };

            var blocks = cms.Blocks.AllWithView();

            Log.Add($"Found {blocks.Count} content blocks");

            var result = finalBuilder(views, blocks);

            return(wrapLog("ok", result));
        }
コード例 #2
0
        public dynamic Usage(int appId, Guid guid)
        {
            var wrapLog = Log.Call <dynamic>($"{appId}, {guid}");

            // extra security to only allow zone change if host user
            var permCheck = new MultiPermissionsApp(BlockBuilder, appId, Log);

            if (!permCheck.EnsureAll(GrantSets.ReadSomething, out var exception))
            {
                throw exception;
            }

            var cms = new CmsRuntime(appId, Log, true);
            // treat view as a list - in case future code will want to analyze many views together
            var views = new List <IView> {
                cms.Views.Get(guid)
            };

            var blocks = cms.Blocks.AllWithView();

            Log.Add($"Found {blocks.Count} content blocks");

            // create array with all 2sxc modules in this portal
            var allMods = new Pages(Log).AllModulesWithContent(PortalSettings.PortalId);

            Log.Add($"Found {allMods.Count} modules");

            var result = views.Select(vwb => new ViewDto(vwb, blocks, allMods));

            return(wrapLog("ok", result));
        }
コード例 #3
0
        public Guid?SaveTemplateId(int templateId, bool forceCreateContentGroup)
        {
            var permCheck = new MultiPermissionsApp(BlockBuilder, App.AppId, Log);

            if (!permCheck.EnsureAll(GrantSets.WriteSomething, out var exp))
            {
                throw exp;
            }

            return(BlockEditor.SaveTemplateId(templateId, forceCreateContentGroup));
        }
コード例 #4
0
        public Guid?SaveTemplateId(int templateId, bool forceCreateContentGroup)
        {
            var permCheck = new MultiPermissionsApp().Init(_context, _block.App, Log);

            if (!permCheck.EnsureAll(GrantSets.WriteSomething, out var error))
            {
                throw HttpException.PermissionDenied(error);
            }

            return(BlockEditorBase.GetEditor(_block).SaveTemplateId(templateId, forceCreateContentGroup));
        }
コード例 #5
0
        public Guid?SaveTemplateId(int templateId, bool forceCreateContentGroup)
        {
            var permCheck = new MultiPermissionsApp(SxcInstance, App.AppId, Log);

            if (!permCheck.EnsureAll(GrantSets.WriteSomething, out var exp))
            {
                throw exp;
            }

            return(ContentGroupReferenceManager.SaveTemplateId(templateId, forceCreateContentGroup));
        }
コード例 #6
0
ファイル: EntityBackend.cs プロジェクト: kieran23101/2sxc
        public dynamic Usage(IInstanceContext context, IApp app, Guid guid)
        {
            var permCheck = new MultiPermissionsApp().Init(context, app, Log);

            if (!permCheck.EnsureAll(GrantSets.ReadSomething, out var error))
            {
                throw HttpException.PermissionDenied(error);
            }

            var appData       = permCheck.App.Data;
            var item          = appData.List.One(guid);
            var relationships = item.Relationships.AllRelationships;

            // var result = relationships.Select(r => new EntityInRelationDto(r.))
            // todo: don't forget Metadata relationships
            return(null);
        }
コード例 #7
0
        public dynamic Usage(int appId, Guid guid)
        {
            var permCheck = new MultiPermissionsApp(BlockBuilder, appId, Log);

            if (!permCheck.EnsureAll(GrantSets.ReadSomething, out var exception))
            {
                throw exception;
            }

            var appData       = permCheck.App.Data;
            var item          = appData.List.One(guid);
            var relationships = item.Relationships.AllRelationships;

            // var result = relationships.Select(r => new EntityInRelationDto(r.))
            // todo: don't forget Metadata relationships
            return(null);
        }