Skip to content

Commit e024150

Browse files
vishnukarthickthangasamy
authored andcommitted
feature(REPORT-327626): core samples
1 parent 925b430 commit e024150

File tree

257 files changed

+19788
-3581
lines changed

Some content is hidden

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

257 files changed

+19788
-3581
lines changed

Controllers/ExternalReportServer.cs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ public ExternalServer(IWebHostEnvironment hostingEnvironment)
3030
basePath = _hostingEnvironment.WebRootPath;
3131
}
3232

33-
public override List<CatalogItem> GetItems(string folderName, ItemTypeEnum type)
33+
public override List<CatalogItem> GetItems(string folderName, ItemTypeEnum type, string permissionType)
3434
{
3535
List<CatalogItem> _items = new List<CatalogItem>();
3636

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

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

4848
if (type == ItemTypeEnum.DataSet)
4949
{
50-
foreach (var file in Directory.GetFiles(targetFolder + "DataSet"))
50+
foreach (var file in Directory.GetFiles(Path.Combine(targetFolder, "DataSet")))
5151
{
5252
CatalogItem catalogItem = new CatalogItem();
5353
catalogItem.Name = Path.GetFileNameWithoutExtension(file);
@@ -58,7 +58,7 @@ public override List<CatalogItem> GetItems(string folderName, ItemTypeEnum type)
5858
}
5959
else if (type == ItemTypeEnum.DataSource)
6060
{
61-
foreach (var file in Directory.GetFiles(targetFolder + "DataSource"))
61+
foreach (var file in Directory.GetFiles(Path.Combine(targetFolder, "DataSource")))
6262
{
6363
CatalogItem catalogItem = new CatalogItem();
6464
catalogItem.Name = Path.GetFileNameWithoutExtension(file);
@@ -102,9 +102,8 @@ public override bool CreateReport(string reportName, string folderName, byte[] r
102102

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

109108
if (File.Exists(reportPath))
110109
{
@@ -131,9 +130,8 @@ public override bool EditReport(byte[] reportdata)
131130
string reportPath = this.ReportPath.TrimStart('/').TrimEnd('/').Trim();
132131
string reportName = reportPath.Substring(reportPath.IndexOf('/') + 1).Trim();
133132
string catagoryName = reportPath.Substring(0, reportPath.IndexOf('/') > 0 ? reportPath.IndexOf('/') : 0).Trim();
134-
string targetFolder = this.basePath + @"\Resources\Report\";
135-
136-
string reportPat = targetFolder + catagoryName + @"\" + reportName;
133+
string targetFolder = Path.Combine(this.basePath, "resources", "Report");
134+
string reportPat = Path.Combine(targetFolder, catagoryName, reportName);
137135
File.WriteAllBytes(reportPat, reportdata.ToArray());
138136

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

150-
string targetFolder = this.basePath + @"\Resources\DataSource\";
151-
152-
string dataSourcePath = targetFolder + dataSource + ".rds";
148+
string targetFolder = Path.Combine(this.basePath, "resources", "DataSource");
149+
string dataSourcePath = Path.Combine(targetFolder, $"{dataSource}.rds");
153150

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

177174
public override SharedDatasetinfo GetSharedDataDefinition(string dataSet)
178175
{
179-
string targetFolder = this.basePath + @"\Resources\DataSet\";
180-
string dataSetPath = targetFolder + dataSet + ".rsd";
176+
string targetFolder = Path.Combine(this.basePath, "resources", "DataSet");
177+
string dataSetPath = Path.Combine(targetFolder, $"{dataSet}.rsd");
181178

182179
if (File.Exists(dataSetPath))
183180
{
@@ -211,4 +208,4 @@ private Stream GetFileToStream(byte[] _fileContent)
211208
return memStream;
212209
}
213210
}
214-
}
211+
}

Controllers/LogExtension.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ public static void RegisterLog4NetConfig(string configPath = "")
7979
{
8080
XmlConfigurator.Configure(repository, new System.IO.FileInfo(configPath));
8181
}
82-
else if (File.Exists(prjDir + "\\Log4Net.config"))
82+
else if (File.Exists(Path.Combine(prjDir, "log4net.config")))
8383
{
84-
XmlConfigurator.Configure(repository, new System.IO.FileInfo(prjDir + "\\Log4Net.config"));
84+
XmlConfigurator.Configure(repository, new System.IO.FileInfo(Path.Combine(prjDir, "log4net.config")));
8585
}
86-
else if (File.Exists(prjDir + "\\logs\\Log4Net.config"))
86+
else if (File.Exists(Path.Combine(prjDir, "logs", "log4net.config")))
8787
{
88-
XmlConfigurator.Configure(repository, new System.IO.FileInfo(prjDir + "\\logs\\Log4Net.config"));
88+
XmlConfigurator.Configure(repository, new System.IO.FileInfo(Path.Combine(prjDir, "logs", "log4net.config")));
8989
}
9090
else
9191
{
@@ -107,7 +107,9 @@ public static void RegisterLog4NetConfig(FileInfo configInfo)
107107

108108
private static string GetExecutablePath()
109109
{
110-
string path = (string)(log4net.GlobalContext.Properties["LogPath"] + "\\");
110+
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
111+
UriBuilder uri = new UriBuilder(codeBase);
112+
string path = Uri.UnescapeDataString(uri.Path);
111113
return Path.GetDirectoryName(path);
112114
}
113115
}

Controllers/MetaData.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dynamic getReportSampleData(string controllerName)
1717
dynamic sampleData = null;
1818
foreach (dynamic sample in samples)
1919
{
20-
if ((sample.routerPath == "" && sample.basePath == controllerName) || sample.routerPath == controllerName)
20+
if ((sample.controllerName == "" && sample.basePath == controllerName) || sample.controllerName == controllerName)
2121
{
2222
sampleData = sample;
2323
break;
@@ -48,6 +48,7 @@ public MetaDataInfo updateSampleMetaData(dynamic sampleData)
4848
{
4949
string title = String.IsNullOrEmpty((string)sampleData.metaData.title) ? sampleData.sampleName : sampleData.metaData.title;
5050
string basePath = new Regex(@"(?<!^)(?=[A-Z])").Replace((string)sampleData.basePath, " ", 1);
51+
basePath = string.Join(" ", basePath.Split('-').Select(word => char.ToUpper(word[0]) + word.Substring(1)));
5152
title += " | ASP.NET Core " + basePath.Trim();
5253
title = title.Length < 45 ? title += " | Bold Reports" : title;
5354
return new MetaDataInfo(title, (string)sampleData.metaData.description);
@@ -60,11 +61,11 @@ public MetaDataInfo updatePreviewMetaData(dynamic sampleData)
6061
string metaContent;
6162
switch ((string)sampleData.basePath)
6263
{
63-
case "ReportViewer":
64+
case "report-viewer":
6465
metaContent = "The ASP.NET Core Bold Report Viewer allows the end-users to visualize the " + title + " report in browsers.";
6566
title += " | Preview | ASP.NET Core Report Viewer";
6667
break;
67-
case "ReportWriter":
68+
case "report-writer":
6869
title += " | Preview | ASP.NET Core Report Writer";
6970
metaContent = "The ASP.NET Core Bold Report Writer allows the end-users to download the report in browsers without visualizing the report.";
7071
break;

Controllers/PreviewController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
namespace ReportsCoreSamples.Controllers
88
{
9-
9+
1010
public class PreviewController : MetaData
1111
{
12+
[HttpGet("preview")]
1213
public IActionResult Preview()
1314
{
1415
string foderName = this.ControllerContext.RouteData.Values["controller"].ToString();

Controllers/ReportDesignerController.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,31 @@
77

88
namespace ReportsCoreSamples.Controllers
99
{
10-
10+
[Route("report-designer")]
1111
public class ReportDesignerController : Controller
1212
{
13+
[HttpGet("")]
1314
public IActionResult Index()
1415
{
1516
ViewBag.action = "Preview";
1617
ViewBag.isDesigner = true;
1718
ViewBag.toolbarSettings = new BoldReports.Models.ReportDesigner.ToolbarSettings();
1819
ViewBag.toolbarSettings.Items = BoldReports.ReportDesignerEnums.ToolbarItems.All
19-
& ~BoldReports.ReportDesignerEnums.ToolbarItems.Save & ~BoldReports.ReportDesignerEnums.ToolbarItems.Open;
20+
& ~BoldReports.ReportDesignerEnums.ToolbarItems.New & ~BoldReports.ReportDesignerEnums.ToolbarItems.Save & ~BoldReports.ReportDesignerEnums.ToolbarItems.Open;
21+
string url = this.HttpContext.Request.Host.ToString();
2022
ViewBag.permissionSettings = new BoldReports.Models.ReportDesigner.PermissionSettings();
21-
ViewBag.permissionSettings.DataSource = BoldReports.ReportDesignerEnums.Permission.All & ~BoldReports.ReportDesignerEnums.Permission.Create;
23+
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;
2224
this.updateMetaData("RDL");
2325
return View();
2426
}
27+
[HttpGet("rdlc")]
2528
public IActionResult RDLC()
2629
{
2730
ViewBag.action = "Preview";
2831
ViewBag.isDesigner = true;
2932
ViewBag.toolbarSettings = new BoldReports.Models.ReportDesigner.ToolbarSettings();
3033
ViewBag.toolbarSettings.Items = BoldReports.ReportDesignerEnums.ToolbarItems.All
31-
& ~BoldReports.ReportDesignerEnums.ToolbarItems.Save & ~BoldReports.ReportDesignerEnums.ToolbarItems.Open;
34+
& ~BoldReports.ReportDesignerEnums.ToolbarItems.New & ~BoldReports.ReportDesignerEnums.ToolbarItems.Save & ~BoldReports.ReportDesignerEnums.ToolbarItems.Open;
3235
ViewBag.permissionSettings = new BoldReports.Models.ReportDesigner.PermissionSettings();
3336
ViewBag.permissionSettings.DataSource = BoldReports.ReportDesignerEnums.Permission.All & ~BoldReports.ReportDesignerEnums.Permission.Create;
3437
this.updateMetaData("RDLC");
@@ -42,7 +45,7 @@ dynamic getReportSampleData(string routerPath)
4245
dynamic sampleData = null;
4346
foreach (dynamic sample in samples)
4447
{
45-
if (sample.routerPath == routerPath)
48+
if (sample.controllerName == routerPath)
4649
{
4750
sampleData = sample;
4851
break;

Controllers/ReportDesignerWebApiController.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ public bool DisposeObjects()
6969
{
7070
try
7171
{
72-
string targetFolder = this._hostingEnvironment.WebRootPath + "\\";
73-
targetFolder += "Cache";
72+
string targetFolder = Path.Combine(this._hostingEnvironment.WebRootPath, "Cache");
7473

7574
if (Directory.Exists(targetFolder))
7675
{
@@ -118,8 +117,15 @@ public void OnInitReportOptions(ReportViewerOptions reportOption)
118117
string reportName = reportOption.ReportModel.ReportPath;
119118
reportOption.ReportModel.ReportingServer = this.Server;
120119
reportOption.ReportModel.ReportServerUrl = this.ServerURL;
120+
reportOption.ReportModel.EmbedImageData = true;
121121
reportOption.ReportModel.ReportServerCredential = new NetworkCredential("Sample", "Passwprd");
122122

123+
if (reportOption.ReportModel.FontSettings == null)
124+
{
125+
reportOption.ReportModel.FontSettings = new BoldReports.RDL.Data.FontSettings();
126+
}
127+
reportOption.ReportModel.FontSettings.BasePath = Path.Combine(_hostingEnvironment.WebRootPath, "fonts");
128+
123129
}
124130

125131
public void OnReportLoaded(ReportViewerOptions reportOption)

Controllers/ReportViewer/BarcodeController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
namespace ReportsCoreSamples.Controllers
88
{
9+
[Route("report-viewer/barcode")]
910
public class BarcodeController : PreviewController
1011
{
12+
[HttpGet("")]
1113
public IActionResult Index()
1214
{
1315
this.updateMetaData();

Controllers/ReportViewer/CompanySalesController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
namespace ReportsCoreSamples.Controllers
88
{
9+
[Route("report-viewer/company-sales")]
910
public class CompanySalesController : PreviewController
1011
{
12+
[HttpGet("")]
1113
public IActionResult Index()
1214
{
1315
this.updateMetaData();

Controllers/ReportViewer/ConditionalRowFormattingController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
namespace ReportsCoreSamples.Controllers
88
{
9+
[Route("report-viewer/conditional-row-formatting")]
910
public class ConditionalRowFormattingController : PreviewController
1011
{
12+
[HttpGet("")]
1113
public IActionResult Index()
1214
{
1315
this.updateMetaData();

Controllers/ReportViewer/ConsolidatedBalanceSheetController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
namespace ReportsCoreSamples.Controllers.ReportViewer
88
{
9+
[Route("report-viewer/consolidated-balance-sheet")]
910
public class ConsolidatedBalanceSheetController : PreviewController
1011
{
12+
[HttpGet("")]
1113
public IActionResult Index()
1214
{
1315
this.updateMetaData();

0 commit comments

Comments
 (0)