/// <summary> /// Run the code example. /// </summary> /// <param name="service">An initialized Dfa Reporting service object /// </param> public override void Run(DfareportingService service) { long reportId = long.Parse(_T("INSERT_REPORT_ID_HERE")); long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE")); // Limit the fields returned. String fields = "nextPageToken,items(fileName,id,status)"; FileList files; String nextPageToken = null; do { // Create and execute the report files list request. ReportsResource.FilesResource.ListRequest request = service.Reports.Files.List(profileId, reportId); request.Fields = fields; request.PageToken = nextPageToken; files = request.Execute(); foreach (File file in files.Items) { Console.WriteLine("Report file with ID {0} and file name \"{1}\" has status \"{2}\".", file.Id, file.FileName, file.Status); } // Update the next page token. nextPageToken = files.NextPageToken; } while (files.Items.Any() && !String.IsNullOrEmpty(nextPageToken)); }
private File FindFile(DfareportingService service, long profileId, long reportId) { // [START find_file] MOE:strip_line File target = null; FileList files; String nextPageToken = null; do { // Create and execute the files list request. ReportsResource.FilesResource.ListRequest request = service.Reports.Files.List(profileId, reportId); request.PageToken = nextPageToken; files = request.Execute(); foreach (File file in files.Items) { if (IsTargetFile(file)) { target = file; break; } } // Update the next page token. nextPageToken = files.NextPageToken; } while (target == null && files.Items.Any() && !String.IsNullOrEmpty(nextPageToken)); // [END find_file] MOE:strip_line if (target != null) { Console.WriteLine("Found file {0} with filename \"{1}\".", target.Id, target.FileName); return(target); } Console.WriteLine( "Unable to find file for profile ID {0} and report ID {1}.", profileId, reportId); return(null); }