Skip to content

Commit 9ada3c9

Browse files
feature(REPORT-461761): Bold Reports 11.1 Release Changes
1 parent a8f7c98 commit 9ada3c9

File tree

176 files changed

+9430
-629
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+9430
-629
lines changed

Controllers/ExternalReportServer.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,23 @@ public override List<CatalogItem> GetItems(string folderName, ItemTypeEnum type,
4747

4848
if (type == ItemTypeEnum.DataSet)
4949
{
50-
foreach (var file in Directory.GetFiles(Path.Combine(targetFolder, "DataSet")))
50+
var dataSetProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(Path.Combine(targetFolder, "DataSet"));
51+
foreach (var file in dataSetProvider.GetDirectoryContents("").Where(f => !f.IsDirectory))
5152
{
5253
CatalogItem catalogItem = new CatalogItem();
53-
catalogItem.Name = Path.GetFileNameWithoutExtension(file);
54+
catalogItem.Name = Path.GetFileNameWithoutExtension(file.Name);
5455
catalogItem.Type = ItemTypeEnum.DataSet;
5556
catalogItem.Id = Regex.Replace(catalogItem.Name, @"[^0-9a-zA-Z]+", "_");
5657
_items.Add(catalogItem);
5758
}
5859
}
5960
else if (type == ItemTypeEnum.DataSource)
6061
{
61-
foreach (var file in Directory.GetFiles(Path.Combine(targetFolder, "DataSource")))
62+
var dataSourceProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(Path.Combine(targetFolder, "DataSource"));
63+
foreach (var file in dataSourceProvider.GetDirectoryContents("").Where(f => !f.IsDirectory))
6264
{
6365
CatalogItem catalogItem = new CatalogItem();
64-
catalogItem.Name = Path.GetFileNameWithoutExtension(file);
66+
catalogItem.Name = Path.GetFileNameWithoutExtension(file.Name);
6567
catalogItem.Type = ItemTypeEnum.DataSource;
6668
catalogItem.Id = Regex.Replace(catalogItem.Name, @"[^0-9a-zA-Z]+", "_");
6769
_items.Add(catalogItem);
@@ -82,10 +84,11 @@ public override List<CatalogItem> GetItems(string folderName, ItemTypeEnum type,
8284
{
8385
string reportTypeExt = this.reportType == "RDLC" ? ".rdlc" : ".rdl";
8486

85-
foreach (var file in Directory.GetFiles(targetFolder, "*" + reportTypeExt))
87+
var reportProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(targetFolder);
88+
foreach (var file in reportProvider.GetDirectoryContents("").Where(f => !f.IsDirectory && f.Name.EndsWith(reportTypeExt)))
8689
{
8790
CatalogItem catalogItem = new CatalogItem();
88-
catalogItem.Name = Path.GetFileNameWithoutExtension(file);
91+
catalogItem.Name = Path.GetFileNameWithoutExtension(file.Name);
8992
catalogItem.Type = ItemTypeEnum.Report;
9093
catalogItem.Id = Regex.Replace(catalogItem.Name, @"[^0-9a-zA-Z]+", "_");
9194
_items.Add(catalogItem);
@@ -116,6 +119,7 @@ public override System.IO.Stream GetReport()
116119
private Stream ReadFiles(string filePath)
117120
{
118121
using (FileStream fileStream = File.OpenRead(filePath))
122+
fileStream.Position = 0;
119123
{
120124
fileStream.Position = 0;
121125
MemoryStream memStream = new MemoryStream();
@@ -132,8 +136,10 @@ public override bool EditReport(byte[] reportdata)
132136
string catagoryName = reportPath.Substring(0, reportPath.IndexOf('/') > 0 ? reportPath.IndexOf('/') : 0).Trim();
133137
string targetFolder = Path.Combine(this.basePath, "resources", "Report");
134138
string reportPat = Path.Combine(targetFolder, catagoryName, reportName);
139+
return true;
135140
File.WriteAllBytes(reportPat, reportdata.ToArray());
136141

142+
137143
return true;
138144
}
139145

@@ -197,7 +203,9 @@ T DeseralizeObj<T>(Stream str)
197203
{
198204
XmlSerializer serializer = new XmlSerializer(typeof(T));
199205
XmlReader reader = XmlReader.Create(str);
206+
{
200207
return (T)serializer.Deserialize(reader);
208+
memStream.Write(_fileContent, 0, _fileContent.Length);
201209
}
202210

203211
private Stream GetFileToStream(byte[] _fileContent)

Controllers/LogExtension.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,23 @@ public static void RegisterLog4NetConfig(string configPath = "")
7777
var prjDir = Path.GetFullPath(Path.Combine(folderPath));
7878
if (!string.IsNullOrEmpty(configPath) && File.Exists(configPath))
7979
{
80-
XmlConfigurator.Configure(repository, new System.IO.FileInfo(configPath));
80+
var fileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(Path.GetDirectoryName(configPath));
81+
var fileInfo = fileProvider.GetFileInfo(Path.GetFileName(configPath));
82+
using var configStream = fileInfo.CreateReadStream();
83+
XmlConfigurator.Configure(repository, configStream);
8184
}
8285
else if (File.Exists(Path.Combine(prjDir, "log4net.config")))
8386
{
84-
XmlConfigurator.Configure(repository, new System.IO.FileInfo(Path.Combine(prjDir, "log4net.config")));
87+
var configFile = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(prjDir).GetFileInfo("log4net.config");
88+
using var configStream = configFile.CreateReadStream();
89+
XmlConfigurator.Configure(repository, configStream);
8590
}
8691
else if (File.Exists(Path.Combine(prjDir, "logs", "log4net.config")))
8792
{
88-
XmlConfigurator.Configure(repository, new System.IO.FileInfo(Path.Combine(prjDir, "logs", "log4net.config")));
93+
var fileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(Path.Combine(prjDir, "logs"));
94+
var configFile = fileProvider.GetFileInfo("log4net.config");
95+
using var configStream = configFile.CreateReadStream();
96+
XmlConfigurator.Configure(repository, configStream);
8997
}
9098
else
9199
{

Controllers/PreviewController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public IActionResult Preview()
1515
string foderName = this.ControllerContext.RouteData.Values["controller"].ToString();
1616
ViewBag.action = "Preview";
1717
ViewBag.isDesigner = false;
18-
if (foderName == "ExternalParameterReport")
18+
if (foderName == "ExternalParameterReport" || foderName == "MultiLanguageReport")
1919
{
2020
ViewBag.parameterSettings = new BoldReports.Models.ReportViewer.ParameterSettings();
2121
ViewBag.parameterSettings.HideParameterBlock = true;

Controllers/ReportDesignerWebApiController.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using Microsoft.Extensions.Configuration;
34
using System.Linq;
45
using System.Threading.Tasks;
56
using Microsoft.AspNetCore.Http;
@@ -24,6 +25,7 @@ public class ReportDesignerWebApiController : Controller, IReportDesignerControl
2425
{
2526
private Microsoft.Extensions.Caching.Memory.IMemoryCache _cache;
2627
private IWebHostEnvironment _hostingEnvironment;
28+
private readonly IConfiguration _configuration;
2729
internal ReportHelperSettings _helperSettings = null;
2830
internal ExternalServer Server
2931
{
@@ -41,10 +43,11 @@ internal ReportHelperSettings HelperSettings
4143
set { this._helperSettings = value; }
4244
}
4345

44-
public ReportDesignerWebApiController(Microsoft.Extensions.Caching.Memory.IMemoryCache memoryCache, IWebHostEnvironment hostingEnvironment)
46+
public ReportDesignerWebApiController(Microsoft.Extensions.Caching.Memory.IMemoryCache memoryCache, IWebHostEnvironment hostingEnvironment, IConfiguration configuration)
4547
{
4648
_cache = memoryCache;
4749
_hostingEnvironment = hostingEnvironment;
50+
_configuration = configuration;
4851
ExternalServer externalServer = new ExternalServer(_hostingEnvironment);
4952
this.Server = externalServer;
5053
this.ServerURL = "Sample";
@@ -77,13 +80,15 @@ public bool DisposeObjects()
7780

7881
for (var index = 0; index < dirs.Length; index++)
7982
{
80-
string[] files = Directory.GetFiles(dirs[index]);
83+
var dirProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(dirs[index]);
84+
var files = dirProvider.GetDirectoryContents("").Where(f => !f.IsDirectory).Select(f => Path.Combine(dirs[index], f.Name)).ToArray();
8185

8286
var fileCount = 0;
8387
for (var fileIndex = 0; fileIndex < files.Length; fileIndex++)
8488
{
85-
FileInfo fi = new FileInfo(files[fileIndex]);
86-
if (fi.LastAccessTimeUtc < DateTime.UtcNow.AddDays(-2))
89+
var fileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(Path.GetDirectoryName(files[fileIndex]));
90+
var fileInfo = fileProvider.GetFileInfo(Path.GetFileName(files[fileIndex]));
91+
if (fileInfo.Exists && fileInfo.LastModified < DateTimeOffset.UtcNow.AddDays(-2))
8792
{
8893
fileCount++;
8994
}
@@ -118,7 +123,8 @@ public void OnInitReportOptions(ReportViewerOptions reportOption)
118123
reportOption.ReportModel.ReportingServer = this.Server;
119124
reportOption.ReportModel.ReportServerUrl = this.ServerURL;
120125
reportOption.ReportModel.EmbedImageData = true;
121-
reportOption.ReportModel.ReportServerCredential = new NetworkCredential("Sample", "Passwprd");
126+
reportOption.ReportModel.ReportServerCredential = new NetworkCredential(_configuration["reportServer:userName"], _configuration["reportServer:password"]);
127+
reportOption.ReportModel.ExportResources.BrowserExecutablePath = Path.Combine(_hostingEnvironment.WebRootPath, "puppeteer", "Win-901912", "chrome-win");
122128

123129
if (reportOption.ReportModel.FontSettings == null)
124130
{
@@ -145,7 +151,7 @@ public object PostFormDesignerAction()
145151
{
146152
return ReportDesignerHelper.ProcessDesigner(null, this, null, this._cache);
147153
}
148-
154+
149155
[HttpPost]
150156
public object PostFormReportAction()
151157
{
@@ -203,7 +209,6 @@ public bool SetData(string key, string itemId, ItemInfo itemData, out string err
203209
{
204210
System.IO.File.Delete(writePath);
205211
}
206-
207212
System.IO.File.WriteAllBytes(writePath, bytes);
208213
stream.Close();
209214
stream.Dispose();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
7+
namespace ReportsCoreSamples.Controllers
8+
{
9+
[Route("report-viewer/dynamic-logos")]
10+
public class DynamicLogosController : PreviewController
11+
{
12+
[HttpGet("")]
13+
public IActionResult Index()
14+
{
15+
this.updateMetaData();
16+
return View();
17+
}
18+
}
19+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using ReportsCoreSamples.Models;
6+
using Microsoft.Extensions.Caching.Memory;
7+
using Microsoft.AspNetCore.Mvc;
8+
9+
namespace ReportsCoreSamples.Controllers
10+
{
11+
[Route("report-viewer/multi-language-report")]
12+
public class MultiLanguageReportController : PreviewController
13+
{
14+
private Microsoft.Extensions.Caching.Memory.IMemoryCache _cache;
15+
public MultiLanguageReportController(Microsoft.Extensions.Caching.Memory.IMemoryCache memoryCache)
16+
{
17+
_cache = memoryCache;
18+
}
19+
[HttpGet("")]
20+
public IActionResult Index()
21+
{
22+
ViewBag.parameterSettings = new BoldReports.Models.ReportViewer.ParameterSettings();
23+
ViewBag.parameterSettings.HideParameterBlock = true;
24+
this.updateMetaData();
25+
return View();
26+
}
27+
}
28+
}

Controllers/ReportViewerWebApiController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ public void OnInitReportOptions(ReportViewerOptions reportOption)
6868
{
6969
reportPath += ".rdlc";
7070
}
71-
FileStream reportStream = new FileStream(Path.Combine(basePath, "resources", "Report", reportPath), FileMode.Open, FileAccess.Read);
72-
reportOption.ReportModel.Stream = reportStream;
71+
var reportFileInfo = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(Path.Combine(basePath, "resources", "Report")).GetFileInfo(reportPath);
72+
reportOption.ReportModel.Stream = reportFileInfo.Exists ? reportFileInfo.CreateReadStream() : throw new FileNotFoundException();
7373

7474
if (reportOption.ReportModel.FontSettings == null)
7575
{
7676
reportOption.ReportModel.FontSettings = new BoldReports.RDL.Data.FontSettings();
7777
}
7878
reportOption.ReportModel.FontSettings.BasePath = Path.Combine(_hostingEnvironment.WebRootPath, "fonts");
79-
79+
reportOption.ReportModel.ExportResources.BrowserExecutablePath = Path.Combine(_hostingEnvironment.WebRootPath, "puppeteer", "Win-901912", "chrome-win");
8080
}
8181

8282
// Method will be called when reported is loaded with internally to start to layout process with ReportHelper.
@@ -92,7 +92,7 @@ public object GetResource(ReportResource resource)
9292
{
9393
return ReportHelper.GetResource(resource, this, this._cache);
9494
}
95-
95+
9696
[HttpPost]
9797
public object PostFormReportAction()
9898
{

Controllers/ReportWriterController.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ public IActionResult Generate(string reportName, string type)
5959
reportWriter.ReportServerCredential = System.Net.CredentialCache.DefaultCredentials;
6060

6161
reportWriter.ReportProcessingMode = ProcessingMode.Remote;
62-
reportWriter.ExportSettings = new customBrowsertype(_hostingEnvironment);
6362
reportWriter.ExportResources.BrowserType = ExportResources.BrowserTypes.External;
6463
reportWriter.ExportResources.ResourcePath = Path.Combine(basePath, "puppeteer");
64+
string puppeteerPath = reportWriter.ExportResources.ResourcePath + @"/Win-901912/chrome-win/chrome.exe";
65+
reportWriter.ExportSettings = new customBrowsertype(puppeteerPath);
66+
reportWriter.ExportResources.BrowserExecutablePath = Path.GetDirectoryName(puppeteerPath);
6567

66-
FileStream inputStream = new FileStream(Path.Combine(basePath, "resources", "Report", reportName + ".rdl"), FileMode.Open, FileAccess.Read);
68+
var reportFileInfo = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(Path.Combine(basePath, "resources", "Report")).GetFileInfo(reportName + ".rdl");
69+
var inputStream = reportFileInfo.Exists ? reportFileInfo.CreateReadStream() : throw new FileNotFoundException();
6770
reportWriter.LoadReport(inputStream);
6871

6972
reportWriter.ExportResources.Scripts = new List<string>
@@ -139,20 +142,18 @@ public IActionResult Generate(string reportName, string type)
139142

140143
public class customBrowsertype : ExportSettings
141144
{
142-
private IWebHostEnvironment _hostingEnvironment;
145+
private string _puppeteerPath;
143146

144-
public customBrowsertype(IWebHostEnvironment hostingEnvironment)
147+
public customBrowsertype(string path)
145148
{
146-
_hostingEnvironment = hostingEnvironment;
149+
_puppeteerPath = path;
147150
}
148151
public override string GetImageFromHTML(string url)
149152
{
150153
return ConvertBase64(url).Result;
151154
}
152155
public async Task<string> ConvertBase64(string url)
153156
{
154-
string puppeteerChromeExe = "";
155-
puppeteerChromeExe = Path.Combine(_hostingEnvironment.WebRootPath, "puppeteer", "Win-901912", "chrome-win", "chrome.exe");
156157
await using var browser = await PuppeteerSharp.Puppeteer.LaunchAsync(new PuppeteerSharp.LaunchOptions
157158
{
158159
Headless = true,
@@ -167,7 +168,7 @@ public async Task<string> ConvertBase64(string url)
167168
"--dump-blink-runtime-call-stats",
168169
"--profiling-flush",
169170
},
170-
ExecutablePath = puppeteerChromeExe
171+
ExecutablePath = _puppeteerPath
171172
});
172173
await using var page = await browser.NewPageAsync();
173174
await page.GoToAsync(url);

Models/SampleData.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ namespace ReportsCoreSamples.Models
1010
public class SampleData
1111
{
1212
private IWebHostEnvironment _hostingEnvironment;
13-
public SampleData(IWebHostEnvironment environment)
13+
public SampleData(IWebHostEnvironment environment)
1414
{
1515
_hostingEnvironment = environment;
1616
}
1717
public dynamic getSampleData()
1818
{
19-
string json = System.IO.File.ReadAllText(_hostingEnvironment.WebRootPath + "/samples.json");
20-
dynamic sampleJson = JsonConvert.DeserializeObject(json);
21-
return sampleJson;
19+
var fileInfo = _hostingEnvironment.WebRootFileProvider.GetFileInfo("samples.json");
20+
using var reader = new System.IO.StreamReader(fileInfo.CreateReadStream());
21+
return new JsonSerializer().Deserialize(reader, typeof(object));
2222
}
2323
}
2424
}
-35.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)