How to send parameters to Stimulsoft Report in Asp.Net Core 2.0? - asp.net-core

I use Asp.net Core 2.0 Web Application.
I have a simple stimulsoft report file.
my report has a parameter Called #ID.
If I Use the report without parameter, it's working well, But When I send parameter to report, it's not working and report loaded empty.
my Code is:
var _Report = new Stimulsoft.Report.StiReport();
_Report.Load(#"C:\temp\report.mrt"); // load report
((StiSqlDatabase)_Report.Dictionary.Databases["Connection"]).ConnectionString = "new connectionString "; // change connection
_Report.DataSources["DataSource1"].Parameters["#ID"].ParameterValue = 5171; // set parameter value
_Report.Render();
Note: I use Asp.net Core version 2.0.
this code is working in asp.net well.
please help me.
thanks.

Wow!!!
solved.
I should use from Value Instead ParameterValue.
Like below:
_Report.DataSources["DataSource1"].Parameters["#ID"].Value = 5171;

Related

Assembly name was changed after deployment in core web api application

I am using VS 2019 to develop core.net web Api. I am trying to read the all methods and Parameters inside my controller. I am using Repository pattern to develop API.
Below is the code from my repository.
var method = MethodBase.GetCurrentMethod();
_log4net.Info("Assembly Name : " + Assembly.GetCallingAssembly().FullName);
_log4net.Info("Method Name : " + method.Name);
_log4net.Info("Repository Name :" + method.ReflectedType.FullName);
var result =
((System.Reflection.TypeInfo)Assembly.GetCallingAssembly().GetTypes().Where(type
=> type.FullName.Contains("AsmeController")).FirstOrDefault()).DeclaredMethods;
_log4net.Info(result);
Log's:
In Debug Mode:
After deployment in IIS
This code is working as expected and returns the list of Method Info in Debug mode and not working and return Null in Release mode even after deployed in IIS.
As i observed using logs, Assembly name was changing Demo.dll to “ Assembly Name : Anonymously Hosted DynamicMethods Assembly “ after deployment.
Please give me suggestions to solve this problem.
For the work around i am directly reading the application dll, Instead of reading current assembly. So that i can able to access the all info from there.
string assemblyFile = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location + "\\Demo.dll");
Assembly testAssembly = Assembly.LoadFile(assemblyFile);
var result = ((TypeInfo)testAssembly.GetTypes().Where(type => type.FullName.Contains("AsmeController")).FirstOrDefault()).DeclaredMethods;

DiffGrams for .NET Core. We are upgrading our project to .NET Core 3.x so need to find the DiffGrams used in the previous version of .NET

We are upgrading our .NET 2.0 application to .NET Core 3.x there's a DiffGrams used to capture the Table field updates (before/after values) used for Auditing purpose. I have to achieve the similar in the .NET Core 3.x. I am not sure which one is the equivalent for .NET Core 3.x.
Could you anyone help me guide on this? Thank you.
DataSet.WriteXml/DataSet.ReadXml method applies to .NET Core 3.x.
The WriteXml method provides a way to write either data only, or both data and schema from a DataSet into an XML document.
private void WriteXmlToFile(DataSet thisDataSet)
{
if (thisDataSet == null) { return; }
// Create a file name to write to.
string filename = "XmlDoc.xml";
// Create the FileStream to write with.
System.IO.FileStream stream = new System.IO.FileStream
(filename, System.IO.FileMode.Create);
// Create an XmlTextWriter with the fileStream.
System.Xml.XmlTextWriter xmlWriter =
new System.Xml.XmlTextWriter(stream,
System.Text.Encoding.Unicode);
// Write to the file with the WriteXml method.
thisDataSet.WriteXml(xmlWriter, XmlWriteMode.DiffGram);
xmlWriter.Close();
}
The resultant XML code is rooted in the <diffgr:diffgram> node and contains up to three distinct data sections, as follows:
<diffgr:diffgram>
<MyDataSet>
:
</MyDataSet>
<diffgr:before>
:
</diffgr:before>
<diffgr:errors>
:
</diffgr:errors>
</diffgr:diffgram>

How can I compile Razor templates on demand?

Antaris RazorEngine supports a simple compiler with a straight forward templating syntax:
string template = "<div>Hello #Model.Name</div>";
var model = new Person { Name = "Matt" };
string result = Engine.Razor.RunCompile(template, "key", typeof(Person), model);
However, this project hasn't been updated since Jan 2018. Can I do this same type of compilation somehow using ASP.NET Core Razor SDK? I have a .NET core C# project that I want to run this in.
I am looking for a hello world example of taking a string template as input and compiling it. If there's any confusion see the code example I posted above.

How can I read version of project in dotnet core (formerly asp.net mvc6)

how can I read assembly version information for my project, the value which in this case comes from the from project.json, and read that in my ASP.net core Controller and pass it to the view?
You can use Razor to get this right from the View and bypass the Controller.
<b>Version</b> #(
Assembly.GetAssembly(typeof(HomeController))
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion
)
To get your application version, as it exists in project.json, you would write:
string appVersion = Assembly.
GetEntryAssembly().
GetCustomAttribute<AssemblyInformationalVersionAttribute>().
InformationalVersion;
Additionally, if you want to know which version of .net core your app is running on you can do this:
....
string dotNetRuntimeVersion = typeof(RuntimeEnvironment)
.GetTypeInfo()
.Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion;
You may need to add these units to your using for the above runtime version snippet:
using Microsoft.DotNet.InternalAbstractions;
using System.Reflection;
You can get the AssemblyInformationalVersionAttribute from your project's assembly and then pass it to the view.
Here's how to get that attribute: https://github.com/aspnet/dnx/blob/dev/src/Microsoft.Dnx.Host/RuntimeEnvironment.cs#L35-L44
In an early beta version you could add constructor to your controller with parameter IApplicationEnvironment. this param have a property with Version name
public HomeController(IApplicationEnvironment appEnvironment) {
this.appEnvironment = appEnvironment;
}
(No longer works in ASP.net core 1.0)

Asp 5 ServerVariables

I am in the progress of rewriting some code to work with ASP 5.
The old code does the following:
string Local_IP=Request.ServerVariables["LOCAL_ADDR"];
string HTTP_reverse_VIA = Request.ServerVariables["HTTP_REVERSE_VIA"];
How do I get the corresponding information from ASP 5?
HttpContext has the GetFeature method, using this method we can get feature information.
Here we are want to get Server Variables of IIS; check project.json "Microsoft.AspNet.Server.IIS" is used for running ASP.NET 5.
We have to use GetFeature of 'Microsoft.AspNet.Server.IIS' which contains Server variables feature. use the below code
var varibleFeature = Context.GetFeature<Microsoft.AspNet.Server.IIS.Features.IServerVariablesFeature>();
if (varibleFeature != null)
{
var valuesList = varibleFeature.ServerVariables;
//read through valuesList dictionary for Server Variables
}
Since I was running on IIS Express, it gave few variables but not the one mentioned in your question.
Please deploy it on IIS and explore more.