/// <summary>
        /// Gets a JSON list of the available member types
        /// </summary>
        /// <returns>JSON response of available criteria</returns>
        /// <remarks>Using ContentResult so can serialize with camel case for consistency in client-side code</remarks>
        public ContentResult GetMemberTypes()
        {
            var memberTypes = _memberTypeService.GetAll()
                              .OrderBy(x => x.Alias)
                              .Select(x => x.Alias);

            return(CamelCasedJsonResult(memberTypes));
        }
        public IActionResult GetMemberTypes()
        {
            var memberTypes = _memberTypeService.GetAll()
                              .OrderBy(x => x.Alias)
                              .Select(x => x.Alias);

            return(new OkObjectResult(memberTypes));
        }
        public IList <TypeModel> GetAllTypes()
        {
            var types = new List <TypeModel>();

            types.AddRange(GetTypes(PublishedItemType.Content, _contentTypeService.GetAll().Cast <IContentTypeComposition>().ToArray()));
            types.AddRange(GetTypes(PublishedItemType.Media, _mediaTypeService.GetAll().Cast <IContentTypeComposition>().ToArray()));
            types.AddRange(GetTypes(PublishedItemType.Member, _memberTypeService.GetAll().Cast <IContentTypeComposition>().ToArray()));

            return(EnsureDistinctAliases(types));
        }
Exemplo n.º 4
0
        protected override ActionResult <TreeNode> CreateRootNode(FormCollection queryStrings)
        {
            var rootResult = base.CreateRootNode(queryStrings);

            if (!(rootResult.Result is null))
            {
                return(rootResult);
            }
            var root = rootResult.Value;

            //check if there are any member types
            root.HasChildren = _memberTypeService.GetAll().Any();
            return(root);
        }
