This repository has been archived by the owner on May 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
HomeController.cs
96 lines (77 loc) · 3.22 KB
/
HomeController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Hosting;
using Stimulsoft.Report.NetCore;
namespace Managing_Data_in_Reports.Controllers
{
public class HomeController : Controller
{
private readonly IHostingEnvironment _hostEnvironment;
public HomeController(IHostingEnvironment hostEnvironment)
{
//Stimulsoft.Base.StiLicense.Key = "6vJhGtLLLz2GNviWmUTrhSqnO...";
//Stimulsoft.Base.StiLicense.LoadFromFile("license.key");
//Stimulsoft.Base.StiLicense.LoadFromStream(stream);
_hostEnvironment = hostEnvironment;
}
public IActionResult Index()
{
return View();
}
public IActionResult About()
{
ViewData["Message"] = "Stimulsoft Reports.Web for .NET Core";
return View();
}
public IActionResult Contact()
{
ViewData["Message"] = "Stimulsoft";
return View();
}
public IActionResult Error()
{
return View();
}
public IActionResult GetReport()
{
return StiNetCoreViewer.GetReportResult(this, _hostEnvironment.WebRootPath + "\\reports\\SimpleList.mrt");
}
public IActionResult GetReportData()
{
StiRequestParams requestParams = StiNetCoreViewer.GetRequestParams(this);
// JSON data
if (requestParams.Connection.Type == StiConnectionType.JSON)
{
return StiNetCoreViewer.GetReportDataResult(this, _hostEnvironment.WebRootPath + "\\data\\Demo.json");
}
// XML data
if (requestParams.Connection.Type == StiConnectionType.XML)
{
string pathData = requestParams.Connection.PathData;
string pathSchema = requestParams.Connection.PathSchema;
string data = pathSchema != null
? System.IO.File.ReadAllText(_hostEnvironment.WebRootPath + "\\" + pathSchema)
: System.IO.File.ReadAllText(_hostEnvironment.WebRootPath + "\\" + pathData);
return StiNetCoreViewer.GetReportDataResult(this, data);
//return StiNetCoreViewer.GetReportDataResult(this, _hostEnvironment.WebRootPath + "\\" + pathData);
}
// SQL data
if (requestParams.Connection.Type == StiConnectionType.MSSQL)
{
string connectionString = requestParams.Connection.ConnectionString;
string queryString = requestParams.Connection.QueryString;
StiDataResult result = new StiDataResult()
{
Columns = new string[2] { "Column1", "Column2" },
Types = new string[2] { "number", "string" },
Rows = new string[3][] { new string[2] { "1", "Row1" }, new string[2] { "2", "Row2" }, new string[2] { "3", "Row3" } }
};
return StiNetCoreViewer.GetReportDataResult(this, result);
}
return StiNetCoreViewer.GetReportDataResult(this);
}
public IActionResult ViewerEvent()
{
return StiNetCoreViewer.ViewerEventResult(this);
}
}
}