找回密码
 立即注册

QQ登录

只需一步,快速开始

zhengwei_cq

初级会员

55

主题

136

帖子

427

积分

初级会员

积分
427

[已处理] web设计器

zhengwei_cq
初级会员   /  发表于:2021-9-23 11:27  /   查看:1706  /  回复:1
1金币
本帖最后由 Crystal.Li 于 2021-9-24 14:45 编辑

报表设计器在预览时钻取报表提示“找不到xxx文件”的路径,但是在集成在web网页上可以,我自定义了设计的路径,取配置文件中的路径。
请看我的Startup.cs中的代码:
public class Startup
    {
        public static string EmbeddedReportsPrefix = "WebDesigner_MVC_Core.Reports";
        private static readonly DirectoryInfo ResourcesRootDirectory =
             new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "resources" + Path.DirectorySeparatorChar));

        private static readonly DirectoryInfo TemplatesRootDirectory =
            new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "templates" + Path.DirectorySeparatorChar));
        IConfiguration cfg { get; set; }
        public Startup(IConfiguration _cfg)
        {
            this.cfg = _cfg;
        }

        private static readonly DirectoryInfo DataSetsRootDirectory =
            new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "datasets") + Path.DirectorySeparatorChar);
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services
                 .AddReporting()
                 .AddDesigner()
                 .AddSingleton<ITemplatesService>(new FileSystemTemplates(!string.IsNullOrEmpty(cfg["TemplateReportSource"]) ? new DirectoryInfo(Path.Combine(cfg["TemplateReportSource"] + Path.DirectorySeparatorChar)) : new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "resources" + Path.DirectorySeparatorChar))))
                 .AddSingleton<IDataSetsService>(new FileSystemDataSets(DataSetsRootDirectory))
                 .AddMvc(options => options.EnableEndpointRouting = false)
                 .AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseReporting(config => {
                config.UseFileStore(!string.IsNullOrEmpty(cfg["CustomReportSource"]) ? new DirectoryInfo(Path.Combine(cfg["CustomReportSource"] + Path.DirectorySeparatorChar)) : new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "resources" + Path.DirectorySeparatorChar)));
                //config.UseEmbeddedTemplates(EmbeddedReportsPrefix, Assembly.GetAssembly(GetType()));
                //config.UseCompression = true;

            }


            );

            //app.UseReporting(config =>
            //config.UseFileStore(!string.IsNullOrEmpty(cfg["CustomReportSource"]) ? new DirectoryInfo(Path.Combine(cfg["CustomReportSource"] + Path.DirectorySeparatorChar)) : new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "resources" + Path.DirectorySeparatorChar)))
            //);

            app.UseDesigner(config => config.UseFileStore(!string.IsNullOrEmpty(cfg["CustomReportSource"]) ? new DirectoryInfo(Path.Combine(cfg["CustomReportSource"] + Path.DirectorySeparatorChar)) : new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "resources" + Path.DirectorySeparatorChar)), false));

            app.UseStaticFiles();
            app.UseMvc();
        }
    }



配置文件代码:

最佳答案

查看完整内容

您好,这个通过这一段代码看不出,我们这边使用示例工程测试是ok的。一般遇到这种问题,您可以加断点调试一下,看报表路径是否正常。

1 个回复

倒序浏览
最佳答案
最佳答案
Crystal.Li讲师达人认证 悬赏达人认证
论坛元老   /  发表于:2021-9-23 11:27:25
来自 2#
您好,这个通过这一段代码看不出,我们这边使用示例工程测试是ok的。一般遇到这种问题,您可以加断点调试一下,看报表路径是否正常。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部