Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 子报表在设计器中显示,但不在文档查看器[DevExpress]中显示_C#_Asp.net Core_Devexpress - Fatal编程技术网

C# 子报表在设计器中显示,但不在文档查看器[DevExpress]中显示

C# 子报表在设计器中显示,但不在文档查看器[DevExpress]中显示,c#,asp.net-core,devexpress,C#,Asp.net Core,Devexpress,我使用通过存储过程填充的子报表创建了一个主详细信息报表。我正在文档查看器中将主报告作为Url传递以绑定该方法。预览时一切正常,但运行时只显示主报告。 我不知道为什么它不起作用。当我们预览主报表时,它会显示作为组页脚插入主报表中的主报表数据和子报表数据。但当我们运行应用程序时,它只显示主报告数据。子报表根本不显示。我还检查了浏览器控制台上的错误。它很好。 主报表和子报表都有数据源,我们必须给出两个参数来显示预览中显示的数据。 请帮帮我有什么问题。 我已经发布了三个班级的代码 报表存储WEb扩展类

我使用通过存储过程填充的子报表创建了一个主详细信息报表。我正在文档查看器中将主报告作为Url传递以绑定该方法。预览时一切正常,但运行时只显示主报告。 我不知道为什么它不起作用。当我们预览主报表时,它会显示作为组页脚插入主报表中的主报表数据和子报表数据。但当我们运行应用程序时,它只显示主报告数据。子报表根本不显示。我还检查了浏览器控制台上的错误。它很好。 主报表和子报表都有数据源,我们必须给出两个参数来显示预览中显示的数据。 请帮帮我有什么问题。
我已经发布了三个班级的代码

报表存储WEb扩展类

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.ServiceModel;
using System.Threading.Tasks;

