Beispiel #1
0
        public override MultistepActionSettings Setup(int siteId, int contentId, bool?boundToExternal)
        {
            var content = ContentRepository.GetById(contentId);

            if (content == null)
            {
                throw new ApplicationException(string.Format(SiteStrings.SiteNotFound, siteId));
            }

            List <Content.TreeItem> rebuildedViewSubContents;
            var helper = new VirtualContentHelper();

            using (VirtualFieldRepository.LoadVirtualFieldsRelationsToMemory(contentId))
            {
                rebuildedViewSubContents = helper.TraverseForUpdateVirtualSubContents(content);
            }

            _rebuildViewsCommand = new RebuildVirtualContentViewsCommand(contentId, content.Name, rebuildedViewSubContents);
            _rebuildViewsCommand.Setup();

            _rebuildUserQueryCommand = new RebuildUserQueryCommand(contentId, content.Name, rebuildedViewSubContents);
            _rebuildUserQueryCommand.Setup();

            return(base.Setup(siteId, contentId, boundToExternal));
        }
Beispiel #2
0
        public static Field Update(Field item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            if (!FieldRepository.Exists(item.Id))
            {
                throw new ApplicationException(string.Format(FieldStrings.FieldNotFound, item.Id));
            }

            if (item.Content.VirtualType == VirtualType.None)
            {
                throw new ApplicationException($"Content {item.Content.Id} of field {item.Id} is not virtual.");
            }

            using (VirtualFieldRepository.LoadVirtualFieldsRelationsToMemory(item.ContentId))
            {
                var newField = ((IFieldRepository) new FieldRepository()).Update(item);
                var helper   = new VirtualContentHelper();

                helper.DropContentViews(newField.Content);
                helper.CreateContentViews(newField.Content);

                // Обновить дочерние виртуальные контенты
                helper.UpdateVirtualFields(newField);
                return(newField);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Обновляет виртуальный контент
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public static Content Update(Content content)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }

            var helper = new VirtualContentHelper(content.ForceVirtualFieldIds?.ToList());

            using (VirtualFieldRepository.LoadVirtualFieldsRelationsToMemory(content.Id))
            {
                // Если тип контента изменился
                // то удалить связанную с контентом информацию
                if (content.StoredVirtualType != content.VirtualType)
                {
                    helper.RemoveContentData(content);
                }

                // Обновить контент
                var dbContent = VirtualContentRepository.Update(content);

                // Спициальное обновления для конкретного типа контента
                if (content.VirtualType == VirtualType.Join)
                {
                    dbContent = helper.UpdateJoinContent(content, dbContent);
                }
                else if (content.VirtualType == VirtualType.Union)
                {
                    dbContent = helper.UpdateUnionContent(content, dbContent);
                }
                else if (content.VirtualType == VirtualType.UserQuery)
                {
                    dbContent = helper.UpdateUserQueryContent(content, dbContent);
                }

                dbContent.NewVirtualFieldIds = helper.NewFieldIds;
                return(dbContent);
            }
        }
        public MultistepActionStepResult Step(int step)
        {
            var context = HttpContext.Current.Session[HttpContextSession.RebuildUserQueryCommandProcessingContext] as RebuildUserQueryCommandContext;
            var ids     = context.ContentIdsToRebuild
                          .Skip(step * ItemsPerStep)
                          .Take(ItemsPerStep)
                          .ToArray();

            var helper   = new VirtualContentHelper();
            var contents = ContentRepository.GetList(ids).ToDictionary(n => n.Id);

            using (VirtualFieldRepository.LoadVirtualFieldsRelationsToMemory(ContentId))
            {
                foreach (var content in ids.Select(n => contents[n]).Where(n => n.VirtualType == VirtualType.UserQuery))
                {
                    helper.UpdateUserQueryAsSubContent(content);
                }
            }

            return(new MultistepActionStepResult {
                ProcessedItemsCount = ItemsPerStep
            });
        }