The following sample report template once imported, would be available from the Service Workorders grid and the Items grid . Before selecting to print the report template, you would filter the grid to display the records you wish to report on - such as workorders that have a specific Workorder Status for a specific client for a specific date range.
Download the report template Average Response Time - Service Workorders grid.zip, extract and import
A sample view of the report template:
Details about the report template:
Open the report template via the Report Designer and refer to the following areas that are unique about this report template so that you can customize further, and/or refer to this report template when creating your own.
The reportHeaderBand1 has the following OnBeforePrint script to set the variables used to determine the average: dir=ltr " ">
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
}
//set variables for determining average
TimeSpan TotalResponseTime;
int CountOfLaborItems = 0;
The DetailBand of the WorkorderItem area has the property Visible set to False, so that the Request Date field does not show, but we need this field here because we are using it in a script in the Labor’s band.
The Detail1 band of the Labor area has the following OnBeforePrint script so that the field xrTableCell12will display the response time for each record, as well as maintain a running total of seconds to be used when determining the average at the end of the report: dir=ltr " ">
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
//this gets the object value of the Start Date & Time
DateTime dt1 = Convert.ToDateTime(DetailReport1.GetCurrentColumnValue(“LT_WorkorderItemLabor_Label_ServiceStartDate”));
//this gets the object value of the Requested Date & Time
DateTime dt2 = Convert.ToDateTime(DetailReport.GetCurrentColumnValue(“LT_WorkorderItem_Label_RequestDate”));
//the following two lines determine if the start date or request date is missing a valid date
TimeSpan ts = TimeSpan.Zero;
xrTableCell12.Text = “Missing a valid date”;
//if request date and label date are valid, than the following below it occurs
if (!(dt1.Year == 1 || dt2.Year == 1))
{
//this subtracts the Requested date & time from the Start date & time
ts = dt1.Subtract(dt2);
//this displays the timespan in total days(if you want to display in hours than change TotalDays to TotalHours
xrTableCell12.Text = ts.Days.ToString()+" Days " +
ts.Hours.ToString()+" Hours " +
ts.Minutes.ToString()+" Minutes " +
ts.Seconds.ToString()+" Seconds";
// this maintains a running total of Actual Difference for each record
//into the TotalResponseTime we will use at the end of the report to get the average
TotalResponseTime += ts;
//Add 1 to the count of labor so that we divide by the correct amount
CountOfLaborItems ++;
}
}
The ReportFooter band has the OnBeforePrint script to display the average response time: 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);
[i]//the following displays the average of the total counted response times
xrLabel5.Text = AverageRes