namespace CheckReport
{
    public class ReportStorageWebExtension : DevExpress.XtraReports.Web.Extensions.ReportStorageWebExtension
    {
        readonly string reportDirectory;
        const string FileExtension = ".repx";
        public ReportStorageWebExtension(string reportDirectory)
        {
            this.reportDirectory = reportDirectory;
        }
        public override bool CanSetData(string url)
        {
            // Determines whether or not it is possible to store a report by a given URL. 
            // For instance, make the CanSetData method return false for reports that should be read-only in your storage. 
            // This method is called only for valid URLs (i.e., if the IsValidUrl method returned true) before the SetData method is called.
            return true;
        }
        public override bool IsValidUrl(string url)
        {
            // Determines whether or not the URL passed to the current Report Storage is valid. 
            // For instance, implement your own logic to prohibit URLs that contain white spaces or some other special characters. 
            // This method is called before the CanSetData and GetData methods.
            return true;
        }
        public override byte[] GetData(string url)
        {
            // Returns report layout data stored in a Report Storage using the specified URL. 
            // This method is called only for valid URLs after the IsValidUrl method is called.
            try
            {
                return File.ReadAllBytes(Path.Combine(reportDirectory, url + FileExtension));
            }
            catch (Exception ex)
            {
                throw new FaultException(new FaultReason(string.Format("Could not find report '{0}'.", url)), new FaultCode("Server"), "GetData");
            }
        }
        public override Dictionary<string, string> GetUrls()
        {
            // Returns a dictionary of the existing report URLs and display names. 
            // This method is called when running the Report Designer, 
            // before the Open Report and Save Report dialogs are shown and after a new report is saved to a storage.
            return Directory.GetFiles(reportDirectory, "*" + FileExtension)
                                     .Select(Path.GetFileNameWithoutExtension)
                                     .ToDictionary<string, string>(x => x);
        }
        public override void SetData(XtraReport report, string url)
        {
            // Stores the specified report to a Report Storage using the specified URL. 
            // This method is called only after the IsValidUrl and CanSetData methods are called.
            report.SaveLayoutToXml(Path.Combine(reportDirectory, url + FileExtension));
        }
        public override string SetNewData(XtraReport report, string defaultUrl)
        {
            // Stores the specified report using a new URL. 
            // The IsValidUrl and CanSetData methods are never called before this method. 
            // You can validate and correct the specified URL directly in the SetNewData method implementation 
            // and return the resulting URL used to save a report in your storage.
            SetData(report, defaultUrl);
            return defaultUrl;
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.IO;
使用System.Linq;
使用System.ServiceModel;
使用System.Threading.Tasks;
命名空间检查报告
{
公共类ReportStorageWebExtension:DevExpress.XtraReports.Web.Extensions.ReportStorageWebExtension
{
只读字符串报告目录;
常量字符串FileExtension=“.repx”;
公共ReportStorageWebExtension(字符串reportDirectory)
{
this.reportDirectory=reportDirectory;
}
公共覆盖bool CanSetData(字符串url)
{
//确定是否可以按给定URL存储报表。
//例如,对于存储中应为只读的报告,使CanSetData方法返回false。
//在调用SetData方法之前,仅对有效URL(即,如果IsValidUrl方法返回true)调用此方法。
返回true;
}
公共覆盖bool isvalidull(字符串url)
{
//确定传递到当前报表存储的URL是否有效。
//例如,实现您自己的逻辑来禁止包含空格或其他特殊字符的URL。
//此方法在CanSetData和GetData方法之前调用。
返回true;
}
公共覆盖字节[]GetData(字符串url)
{
//使用指定的URL返回存储在报表存储中的报表布局数据。
//在调用IsValidUrl方法后,仅对有效URL调用此方法。
尝试
{
返回File.ReadAllBytes(Path.Combine(reportDirectory,url+FileExtension));
}
捕获(例外情况除外)
{
抛出新的FaultException(新的FaultReason(string.Format(“找不到报告“{0}.”,url)),新的FaultCode(“服务器”),“GetData”);
}
}
公共覆盖字典getURL()
{
//返回现有报表URL和显示名称的字典。
//在运行报表设计器时调用此方法,
//在显示“打开报告”和“保存报告”对话框之前,以及在将新报告保存到存储器之后。
return Directory.GetFiles(reportDirectory,“*”+文件扩展名)
.Select(Path.GetFileNameWithoutExtension)
.ToDictionary(x=>x);
}
公共覆盖void SetData(XtraReport报告,字符串url)
{
//使用指定的URL将指定的报表存储到报表存储中。
//仅在调用IsValidUrl和CanSetData方法后才调用此方法。
report.SaveLayoutToXml(Path.Combine(reportDirectory,url+FileExtension));
}
公共重写字符串SetNewData(XtraReport报告,字符串defaultUrl)
{
//使用新URL存储指定的报告。
//在此方法之前从未调用IsValidUrl和CanSetData方法。
//您可以在SetNewData方法实现中直接验证和更正指定的URL
//并返回用于在存储器中保存报告的结果URL。
SetData(报告,默认URL);
返回defaultUrl;
}
}
}
观众


@{
    ViewData["Title"] = "Report";
}

<h2>Report</h2>

@using DevExpress.AspNetCore
@model DevExpress.XtraReports.UI.XtraReport
<link href="~/node_modules/jquery-ui-dist/jquery-ui.min.css" rel="stylesheet" />
<link href="~/node_modules/devextreme/dist/css/dx.common.css" rel="stylesheet" />
<link href="~/node_modules/devextreme/dist/css/dx.light.css" rel="stylesheet" />
<link href="~/node_modules/@@devexpress/analytics-core/dist/css/dx-analytics.common.css" rel="stylesheet" />
<link href="~/node_modules/@@devexpress/analytics-core/dist/css/dx-analytics.light.css" rel="stylesheet" />
<link href="~/node_modules/devexpress-reporting/dist/css/dx-webdocumentviewer.css" rel="stylesheet" />
<!-- 3rd-party dependencies -->
<script src="~/node_modules/jquery/dist/jquery.js"></script>
<script src="~/node_modules/jquery-ui-dist/jquery-ui.js"></script>
<script src="~/node_modules/knockout/build/output/knockout-latest.js"></script>
<script src="~/node_modules/cldrjs/dist/cldr.js"></script>
<script src="~/node_modules/cldrjs/dist/cldr/event.js"></script>
<script src="~/node_modules/cldrjs/dist/cldr/supplemental.js"></script>
<script src="~/node_modules/cldrjs/dist/cldr/unresolved.js"></script>
<script src="~/node_modules/globalize/dist/globalize.js"></script>
<script src="~/node_modules/globalize/dist/globalize/message.js"></script>
<script src="~/node_modules/globalize/dist/globalize/number.js"></script>
<script src="~/node_modules/globalize/dist/globalize/currency.js"></script>
<script src="~/node_modules/globalize/dist/globalize/date.js"></script>
<script src="~/node_modules/devextreme/dist/js/dx.all.js"></script>
<script src="~/node_modules/@@devexpress/analytics-core/dist/js/dx-analytics-core.min.js"></script>
<script src="~/node_modules/devexpress-reporting/dist/js/dx-webdocumentviewer.min.js"></script>

<script>
    $(function () {
        $("body").addClass("sidebar-xs");
    });
</script>
<input type="hidden" class="reportType" value="@ViewBag.reportType">
<input type="hidden" class="reportName" value="@ViewBag.ReportName">
<input type="hidden" class="reportType" value="NonParametrize">
@if (ViewBag.reportType == "Parametriz")
{
    <style type="text/css">
        .dxrd-preview .dxrd-right-panel-collapse, .dxrd-preview .dxrd-right-panel, .dxrd-preview .dxrd-right-tabs {
            display: none;
        }

        .dxrd-designer-wrapper .dx-shadow.dxrd-tab-panel-right {
            display: none;
        }
    </style>
    @Html.DevExpress().WebDocumentViewer("DocumentViewer").Height("1000px").Bind(Model);
}
else
{
    @Html.DevExpress().WebDocumentViewer("DocumentViewer").Height("1000px").Bind(ViewBag.ReportName);
}


@{
ViewData[“标题”]=“报告”;
}
报告
@使用DevExpress.AspNetCore
@型号DevExpress.XtraReports.UI.XtraReport
$(函数(){
$(“body”).addClass(“侧边栏xs”);
});
@如果(ViewBag.reportType==“Parameteriz”)
{
.dxrd预览.dxrd右面板折叠.dxrd预览.dxrd右面板.dxrd预览.dxrd右选项卡{
显示:无;
}
.dxrd设计器包装.dx-shadow.dxrd-tab-panel-right{
显示:无;
}
@Html.DevExpress().WebDocumentViewer(“DocumentViewer”).Height(“1000px”).Bind(模型);
}
其他的
{
@Html.DevExpress().WebDocumentViewer(“DocumentViewer”).Height(“1000px”).Bind(ViewBag.ReportName);
}
Startup.cs

using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using DevExpress.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;

namespace CheckReport
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services.AddDevExpressControls();
            services.AddMvc();
        }

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

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, "node_modules")),
                RequestPath = "/node_modules"
            });
            var reportDirectory = Path.Combine(env.ContentRootPath, "Report");
            DevExpress.XtraReports.Web.Extensions.ReportStorageWebExtension.RegisterExtensionGlobal(new ReportStorageWebExtension(reportDirectory));
            DevExpress.XtraReports.Configuration.Settings.Default.UserDesignerOptions.DataBindingMode = DevExpress.XtraReports.UI.DataBindingMode.Expressions;
            app.UseDevExpressControls();
        }

    }
}
使用System.Collections.Generic;
使用System.IO;
使用System.Linq;
使用System.Threading.Tasks;
使用DevExpress.AspNetCore;
使用Microsoft.AspNetCore.Builder;
使用Microsoft.AspNetCore.Hosting;
使用Microsoft.AspNetCore.Http;
使用Microsoft.AspNetCore.HttpsPolicy;
使用Microsoft.AspNetCore.Mvc;
使用Microsoft.Extensions.Configuration;
使用Microsoft.Extensions.DependencyInjection;
使用Microsoft.Extensions.FileProviders;
命名空间检查报告
{
公营创业
{
公共启动(IConfiguration配置)
{
配置=配置;
}
公共IConfiguration配置{get;}
//此方法由运行时调用。请使用此方法将服务添加到容器中。
public void配置服务(IServiceCollection服务)
{
配置(选项=>
{
//这个lambda决定了我们
@Html.DevExpress().WebDocumentViewer("DocumentViewer").Height("1000px").Bind(new aspNetCoreReportingApp.Reports.DSR_Khudian());