User-defined function behavior error.

Stimulsoft Reports.WEB discussion
Post Reply
User avatar
rip_it
Posts: 4
Joined: Thu Jul 12, 2018 8:16 am

User-defined function behavior error.

Post 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 1329 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 1329 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 1329 times
Is there any way to make it print normally?
I need help.
Attachments
ReportC.mrt
My Report File
(4.7 KiB) Downloaded 221 times
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: User-defined function behavior error.

Post 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.
User avatar
rip_it
Posts: 4
Joined: Thu Jul 12, 2018 8:16 am

Re: User-defined function behavior error.

Post 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.
Andrew
Posts: 4104
Joined: Fri Jun 09, 2006 3:58 am

Re: User-defined function behavior error.

Post by Andrew »

You are welcome!
Post Reply