Exemplo n.º 1
0
        public virtual void UpdateAction(Repository repository, TextContent originalContent, TextFolder targetFolder, bool keepStatus)
        {
            var contents = BroadcastingContentHelper.GetContentsByOriginalUUID(targetFolder, originalContent.UUID).ToArray();
            var categoriesOfOriginalContent = GetAllCategories(originalContent).ToArray();

            if (originalContent.Published.HasValue && originalContent.Published.Value == true && contents.Length == 0)
            {
                Services.ServiceFactory.TextContentManager.Copy(originalContent, targetFolder, keepStatus, true, null);
            }
            else
            {
                foreach (var drivedContent in contents)
                {
                    if (drivedContent.IsLocalized != null && drivedContent.IsLocalized.Value == false)
                    {
                        var values = BroadcastingContentHelper.ExcludeBasicFields(originalContent);
                        if (keepStatus)
                        {
                            if (originalContent.Published.HasValue)
                            {
                                values["Published"] = originalContent.Published.Value.ToString();
                            }
                        }
                        var categoriesOfDrivedContent = GetAllCategories(drivedContent);
                        Services.ServiceFactory.TextContentManager.Update(repository, targetFolder, drivedContent.UUID, values, null, DateTime.UtcNow, categoriesOfOriginalContent, categoriesOfDrivedContent);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public virtual void UpdateAction(Repository repository, TextContent originalContent, TextFolder targetFolder, bool keepStatus)
        {
            var contents = BroadcastingContentHelper.GetContentsByOriginalUUID(targetFolder, originalContent.UUID).ToArray();
            var categoriesOfOriginalContent = GetAllCategories(originalContent).ToArray();

            if (originalContent.Published.HasValue && originalContent.Published.Value == true && contents.Length == 0)
            {
                Services.ServiceFactory.TextContentManager.Copy(originalContent, targetFolder, keepStatus, true, null);
            }
            else
            {
                foreach (var drivedContent in contents)
                {
                    if (drivedContent.IsLocalized != null && drivedContent.IsLocalized.Value == false)
                    {
                        var values = BroadcastingContentHelper.ExcludeBasicFields(originalContent);
                        if (keepStatus)
                        {
                            if (originalContent.Published.HasValue)
                            {
                                values["Published"] = originalContent.Published.Value.ToString();
                            }
                        }
                        var versions = Kooboo.CMS.Content.Versioning.VersionManager.AllVersionInfos(originalContent);
                        if (versions.Count() > 0)
                        {
                            drivedContent.OriginalLastestVisitedVersionId = Kooboo.CMS.Content.Versioning.VersionManager.AllVersionInfos(originalContent).Max(it => it.Version);
                        }
                        var categoriesOfDrivedContent = GetAllCategories(drivedContent);
                        Services.ServiceFactory.TextContentManager.Update(repository, targetFolder, drivedContent.UUID, values, null, DateTime.UtcNow, categoriesOfOriginalContent, categoriesOfDrivedContent, originalContent.UserId);
                    }
                    else
                    {
                        drivedContent.OriginalUpdateTimes = drivedContent.OriginalUpdateTimes + 1;
                        _textContentProvider.Update(drivedContent, drivedContent);
                    }
                }
            }
        }