Exemplo n.º 5
0
        public IList <TypeModel> GetAllTypes()
        {
            var types = new List <TypeModel>();

            // TODO: this will require 3 rather large SQL queries on startup in PureLive. I know that these will be cached after lookup but it will slow
            // down startup time ... BUT these queries are also used in NuCache on startup so we can't really avoid them. Maybe one day we can
            // load all of these in in one query and still have them cached per service, and/or somehow improve the perf of these since they are used on startup
            // in more than one place.
            types.AddRange(GetTypes(PublishedItemType.Content, _contentTypeService.GetAll().Cast <IContentTypeComposition>().ToArray()));
            types.AddRange(GetTypes(PublishedItemType.Media, _mediaTypeService.GetAll().Cast <IContentTypeComposition>().ToArray()));
            types.AddRange(GetTypes(PublishedItemType.Member, _memberTypeService.GetAll().Cast <IContentTypeComposition>().ToArray()));

            return(EnsureDistinctAliases(types));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Returns the references (usages) for the data type
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public DataTypeReferences GetReferences(int id)
        {
            var result = new DataTypeReferences();
            var usages = _dataTypeService.GetReferences(id);

            foreach (var groupOfEntityType in usages.GroupBy(x => x.Key.EntityType))
            {
                //get all the GUIDs for the content types to find
                var guidsAndPropertyAliases = groupOfEntityType.ToDictionary(i => ((GuidUdi)i.Key).Guid, i => i.Value);

                if (groupOfEntityType.Key == ObjectTypes.GetUdiType(UmbracoObjectTypes.DocumentType))
                {
                    result.DocumentTypes = GetContentTypeUsages(_contentTypeService.GetAll(guidsAndPropertyAliases.Keys), guidsAndPropertyAliases);
                }
                else if (groupOfEntityType.Key == ObjectTypes.GetUdiType(UmbracoObjectTypes.MediaType))
                {
                    result.MediaTypes = GetContentTypeUsages(_mediaTypeService.GetAll(guidsAndPropertyAliases.Keys), guidsAndPropertyAliases);
                }
                else if (groupOfEntityType.Key == ObjectTypes.GetUdiType(UmbracoObjectTypes.MemberType))
                {
                    result.MemberTypes = GetContentTypeUsages(_memberTypeService.GetAll(guidsAndPropertyAliases.Keys), guidsAndPropertyAliases);
                }
            }

            return(result);
        }
        public IEnumerable <MemberColumn> GetMemberColumns(string memberType = null)
        {
            var  excludedColumns = settings.ExcludedColumns ?? Array.Empty <string>();
            bool foundType       = false;

            if (!string.IsNullOrWhiteSpace(memberType))
            {
                var type = memberTypeService.Get(memberType);
                if (type != null)
                {
                    foundType = true;
                    foreach (var col in type.GetColumns(excludedColumns))
                    {
                        yield return(col);
                    }
                }
            }
            if (!foundType)
            {
                // This is only used to track columns we already have added.
                var columns = new List <string>();
                foreach (var type in memberTypeService.GetAll())
                {
                    foreach (var col in type.GetColumns(excludedColumns))
                    {
                        if (!columns.Contains(col.Alias))
                        {
                            columns.Add(col.Alias);
                            yield return(col);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        public IEnumerable <uSyncAction> ExportAll(string folder)
        {
            List <uSyncAction> actions = new List <uSyncAction>();

            foreach (var item in _memberTypeService.GetAll())
            {
                if (item != null)
                {
                    actions.Add(ExportToDisk(item, folder));
                }
            }

            return(actions);
        }
Exemplo n.º 9
0
        private void IndexProviderTransformingIndexValues(object sender, IndexingItemEventArgs e)
        {
            //var indexProvider = sender as BaseIndexProvider;

            var memberTypes = memberTypeService.GetAll().Select(x => x.Alias);

            if (!memberTypes.InvariantContains(e.ValueSet.ItemType))
            {
                return;
            }

            // Get the groups
            AddGroups(e);
            var member = memberService.GetById(int.Parse(e.ValueSet.Id));
            IndexMembershipFields(e, member);

        }
Exemplo n.º 10
0
        private void TreeControllerBase_TreeNodesRendering(TreeControllerBase sender, TreeNodesRenderingEventArgs e)
        {
            switch (sender.TreeAlias)
            {
            case Constants.Trees.DocumentTypes:
                UpdateNodeIcons(e, _contentTypeService.GetAll()?.ToDictionary(c => c.Id, c => c.Icon), Constants.Trees.DocumentTypes);
                break;

            case Constants.Trees.MemberTypes:
                UpdateNodeIcons(e, _memberTypeService.GetAll()?.ToDictionary(c => c.Id, c => c.Icon), Constants.Trees.MemberTypes);
                break;

            case Constants.Trees.MediaTypes:
                UpdateNodeIcons(e, _mediaTypeService.GetAll()?.ToDictionary(c => c.Id, c => c.Icon), Constants.Trees.MediaTypes);
                break;
            }
        }
Exemplo n.º 11
0
    protected override ActionResult <TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)
    {
        var nodes = new TreeNodeCollection();

        if (id == Constants.System.RootString)
        {
            nodes.Add(
                CreateTreeNode(
                    Constants.Conventions.MemberTypes.AllMembersListId,
                    id,
                    queryStrings,
                    LocalizedTextService.Localize("member", "allMembers"),
                    Constants.Icons.MemberType,
                    true,
                    queryStrings.GetRequiredValue <string>("application") +
                    TreeAlias.EnsureStartsWith('/') +
                    "/list/" +
                    Constants.Conventions.MemberTypes.AllMembersListId));

            nodes.AddRange(_memberTypeService.GetAll()
                           .Select(memberType =>
                                   CreateTreeNode(
                                       memberType.Alias,
                                       id,
                                       queryStrings,
                                       memberType.Name,
                                       memberType.Icon.IfNullOrWhiteSpace(Constants.Icons.Member),
                                       true,
                                       queryStrings.GetRequiredValue <string>("application") + TreeAlias.EnsureStartsWith('/') +
                                       "/list/" + memberType.Alias)));
        }

        //There is no menu for any of these nodes
        nodes.ForEach(x => x.MenuUrl = null);

        //All nodes are containers
        nodes.ForEach(x => x.AdditionalData.Add("isContainer", true));

        return(nodes);
    }
    private void RefreshMemberOfMemberTypes(int[] memberTypeIds)
    {
        const int pageSize = 500;

        IEnumerable <IMemberType> memberTypes = _memberTypeService.GetAll(memberTypeIds);

        foreach (IMemberType memberType in memberTypes)
        {
            var page  = 0;
            var total = long.MaxValue;
            while (page * pageSize < total)
            {
                IEnumerable <IMember> memberToRefresh = _memberService.GetAll(
                    page++, pageSize, out total, "LoginName", Direction.Ascending,
                    memberType.Alias);

                foreach (IMember c in memberToRefresh)
                {
                    _umbracoIndexingHandler.ReIndexForMember(c);
                }
            }
        }
    }
Exemplo n.º 13
0
        /// <summary>
        /// Checks the tree alias and node alias to see if we should update the icon
        /// Gets the types from the type services and calls the method to update the node icons
        /// </summary>
        /// <param name="sender">Tree controller base</param>
        /// <param name="e">Event args</param>
        private void TreeControllerBase_TreeNodesRendering(TreeControllerBase sender, TreeNodesRenderingEventArgs e)
        {
            switch (sender.TreeAlias)
            {
            case "documentTypes":
                var contentTypeIcons = _contentTypeService.GetAll().ToDictionary(c => c.Id, c => c.Icon);
                UpdateNodeIcons(e, contentTypeIcons, "documentTypes");
                break;

            case "memberTypes":
                var memberTypeIcons = _memberTypeService.GetAll().ToDictionary(c => c.Id, c => c.Icon);
                UpdateNodeIcons(e, memberTypeIcons, "memberTypes");
                break;

            case "mediaTypes":
                var mediaTypeIcons = _mediaTypeService.GetAll().ToDictionary(c => c.Id, c => c.Icon);
                UpdateNodeIcons(e, mediaTypeIcons, "mediaTypes");
                break;

            default:
                // don't change the icon
                break;
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Gets the content types.
 /// </summary>
 /// <returns>
 /// The content types.
 /// </returns>
 protected override IMemberType[] GetContentTypes()
 {
     return(_memberTypeService.GetAll().ToArray());
 }
 /// <summary>
 /// Returns all member types
 /// </summary>
 public IEnumerable <ContentTypeBasic> GetAllTypes() =>
 _memberTypeService.GetAll()
 .Select(_umbracoMapper.Map <IMemberType, ContentTypeBasic>);
Exemplo n.º 16
0
 public IEnumerable <ContentTypeBasic> GetAllTypes()
 {
     return(_memberTypeService.GetAll()
            .Select(_umbracoMapper.Map <IMemberType, ContentTypeBasic>).WhereNotNull());
 }
        /// <summary>
        /// Reindex all members
        /// </summary>
        /// <param name="type"></param>
        protected override void PerformIndexAll(string type)
        {
            //This only supports members
            if (SupportedTypes.Contains(type) == false)
            {
                return;
            }

            DataService.LogService.AddInfoLog(-1, string.Format("PerformIndexAll - Start data queries - {0}", type));
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            try
            {
                if (DisableXmlDocumentLookup == false)
                {
                    ReindexWithXmlEntries(type, -1,
                                          () => _memberTypeService.GetAll().ToArray(),
                                          (path, pIndex, pSize) =>
                    {
                        long totalContent;
                        var result = _memberService.GetPagedXmlEntries(pIndex, pSize, out totalContent).ToArray();
                        var more   = result.Length == pSize;
                        return(Tuple.Create(result, more));
                    },
                                          i => _memberService.GetById(i));
                }
                else
                {
                    const int pageSize  = 1000;
                    var       pageIndex = 0;

                    IMember[] members;

                    if (IndexerData.IncludeNodeTypes.Any())
                    {
                        //if there are specific node types then just index those
                        foreach (var nodeType in IndexerData.IncludeNodeTypes)
                        {
                            do
                            {
                                long total;
                                members = _memberService.GetAll(pageIndex, pageSize, out total, "LoginName", Direction.Ascending, true, null, nodeType).ToArray();

                                AddNodesToIndex(GetSerializedMembers(members), type);

                                pageIndex++;
                            } while (members.Length == pageSize && IsCancellationRequested == false); //don't continue if the app is shutting down
                        }
                    }
                    else
                    {
                        //no node types specified, do all members
                        do
                        {
                            int total;
                            members = _memberService.GetAll(pageIndex, pageSize, out total).ToArray();

                            AddNodesToIndex(GetSerializedMembers(members), type);

                            pageIndex++;
                        } while (members.Length == pageSize && IsCancellationRequested == false); //don't continue if the app is shutting down
                    }
                }
            }
            finally
            {
                stopwatch.Stop();
            }

            DataService.LogService.AddInfoLog(-1, string.Format("PerformIndexAll - End data queries - {0}, took {1}ms", type, stopwatch.ElapsedMilliseconds));
        }
Exemplo n.º 18
0
 protected override IEnumerable <IContentTypeBase> GetAllContentTypes()
 {
     return(_service.GetAll());
 }