示例#1
0
        public void UnInstallStore(string storeAliasWithoutSpaces)
        {
            var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
            var contentTypeList    = new List <IContentType>();

            // add disable true/false propertytypes to the document types that require them
            foreach (var documentTypeAlias in StoreHelper.StoreDependantDocumentTypeAliasList)
            {
                var contentType = contentTypeService.GetContentType(documentTypeAlias);
                if (contentType == null)
                {
                    continue;
                }
                contentTypeList.Add(contentType);

                var disableAlias  = string.Format("disable_{0}", storeAliasWithoutSpaces);
                var templateAlias = string.Format("template_{0}", storeAliasWithoutSpaces);

                CMSInstaller.GetOrAddPropertyGroup(contentType, storeAliasWithoutSpaces).PropertyTypes.RemoveAll(p => p.Alias == disableAlias || p.Alias == templateAlias);

                if (!contentType.PropertyGroups[storeAliasWithoutSpaces].PropertyTypes.Any())
                {
                    contentType.PropertyGroups.Remove(storeAliasWithoutSpaces);
                }
            }

            contentTypeService.Save(contentTypeList);

            library.RefreshContent();
        }
示例#2
0
        public void InstallStore(string storeAliasWithoutSpaces)
        {
            var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
            var dataTypeService    = ApplicationContext.Current.Services.DataTypeService;
            var contentTypeList    = new List <IContentType>();

            var trueFalseDataTypeDef           = dataTypeService.GetDataTypeDefinitionById(new Guid("92897bc6-a5f3-4ffe-ae27-f2e7e33dda49"));
            var storeTemplatePickerDataTypeDef = dataTypeService.GetDataTypeDefinitionById(new Guid("a20c7c00-09f1-448d-9656-f5cb012107af")) ?? dataTypeService.GetDataTypeDefinitionById(new Guid("2ad05995-470e-47d9-956d-dd2ec892343d"));

            if (storeTemplatePickerDataTypeDef == null)
            {
                throw new Exception("Could not find storeTemplatePickerDataType");
            }

            // add disable true/false propertytypes to the document types that require them
            foreach (var documentTypeAlias in StoreHelper.StoreDependantDocumentTypeAliasList)
            {
                var contentType = contentTypeService.GetContentType(documentTypeAlias);
                if (contentType == null)
                {
                    continue;
                }
                contentTypeList.Add(contentType);

                var disableAlias = string.Format("disable_{0}", storeAliasWithoutSpaces);
                if (contentType.PropertyTypes.All(p => p.Alias != disableAlias))
                {
                    CMSInstaller.GetOrAddPropertyGroup(contentType, storeAliasWithoutSpaces).PropertyTypes.Add(new PropertyType(trueFalseDataTypeDef)
                    {
                        Alias = disableAlias, Name = "#Disable", Description = "#DisableDescription",
                    });
                }
                if (Category.IsAlias(documentTypeAlias) || Product.IsAlias(documentTypeAlias))
                {
                    var templateAlias = string.Format("template_{0}", storeAliasWithoutSpaces);
                    if (contentType.PropertyTypes.All(p => p.Alias != templateAlias))
                    {
                        CMSInstaller.GetOrAddPropertyGroup(contentType, storeAliasWithoutSpaces).PropertyTypes.Add(new PropertyType(storeTemplatePickerDataTypeDef)
                        {
                            Alias = templateAlias, Name = "#Template", Description = "#TemplateDescription",
                        });
                    }
                }
            }
            contentTypeService.Save(contentTypeList);
        }