Skip to content

Commit

Permalink
feature(REPORT-327626): core samples
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnu committed May 3, 2024
1 parent 925b430 commit 4aa9245
Show file tree
Hide file tree
Showing 257 changed files with 19,788 additions and 3,581 deletions.
31 changes: 14 additions & 17 deletions Controllers/ExternalReportServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public ExternalServer(IWebHostEnvironment hostingEnvironment)
basePath = _hostingEnvironment.WebRootPath;
}

public override List<CatalogItem> GetItems(string folderName, ItemTypeEnum type)
public override List<CatalogItem> GetItems(string folderName, ItemTypeEnum type, string permissionType)
{
List<CatalogItem> _items = new List<CatalogItem>();

string targetFolder = this.basePath + @"\Resources\";
string targetFolder = Path.Combine(this.basePath, "resources");

if (type == ItemTypeEnum.Folder || type == ItemTypeEnum.Report)
{
targetFolder = targetFolder + @"Report\";
targetFolder = Path.Combine(targetFolder, "Report");
if (!(string.IsNullOrEmpty(folderName) || folderName.Trim() == "/"))
{
targetFolder = targetFolder + folderName;
Expand All @@ -47,7 +47,7 @@ public override List<CatalogItem> GetItems(string folderName, ItemTypeEnum type)

if (type == ItemTypeEnum.DataSet)
{
foreach (var file in Directory.GetFiles(targetFolder + "DataSet"))
foreach (var file in Directory.GetFiles(Path.Combine(targetFolder, "DataSet")))
{
CatalogItem catalogItem = new CatalogItem();
catalogItem.Name = Path.GetFileNameWithoutExtension(file);
Expand All @@ -58,7 +58,7 @@ public override List<CatalogItem> GetItems(string folderName, ItemTypeEnum type)
}
else if (type == ItemTypeEnum.DataSource)
{
foreach (var file in Directory.GetFiles(targetFolder + "DataSource"))
foreach (var file in Directory.GetFiles(Path.Combine(targetFolder, "DataSource")))
{
CatalogItem catalogItem = new CatalogItem();
catalogItem.Name = Path.GetFileNameWithoutExtension(file);
Expand Down Expand Up @@ -102,9 +102,8 @@ public override bool CreateReport(string reportName, string folderName, byte[] r

public override System.IO.Stream GetReport()
{
string reportBasePath = @"\Resources\Report\";
string targetFolder = this.basePath + reportBasePath;
string reportPath = Path.HasExtension(this.ReportPath) ? targetFolder + this.ReportPath : targetFolder + this.ReportPath + "." + this.reportType.ToLower();
string targetFolder = Path.Combine(this.basePath, "resources", "Report");
string reportPath = Path.HasExtension(this.ReportPath) ? Path.Combine(targetFolder, this.ReportPath) : Path.Combine(targetFolder, $"{this.ReportPath}.{this.reportType.ToLower()}");

if (File.Exists(reportPath))
{
Expand All @@ -131,9 +130,8 @@ public override bool EditReport(byte[] reportdata)
string reportPath = this.ReportPath.TrimStart('/').TrimEnd('/').Trim();
string reportName = reportPath.Substring(reportPath.IndexOf('/') + 1).Trim();
string catagoryName = reportPath.Substring(0, reportPath.IndexOf('/') > 0 ? reportPath.IndexOf('/') : 0).Trim();
string targetFolder = this.basePath + @"\Resources\Report\";

string reportPat = targetFolder + catagoryName + @"\" + reportName;
string targetFolder = Path.Combine(this.basePath, "resources", "Report");
string reportPat = Path.Combine(targetFolder, catagoryName, reportName);
File.WriteAllBytes(reportPat, reportdata.ToArray());

return true;
Expand All @@ -147,9 +145,8 @@ public override DataSourceDefinition GetDataSourceDefinition(string dataSource)
dataSource = _dataSrcPathHierarchy.Last().TrimStart('/');
}

string targetFolder = this.basePath + @"\Resources\DataSource\";

string dataSourcePath = targetFolder + dataSource + ".rds";
string targetFolder = Path.Combine(this.basePath, "resources", "DataSource");
string dataSourcePath = Path.Combine(targetFolder, $"{dataSource}.rds");

if (File.Exists(dataSourcePath))
{
Expand All @@ -176,8 +173,8 @@ DataSourceDefinition GetDataSourceDefinition(byte[] dataSourceContent, string na

public override SharedDatasetinfo GetSharedDataDefinition(string dataSet)
{
string targetFolder = this.basePath + @"\Resources\DataSet\";
string dataSetPath = targetFolder + dataSet + ".rsd";
string targetFolder = Path.Combine(this.basePath, "resources", "DataSet");
string dataSetPath = Path.Combine(targetFolder, $"{dataSet}.rsd");

if (File.Exists(dataSetPath))
{
Expand Down Expand Up @@ -211,4 +208,4 @@ private Stream GetFileToStream(byte[] _fileContent)
return memStream;
}
}
}
}
12 changes: 7 additions & 5 deletions Controllers/LogExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ public static void RegisterLog4NetConfig(string configPath = "")
{
XmlConfigurator.Configure(repository, new System.IO.FileInfo(configPath));
}
else if (File.Exists(prjDir + "\\Log4Net.config"))
else if (File.Exists(Path.Combine(prjDir, "log4net.config")))
{
XmlConfigurator.Configure(repository, new System.IO.FileInfo(prjDir + "\\Log4Net.config"));
XmlConfigurator.Configure(repository, new System.IO.FileInfo(Path.Combine(prjDir, "log4net.config")));
}
else if (File.Exists(prjDir + "\\logs\\Log4Net.config"))
else if (File.Exists(Path.Combine(prjDir, "logs", "log4net.config")))
{
XmlConfigurator.Configure(repository, new System.IO.FileInfo(prjDir + "\\logs\\Log4Net.config"));
XmlConfigurator.Configure(repository, new System.IO.FileInfo(Path.Combine(prjDir, "logs", "log4net.config")));
}
else
{
Expand All @@ -107,7 +107,9 @@ public static void RegisterLog4NetConfig(FileInfo configInfo)

private static string GetExecutablePath()
{
string path = (string)(log4net.GlobalContext.Properties["LogPath"] + "\\");
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}
Expand Down
7 changes: 4 additions & 3 deletions Controllers/MetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dynamic getReportSampleData(string controllerName)
dynamic sampleData = null;
foreach (dynamic sample in samples)
{
if ((sample.routerPath == "" && sample.basePath == controllerName) || sample.routerPath == controllerName)
if ((sample.controllerName == "" && sample.basePath == controllerName) || sample.controllerName == controllerName)
{
sampleData = sample;
break;
Expand Down Expand Up @@ -48,6 +48,7 @@ public MetaDataInfo updateSampleMetaData(dynamic sampleData)
{
string title = String.IsNullOrEmpty((string)sampleData.metaData.title) ? sampleData.sampleName : sampleData.metaData.title;
string basePath = new Regex(@"(?<!^)(?=[A-Z])").Replace((string)sampleData.basePath, " ", 1);
basePath = string.Join(" ", basePath.Split('-').Select(word => char.ToUpper(word[0]) + word.Substring(1)));
title += " | ASP.NET Core " + basePath.Trim();
title = title.Length < 45 ? title += " | Bold Reports" : title;
return new MetaDataInfo(title, (string)sampleData.metaData.description);
Expand All @@ -60,11 +61,11 @@ public MetaDataInfo updatePreviewMetaData(dynamic sampleData)
string metaContent;
switch ((string)sampleData.basePath)
{
case "ReportViewer":
case "report-viewer":
metaContent = "The ASP.NET Core Bold Report Viewer allows the end-users to visualize the " + title + " report in browsers.";
title += " | Preview | ASP.NET Core Report Viewer";
break;
case "ReportWriter":
case "report-writer":
title += " | Preview | ASP.NET Core Report Writer";
metaContent = "The ASP.NET Core Bold Report Writer allows the end-users to download the report in browsers without visualizing the report.";
break;
Expand Down
3 changes: 2 additions & 1 deletion Controllers/PreviewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

namespace ReportsCoreSamples.Controllers
{

public class PreviewController : MetaData
{
[HttpGet("preview")]
public IActionResult Preview()
{
string foderName = this.ControllerContext.RouteData.Values["controller"].ToString();
Expand Down
13 changes: 8 additions & 5 deletions Controllers/ReportDesignerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,31 @@

namespace ReportsCoreSamples.Controllers
{

[Route("report-designer")]
public class ReportDesignerController : Controller
{
[HttpGet("")]
public IActionResult Index()
{
ViewBag.action = "Preview";
ViewBag.isDesigner = true;
ViewBag.toolbarSettings = new BoldReports.Models.ReportDesigner.ToolbarSettings();
ViewBag.toolbarSettings.Items = BoldReports.ReportDesignerEnums.ToolbarItems.All
& ~BoldReports.ReportDesignerEnums.ToolbarItems.Save & ~BoldReports.ReportDesignerEnums.ToolbarItems.Open;
& ~BoldReports.ReportDesignerEnums.ToolbarItems.New & ~BoldReports.ReportDesignerEnums.ToolbarItems.Save & ~BoldReports.ReportDesignerEnums.ToolbarItems.Open;
string url = this.HttpContext.Request.Host.ToString();
ViewBag.permissionSettings = new BoldReports.Models.ReportDesigner.PermissionSettings();
ViewBag.permissionSettings.DataSource = BoldReports.ReportDesignerEnums.Permission.All & ~BoldReports.ReportDesignerEnums.Permission.Create;
ViewBag.permissionSettings.DataSource = !string.IsNullOrEmpty(url) ? url.Contains("demos.boldreports.com") ? (BoldReports.ReportDesignerEnums.Permission.All & ~BoldReports.ReportDesignerEnums.Permission.Create) : BoldReports.ReportDesignerEnums.Permission.All : BoldReports.ReportDesignerEnums.Permission.All;
this.updateMetaData("RDL");
return View();
}
[HttpGet("rdlc")]
public IActionResult RDLC()
{
ViewBag.action = "Preview";
ViewBag.isDesigner = true;
ViewBag.toolbarSettings = new BoldReports.Models.ReportDesigner.ToolbarSettings();
ViewBag.toolbarSettings.Items = BoldReports.ReportDesignerEnums.ToolbarItems.All
& ~BoldReports.ReportDesignerEnums.ToolbarItems.Save & ~BoldReports.ReportDesignerEnums.ToolbarItems.Open;
& ~BoldReports.ReportDesignerEnums.ToolbarItems.New & ~BoldReports.ReportDesignerEnums.ToolbarItems.Save & ~BoldReports.ReportDesignerEnums.ToolbarItems.Open;
ViewBag.permissionSettings = new BoldReports.Models.ReportDesigner.PermissionSettings();
ViewBag.permissionSettings.DataSource = BoldReports.ReportDesignerEnums.Permission.All & ~BoldReports.ReportDesignerEnums.Permission.Create;
this.updateMetaData("RDLC");
Expand All @@ -42,7 +45,7 @@ dynamic getReportSampleData(string routerPath)
dynamic sampleData = null;
foreach (dynamic sample in samples)
{
if (sample.routerPath == routerPath)
if (sample.controllerName == routerPath)
{
sampleData = sample;
break;
Expand Down
10 changes: 8 additions & 2 deletions Controllers/ReportDesignerWebApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public bool DisposeObjects()
{
try
{
string targetFolder = this._hostingEnvironment.WebRootPath + "\\";
targetFolder += "Cache";
string targetFolder = Path.Combine(this._hostingEnvironment.WebRootPath, "Cache");

if (Directory.Exists(targetFolder))
{
Expand Down Expand Up @@ -118,8 +117,15 @@ public void OnInitReportOptions(ReportViewerOptions reportOption)
string reportName = reportOption.ReportModel.ReportPath;
reportOption.ReportModel.ReportingServer = this.Server;
reportOption.ReportModel.ReportServerUrl = this.ServerURL;
reportOption.ReportModel.EmbedImageData = true;
reportOption.ReportModel.ReportServerCredential = new NetworkCredential("Sample", "Passwprd");

if (reportOption.ReportModel.FontSettings == null)
{
reportOption.ReportModel.FontSettings = new BoldReports.RDL.Data.FontSettings();
}
reportOption.ReportModel.FontSettings.BasePath = Path.Combine(_hostingEnvironment.WebRootPath, "fonts");

}

public void OnReportLoaded(ReportViewerOptions reportOption)
Expand Down
2 changes: 2 additions & 0 deletions Controllers/ReportViewer/BarcodeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers
{
[Route("report-viewer/barcode")]
public class BarcodeController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
2 changes: 2 additions & 0 deletions Controllers/ReportViewer/CompanySalesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers
{
[Route("report-viewer/company-sales")]
public class CompanySalesController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers
{
[Route("report-viewer/conditional-row-formatting")]
public class ConditionalRowFormattingController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers.ReportViewer
{
[Route("report-viewer/consolidated-balance-sheet")]
public class ConsolidatedBalanceSheetController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
2 changes: 2 additions & 0 deletions Controllers/ReportViewer/CustomerSupportAnalysisController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers
{
[Route("report-viewer/customer-support-analysis")]
public class CustomerSupportAnalysisController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
2 changes: 2 additions & 0 deletions Controllers/ReportViewer/DataBarController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers
{
[Route("report-viewer/data-bar")]
public class DataBarController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
2 changes: 2 additions & 0 deletions Controllers/ReportViewer/DynamicChartSeriesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers
{
[Route("report-viewer/dynamic-chart-series")]
public class DynamicChartSeriesController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
2 changes: 2 additions & 0 deletions Controllers/ReportViewer/DynamicColumnsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers
{
[Route("report-viewer/dynamic-columns")]
public class DynamicColumnsController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
2 changes: 2 additions & 0 deletions Controllers/ReportViewer/ExternalParameterReportController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

namespace ReportsCoreSamples.Controllers
{
[Route("report-viewer/external-parameter-report")]
public class ExternalParameterReportController : PreviewController
{
private Microsoft.Extensions.Caching.Memory.IMemoryCache _cache;
public ExternalParameterReportController(Microsoft.Extensions.Caching.Memory.IMemoryCache memoryCache)
{
_cache = memoryCache;
}
[HttpGet("")]
public IActionResult Index()
{
ViewBag.parameterSettings = new BoldReports.Models.ReportViewer.ParameterSettings();
Expand Down
2 changes: 2 additions & 0 deletions Controllers/ReportViewer/GroupingAggregateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers
{
[Route("report-viewer/grouping-aggregate")]
public class GroupingAggregateController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
2 changes: 2 additions & 0 deletions Controllers/ReportViewer/InvoiceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers
{
[Route("report-viewer/invoice")]
public class InvoiceController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
2 changes: 2 additions & 0 deletions Controllers/ReportViewer/LoadLargeDataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers.ReportViewer
{
[Route("report-viewer/load-large-data")]
public class LoadLargeDataController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
2 changes: 2 additions & 0 deletions Controllers/ReportViewer/MailMergeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers
{
[Route("report-viewer/mail-merge")]
public class MailMergeController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ReportsCoreSamples.Controllers
{
[Route("report-viewer/northwind-products-suppliers-report")]
public class NorthwindProductsSuppliersReportController : PreviewController
{
[HttpGet("")]
public IActionResult Index()
{
this.updateMetaData();
Expand Down
Loading

0 comments on commit 4aa9245

Please sign in to comment.