Beispiel #1
0
        private string GetIcon(LogDto logItem)
        {
            switch (logItem.EntityType.ToLower())
            {
            case "document":
                return(_contentService.GetById(logItem.NodeId).ContentType.Icon);

            case "media":
                return(_mediaService.GetById(logItem.NodeId).ContentType.Icon);

            case "member":
                return(_memberTypeService.Get(_memberService.GetById(logItem.NodeId).ContentTypeAlias).Icon);

            case "documenttype":
                return(_contentTypeService.Get(logItem.NodeId).Icon);

            case "mediatype":
                return(_mediaTypeService.Get(logItem.NodeId).Icon);

            case "membertype":
                return(_memberTypeService.Get(logItem.NodeId).Icon);

            case "datatype":
                return(_dataTypeService.GetAll(new[] { logItem.NodeId }).FirstOrDefault().Editor.Icon);

            case "dictionaryitem":
                return("icon-book-alt");

            default:
                return("icon-newspaper");
            }
        }
Beispiel #2
0
        public void TestAll()
        {
            IDataTypeService service = UnitOfWork.GetService <IDataTypeService>();
            IServiceQueryResultList <DataTypeData> result = service.GetAll();
            List <DataTypeData> list = result.DataList.ToList();

            if (list != null)
            {
            }
        }
Beispiel #3
0
        /// <inheritdoc />
        public PublishedDataType GetDataType(int id)
        {
            Dictionary <int, PublishedDataType> publishedDataTypes;

            lock (_publishedDataTypesLocker)
            {
                if (_publishedDataTypes == null)
                {
                    var dataTypes = _dataTypeService.GetAll();
                    _publishedDataTypes = dataTypes.ToDictionary(x => x.Id, CreatePublishedDataType);
                }

                publishedDataTypes = _publishedDataTypes;
            }

            if (!publishedDataTypes.TryGetValue(id, out var dataType))
            {
                throw new ArgumentException($"Could not find a datatype with identifier {id}.", nameof(id));
            }

            return(dataType);
        }
    protected override ActionResult <TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)
    {
        if (!int.TryParse(id, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intId))
        {
            throw new InvalidOperationException("Id must be an integer");
        }

        var nodes = new TreeNodeCollection();

        //Folders first
        nodes.AddRange(
            _entityService.GetChildren(intId, UmbracoObjectTypes.DataTypeContainer)
            .OrderBy(entity => entity.Name)
            .Select(dt =>
        {
            TreeNode node = CreateTreeNode(dt, Constants.ObjectTypes.DataType, id, queryStrings,
                                           Constants.Icons.Folder, dt.HasChildren);
            node.Path     = dt.Path;
            node.NodeType = "container";
            // TODO: This isn't the best way to ensure a no operation process for clicking a node but it works for now.
            node.AdditionalData["jsClickCallback"] = "javascript:void(0);";
            return(node);
        }));

        //if the request is for folders only then just return
        if (queryStrings["foldersonly"].ToString().IsNullOrWhiteSpace() == false && queryStrings["foldersonly"] == "1")
        {
            return(nodes);
        }

        //System ListView nodes
        IEnumerable <int> systemListViewDataTypeIds = GetNonDeletableSystemListViewDataTypeIds();

        IEntitySlim[] children  = _entityService.GetChildren(intId, UmbracoObjectTypes.DataType).ToArray();
        var           dataTypes = _dataTypeService.GetAll(children.Select(c => c.Id).ToArray()).ToDictionary(dt => dt.Id);

        nodes.AddRange(
            children
            .OrderBy(entity => entity.Name)
            .Select(dt =>
        {
            IDataType dataType = dataTypes[dt.Id];
            TreeNode node      = CreateTreeNode(dt.Id.ToInvariantString(), id, queryStrings, dt.Name,
                                                dataType.Editor?.Icon, false);
            node.Path = dt.Path;
            return(node);
        })
            );

        return(nodes);
    }
        internal List <TDto> RetrieveAll <TDto>(IDataConverter <DataTypeData, TDto> converter)
            where TDto : class
        {
            ArgumentValidator.IsNotNull("converter", converter);
            IDataTypeService service = UnitOfWork.GetService <IDataTypeService>();

            var query = service.GetAll();

            if (query.HasResult)
            {
                return(query.DataToDtoList(converter).ToList());
            }

            return(null);
        }
        /// <inheritdoc />
        public PublishedDataType GetDataType(int id)
        {
            Dictionary <int, PublishedDataType> publishedDataTypes;

            lock (_publishedDataTypesLocker)
            {
                if (_publishedDataTypes == null)
                {
                    var dataTypes = _dataTypeService.GetAll();
                    _publishedDataTypes = dataTypes.ToDictionary(
                        x => x.Id,
                        x => new PublishedDataType(x.Id, x.EditorAlias, x is DataType d ? d.GetLazyConfiguration() : new Lazy <object>(() => x.Configuration)));
                }

                publishedDataTypes = _publishedDataTypes;
            }

            if (!publishedDataTypes.TryGetValue(id, out var dataType))
            {
                throw new ArgumentException("Not a valid datatype identifier.", nameof(id));
            }

            return(dataType);
        }
        internal IEnumerable <BindingListItem> GetBindingList()
        {
            List <BindingListItem> dataSource = new List <BindingListItem>();
            IDataTypeService       service    = UnitOfWork.GetService <IDataTypeService>();
            var query = service.GetAll();

            if (query.HasResult)
            {
                foreach (DataTypeData data in query.DataList)
                {
                    dataSource.Add(new BindingListItem(data.Id, data.Name));
                }
            }

            return(dataSource);
        }
Beispiel #8
0
 public IEnumerable <DataTypeBasic> GetAll()
 {
     return(_dataTypeService
            .GetAll()
            .Select(_umbracoMapper.Map <IDataType, DataTypeBasic>).Where(x => x.IsSystemDataType == false));
 }
Beispiel #9
0
        private string AddMemberProperties()
        {
            bool          saveMemberContent = false;
            StringBuilder contentStatus     = new StringBuilder();

            string groupname = "Forum Settings";
            string mType     = "Member";

            contentStatus.Append("<ul>");

            var newaccountType = _localizationService.GetDictionaryItemByKey("ForumAuthConstants.NewAccountMemberType");

            if (newaccountType != null)
            {
                mType = newaccountType.GetDefaultValue();
            }
            IMemberType memberContentType = _memberTypeService.Get(mType);

            var dataTypeDefinitions = _dataTypeService.GetAll().ToArray();                                           //.ToArray() because arrays are fast and easy.

            var truefalse = dataTypeDefinitions.FirstOrDefault(p => p.EditorAlias.ToLower() == "umbraco.truefalse"); //we want the TrueFalse data type.
            var textbox   = dataTypeDefinitions.FirstOrDefault(p => p.EditorAlias.ToLower() == "umbraco.textbox");   //we want the TextBox data type.

            try
            {
                if (!memberContentType.PropertyGroups.Contains(groupname))
                {
                    memberContentType.AddPropertyGroup(groupname); //add a property group, not needed, but I wanted it
                    saveMemberContent = true;
                }
                contentStatus.Append("<li>");

                if (!memberContentType.PropertyTypeExists("receiveNotifications"))
                {
                    contentStatus.Append("Adding property receiveNotifications");

                    saveMemberContent = memberContentType.AddPropertyType(new PropertyType(truefalse)
                    {
                        Name        = "Receive Notifications",
                        Alias       = "receiveNotifications",
                        Description = "Get an email when someone posts in a topic you are participating.",
                        Mandatory   = false
                    }, groupname);
                    if (saveMemberContent)
                    {
                        memberContentType.SetMemberCanEditProperty("receiveNotifications", true);
                        memberContentType.SetMemberCanViewProperty("receiveNotifications", true);
                    }
                    contentStatus.Append("<strong>done</strong>");
                }
                else
                {
                    memberContentType.SetMemberCanEditProperty("receiveNotifications", true);
                    memberContentType.SetMemberCanViewProperty("receiveNotifications", true);
                }
                contentStatus.Append("</li><li>");

                if (!memberContentType.PropertyTypeExists("hasVerifiedAccount"))
                {
                    contentStatus.Append("Adding property hasVerifiedAccount");
                    saveMemberContent = memberContentType.AddPropertyType(new PropertyType(truefalse)
                    {
                        Name        = "Has verified Email",
                        Alias       = "hasVerifiedAccount",
                        Description = "User has verified their account.",
                        Mandatory   = false
                    }, groupname);

                    contentStatus.Append("<strong>done</strong>");
                }
                contentStatus.Append("</li><li>");

                if (!memberContentType.PropertyTypeExists("resetGuid"))
                {
                    contentStatus.Append("Adding property resetGuid");
                    saveMemberContent = memberContentType.AddPropertyType(new PropertyType(textbox)
                    {
                        Name        = "Reset Guid",
                        Alias       = "resetGuid",
                        Description = "Guid set when user requests a password reset.",
                        Mandatory   = false
                    }, groupname);
                    if (saveMemberContent)
                    {
                        memberContentType.SetIsSensitiveProperty("resetGuid", true);
                    }
                    contentStatus.Append("<strong>done</strong>");
                }
                contentStatus.Append("</li><li>");

                if (!memberContentType.PropertyTypeExists("joinedDate"))
                {
                    contentStatus.Append("Adding property joinedDate");
                    saveMemberContent = memberContentType.AddPropertyType(new PropertyType(textbox)
                    {
                        Name        = "Joined date",
                        Alias       = "joinedDate",
                        Description = "Date the user joined (validated email).",
                        Mandatory   = false
                    }, groupname);
                    if (saveMemberContent)
                    {
                        memberContentType.SetMemberCanViewProperty("joinedDate", true);
                    }
                    contentStatus.Append("<strong>done</strong>");
                }
                contentStatus.Append("</li>");
                if (saveMemberContent)
                {
                    _memberTypeService.Save(memberContentType); //save the content type
                }
                else
                {
                    throw new ArgumentException("Unable to add custom Member properties");
                }
            }
            catch (Exception e)
            {
                Current.Logger.Error(System.Reflection.MethodBase.GetCurrentMethod().GetType(), e, "Executing ForumInstallHandler:Add member types");
                contentStatus.Append($"<li>Error adding properties: {e.Message}</li>");
            }
            contentStatus.Append("</ul>");

            return(contentStatus.ToString());
        }