public static IPagesBuilder AddRazorContentPage(this IPagesBuilder builder, Action <ContentPageOptions> optionAction)
        {
            var contentPageOptions = new ContentPageOptions();

            optionAction?.Invoke(contentPageOptions);

            var services = builder.Services;

            services.AddHttpContextAccessor();

            services.Configure <RazorPagesOptions>(options =>
            {
                options.Conventions.AddPageRoute(contentPageOptions.ContentPageName, "{**url}");
            });

            services.AddTransient <Url.IPageLinkGenerator, Url.RazorPageLinkGenerator>();
            services.AddTransient <Files.IFileUrlGenerator, Url.FileUrlGenerator>();

            services.AddSingleton <Views.IViewLocator, Views.RazorViewLocator>();
            services.AddScoped <Views.IViewRenderService, Views.RazorViewRenderService>();

            services.Configure(optionAction);

            return(builder);
        }
Пример #2
0
        internal static ListResult <ContentListItem> GetList(ContentListFilter filter, ListCommand cmd, int[] selectedContentIDs = null, int workflowId = 0)
        {
            using (var scope = new QPConnectionScope())
            {
                var options = new ContentPageOptions
                {
                    ContentName    = filter.ContentName,
                    SiteId         = filter.SiteId,
                    IsVirtual      = filter.IsVirtual,
                    GroupId        = filter.GroupId,
                    Mode           = filter.Mode,
                    SelectedIDs    = selectedContentIDs,
                    UserId         = QPContext.CurrentUserId,
                    UseSecurity    = !QPContext.IsAdmin,
                    IsAdmin        = QPContext.IsAdmin,
                    SortExpression = cmd.SortExpression,
                    StartRecord    = cmd.StartRecord,
                    PageSize       = cmd.PageSize,
                    LanguageId     = QPContext.CurrentUserIdentity.LanguageId,
                    CustomFilter   = filter.CustomFilter
                };

                var rows = Common.GetContentsPage(scope.DbConnection, options, out var totalRecords);
                return(new ListResult <ContentListItem> {
                    Data = MapperFacade.ContentListItemRowMapper.GetBizList(rows.ToList()), TotalRecords = totalRecords
                });
            }
        }
Пример #3
0
 public RazorPageLinkGenerator(LinkGenerator linkGenerator, IHttpContextAccessor httpContextAccessor, IPageUrlHelper pageUrlHelper, IOptions <ContentPageOptions> contentPageOptions)
 {
     this.linkGenerator       = linkGenerator ?? throw new ArgumentNullException(nameof(linkGenerator));
     this.httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
     this.pageUrlHelper       = pageUrlHelper ?? throw new ArgumentNullException(nameof(pageUrlHelper));
     this.contentPageOptions  = contentPageOptions?.Value ?? throw new ArgumentNullException(nameof(contentPageOptions.Value));
 }