private void MapHistoryCleanup(Dictionary <int, IContentTypeComposition> contentTypes)
        {
            // get templates
            Sql <ISqlContext> sql1 = Sql()
                                     .Select <ContentVersionCleanupPolicyDto>()
                                     .From <ContentVersionCleanupPolicyDto>()
                                     .OrderBy <ContentVersionCleanupPolicyDto>(x => x.ContentTypeId);

            var contentVersionCleanupPolicyDtos = Database.Fetch <ContentVersionCleanupPolicyDto>(sql1);

            var contentVersionCleanupPolicyDictionary =
                contentVersionCleanupPolicyDtos.ToDictionary(x => x.ContentTypeId);

            foreach (IContentTypeComposition c in contentTypes.Values)
            {
                if (!(c is ContentType contentType))
                {
                    continue;
                }

                var historyCleanup = new HistoryCleanup();

                if (contentVersionCleanupPolicyDictionary.TryGetValue(contentType.Id, out var versionCleanup))
                {
                    historyCleanup.PreventCleanup = versionCleanup.PreventCleanup;
                    historyCleanup.KeepAllVersionsNewerThanDays   = versionCleanup.KeepAllVersionsNewerThanDays;
                    historyCleanup.KeepLatestVersionPerDayForDays = versionCleanup.KeepLatestVersionPerDayForDays;
                }

                contentType.HistoryCleanup = historyCleanup;
            }
        }
Пример #2
0
        private XElement SerializeCleanupPolicy(HistoryCleanup cleanupPolicy)
        {
            if (cleanupPolicy == null)
            {
                throw new ArgumentNullException(nameof(cleanupPolicy));
            }

            var element = new XElement("HistoryCleanupPolicy",
                                       new XAttribute("preventCleanup", cleanupPolicy.PreventCleanup));

            if (cleanupPolicy.KeepAllVersionsNewerThanDays.HasValue)
            {
                element.Add(new XAttribute("keepAllVersionsNewerThanDays", cleanupPolicy.KeepAllVersionsNewerThanDays));
            }

            if (cleanupPolicy.KeepLatestVersionPerDayForDays.HasValue)
            {
                element.Add(new XAttribute("keepLatestVersionPerDayForDays", cleanupPolicy.KeepLatestVersionPerDayForDays));
            }

            return(element);
        }
Пример #3
0
 /// <summary>
 /// Constuctor for creating a ContentType with the parent as an inherited type.
 /// </summary>
 /// <remarks>Use this to ensure inheritance from parent.</remarks>
 /// <param name="parent"></param>
 /// <param name="alias"></param>
 public ContentType(IContentType parent, string alias)
     : base(parent, alias)
 {
     _allowedTemplates = new List <ITemplate>();
     HistoryCleanup    = new HistoryCleanup();
 }
Пример #4
0
 /// <summary>
 /// Constuctor for creating a ContentType with the parent's id.
 /// </summary>
 /// <remarks>Only use this for creating ContentTypes at the root (with ParentId -1).</remarks>
 /// <param name="parentId"></param>
 public ContentType(int parentId) : base(parentId)
 {
     _allowedTemplates = new List <ITemplate>();
     HistoryCleanup    = new HistoryCleanup();
 }