Hi,
I'm having trouble extending Report Designer with User Function.
I've created an assembly with 3 functions the following code:
using System;
using Telerik.Reporting.Expressions;
namespace ReportLib
{
public static class SVFunctions
{
[Function(Category = "My Functions", Namespace = "ReportLib", Description = "Duration")]
public static string Duration(DateTime Start, DateTime End)
{
TimeSpan ts = End- Start;
double Ore = ts.TotalHours;
double Minuti = ts.TotalMinutes - (Ore*60);
double Secondi = ts.TotalSeconds - (Ore*60) - (Minuti*60);
return string.Format("{0:0}:{1:0}:{2:0}", Ore, Minuti, Secondi);
}
[Function(Category = "My Functions", Namespace = "ReportLib", Description = "ToLocalTime")]
public static DateTime ToLocalTime(DateTime utc)
{
return utc.ToLocalTime();
}
[Function(Category = "My Functions", Namespace = "ReportLib", Description = "Adesso")]
public static string Adesso()
{
return "12/12/2014";
}
}
I've added the reference of the assembly inside the ReportDesigner config file.
<Telerik.Reporting>
<AssemblyReferences>
<add name="ReportLib" version="1.0.0.0" />
</AssemblyReferences>
</Telerik.Reporting>
I've created a report and with a text field using an expression that references to the function Adesso() as you can see in to the attached picture.
When I run the report I've the following error (shown into the picture)
An error was occurred while processing TexBox 'xxx'. The Expression contains object 'ReportLib' that is not defined in the current context.
What's I'm doing wrong
Michele
I'm having trouble extending Report Designer with User Function.
I've created an assembly with 3 functions the following code:
using System;
using Telerik.Reporting.Expressions;
namespace ReportLib
{
public static class SVFunctions
{
[Function(Category = "My Functions", Namespace = "ReportLib", Description = "Duration")]
public static string Duration(DateTime Start, DateTime End)
{
TimeSpan ts = End- Start;
double Ore = ts.TotalHours;
double Minuti = ts.TotalMinutes - (Ore*60);
double Secondi = ts.TotalSeconds - (Ore*60) - (Minuti*60);
return string.Format("{0:0}:{1:0}:{2:0}", Ore, Minuti, Secondi);
}
[Function(Category = "My Functions", Namespace = "ReportLib", Description = "ToLocalTime")]
public static DateTime ToLocalTime(DateTime utc)
{
return utc.ToLocalTime();
}
[Function(Category = "My Functions", Namespace = "ReportLib", Description = "Adesso")]
public static string Adesso()
{
return "12/12/2014";
}
}
I've added the reference of the assembly inside the ReportDesigner config file.
<Telerik.Reporting>
<AssemblyReferences>
<add name="ReportLib" version="1.0.0.0" />
</AssemblyReferences>
</Telerik.Reporting>
I've created a report and with a text field using an expression that references to the function Adesso() as you can see in to the attached picture.
When I run the report I've the following error (shown into the picture)
An error was occurred while processing TexBox 'xxx'. The Expression contains object 'ReportLib' that is not defined in the current context.
What's I'm doing wrong
Michele