Try our conversational search powered by Generative AI!

Content Type Synchronization

tss
tss
Vote:
 

Hi

We have been trying out working against a single EPiServer database in development, and it works fine in most instances.

But there is one major problem

Content Type Synchronization 

the problem is that new Content Types are deleted by the syncronization when sombody doesn't have the new content type and starts the site.

Example one

  • Developer 1: created a new Page Type and starts EPiServer to create an instance of the new Page, he starts creating the new page and is writing content in the Create dialog
  • Developer 2: starts his EPiServer site, The syncronization kicks in and delets the new Content Type.
  • Developer 1: klicks the Create button and BOOM he sees an SQL Exception from the database telling that EPiServer couldn't find the new Page Type.

Would it be possible to add an option to the Content Type Syncronization that disables the delete part of the syncronization?

#121628
May 15, 2015 14:27
Vote:
 

Haven't verified it. But worth a try I guess:

public class CustomContentTypeModelScanner : ContentTypeModelScanner
    {
        public CustomContentTypeModelScanner(
            ITypeScannerLookup typeScannerLookup,
            ContentTypeModelRegister typeModelRegister,
            ContentModelValidator modelValidator,
            ContentTypeModelRepository contentTypeModelRepository,
            IContentTypeModelAssigner contentTypeModelAssigner,
            ContentDataInterceptorHandler modelTypeInterceptorHandler,
            ContentDataInterceptor modelTypeInterceptor,
            TemplateModelRepository templateModelRepository,
            IContentTypeModelFilter[] filters,
            IEnumerable<ContentScannerExtension> registerExtensions,
            IAvailableModelSettingsRepository availableContentTypeService)
            : base(
                typeScannerLookup,
                typeModelRegister,
                modelValidator,
                contentTypeModelRepository,
                contentTypeModelAssigner,
                modelTypeInterceptorHandler,
                modelTypeInterceptor,
                templateModelRepository,
                filters,
                registerExtensions,
                availableContentTypeService)
        {
        }

        protected override bool DeleteUnusedContentTypes
        {
            get
            {
                return false;
            }
        }
    }

    [InitializableModule]
    [ModuleDependency(typeof(InitializationModule))]
    public class SwapContentTypeModelScannerModule : IConfigurableModule
    {
        public void Initialize(InitializationEngine context)
        {
        }

        public void Uninitialize(InitializationEngine context)
        {
        }

        public void ConfigureContainer(ServiceConfigurationContext context)
        {
            context.Container.Configure(ctx => ctx.For<IContentTypeModelScanner>().Use<CustomContentTypeModelScanner>());
            context.Container.Configure(ctx => ctx.For<ContentTypeModelScanner>().Use<CustomContentTypeModelScanner>());
        }
    }
#121638
May 16, 2015 22:48
tss
Vote:
 

Thanks! 

Didn't think of that, I will test it out and just wrap the configuration so that it only registers if there is a app settting telling it to do so :-)

#121804
May 18, 2015 8:26
tss
Vote:
 

The above code works perfectly!

We just wrapped the Configure with a check against App Settings so that we cna disable the behavior when needed.

Thanks for the help.

PS: for some reason I can't mark your post as an Answer..

#121875
May 19, 2015 11:22
Vote:
 

I'm not into collecting answered questions. That's fine with me :)

#121881
May 19, 2015 12:35
Vote:
 

Noble of you Valdis, but for the sake of the quality of the forum, I'm marking it anyway :-)

#143770
Jan 30, 2016 0:25
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.