Page 1 of 1

User-defined function behavior error.

Posted: Mon Nov 05, 2018 8:15 am
by rip_it
Hello ;)

An action error exists after adding a custom function to the report file.

Development Environment: Net Core 2.0 MVC
Report Version : 2018.3.3 (Stimulsoft.Reports.Web.NetCore Ver. 2018.3.3)

I want to print the number format in the format I want..
(ex: 2500.12345 => 2,500.12345, 2500 => 2,500)
I searched the forums about how to add user-defined functions.

"Register a custom function in a report" => viewtopic.php?f=13&t=52471

I have tested the sample report file in the search results.

Designer screen:
Designer screen
Designer screen
rd_01.png (8.76 KiB) Viewed 1537 times
Code:

Code: Select all

	public class MyFunction
	{
		private const string Category = "MyFuncCategory";

		public static string MyFunc(string value)
		{
			return value.ToUpper();
		}

		public static void RegisterFunctions()
		{
			var ParamNames = new string[1];
			var ParamTypes = new Type[1];
			var ParamDescriptions = new string[1];

			ParamNames[0] = "value";
			ParamDescriptions[0] = "Descriptions";
			ParamTypes[0] = typeof(string);

			Stimulsoft.Report.Dictionary.StiFunctions.RemoveFunction("MyFunc");
			Stimulsoft.Report.Dictionary.StiFunctions.AddFunction(Category, "MyFunc", "MyFunc", "Description", typeof(MyFunction),
				typeof(string), "Return Description", ParamTypes, ParamNames, ParamDescriptions);
		}
	}
	
	public class Report : Stimulsoft.Report.StiReport
        {
             public Report()        {
                  this.InitializeComponent();
		  MyFunction.RegisterFunctions();
             }
             ....
             ....
        }
	
	
Viewer screen:
Viewer screen
Viewer screen
rd_02.png (5.66 KiB) Viewed 1537 times
It is good printed in the Review tool and the Designer tool Review menu.

However, in the development environment, the output is not normal.

Controller:

Code: Select all

	public IActionResult GetReport()
        {
            StiReport report = new StiReport();

            var path = StiNetCoreHelper.MapPath(this, "Reports/ReportC.mrt");
            report.Load(path);

            return StiNetCoreViewer.GetReportResult(this, report);
        }
Web browser screen:
Web browser screen
Web browser screen
rd_03.png (2.98 KiB) Viewed 1537 times
Is there any way to make it print normally?
I need help.

Re: User-defined function behavior error.

Posted: Fri Nov 09, 2018 6:48 am
by HighAley
Hello.

Unfortunately, there is no compilation in .Net Core.
You could add your code that registers the function outside the report class.

Code: Select all

MyFunction.RegisterFunctions();
Thank you.

Re: User-defined function behavior error.

Posted: Tue Nov 13, 2018 5:39 am
by rip_it
HighAley wrote: Fri Nov 09, 2018 6:48 am Hello.

Unfortunately, there is no compilation in .Net Core.
You could add your code that registers the function outside the report class.

Code: Select all

MyFunction.RegisterFunctions();
Thank you.
Yes, I see.
Thank you for your answer.

Re: User-defined function behavior error.

Posted: Tue Nov 13, 2018 8:48 am
by Andrew
You are welcome!