public void TestRunDeliveryReport() { ReportJob reportJob = new ReportJob(); reportJob.reportQuery = new ReportQuery(); reportJob.reportQuery.dimensions = new Dimension[] {Dimension.ORDER_ID, Dimension.ORDER_NAME}; reportJob.reportQuery.columns = new Column[] {Column.AD_SERVER_IMPRESSIONS, Column.AD_SERVER_CLICKS, Column.AD_SERVER_CTR, Column.AD_SERVER_CPM_AND_CPC_REVENUE, Column.AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM}; reportJob.reportQuery.dateRangeType = DateRangeType.LAST_MONTH; Assert.DoesNotThrow(delegate() { reportJob = reportService.runReportJob(reportJob); }); Assert.NotNull(reportJob); }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { ReportService reportService = (ReportService) user.GetService( DfpService.v201308.ReportService); long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE")); // Create statement object to filter for an order. Statement filterStatement = new StatementBuilder("WHERE ORDER_ID = :id").AddValue( "id", orderId).ToStatement(); // Create report job. ReportJob reportJob = new ReportJob(); reportJob.reportQuery = new ReportQuery(); reportJob.reportQuery.dimensions = new Dimension[] {Dimension.ORDER_ID, Dimension.ORDER_NAME}; reportJob.reportQuery.dimensionAttributes = new DimensionAttribute[] { DimensionAttribute.ORDER_TRAFFICKER, DimensionAttribute.ORDER_START_DATE_TIME, DimensionAttribute.ORDER_END_DATE_TIME}; reportJob.reportQuery.columns = new Column[] {Column.AD_SERVER_IMPRESSIONS, Column.AD_SERVER_CLICKS, Column.AD_SERVER_CTR, Column.AD_SERVER_CPM_AND_CPC_REVENUE, Column.AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM}; reportJob.reportQuery.dateRangeType = DateRangeType.LAST_MONTH; reportJob.reportQuery.statement = filterStatement; try { // Run report. reportJob = reportService.runReportJob(reportJob); // Wait for report to complete. while (reportJob.reportJobStatus == ReportJobStatus.IN_PROGRESS) { Console.WriteLine("Report job with id = '{0}' is still running.", reportJob.id); Thread.Sleep(30000); // Get report job. reportJob = reportService.getReportJob(reportJob.id); } if (reportJob.reportJobStatus == ReportJobStatus.COMPLETED) { Console.WriteLine("Report job with id = '{0}' completed successfully.", reportJob.id); } else if (reportJob.reportJobStatus == ReportJobStatus.FAILED) { Console.WriteLine("Report job with id = '{0}' failed to complete successfully.", reportJob.id); } } catch (Exception ex) { Console.WriteLine("Failed to run delivery report. Exception says \"{0}\"", ex.Message); } }
public void TestRunInventoryReport() { ReportJob reportJob = new ReportJob(); reportJob.reportQuery = new ReportQuery(); reportJob.reportQuery.dimensions = new Dimension[] {Dimension.DATE}; reportJob.reportQuery.columns = new Column[] {Column.AD_SERVER_IMPRESSIONS, Column.AD_SERVER_CLICKS, Column.DYNAMIC_ALLOCATION_INVENTORY_LEVEL_IMPRESSIONS, Column.DYNAMIC_ALLOCATION_INVENTORY_LEVEL_CLICKS, Column.TOTAL_INVENTORY_LEVEL_IMPRESSIONS, Column.TOTAL_INVENTORY_LEVEL_CPM_AND_CPC_REVENUE}; reportJob.reportQuery.dateRangeType = DateRangeType.LAST_WEEK; ReportJob newReportJob = null; Assert.DoesNotThrow(delegate() { reportJob = reportService.runReportJob(reportJob); }); Assert.NotNull(reportJob); }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { ReportService reportService = (ReportService) user.GetService( DfpService.v201308.ReportService); // Create report job. ReportJob reportJob = new ReportJob(); reportJob.reportQuery = new ReportQuery(); reportJob.reportQuery.dimensions = new Dimension[] {Dimension.DATE}; reportJob.reportQuery.columns = new Column[] { Column.AD_SERVER_IMPRESSIONS, Column.AD_SERVER_CLICKS, Column.DYNAMIC_ALLOCATION_INVENTORY_LEVEL_IMPRESSIONS, Column.DYNAMIC_ALLOCATION_INVENTORY_LEVEL_CLICKS, Column.TOTAL_INVENTORY_LEVEL_IMPRESSIONS, Column.TOTAL_INVENTORY_LEVEL_CPM_AND_CPC_REVENUE }; reportJob.reportQuery.adUnitView = ReportQueryAdUnitView.HIERARCHICAL; reportJob.reportQuery.dateRangeType = DateRangeType.LAST_WEEK; try { // Run report. reportJob = reportService.runReportJob(reportJob); // Wait for report to complete. while (reportJob.reportJobStatus == ReportJobStatus.IN_PROGRESS) { Console.WriteLine("Report job with id = '{0}' is still running.", reportJob.id); Thread.Sleep(30000); // Get report job. reportJob = reportService.getReportJob(reportJob.id); } if (reportJob.reportJobStatus == ReportJobStatus.COMPLETED) { Console.WriteLine("Report job with id = '{0}' completed successfully.", reportJob.id); } else if (reportJob.reportJobStatus == ReportJobStatus.FAILED) { Console.WriteLine("Report job with id = '{0}' failed to complete successfully.", reportJob.id); } } catch (Exception ex) { Console.WriteLine("Failed to run inventory report. Exception says \"{0}\"", ex.Message); } }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { ReportService reportService = (ReportService) user.GetService( DfpService.v201308.ReportService); // Create report job. ReportJob reportJob = new ReportJob(); // Create report query. ReportQuery reportQuery = new ReportQuery(); reportQuery.dateRangeType = DateRangeType.LAST_MONTH; reportQuery.dimensions = new Dimension[] {Dimension.ORDER_ID, Dimension.ORDER_NAME}; reportQuery.columns = new Column[] {Column.MERGED_AD_SERVER_IMPRESSIONS, Column.MERGED_AD_SERVER_CLICKS, Column.MERGED_AD_SERVER_CTR, Column.MERGED_AD_SERVER_CPM_AND_CPC_REVENUE, Column.MERGED_AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM}; reportJob.reportQuery = reportQuery; try { // Run report job. reportJob = reportService.runReportJob(reportJob); do { Console.WriteLine("Report with ID '{0}' is still running.", reportJob.id); Thread.Sleep(30000); // Get report job. reportJob = reportService.getReportJob(reportJob.id); } while (reportJob.reportJobStatus == ReportJobStatus.IN_PROGRESS); if (reportJob.reportJobStatus == ReportJobStatus.FAILED) { Console.WriteLine("Report job with ID '{0}' failed to finish successfully.", reportJob.id); } else { Console.WriteLine("Report job with ID '{0}' completed successfully.", reportJob.id); } } catch (Exception ex) { Console.WriteLine("Failed to run delivery report. Exception says \"{0}\"", ex.Message); } }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { ReportService reportService = (ReportService) user.GetService( DfpService.v201308.ReportService); // Create report job. ReportJob reportJob = new ReportJob(); reportJob.reportQuery = new ReportQuery(); reportJob.reportQuery.dimensions = new Dimension[] {Dimension.SALESPERSON_ID, Dimension.SALESPERSON_NAME}; reportJob.reportQuery.columns = new Column[] { Column.AD_SERVER_IMPRESSIONS, Column.AD_SERVER_CPM_AND_CPC_REVENUE, Column.AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM }; reportJob.reportQuery.dateRangeType = DateRangeType.LAST_MONTH; try { // Run report. reportJob = reportService.runReportJob(reportJob); // Wait for report to complete. while (reportJob.reportJobStatus == ReportJobStatus.IN_PROGRESS) { Console.WriteLine("Report job with id = '{0}' is still running.", reportJob.id); Thread.Sleep(30000); // Get report job. reportJob = reportService.getReportJob(reportJob.id); } if (reportJob.reportJobStatus == ReportJobStatus.COMPLETED) { Console.WriteLine("Report job with id = '{0}' completed successfully.", reportJob.id); } else if (reportJob.reportJobStatus == ReportJobStatus.FAILED) { Console.WriteLine("Report job with id = '{0}' failed to complete successfully.", reportJob.id); } } catch (Exception ex) { Console.WriteLine("Failed to run sales report. Exception says \"{0}\"", ex.Message); } }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { ReportService reportService = (ReportService) user.GetService( DfpService.v201308.ReportService); // Create report job. ReportJob reportJob = new ReportJob(); // Create report query. ReportQuery reportQuery = new ReportQuery(); reportQuery.dateRangeType = DateRangeType.REACH_LIFETIME; reportQuery.dimensions = new Dimension[] {Dimension.LINE_ITEM_ID, Dimension.LINE_ITEM_NAME}; reportQuery.columns = new Column[] {Column.REACH_FREQUENCY, Column.REACH_AVERAGE_REVENUE, Column.REACH}; reportJob.reportQuery = reportQuery; try { // Run report. reportJob = reportService.runReportJob(reportJob); // Wait for report to complete. while (reportJob.reportJobStatus == ReportJobStatus.IN_PROGRESS) { Console.WriteLine("Report job with id = '{0}' is still running.", reportJob.id); Thread.Sleep(30000); // Get report job. reportJob = reportService.getReportJob(reportJob.id); } if (reportJob.reportJobStatus == ReportJobStatus.COMPLETED) { Console.WriteLine("Report job with id = '{0}' completed successfully.", reportJob.id); } else if (reportJob.reportJobStatus == ReportJobStatus.FAILED) { Console.WriteLine("Report job with id = '{0}' failed to complete successfully.", reportJob.id); } } catch (Exception ex) { Console.WriteLine("Failed to run delivery report. Exception says \"{0}\"", ex.Message); } }
public virtual ReportJob runReportJob(ReportJob reportJob) { object[] results = this.Invoke("runReportJob", new object[] { reportJob }); return ((ReportJob) (results[0])); }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { // Get the LineItemService. LineItemService lineItemService = (LineItemService) user.GetService(DfpService.v201308.LineItemService); // Get the ReportService. ReportService reportService = (ReportService) user.GetService(DfpService.v201308.ReportService); try { // Set the ID of the order to get line items from. long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE")); // Sets defaults for page and filterStatement. LineItemPage page = new LineItemPage(); int offset = 0; // Create a statement to only select line items from a given order. String filterText = "WHERE orderId = :orderId LIMIT 500"; Statement filterStatement = new StatementBuilder(filterText).AddValue("orderId", orderId).ToStatement(); // Collect all line item custom field IDs for an order. List<long> customFieldIds = new List<long>(); do { filterStatement.query = filterText + " OFFSET " + offset; // Get line items by statement. page = lineItemService.getLineItemsByStatement(filterStatement); // Get custom field IDs from the line items of an order. if (page.results != null) { foreach (LineItem lineItem in page.results) { if (lineItem.customFieldValues != null) { foreach (BaseCustomFieldValue customFieldValue in lineItem.customFieldValues) { if (!customFieldIds.Contains(customFieldValue.customFieldId)) { customFieldIds.Add(customFieldValue.customFieldId); } } } } } offset += 500; } while (offset < page.totalResultSetSize); // Create statement to filter for an order. filterStatement = new StatementBuilder("WHERE ORDER_ID = :orderId").AddValue("orderId", orderId) .ToStatement(); // Create report job. ReportJob reportJob = new ReportJob(); // Create report query. ReportQuery reportQuery = new ReportQuery(); reportQuery.dateRangeType = DateRangeType.LAST_MONTH; reportQuery.dimensions = new Dimension[] {Dimension.LINE_ITEM_ID, Dimension.LINE_ITEM_NAME}; reportQuery.statement = filterStatement; reportQuery.customFieldIds = customFieldIds.ToArray(); reportQuery.columns = new Column[] {Column.AD_SERVER_IMPRESSIONS}; reportJob.reportQuery = reportQuery; // Run report job. reportJob = reportService.runReportJob(reportJob); do { Console.WriteLine("Report with ID '{0}' is still running.", reportJob.id); Thread.Sleep(30000); // Get report job. reportJob = reportService.getReportJob(reportJob.id); } while (reportJob.reportJobStatus == ReportJobStatus.IN_PROGRESS); if (reportJob.reportJobStatus == ReportJobStatus.FAILED) { Console.WriteLine("Report job with ID '{0}' failed to finish successfully.", reportJob.id); } else { Console.WriteLine("Report job with ID '{0}' completed successfully.", reportJob.id); } } catch (Exception ex) { Console.WriteLine("Failed to run cusom fields report. Exception says \"{0}\"", ex.Message); } }
public ReportJob CreateReport(DfpUser user) { // Get ReportService. ReportService reportService = (ReportService) user.GetService(DfpService.v201308.ReportService); ReportJob reportJob = new ReportJob(); reportJob.reportQuery = new ReportQuery(); reportJob.reportQuery.dimensions = new Dimension[] {Dimension.ORDER_ID, Dimension.ORDER_NAME}; reportJob.reportQuery.columns = new Column[] {Column.AD_SERVER_IMPRESSIONS, Column.AD_SERVER_CLICKS, Column.AD_SERVER_CTR, Column.AD_SERVER_CPM_AND_CPC_REVENUE, Column.AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM}; reportJob.reportQuery.dateRangeType = DateRangeType.LAST_MONTH; return reportService.runReportJob(reportJob); }