|
|
|
AyaNova Sales & Support
      
Group: Administrators
Last Login: Today @ 10:45:49 AM
Posts: 1,689,
Visits: 3,988
|
|
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
|
|
|
|