Я создал подробный отчет с использованием подотчетов, которые заполняются с помощью хранимых процедур. Я передаю основной отчет как URL в программе просмотра документов, чтобы связать метод. Все хорошо, когда мы делаем предварительный просмотр, но во время выполнения отображается только основной отчет. Я понятия не имею, почему это не работает. при предварительном просмотре основного отчета в нем отображаются основные данные отчета и данные подотчета, которые вставляются в основной отчет как нижний колонтитул группы. но когда мы запускаем приложение, оно показывает только данные основного отчета. Подотчет не отображается вообще. Я также проверил ошибку на консоли браузера. И это нормально. И основной отчет, и дополнительный отчет имеют источник данных, и мы должны предоставить два параметра для отображения данных, которые отображаются в предварительном просмотре. Пожалуйста, помогите мне в чем проблема ..
Я разместил код трех классов.
Класс хранения веб-отчетов для хранения
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;
}
}
}
Просмотрщик
@{
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);
}
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();
}
}
}