/// <summary>
        /// Sorts the specified list.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <returns></returns>
        protected IQueryable <Taxon> Sort(IQueryable <Taxon> list)
        {
            int?totalCount = 1;

            string sortExp = this.SortExpression;

            try
            {
                if (this.SortExpression == "AsSetManually")
                {
                    sortExp = string.Empty;
                }
                list = DataProviderBase.SetExpressions(query: list,
                                                       filterExpression: null,
                                                       orderExpression: sortExp,
                                                       skip: null,
                                                       take: null,
                                                       totalCount: ref totalCount);
            }
            catch (Exception)
            {
                list = DataProviderBase.SetExpressions(query: list,
                                                       filterExpression: null,
                                                       orderExpression: DefaultSortExpression,
                                                       skip: null,
                                                       take: null,
                                                       totalCount: ref totalCount);
            }
            return(list);
        }
        protected override IQueryable <TItem> SetExpression <TItem>(IQueryable <TItem> query, string filterExpression, string sortExpr, int?itemsToSkip, int?itemsToTake, ref int?totalCount)
        {
            try
            {
                query = DataProviderBase.SetExpressions(
                    query,
                    filterExpression,
                    sortExpr,
                    itemsToSkip,
                    itemsToTake,
                    ref totalCount);
            }
            catch (MemberAccessException)
            {
                query = DataProviderBase.SetExpressions(
                    query,
                    filterExpression,
                    ListsModel.DefaultSortExpression,
                    itemsToSkip,
                    itemsToTake,
                    ref totalCount);
            }

            return(query);
        }
Exemple #3
0
        private dynamic[] SetExpression(IQueryable <IDataItem> query, string filterExpression, string sortExpr, int?itemsToSkip, int?itemsToTake, ref int?totalCount)
        {
            if (sortExpr == "AsSetManually")
            {
                query = DataProviderBase.SetExpressions(
                    query,
                    filterExpression,
                    string.Empty,
                    null,
                    null,
                    ref totalCount);

                query = query.OfType <ILifecycleDataItemGeneric>()
                        .Select(x => new
                {
                    item       = x,
                    orderIndex = this.selectedItemsIds.IndexOf(x.OriginalContentId.ToString()) >= 0 ?
                                 this.selectedItemsIds.IndexOf(x.OriginalContentId.ToString()) :
                                 this.selectedItemsIds.IndexOf(x.Id.ToString())
                })
                        .OrderBy(x => x.orderIndex)
                        .Select(x => x.item);

                if (itemsToSkip.HasValue && itemsToSkip.Value > 0)
                {
                    query = query.Skip(itemsToSkip.Value);
                }

                if (itemsToTake.HasValue && itemsToTake.Value > 0)
                {
                    query = query.Take(itemsToTake.Value);
                }
            }
            else
            {
                try
                {
                    query = DataProviderBase.SetExpressions(
                        query,
                        filterExpression,
                        sortExpr,
                        itemsToSkip,
                        itemsToTake,
                        ref totalCount);
                }
                catch (MemberAccessException)
                {
                    this.SortExpression = DefaultSortExpression;
                    query = DataProviderBase.SetExpressions(
                        query,
                        filterExpression,
                        this.SortExpression,
                        itemsToSkip,
                        itemsToTake,
                        ref totalCount);
                }
            }

            return(query.ToArray <dynamic>());
        }
        private List <ScheduledTaskData> GetScheduledTasks()
        {
            var manager = SchedulingManager.GetManager();

            // we don't need total count
            int?count = null;

            var tasks = DataProviderBase.SetExpressions(manager.GetTaskData(),
                                                        FilterExpression,
                                                        OrderExpression,
                                                        null,
                                                        null,
                                                        ref count);

            return(tasks.ToList());
        }
Exemple #5
0
        // Base SetExpression applyes ILifecycleDataItemGeneric filter when sort is AsSetManually, which is not applicable on blogs.
        /// <inheritDoc/>
        protected override IQueryable <TItem> SetExpression <TItem>(IQueryable <TItem> query, string filterExpression, string sortExpr, int?itemsToSkip, int?itemsToTake, ref int?totalCount)
        {
            if (sortExpr == "AsSetManually")
            {
                IList <string> selectedItemsIds = new List <string>();
                if (!this.SerializedSelectedItemsIds.IsNullOrEmpty())
                {
                    selectedItemsIds = JsonSerializer.DeserializeFromString <IList <string> >(this.SerializedSelectedItemsIds);
                }

                query = DataProviderBase.SetExpressions(
                    query,
                    filterExpression,
                    string.Empty,
                    null,
                    null,
                    ref totalCount);

                query = query.Select(x => new
                {
                    item       = x,
                    orderIndex = selectedItemsIds.IndexOf(x.Id.ToString())
                })
                        .OrderBy(x => x.orderIndex)
                        .Select(x => x.item)
                        .OfType <TItem>();

                if (itemsToSkip.HasValue && itemsToSkip.Value > 0)
                {
                    query = query.Skip(itemsToSkip.Value);
                }

                if (itemsToTake.HasValue && itemsToTake.Value > 0)
                {
                    query = query.Take(itemsToTake.Value);
                }
            }
            else
            {
                query = base.SetExpression <TItem>(query, filterExpression, sortExpr, itemsToSkip, itemsToTake, ref totalCount);
            }

            return(query);
        }
Exemple #6
0
        /// <summary>
        /// Gets the email templates.
        /// </summary>
        /// <param name="filterExpression">The filter expression.</param>
        /// <returns></returns>
        public static IDictionary <Guid, string> GetEmailTemplates(string filterExpression)
        {
            var pageManager = PageManager.GetManager();
            IQueryable <ControlPresentation> allTemplates;

            allTemplates = pageManager.GetPresentationItems <ControlPresentation>();
            var layoutTemplates   = allTemplates.Where(tmpl => tmpl.DataType == Presentation.EmailTemplate);
            int?totalCount        = 0;
            var filteredTemplates = DataProviderBase.SetExpressions(layoutTemplates, filterExpression, string.Empty, 0, 0, ref totalCount);

            IDictionary <Guid, string> templateViewModel = new Dictionary <Guid, string>();

            foreach (var template in filteredTemplates)
            {
                templateViewModel.Add(template.Id, template.Name);
            }

            return(templateViewModel);
        }
        protected IQueryable SetExpression(string filterExpression, string sortExpr, int?itemsToSkip, int?itemsToTake, ref int?totalCount)
        {
            var profileType = TypeResolutionService.ResolveType(this.ProfileTypeFullName);

            var skip = itemsToSkip.HasValue ? itemsToSkip.Value : 0;
            var take = itemsToTake.HasValue ? itemsToTake.Value : 0;

            IQueryable query         = this.Manager.Provider.GetItems(profileType, null, null, 0, 0).AsQueryable();
            var        userProviders = UserManager.GetManager().GetContextProviders().Select(p => p.Name).ToArray();

            query = query.Cast <UserProfile>().Where(p => p.UserLinks.Any(l => userProviders.Contains(l.MembershipManagerInfo.ProviderName)));

            try
            {
                query = DataProviderBase.SetExpressions(
                    query,
                    filterExpression,
                    sortExpr,
                    skip,
                    take,
                    ref totalCount);
            }
            catch (MemberAccessException)
            {
                this.SortExpression = DefaultSortExpression;
                query = DataProviderBase.SetExpressions(
                    query,
                    filterExpression,
                    null,
                    skip,
                    take,
                    ref totalCount).AsQueryable();
            }

            return(query);
        }