Adding a Report to a Job
A report defines the information that you want the scan to return. For example, you can create a report that lists files over a given size or files that have not been accessed in the last n days. For a list of reports that you can request, see the FsrmReportType enumeration. A report job can contain only one report of each type.
You can specify a filter value for most of the report types which lets you limit the information provided in the report. To specify a filter value for a report type that is applied to all reports of that type, call the IFsrmReportManager::SetDefaultFilter method. To override the global filter value, you can call the IFsrmReport::SetFilter method.
The following example shows how to create and configure a report for a report job. The AddReportToJob function is defined in the Defining a Report Job example.
// Create and configures a report that lists files that
// have not been accessed in the last five days.
HRESULT AddReportToJob(IFsrmReportJob* pJob)
{
HRESULT hr = S_OK;
IFsrmReport* pReport = NULL;
// Add a report that lists the least recently accessed files.
hr = pJob->CreateReport(FsrmReportType_LeastRecentlyAccessed, &pReport);
if (FAILED(hr))
{
wprintf(L"pJob->CreateReport failed, 0x%x.\n", hr);
goto cleanup;
}
// The name and description are included in the report. The name
// is used as the subject if the report is being mailed.
hr = pReport->put_Name(_bstr_t(L"Least Accessed"));
if (FAILED(hr))
{
wprintf(L"pReport->put_Name failed, 0x%x.\n", hr);
goto cleanup;
}
hr = pReport->put_Description(_bstr_t(L"This report list the files "
L"that have not been accessed within the last five days."));
if (FAILED(hr))
{
wprintf(L"pReport->put_Description failed, 0x%x.\n", hr);
goto cleanup;
}
// Use the filter on the report object to specify the least accessed report.
hr = pReport->SetFilter(FsrmReportFilter_MinAgeDays, _variant_t(5));
if (FAILED(hr))
{
wprintf(L"pReport->SetFilter failed, 0x%x.\n", hr);
goto cleanup;
}
// Save the report job.
hr = pJob->Commit();
if (FAILED(hr))
{
wprintf(L"pJob->Commit failed, 0x%x.\n", hr);
goto cleanup;
}
cleanup:
if (pReport)
pReport->Release();
return hr;
}