轉(zhuǎn)帖|使用教程|編輯:鮑佳佳|2020-07-13 15:57:10.080|閱讀 326 次
概述:本文描述了如何將整體報告應(yīng)用程序分為兩部分,ActiveReports允許您將報表存儲與服務(wù)分離。在更新或修改報告后,您無需重建它,并且分離為報告管理提供了更大的自由度。對于顯示報告的應(yīng)用程序和Web設(shè)計(jì)器使用相同的存儲。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
ActiveReports允許您將報表存儲與服務(wù)分離。在更新或修改報告后,您無需重建它,并且分離為報告管理提供了更大的自由度。對于顯示報告的應(yīng)用程序和Web設(shè)計(jì)器使用相同的存儲。
以下教程介紹了如何設(shè)置報告服務(wù)應(yīng)用程序,以便它從Azure文件獲取報告。
注意:為了簡單起見,本教程使用Monolith應(yīng)用程序,但是相同的代碼可以與單獨(dú)的Reporting Service應(yīng)用程序一起使用。GrapeCity.ActiveReports
5.將appsettings.json文件添加到項(xiàng)目中
6.替換以下內(nèi)容:{ "connectionString": "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=StorageAccountKeyEndingIn==;EndpointSuffix=core.windows.net", "share": "myshare" }7.將AzureReportsStorage.cs文件添加到項(xiàng)目中
public class AzureReportsStorage { private Microsoft.Azure.Storage.File.CloudFileShare _share; public AzureReportsStorage(string connString, string shareName) { var storageAccount = Microsoft.Azure.Storage.CloudStorageAccount.Parse(connString); // Create a CloudFileClient object for credentialed access to Azure Files. var fileClient = storageAccount.CreateCloudFileClient(); // Get a reference to the file share we created previously. this._share = fileClient.GetShareReference(shareName); } public GrapeCity.ActiveReports.PageReportModel.Report GetReport(string fileName) { if (this._share.Exists()) { // Get a reference to the root directory for the share. Microsoft.Azure.Storage.File.CloudFileDirectory rootDir = _share.GetRootDirectoryReference(); // Ensure that the directory exists. if (rootDir.Exists()) { // Get a reference to the file we created previously. Microsoft.Azure.Storage.File.CloudFile file = rootDir.GetFileReference(fileName); // Ensure that the file exists. if (file.Exists()) { var ms = new System.IO.MemoryStream(); file.DownloadToStream(ms); ms.Position = 0; using (var reader = new System.IO.StreamReader(ms)) { var rep = new GrapeCity.ActiveReports.PageReport(reader); return rep.Report; } } else { return null; } } else { return null; } } else { return null; } } }9.在Startup.cs文件中修改Startup構(gòu)造函數(shù),以便它接受IConfiguration實(shí)例并通過傳遞從appsettings.json中讀取連接字符串和共享名來初始化AzureReportsStorage類的實(shí)例:
private AzureReportsStorage _storage; public Startup(IConfiguration configuration) { _storage = new AzureReportsStorage(configuration["connectionString"], configuration["share"]); }10.修改Startup.Configure方法的代碼,以便報告服務(wù)從云存儲獲取報告
app.UseReporting(settings => { // settings.UseEmbeddedTemplates(EmbeddedReportsPrefix, Assembly.GetAssembly(GetType())); settings.UseCustomStore((reportName) => { return this._storage.GetReport(reportName); }); settings.UseCompression = true; });11.打開wwwroot \ index.html文件
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn