示例#1
0
        private EraseContentContext MakeErasureContextFromType(string typeName)
        {
            var ci  = _contentManager.New(typeName);
            var ctx = new EraseContentContext(ci);

            _transactionManager.RequireNew();
            return(ctx);
        }
示例#2
0
        private void Erase(EraseContentContext context)
        {
            Process(context, (ctx, action) => {
                // Invoke Erasing handlers before erasure
                GDPRHandlers.Invoke(handler => handler.Erasing(ctx), Logger);

                action(ctx);
                // Do any erasure operation on the ContentItem object itself

                // Invoke Erased handlers after we are done.
                GDPRHandlers.Invoke(handler => handler.Erased(ctx), Logger);

                // we will handle the DeleteItemsAfterErasure setting here rather than in a handler
                // because we want to make sure it is the last thing. If we put that in a handler,
                // it may execute "out of order" for something else.
                if (context.GDPRPart // if this were null, we wouldn't even be here
                    ?.TypePartDefinition.Settings.GetModel <GDPRPartTypeSettings>()
                    ?.DeleteItemsAfterErasure == true)
                {
                    // Delete the item
                    _contentManager.Remove(context.ContentItem);
                }
            });
        }