If receive error "TimeSpan does not accept floating point Not-a-Number values."

If attempting to print theSample Labor from Request Date Average Response Time reportfrom the Service Workorders grid in AyaNova 4, and you get the following error dir=ltr " ">

“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 becausethe report template’s ReportFooter scripthas 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: dir=ltr " ">

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: dir=ltr " ">

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";

}