How to use JS Designer in the ASP.NET CORE (NET 461)?

Stimulsoft Reports.JS discussion
Post Reply
5441323@qq.com
Posts: 13
Joined: Thu Feb 23, 2017 9:55 am

How to use JS Designer in the ASP.NET CORE (NET 461)?

Post by 5441323@qq.com »

here is my code ,but connect to database error:

[HttpPost]
[Route("api/handler")]
public IActionResult Handler(CommandJson command)
{

Result result = new Result();

if (command.Database == "MySQL") result = MySQLAdapter.Process(command);

if (command.Database == "Firebird") result = FirebirdAdapter.Process(command);

if (command.Database == "MS SQL") result = MSSQLAdapter.Process(command);

if (command.Database == "PostgreSQL") result = PostgreSQLAdapter.Process(command);

return new ObjectResult(result);

}
5441323@qq.com
Posts: 13
Joined: Thu Feb 23, 2017 9:55 am

Re: How to use JS Designer in the ASP.NET CORE (NET 461)?

Post by 5441323@qq.com »

Nothing worse than that.
I solved the problem myself from use my custom adapter in asp.net core .
by the way, the sample adapter for asp.net is very bad!!!!

here is my solution :

1.modify asp.net core project ,support text/plain content type.

2.use post and entity class serilize object .

3.use custom adapter ( its very import for that, could not use static Adapter class !!!)

like this:
public class MSSQLAdapter
{
public Result Process(CommandJson command)
{
var connection = new SqlConnection(command.ConnectionString);

connection.Open();

try
{
if (!String.IsNullOrEmpty(command.QueryString))
{
var sqlCommand = new SqlCommand(command.QueryString, connection);

var reader = sqlCommand.ExecuteReader();

var columns = new List<string>();

var rows = new List<string[]>();

for (var index = 0; index < reader.FieldCount; index++)
{
columns.Add(reader.GetName(index));
}

while (reader.Read())
{
var row = new string[reader.FieldCount];
for (var index = 0; index < reader.FieldCount; index++)
{
object value = null;
if (!reader.IsDBNull(index)) value = reader.GetValue(index);
if (value == null) value = "";
row[index] = value.ToString();

}
rows.Add(row);
}

return new Result { Success = true, Columns = columns.ToArray(), Rows = rows.ToArray() };

}
else
{

return new Result { Success = true };
}
}
catch (Exception e)
{

return new Result { Success = false, Notice = e.Message };

}
finally
{
if (connection.State != ConnectionState.Closed)
{

connection.Close();
}
}

}
}

use:
[HttpPost]
[Route("api/handler")]
public IActionResult Handler(CommandJson command)
{

Result result = new Result();

if (command.Database == "MS SQL") result = new MSSQLAdapter().Process(command);

return new ObjectResult(result);
}

fuck!!!
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to use JS Designer in the ASP.NET CORE (NET 461)?

Post by HighAley »

Hello.

You don't need to make any changes in the database adapters.
Just specify the path to it.
What version of our product do you use?
There is no JS engine on our current builds of .Net Core components.

Thank you.
5441323@qq.com
Posts: 13
Joined: Thu Feb 23, 2017 9:55 am

Re: How to use JS Designer in the ASP.NET CORE (NET 461)?

Post by 5441323@qq.com »

HighAley wrote:Hello.

You don't need to make any changes in the database adapters.
Just specify the path to it.
What version of our product do you use?
There is no JS engine on our current builds of .Net Core components.

Thank you.
thank you very much.

But, once again,we use JS Designer in asp .Net Core . version 18.2 Trial
so,we have to modify adaper .
now,JS Designer run in asp .Net Core project perfect .

finally ,hope .Net Core official sample with js Designer .
Lech Kulikowski
Posts: 6265
Joined: Tue Mar 20, 2018 5:34 am

Re: How to use JS Designer in the ASP.NET CORE (NET 461)?

Post by Lech Kulikowski »

Hello,

Thank you for the information.

We have added this task in our to-do list.

Thank you.
Lech Kulikowski
Posts: 6265
Joined: Tue Mar 20, 2018 5:34 am

Re: How to use JS Designer in the ASP.NET CORE (NET 461)?

Post by Lech Kulikowski »

Hello,

Also, you can use our native Core components:
https://github.com/stimulsoft/Samples-N ... MVC-CSharp

Thank you.
Post Reply