コード例 #1
0
ファイル: SxcPagePublishing.cs プロジェクト: valadas/2sxc
        internal Dictionary <Guid, int> SaveInPagePublishing(
            IBlock blockOrNull,
            int appId,
            List <BundleWithHeader <IEntity> > items,
            bool partOfPage,
            Func <bool, Dictionary <Guid, int> > internalSaveMethod,
            IMultiPermissionCheck permCheck
            )
        {
            var allowWriteLive = permCheck.UserMayOnAll(GrantSets.WritePublished);
            var forceDraft     = !allowWriteLive;

            Log.Add($"allowWrite: {allowWriteLive} forceDraft: {forceDraft}");

            // list of saved IDs
            Dictionary <Guid, int> postSaveIds = null;

            // The internal call which will be used further down
            var appIdentity = State.Identity(null, appId);
            var groupList   = _contentGroupList.Init(appIdentity, Log, Context.UserMayEdit);

            Dictionary <Guid, int> SaveAndSaveGroupsInnerCall(Func <bool, Dictionary <Guid, int> > call,
                                                              bool forceSaveAsDraft)
            {
                var ids = call.Invoke(forceSaveAsDraft);

                // now assign all content-groups as needed
                groupList.IfChangesAffectListUpdateIt(blockOrNull, items, ids);
                return(ids);
            }

            // use dnn versioning if partOfPage
            if (partOfPage)
            {
                Log.Add("partOfPage - save with publishing");
                var versioning = _pagePublishing.Init(Log);
                versioning.DoInsidePublishing(Context,
                                              args => postSaveIds = SaveAndSaveGroupsInnerCall(internalSaveMethod, forceDraft));
            }
            else
            {
                Log.Add("partOfPage false, save without publishing");
                postSaveIds = SaveAndSaveGroupsInnerCall(internalSaveMethod, forceDraft);
            }

            Log.Add(() => $"post save IDs: {string.Join(",", postSaveIds.Select(psi => psi.Key + "(" + psi.Value + ")"))}");
            return(postSaveIds);
        }
コード例 #2
0
        internal Dictionary <Guid, int> SaveInPagePublishing(
            int appId,
            List <BundleWithHeader <IEntity> > items,
            bool partOfPage,
            Func <bool, Dictionary <Guid, int> > internalSaveMethod,
            IMultiPermissionCheck permCheck
            )
        {
            var allowWriteLive = permCheck.UserMayOnAll(GrantSets.WritePublished);
            var forceDraft     = !allowWriteLive;

            Log.Add($"allowWrite: {allowWriteLive} forceDraft: {forceDraft}");

            // list of saved IDs
            Dictionary <Guid, int> postSaveIds = null;

            // The internal call which will be used further down
            Dictionary <Guid, int> SaveAndSaveGroupsInnerCall(Func <bool, Dictionary <Guid, int> > call,
                                                              bool forceSaveAsDraft)
            {
                var ids = call.Invoke(forceSaveAsDraft);

                // now assign all content-groups as needed
                new ContentGroupList(Block, Log).IfChangesAffectListUpdateIt(appId, items, ids);
                return(ids);
            }

            // use dnn versioning if partOfPage
            if (partOfPage)
            {
                Log.Add("partOfPage - save with publishing");
                var versioning = Eav.Factory.Resolve <IPagePublishing>().Init(Log);
                //var dnnContext = new DnnDynamicCode().Init(Block, Log);
                //var instanceId = Block.Context.Container.Id;
                //var userId = Block.Context.User.Guid;
                versioning.DoInsidePublishing(Block.Context,
                                              args => postSaveIds = SaveAndSaveGroupsInnerCall(internalSaveMethod, forceDraft));
            }
            else
            {
                Log.Add("partOfPage false, save without publishing");
                postSaveIds = SaveAndSaveGroupsInnerCall(internalSaveMethod, forceDraft);
            }

            Log.Add(() => $"post save IDs: {string.Join(",", postSaveIds.Select(psi => psi.Key + "(" + psi.Value + ")"))}");
            return(postSaveIds);
        }
コード例 #3
0
ファイル: DnnPublishing.cs プロジェクト: webworkadmin/2sxc
        internal Dictionary <Guid, int> SaveWithinDnnPagePublishing <T>(
            int appId,
            List <BundleWithHeader <T> > items,
            bool partOfPage,
            Func <bool, Dictionary <Guid, int> > internalSaveMethod,
            IMultiPermissionCheck permCheck
            )
        {
            var allowWriteLive = permCheck.UserMayOnAll(GrantSets.WritePublished);
            var forceDraft     = !allowWriteLive;

            Log.Add($"allowWrite: {allowWriteLive} forceDraft: {forceDraft}");

            // list of saved IDs
            Dictionary <Guid, int> postSaveIds = null;

            // The internal call which will be used further down
            Dictionary <Guid, int> SaveAndSaveGroups(Func <bool, Dictionary <Guid, int> > call, bool forceSaveAsDraft)
            {
                var ids = call.Invoke(forceSaveAsDraft);

                // now assign all content-groups as needed
                new ContentGroupList(SxcInstance, Log)
                .IfInListUpdateList(appId, items, ids);
                return(ids);
            }

            // use dnn versioning if partOfPage
            if (partOfPage)
            {
                Log.Add("partOfPage - save with publishing");
                var versioning = Factory.Resolve <IEnvironmentFactory>().PagePublisher(Log);
                var context    = SxcApiControllerBase.GetContext(SxcInstance, Log);
                versioning.DoInsidePublishing(context.Dnn.Module.ModuleID, context.Dnn.User.UserID,
                                              args => postSaveIds = SaveAndSaveGroups(internalSaveMethod, forceDraft));
            }
            else
            {
                Log.Add("partOfPage false, save without publishing");
                postSaveIds = SaveAndSaveGroups(internalSaveMethod, forceDraft);
            }

            Log.Add(() => $"post save IDs: {string.Join(",", postSaveIds.Select(psi => psi.Key + "(" + psi.Value + ")"))}");
            return(postSaveIds);
        }