예제 #1
0
        private void DeleteRelationship(ManyToManyRelationshipRecord record)
        {
            if (record == null)
            {
                return;
            }
            record.PrimaryListProjection.QueryPartRecord.Layouts.Clear();
            record.PrimaryListProjection.QueryPartRecord.FilterGroups.Clear();
            record.RelatedListProjection.QueryPartRecord.Layouts.Clear();
            record.RelatedListProjection.QueryPartRecord.FilterGroups.Clear();
            _manyToManyRepository.Delete(record);
            _relationshipRepository.Delete(record.Relationship);

            string primaryName = record.Relationship.PrimaryEntity.Name;
            string relatedName = record.Relationship.RelatedEntity.Name;

            _schemaUpdateService.DropCustomTable(string.Format("Coevery_DynamicTypes_{0}ContentLinkRecord", record.Relationship.Name));
            _schemaUpdateService.DropCustomTable(string.Format("Coevery_DynamicTypes_{0}{1}PartRecord", record.Relationship.Name, primaryName));
            _schemaUpdateService.DropCustomTable(string.Format("Coevery_DynamicTypes_{0}{1}PartRecord", record.Relationship.Name, relatedName));

            _contentDefinitionManager.DeletePartDefinition(record.Relationship.Name + primaryName + "Part");
            _contentDefinitionManager.DeletePartDefinition(record.Relationship.Name + relatedName + "Part");

            _dynamicAssemblyBuilder.Build();
        }
예제 #2
0
        // <RemoveContentDefinition>
        //  <Types>
        //   <Blog creatable = "true" >
        //    <Body format="abodyformat"/>
        //   </Blog>
        //  </Types>
        //  <Parts>
        //  </Parts>
        // </RemoveContentDefinition>
        public override void Execute(RecipeExecutionContext context)
        {
            foreach (var metadataElement in context.RecipeStep.Step.Elements())
            {
                Logger.Debug("Processing element '{0}'.", metadataElement.Name.LocalName);
                switch (metadataElement.Name.LocalName)
                {
                case "Types":
                    foreach (var element in metadataElement.Elements())
                    {
                        var typeName = XmlConvert.DecodeName(element.Name.LocalName);

                        Logger.Information("Removing content type '{0}'.", typeName);
                        try {
                            _contentDefinitionManager.DeleteTypeDefinition(typeName);
                            _contentDefinitonEventHandlers.ContentTypeRemoved(new ContentTypeRemovedContext {
                                ContentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(typeName)
                            });
                        }
                        catch (Exception ex) {
                            Logger.Error(ex, "Error while removing content type '{0}'.", typeName);
                            throw;
                        }
                    }
                    break;

                case "Parts":
                    foreach (var element in metadataElement.Elements())
                    {
                        var partElement = element;
                        var partName    = XmlConvert.DecodeName(element.Name.LocalName);

                        Logger.Information("Removing content part definition '{0}'.", partName);
                        try {
                            _contentDefinitionManager.DeletePartDefinition(partName);
                            _contentDefinitonEventHandlers.ContentPartRemoved(new ContentPartRemovedContext {
                                ContentPartDefinition = _contentDefinitionManager.GetPartDefinition(partName)
                            });
                        }
                        catch (Exception ex) {
                            Logger.Error(ex, "Error while removing content part definition for '{0}'.", partName);
                            throw;
                        }
                    }
                    break;

                default:
                    Logger.Warning("Unrecognized element '{0}' encountered; skipping", metadataElement.Name.LocalName);
                    break;
                }
            }
        }
예제 #3
0
        public void RemovePart(string name)
        {
            var partDefinition   = _contentDefinitionManager.GetPartDefinition(name);
            var fieldDefinitions = partDefinition.Fields.ToArray();

            foreach (var fieldDefinition in fieldDefinitions)
            {
                RemoveFieldFromPart(fieldDefinition.Name, name);
            }

            _contentDefinitionManager.DeletePartDefinition(name);
            _eventBus.Notify <IContentDefinitionEventHandler>(x => x.ContentPartRemoved(new ContentPartRemovedContext {
                ContentPartDefinition = partDefinition
            }));
        }
        public void RemovePart(string name)
        {
            var partDefinition = _contentDefinitionManager.LoadPartDefinition(name);

            if (partDefinition == null)
            {
                // Couldn't find this named part, ignore it
                return;
            }

            var fieldDefinitions = partDefinition.Fields.ToArray();

            foreach (var fieldDefinition in fieldDefinitions)
            {
                RemoveFieldFromPart(fieldDefinition.Name, name);
            }

            _contentDefinitionManager.DeletePartDefinition(name);
            _contentDefinitionEventHandlers.Invoke((handler, context) => handler.ContentPartRemoved(context), new ContentPartRemovedContext {
                ContentPartDefinition = partDefinition
            }, Logger);
        }
예제 #5
0
        public void RemovePart(string name)
        {
            var partDefinition = _contentDefinitionManager.GetPartDefinition(name);

            if (partDefinition == null)
            {
                // Couldn't find this named part, ignore it
                return;
            }

            var fieldDefinitions = partDefinition.Fields.ToArray();

            foreach (var fieldDefinition in fieldDefinitions)
            {
                RemoveFieldFromPart(fieldDefinition.Name, name);
            }

            _contentDefinitionManager.DeletePartDefinition(name);
            _eventBus.Notify <IContentDefinitionEventHandler>(x => x.ContentPartRemoved(new ContentPartRemovedContext {
                ContentPartDefinition = partDefinition
            }));
        }
예제 #6
0
        public async Task <int> UpdateFrom3()
        {
            // This code can be removed in RC

            // Update content type definitions
            foreach (var contentType in _contentDefinitionManager.ListTypeDefinitions())
            {
                if (contentType.Parts.Any(x => x.PartDefinition.Name == "BodyPart"))
                {
                    _contentDefinitionManager.AlterTypeDefinition(contentType.Name, x => x.RemovePart("BodyPart").WithPart("HtmlBodyPart"));
                }
            }

            _contentDefinitionManager.DeletePartDefinition("BodyPart");

            // We are patching all content item versions by moving the Title to DisplayText
            // This step doesn't need to be executed for a brand new site

            var lastDocumentId = 0;

            for (; ;)
            {
                var contentItemVersions = await _session.Query <ContentItem, ContentItemIndex>(x => x.DocumentId > lastDocumentId).Take(10).ListAsync();

                if (!contentItemVersions.Any())
                {
                    // No more content item version to process
                    break;
                }

                foreach (var contentItemVersion in contentItemVersions)
                {
                    if (UpdateBody(contentItemVersion.Content))
                    {
                        _session.Save(contentItemVersion);
                        _logger.LogInformation($"A content item version's BodyPart was upgraded: '{contentItemVersion.ContentItemVersionId}'");
                    }

                    lastDocumentId = contentItemVersion.Id;
                }

                await _session.CommitAsync();
            }

            bool UpdateBody(JToken content)
            {
                var changed = false;

                if (content.Type == JTokenType.Object)
                {
                    var body = content["BodyPart"]?["Body"]?.Value <string>();

                    if (!String.IsNullOrWhiteSpace(body))
                    {
                        content["HtmlBodyPart"] = new JObject(new JProperty("Html", body));
                        changed = true;
                    }
                }

                foreach (var token in content)
                {
                    changed = UpdateBody(token) || changed;
                }

                return(changed);
            }

            return(4);
        }