AyaNova service management & work order software
AyaNova Support Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



If receive error "TimeSpan does not accept... Expand / Collapse
Author
Message
Posted 3/19/2008 3:37:26 PM
AyaNova Sales & Support

AyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & Support

Group: Administrators
Last Login: Yesterday @ 3:44:41 PM
Posts: 1,800, Visits: 4,181
If attempting to print the Sample Labor from Request Date Average Response Time report from the Service Workorders grid in AyaNova 4, and you get the following error

"The following error occurred when the script in procedure ReportFooter.OnBeforePrint:
 TimeSpan does not accept floating point Not-a-Number values.
Procedure ReportFooter.OnBeforePrint was executed, it will not be called again."

The error is occurring because one or more of the workorders you are printing about do not have any labor records.

And the error occurs because the report template's ReportFooter script has a divide operation that is set the timespan to in the Footer.Beforeprint method and the divisor is zero so the result is a NAN (NotANumber) instead of a divide by zero message (strange that they don't just call it a divide by zero).

If you want to use this report template, but you have no labor records in some of your workorders, edit the OnBeforePrint script for the ReportFooter from:

private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
//the following divides the total seconds by the count so we can get the average
double TotalSeconds = TotalResponseTime.TotalSeconds;
TimeSpan AverageResponseTime = TimeSpan.FromSeconds(TotalSeconds/CountOfLaborItems);

//the following displays the average of the total counted response times
xrLabel5.Text = AverageResponseTime.Days.ToString()+" Days " +
AverageResponseTime.Hours.ToString()+" Hours " +
AverageResponseTime.Minutes.ToString()+" Minutes " +
AverageResponseTime.Seconds.ToString()+" Seconds";

}

To this:

private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
//the following divides the total seconds by the count so we can get the average
double TotalSeconds = TotalResponseTime.TotalSeconds;

//Account for situation where there are 0 labor items:
TimeSpan AverageResponseTime = TimeSpan.FromSeconds(0);
if(CountOfLaborItems!=0) AverageResponseTime = TimeSpan.FromSeconds(TotalSeconds/CountOfLaborItems);

//the following displays the average of the total counted response times
xrLabel5.Text = AverageResponseTime.Days.ToString()+" Days " +
AverageResponseTime.Hours.ToString()+" Hours " +
AverageResponseTime.Minutes.ToString()+" Minutes " +
AverageResponseTime.Seconds.ToString()+" Seconds";

}



AyaNova Sales & Technical Support
http://www.ayanova.com
Post #3897
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: AyaNova Sales & Support

Permissions Expand / Collapse

All times are GMT -8:00, Time now is 8:37am

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.047. 10 queries. Compression Disabled.