public SynchronizeTemplateFieldsTask(UmbracoDataContext context, XmlElement[] input, DocumentType container)
        {
            _context = context;
            _input = input;
            _container = container;
            _datatypes = DataTypeDefinition.GetAll().ToDictionary(dt => dt.Text);

            _tabIds = _context.cmsTabs.ToDictionary(t => DataHelper.GetPath(_context, t), t => t.id);
        }
Esempio n. 2
0
 public static string GetPath(UmbracoDataContext context, cmsContentType ct)
 {
     if (ct.masterContentType != 0)
     {
         var parent = context.cmsContentTypes.Where(t => t.nodeId == ct.masterContentType).FirstOrDefault();
         if (parent != null)
             return GetPath(context, parent) + "/" + ct.alias;
     }
     return ct.alias;
 }
        protected ContentCollectionBase(UmbracoDataContext dataContext, string contentTypeAlias)
        {
            if (dataContext == null)
            {
                throw new ArgumentNullException("dataContext");
            }

            //NOTE: This is strange i know but linqpad subclasses our data context in it's own assembly, we need
            // a ref to our own generated assembly to get th types from that
            _generatedAssembly = dataContext.GetType().BaseType.Assembly;

            DataContext       = dataContext;
            _contentTypeAlias = contentTypeAlias;
            _contentType      = GetContentType(contentTypeAlias);
            if (_contentType == null)
            {
                throw new ArgumentException("No content type found with alias " + contentTypeAlias);
            }
        }
        protected override void DeleteOldItems(StringBuilder log)
        {
            var existingTypes = DocumentType.GetAllAsList().ToDictionary(DataHelper.GetPath);
            foreach (var element in _input)
            {
                var path = element.GetAttribute("path");
                existingTypes.Remove(path);
            }

            var dataContext = new UmbracoDataContext(_connectionString);
            foreach (var dt in existingTypes.Values)
            {
                var contentType = dataContext.cmsContentTypes.Where(t => t.nodeId == dt.Id).FirstOrDefault();
                if (contentType.masterContentType == null)
                    continue;

                dt.delete();
            }
        }
        public ContentQuery(UmbracoDataContext dataContext, string contentTypeAlias)
        {
            if (dataContext == null)
            {
                throw new ArgumentNullException("dataContext");
            }

            //NOTE: This is strange i know but linqpad subclasses our data context in it's own assembly, we need
            // a ref to our own generated assembly to get th types from that
            _generatedAssembly = dataContext.GetType().BaseType.Assembly;

            _dataContext      = dataContext;
            _contentTypeAlias = contentTypeAlias;
            _contentType      = _dataContext.ApplicationContext.Services.ContentTypeService.GetContentType(contentTypeAlias);
            if (_contentType == null)
            {
                throw new ArgumentException("No content type found with alias " + contentTypeAlias);
            }

            _baseQueryable = new DelegateQueryable <T>(DataQuery);
        }
 public ContentCollection(UmbracoDataContext dataContext, string contentTypeAlias)
     : base(dataContext, contentTypeAlias)
 {
 }
        private void UpdateDocTypeIconAndThumbnail(StringBuilder log, XmlElement element, string path, DocumentType dt)
        {
            var changesMade = false;
            var dataContext = new UmbracoDataContext(_connectionString);

            var contentType = dataContext.cmsContentTypes.Where(t => t.nodeId == dt.Id).FirstOrDefault();
            if (contentType == null)
                throw new ApplicationException("ContentType does not exist: " + path);

            var icon = element.GetAttribute("icon");
            if (contentType.icon != icon)
            {
                contentType.icon = icon;
                changesMade = true;
                log.AppendLine("Changed icon on cmsContentType. CT:" + path + ", Icon:" + icon);
            }
            var thumbnail = element.GetAttribute("thumbnail");
            if (thumbnail != contentType.thumbnail)
            {
                contentType.thumbnail = thumbnail;
                changesMade = true;
                log.AppendLine("Changed thumbnail on cmsContentType. CT:" + path + ", Thumbnail:" + thumbnail);
            }

            if (changesMade)
            {
                dataContext.SubmitChanges();
            }
        }
 public FieldTypeInstaller(UmbracoDataContext context)
 {
     _context = context;
     _dataTypeDefinitions = DataTypeDefinition.GetAll().ToDictionary(d => d.Text);
 }
Esempio n. 9
0
 public static string GetPath(UmbracoDataContext context, cmsTab tab)
 {
     return GetPath(context, tab.cmsContentType) + "/" + tab.text;
 }
        protected override void UpdateItems(StringBuilder log)
        {
            var changesMade = false;
            UmbracoDataContext dataContext = null;
            foreach (var element in _input)
            {
                var name = element.GetAttribute("name");
                var sortOrder = Convert.ToInt32(element.GetAttribute("sortOrder"));
                var tab = _container.getVirtualTabs.Where(t => t.Caption == name).FirstOrDefault();
                if (tab == null)
                    throw new ApplicationException("Tab was not created or cache not updated: " + name);

                if (tab.SortOrder != sortOrder)
                {
                    if (dataContext == null)
                        dataContext = new UmbracoDataContext(_connectionString);
                    var cmsTab = dataContext.cmsTabs.Where(t => t.contenttypeNodeId == _container.Id && t.text == name).FirstOrDefault();
                    if (cmsTab == null)
                        throw new ApplicationException("Tab not yet in database: " + name);
                    cmsTab.sortorder = sortOrder;
                    changesMade = true;
                    log.AppendLine("Changed sortorder on tab. DT:" + _container.Text + ", Tab: " + name);
                }
            }

            if (changesMade)
            {
                dataContext.SubmitChanges();
                log.AppendLine("Submitted Changes");
                RefreshContainer(log);
            }
        }