예제 #1
0
        /// <summary>
        /// Checks if there were any changes in document types defined in Umbraco/uSiteBuilder/Both.
        /// Does not check relations between document types (allowed childs and allowable parents)
        /// </summary>
        /// <param name="hasDefaultValues"></param>
        /// <returns></returns>
        public static List <ContentComparison> PreviewDocumentTypeChanges(out bool hasDefaultValues)
        {
#if DEBUG
            Stopwatch timer = new Stopwatch();
            timer.Start();
#endif
            // compare the library based definitions to the Umbraco DB
            var definedDocTypes = PreviewDocTypes(typeof(DocumentTypeBase), "");

#if DEBUG
            timer.Stop();
            StopwatchLogger.AddToLog(string.Format("Total elapsed time for method 'DocumentTypeComparer.PreviewDocumentTypeChanges' - only PreviewDocTypes: {0}ms.", timer.ElapsedMilliseconds));
            timer.Restart();
#endif



#if DEBUG
            timer.Start();
#endif
            hasDefaultValues = _hasDefaultValues;
            // add any umbraco defined doc types that don't exist in the class definitions
            definedDocTypes.AddRange(ContentTypeService.GetAllContentTypes()
                                     .Where(doctype => definedDocTypes.All(dd => dd.Alias != doctype.Alias))
                                     .Select(docType => new ContentComparison {
                Alias = docType.Alias, DocumentTypeStatus = Status.Deleted, DocumentTypeId = docType.Id
            }));

#if DEBUG
            timer.Stop();
            StopwatchLogger.AddToLog(string.Format("Total elapsed time for method 'DocumentTypeComparer.PreviewDocumentTypeChanges' - add any umbraco defined doc types that don't exist in the class definitions: {0}ms.", timer.ElapsedMilliseconds));
            timer.Restart();
#endif

            return(definedDocTypes);
        }