} // btnShowReport_Click private ReportQuery CreateReportQuery(out bool isDaily) { DateTime fDate, tDate; GetDates(out fDate, out tDate, out isDaily); var rq = new ReportQuery { DateStart = fDate, DateEnd = tDate, ShowNonCashTransactions = chkShowNonCash.Checked ? 1 : 0 }; string sUserKey = UserKey.Value.Trim(); if (sUserKey != string.Empty) { int nUserID = 0; if (int.TryParse(sUserKey, out nUserID)) { rq.UserID = nUserID; } else { rq.UserID = null; } rq.UserNameOrEmail = sUserKey; } // if sUserKey is not empty return(rq); } // CreateReportQuery
} // AdjustUIFiltersForReport protected void btnShowReport_Click(object sender, EventArgs e) { bool isDaily; ReportQuery rptDef = CreateReportQuery(out isDaily); var oColumnTypes = new List <string>(); Log.Debug("Show report clicked for report: '{0}'", ddlReportTypes.SelectedItem.Text); bool isError; ATag data = reportHandler.GetReportData(ddlReportTypes.SelectedItem.Text, rptDef, isDaily, oColumnTypes, out isError); if (isError) { ResetBtn_Click(sender, e); } var aoColumnDefs = oColumnTypes.Select( sType => string.Format("{{ \"sType\": \"{0}\" }}", sType) ).ToList(); divReportColumnTypes.Controls.Add(new LiteralControl( "[" + string.Join(", ", aoColumnDefs) + "]" )); var reportData = new LiteralControl(data.ToString()); divReportData.Controls.Add(reportData); } // btnShowReport_Click
/// <summary> /// Handles the Click event of the btnDownloadReport control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="eventArgs">The <see cref="System.EventArgs"/> instance containing /// the event data.</param> protected void OnDownloadReportButtonClick(object sender, EventArgs eventArgs) { ConfigureUserForOAuth(); ReportService reportService = user.GetService <ReportService>(); ReportQuery reportQuery = new ReportQuery(); reportQuery.dimensions = new Dimension[] { Dimension.AD_UNIT_ID, Dimension.AD_UNIT_NAME }; reportQuery.columns = new Column[] { Column.AD_SERVER_IMPRESSIONS, Column.AD_SERVER_CLICKS, Column.ADSENSE_LINE_ITEM_LEVEL_IMPRESSIONS, Column.ADSENSE_LINE_ITEM_LEVEL_CLICKS, Column.TOTAL_LINE_ITEM_LEVEL_IMPRESSIONS, Column.TOTAL_LINE_ITEM_LEVEL_CPM_AND_CPC_REVENUE }; reportQuery.adUnitView = ReportQueryAdUnitView.HIERARCHICAL; reportQuery.dateRangeType = DateRangeType.YESTERDAY; // Create report job. ReportJob reportJob = new ReportJob(); reportJob.reportQuery = reportQuery; string filePath = Path.GetTempFileName(); try { // Run report. reportJob = reportService.runReportJob(reportJob); ReportUtilities reportUtilities = new ReportUtilities(reportService, reportJob.id); // Set download options. ReportDownloadOptions options = new ReportDownloadOptions(); options.exportFormat = ExportFormat.CSV_DUMP; options.useGzipCompression = true; reportUtilities.reportDownloadOptions = options; // Download the report. using (ReportResponse reportResponse = reportUtilities.GetResponse()) { reportResponse.Save(filePath); } } catch (Exception e) { throw new System.ApplicationException("Failed to download report.", e); } Response.AddHeader("content-disposition", "attachment;filename=report.csv.gzip"); Response.WriteFile(filePath); Response.End(); }
public IActionResult ExpensesByCategory([FromQuery] ReportQuery query) { var report = new Dictionary <Guid, dynamic>(); var numMonths = 8; var categories = _categoryRepo.GetAll().Where(c => c.Type == "Expense").ToList(); var end = DateTime.Today.LastDayOfMonth(); var start = end.AddMonths(0 - numMonths + 1).FirstDayOfMonth(); var expenses = _transactionRepo.GetExpensesByCategory(start, end).ToList(); // Add categories with no expenses var missingCategories = categories.Where(c => expenses.All(e => e.categoryId != c.CategoryId)).ToList(); foreach (var category in missingCategories) { expenses.Add(new { categoryId = category.CategoryId, categoryName = category.Name, total = 0.0M, expenses = new List <dynamic>() }); } var monthTotals = new List <dynamic>(); for (int i = 0; i < numMonths; i++) { end = end.FirstDayOfMonth(); var total = expenses.Sum(e => ((IEnumerable <dynamic>)e.expenses).Where(x => x.date == end).Sum(x => (decimal)x.amount)); monthTotals.Add(new { date = end, total }); end = end.AddMonths(-1); } return(Ok(new { expenses, monthTotals })); }
public async Task ShouldPopulateStandardReportFieldsAndSave() { var loggerMock = GetLoggerMock <IReporter>(); Common.SetupConfiguration(_configurationMock); var repositoryMock = new Mock <IRepository>(); var data = Common.SetupDataForBaseReporter(repositoryMock); var dummy = new DummyReporter(repositoryMock.Object, _configurationMock.Object, loggerMock.Object); var query = new ReportQuery { StartDate = DateTime.UtcNow.AddDays(-7), EndDate = DateTime.UtcNow.AddDays(2), ProfileId = data.profile.Id }; var report = await dummy.ReportAsync(query); report.Id.Should().NotBeEmpty(); report.DateTaken.Should().BeCloseTo(DateTime.UtcNow); report.StartDate.Should().Be(query.StartDate); report.EndDate.Should().Be(query.EndDate); report.ProfileName.Should().Be(data.profile.Name); report.ReporterId.Should().Be(dummy.Id); report.ReportName.Should().Be(dummy.Name); repositoryMock.Verify(r => r.CreateAsync(It.IsAny <ReportResult>()), Times.Once()); }
private void AddHeadlinesToSheet(ReportQuery reportQuery) { AddContent("Område"); AddContent("Nummer"); AddContent("Data"); AddContent("Spørring"); if (reportQuery.QueryName == "register-DOK-coverage") { AddContent("Dekning"); } else { AddContent("Antall"); } if (reportQuery.QueryName == "register-DOK-coverage") { AddContent("Valgt"); } else if (reportQuery.QueryName != "register-DOK-selectedSuitability") { AddContent("Tillegg"); } if (reportQuery.QueryName != "register-DOK-coverage") { AddContent("Totalt"); AddContent("% av totalt"); } if (reportQuery.QueryName == "register-DOK-selectedAndAdditional") { AddContent("Oppdatert"); AddContent("Status"); } }
public ReportSQLSource(string name, string prefix, ReportSQLSource parent, ReportQuery reportQuery) { Name = name; Prefix = prefix; Parent = parent; ReportQuery = reportQuery; }
/// <summary> /// Run the code example. /// </summary> public void Run(AdManagerUser user) { using (ReportService reportService = user.GetService <ReportService>()) { // Set the file path where the report will be saved. String filePath = _T("INSERT_FILE_PATH_HERE"); // Create report query. ReportQuery reportQuery = new ReportQuery(); reportQuery.dimensions = new Dimension[] { Dimension.AD_EXCHANGE_DATE, Dimension.AD_EXCHANGE_COUNTRY_NAME }; reportQuery.columns = new Column[] { Column.AD_EXCHANGE_AD_REQUESTS, Column.AD_EXCHANGE_IMPRESSIONS, Column.AD_EXCHANGE_ESTIMATED_REVENUE }; reportQuery.dateRangeType = DateRangeType.LAST_WEEK; // Run in pacific time. reportQuery.timeZoneType = TimeZoneType.AD_EXCHANGE; reportQuery.adxReportCurrency = "EUR"; // Create report job. ReportJob reportJob = new ReportJob(); reportJob.reportQuery = reportQuery; try { // Run report. reportJob = reportService.runReportJob(reportJob); ReportUtilities reportUtilities = new ReportUtilities(reportService, reportJob.id); // Set download options. ReportDownloadOptions options = new ReportDownloadOptions(); options.exportFormat = ExportFormat.CSV_DUMP; options.useGzipCompression = true; reportUtilities.reportDownloadOptions = options; // Download the report. using (ReportResponse reportResponse = reportUtilities.GetResponse()) { reportResponse.Save(filePath); } Console.WriteLine("Report saved to \"{0}\".", filePath); } catch (Exception e) { Console.WriteLine("Failed to run Ad Exchange report. Exception says \"{0}\"", e.Message); } } }
/// <summary> /// Run the code example. /// </summary> public void Run(AdManagerUser user) { using (ReportService reportService = user.GetService <ReportService>()) { // Set the file path where the report will be saved. String filePath = _T("INSERT_FILE_PATH_HERE"); // Create report query. ReportQuery reportQuery = new ReportQuery(); reportQuery.dimensions = new Dimension[] { Dimension.AD_UNIT_ID, Dimension.AD_UNIT_NAME }; reportQuery.columns = new Column[] { Column.AD_SERVER_IMPRESSIONS, Column.AD_SERVER_CLICKS, Column.ADSENSE_LINE_ITEM_LEVEL_IMPRESSIONS, Column.ADSENSE_LINE_ITEM_LEVEL_CLICKS, Column.TOTAL_LINE_ITEM_LEVEL_IMPRESSIONS, Column.TOTAL_LINE_ITEM_LEVEL_CPM_AND_CPC_REVENUE }; reportQuery.adUnitView = ReportQueryAdUnitView.HIERARCHICAL; reportQuery.dateRangeType = DateRangeType.LAST_WEEK; // Create report job. ReportJob reportJob = new ReportJob(); reportJob.reportQuery = reportQuery; try { // Run report. reportJob = reportService.runReportJob(reportJob); ReportUtilities reportUtilities = new ReportUtilities(reportService, reportJob.id); // Set download options. ReportDownloadOptions options = new ReportDownloadOptions(); options.exportFormat = ExportFormat.CSV_DUMP; options.useGzipCompression = true; reportUtilities.reportDownloadOptions = options; // Download the report. using (ReportResponse reportResponse = reportUtilities.GetResponse()) { reportResponse.Save(filePath); } Console.WriteLine("Report saved to \"{0}\".", filePath); } catch (Exception e) { Console.WriteLine("Failed to run inventory report. Exception says \"{0}\"", e.Message); } } }
public async Task <IEnumerable <IntershipView> > GetIntershipByCenterAndTime(ReportQuery query) { var service = _provider.GetRequiredService <IIntershipService>(); var expression = Builders <Intership> .Filter.And( Builders <Intership> .Filter.Eq(x => x.IsPublished, true), Builders <Intership> .Filter.Or( Builders <Intership> .Filter.And( Builders <Intership> .Filter.Lte(x => x.Start, query.Start), Builders <Intership> .Filter.Gte(x => x.End, query.Start) ), Builders <Intership> .Filter.And( Builders <Intership> .Filter.Lte(x => x.Start, query.Start), Builders <Intership> .Filter.Gte(x => x.End, query.End) ), Builders <Intership> .Filter.And( Builders <Intership> .Filter.Gte(x => x.Start, query.Start), Builders <Intership> .Filter.Lte(x => x.End, query.End) ), Builders <Intership> .Filter.And( Builders <Intership> .Filter.Lte(x => x.Start, query.End), Builders <Intership> .Filter.Gte(x => x.End, query.End) ) ) ); if (!query.IsAllCenter) { expression = Builders <Intership> .Filter.And(expression, Builders <Intership> .Filter.In(x => x.CenterCode, query.CenterCodes)); } return(await service.GetByExpression(expression)); }
/// <summary> /// Run the code example. /// </summary> public void Run(AdManagerUser user) { using (ReportService reportService = user.GetService <ReportService>()) { // Set the file path where the report will be saved. String filePath = _T("INSERT_FILE_PATH_HERE"); // Create report job. ReportJob reportJob = new ReportJob(); // Create report query. ReportQuery reportQuery = new ReportQuery() { adUnitView = ReportQueryAdUnitView.FLAT, dateRangeType = DateRangeType.LAST_MONTH, dimensions = new Dimension[] { Dimension.MONTH_AND_YEAR, Dimension.COUNTRY_NAME, Dimension.AD_UNIT_ID, Dimension.AD_UNIT_NAME }, columns = new Column[] { Column.UNIQUE_REACH_FREQUENCY, Column.UNIQUE_REACH_IMPRESSIONS, Column.UNIQUE_REACH } }; reportJob.reportQuery = reportQuery; try { // Run report. reportJob = reportService.runReportJob(reportJob); ReportUtilities reportUtilities = new ReportUtilities(reportService, reportJob.id); // Set download options. ReportDownloadOptions options = new ReportDownloadOptions(); options.exportFormat = ExportFormat.CSV_DUMP; options.useGzipCompression = true; reportUtilities.reportDownloadOptions = options; // Download the report. using (ReportResponse reportResponse = reportUtilities.GetResponse()) { reportResponse.Save(filePath); } Console.WriteLine("Report saved to \"{0}\".", filePath); } catch (Exception e) { Console.WriteLine("Failed to run reach report. Exception says \"{0}\"", e.Message); } } }
/// <summary> /// Return reports for DOK. /// Supported Queries: /// QueryName = "register-DOK-selectedAndAdditional". /// QueryName = "register-DOK-selectedTheme". /// QueryName = "register-DOK-coverage". /// </summary> public ReportResult Post(ReportQuery query) { Trace.WriteLine("QueryName: " + query.QueryName); ReportResult result = new ReportResult(); if (query.QueryName == "register-DOK-selectedAndAdditional") { result = _dokReportService.GetSelectedAndAdditionalDatasets(query); } else if (query.QueryName == "register-DOK-selectedSuitability") { result = _dokReportService.GetSelectedSuitabilityDatasets(query); } else if (query.QueryName == "register-DOK-selectedTheme") { result = _dokReportService.GetSelectedDatasetsByTheme(query); } else if (query.QueryName == "register-DOK-coverage") { result = _dokReportService.GetSelectedDatasetsCoverage(query); } return(result); }
public async Task <IEnumerable <EmployeeCourseView> > GetCourseByCourse(ReportQuery query) { var service = _provider.GetRequiredService <IEmployeeCourseService>(); var expression = Builders <EmployeeCourse> .Filter.And( Builders <EmployeeCourse> .Filter.Eq(x => x.IsPublished, true), Builders <EmployeeCourse> .Filter.Or( Builders <EmployeeCourse> .Filter.And( Builders <EmployeeCourse> .Filter.Lte(x => x.Start, query.Start), Builders <EmployeeCourse> .Filter.Gte(x => x.End, query.Start) ), Builders <EmployeeCourse> .Filter.And( Builders <EmployeeCourse> .Filter.Lte(x => x.Start, query.Start), Builders <EmployeeCourse> .Filter.Gte(x => x.End, query.End) ), Builders <EmployeeCourse> .Filter.And( Builders <EmployeeCourse> .Filter.Gte(x => x.Start, query.Start), Builders <EmployeeCourse> .Filter.Lte(x => x.End, query.End) ), Builders <EmployeeCourse> .Filter.And( Builders <EmployeeCourse> .Filter.Lte(x => x.Start, query.End), Builders <EmployeeCourse> .Filter.Gte(x => x.End, query.End) ) ) ); if (!query.IsAllCourse) { expression = Builders <EmployeeCourse> .Filter.And(expression, Builders <EmployeeCourse> .Filter.In(x => x.CourseCode, query.CourseCodes)); } return(await service.GetByExpression(expression)); }
public async Task <ReportQueryResult> Handle(EvacueeReportQuery query) { var evacueeQuery = new ReportQuery { FileId = query.FileId, TaskNumber = query.TaskNumber, EvacuatedFrom = query.EvacuatedFrom, EvacuatedTo = query.EvacuatedTo, }; var results = (await reportRepository.QueryEvacuee(evacueeQuery)).Items; var evacuees = mapper.Map <IEnumerable <Evacuee> >(results, opt => opt.Items["IncludePersonalInfo"] = query.IncludePersonalInfo.ToString()); var communities = await metadataRepository.GetCommunities(); evacueeQuery.EvacuatedFrom = communities.Where(c => c.Code == evacueeQuery.EvacuatedFrom).SingleOrDefault()?.Name; evacueeQuery.EvacuatedTo = communities.Where(c => c.Code == evacueeQuery.EvacuatedTo).SingleOrDefault()?.Name; var csv = evacuees.ToCSV(evacueeQuery); var content = Encoding.UTF8.GetBytes(csv); var contentType = "text/csv"; return(new ReportQueryResult { Content = content, ContentType = contentType }); }
public async Task <ReportQueryResult> Handle(SupportReportQuery query) { var supportQuery = new ReportQuery { FileId = query.FileId, TaskNumber = query.TaskNumber, EvacuatedFrom = query.EvacuatedFrom, EvacuatedTo = query.EvacuatedTo, }; var supports = (await reportRepository.QuerySupport(supportQuery)).Items; var communities = await metadataRepository.GetCommunities(); supportQuery.EvacuatedFrom = communities.Where(c => c.Code == supportQuery.EvacuatedFrom).SingleOrDefault()?.Name; supportQuery.EvacuatedTo = communities.Where(c => c.Code == supportQuery.EvacuatedTo).SingleOrDefault()?.Name; var csv = supports.ToCSV(supportQuery, "\""); var content = Encoding.UTF8.GetBytes(csv); var contentType = "text/csv"; return(new ReportQueryResult { Content = content, ContentType = contentType }); }
public ReportQuery SaveOrUpdateMerge(ReportQuery reportQuery) { object mergedObj = Session.Merge(reportQuery); HibernateTemplate.SaveOrUpdate(mergedObj); return((ReportQuery)mergedObj); }
private async Task <ReportInput> GetInputData(ReportQuery query) { var profile = await _repository.GetSingleAsync <Profile>(query.ProfileId); if (profile == null) { throw new ArgumentException("Selected profile was not found."); } var repositories = await _repository.GetAsync <VSTSRepository>(r => profile.Repositories.Contains(r.Id)); var members = await _repository.GetAsync <TeamMember>(m => profile.Members.Contains(m.Id)); var projectsIds = repositories.Select(r => r.Project); var projects = await _repository.GetAsync <VSTSProject>(p => projectsIds.Contains(p.Id)); return(new ReportInput { Query = query, Profile = profile, Repositories = repositories, Members = members, Projects = projects }); }
} // constructor public KeyValuePair <ReportQuery, DataTable> Run(Report report, DateTime from, DateTime to) { m_oAsyncData = new SortedDictionary <int, StrategyData>(); m_oSyncData = new SortedDictionary <int, StrategyData>(); m_oDB.ForEachRowSafe( ProcessRow, "RptStrategyRunningTime", CommandSpecies.StoredProcedure, new QueryParameter("DateStart", from), new QueryParameter("DateEnd", to) ); foreach (var pair in m_oAsyncData) { pair.Value.CalculateTimes(); } foreach (var pair in m_oSyncData) { pair.Value.CalculateTimes(); } var reprortQuery = new ReportQuery(report) { DateStart = from, DateEnd = to }; return(new KeyValuePair <ReportQuery, DataTable>(reprortQuery, ToTable())); } // Run
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public void Run(DfpUser user, long savedQueryId) { ReportService reportService = (ReportService)user.GetService( DfpService.v201608.ReportService); // Set the file path where the report will be saved. String filePath = _T("INSERT_FILE_PATH_HERE"); // Create statement to retrieve the saved query. // [START report_guide_include_1] MOE:strip_line StatementBuilder statementBuilder = new StatementBuilder() .Where("id = :id") .OrderBy("id ASC") .Limit(1) .AddValue("id", savedQueryId); SavedQueryPage page = reportService.getSavedQueriesByStatement(statementBuilder.ToStatement()); SavedQuery savedQuery = page.results[0]; if (!savedQuery.isCompatibleWithApiVersion) { throw new InvalidOperationException("Saved query is not compatible with this API version"); } // Optionally modify the query. ReportQuery reportQuery = savedQuery.reportQuery; // [END report_guide_include_1] MOE:strip_line reportQuery.adUnitView = ReportQueryAdUnitView.HIERARCHICAL; // Create a report job using the saved query. ReportJob reportJob = new ReportJob(); reportJob.reportQuery = reportQuery; try { // Run report. reportJob = reportService.runReportJob(reportJob); ReportUtilities reportUtilities = new ReportUtilities(reportService, reportJob.id); // Set download options. ReportDownloadOptions options = new ReportDownloadOptions(); options.exportFormat = ExportFormat.CSV_DUMP; options.useGzipCompression = true; reportUtilities.reportDownloadOptions = options; // Download the report. using (ReportResponse reportResponse = reportUtilities.GetResponse()) { reportResponse.Save(filePath); } Console.WriteLine("Report saved to \"{0}\".", filePath); } catch (Exception e) { Console.WriteLine("Failed to run saved query. Exception says \"{0}\"", e.Message); } }
public Report_FlexibleDriver GetFlexibleDriverScorecard(ReportQuery reportQuery) { IHttpRestRequest request = GetRequest(APIControllerRoutes.ScoringController.GETFLEXIBLEDRIVERSORECARD, HttpMethod.Post); request.AddJsonBody(reportQuery); IHttpRestResponse <Report_FlexibleDriver> response = Execute <Report_FlexibleDriver>(request); return(response.Data); }
public Report_FlexibleStandard GetFlexibleStandardScoreReport(ReportQuery reportQuery) { IHttpRestRequest request = GetRequest(APIControllerRoutes.ScoringController.GETFLEXIBLESTANDARDSCORINGREPORT, HttpMethod.Post); request.AddJsonBody(reportQuery); IHttpRestResponse <Report_FlexibleStandard> response = Execute <Report_FlexibleStandard>(request); return(response.Data); }
public async Task <Report_FlexibleRAG> GetFlexibleRAGScoreReportAsync(ReportQuery reportQuery) { IHttpRestRequest request = GetRequest(APIControllerRoutes.ScoringController.GETFLEXIBLERAGSCORINGREPORT, HttpMethod.Post); request.AddJsonBody(reportQuery); IHttpRestResponse <Report_FlexibleRAG> response = await ExecuteAsync <Report_FlexibleRAG>(request).ConfigureAwait(false); return(response.Data); }
//[InlineData(Messages.InvalidCustomerId, "", "12345", 1000, 500)] //[InlineData(Messages.InvalidSecurityId, "123456789", "", 1000, 500)] //[InlineData(Messages.InvalidSecurityQuantity, "123456789", "12345", 0, 500)] //[InlineData(Messages.InvalidSecurityQuantity, "123456789", "12345", -1, 500)] //[InlineData(Messages.InvalidWithdrawalQuantity, "123456789", "12345", 1000, 0)] //[InlineData(Messages.InvalidWithdrawalQuantity, "123456789", "12345", 1000, -1)] public async Task ShouldReturnFail_AfterHandle_InvalidRequestParameters() //, string customerId, string securityId, decimal securityQuantity, decimal withdrawalQuantity) { List <TypeQuestions> checkBoxes = new List <TypeQuestions>(); var request = new ReportQuery(checkBoxes); Response <ReportResponse> response = await _handler.Handle(request, CancellationToken.None); response.IsFailure.Should().BeTrue(); //response.Messages.Contains(expected).Should().BeTrue(); }
public async Task <Report_FlexibleDriver> GetFlexibleDriverScorecardAsync(ReportQuery reportQuery) { IHttpRestRequest request = GetRequest(APIControllerRoutes.ScoringController.GETFLEXIBLEDRIVERSORECARD, HttpMethod.Post); request.AddJsonBody(reportQuery); IHttpRestResponse <Report_FlexibleDriver> response = await ExecuteAsync <Report_FlexibleDriver>(request).ConfigureAwait(false); return(response.Data); }
/// <summary> /// Run the code example. /// </summary> public void Run(DfpUser user) { using (ReportService reportService = (ReportService)user.GetService(DfpService.v201802.ReportService)) { // Set the file path where the report will be saved. String filePath = _T("INSERT_FILE_PATH_HERE"); // 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); ReportUtilities reportUtilities = new ReportUtilities(reportService, reportJob.id); // Set download options. ReportDownloadOptions options = new ReportDownloadOptions(); options.exportFormat = ExportFormat.CSV_DUMP; options.useGzipCompression = true; reportUtilities.reportDownloadOptions = options; // Download the report. using (ReportResponse reportResponse = reportUtilities.GetResponse()) { reportResponse.Save(filePath); } Console.WriteLine("Report saved to \"{0}\".", filePath); } catch (Exception e) { Console.WriteLine("Failed to run delivery report. Exception says \"{0}\"", e.Message); } } }
public static void GenerateXmlDailyShopReport() { var dbContext = new DealershipDbContext(); ReportQuery query = new ReportQuery(); ICollection <IXmlDailyShopReport> dailyReport = new List <IXmlDailyShopReport>(); IReportWriter dailyWrite = new XmlDailyShopReportWriter(query.DailyShopReport(dbContext, dailyReport)); dailyWrite.Write(); }
public void GeneratePdfAggregateDailySalesReport() { var dbContext = new DealershipDbContext(); ReportQuery query = new ReportQuery(); ICollection <IPdfAggregatedDailySalesReport> totalReport = new List <IPdfAggregatedDailySalesReport>(); IReportWriter totalWriter = new PdfAggregatedDailySalesReportWriter(query.AggregatedDailySalesReports(dbContext, totalReport)); totalWriter.Write(); }
public void GenerateXmlShopReport() { var dbContext = new DealershipDbContext(); ReportQuery query = new ReportQuery(); ICollection <IXmlShopReport> totalReport = new List <IXmlShopReport>(); IReportWriter totalWriter = new XmlShopReportWriter(query.ShopReport(dbContext, totalReport)); totalWriter.Write(); }
} // HandleGenericReport private void BuildReport( Report report, DateTime fromDate, DateTime toDate, string period, ReportDispatcher sender, DateTime oReportGenerationDate, Func <Report, DateTime, DateTime, List <string>, ATag> oBuildHtml, Func <Report, DateTime, DateTime, ExcelPackage> oBuildXls ) { Debug("Building report {0} for period {1}", report.Title, period); var email = new ReportEmail(); switch (period) { case DailyPerdiod: email.Title.Append(new Text(period + " " + report.GetTitle(fromDate, " for "))); break; case WeeklyPerdiod: email.Title.Append(new Text(period + " " + report.GetTitle(fromDate, " for ", toDate))); break; case MonthlyPerdiod: email.Title.Append(new Text(period + " " + report.GetMonthTitle(fromDate))); break; case MonthToDatePerdiod: email.Title.Append(new Text(period + " " + report.GetMonthTitle(fromDate, toDate))); break; } // switch var rptDef = new ReportQuery(report, fromDate, toDate); ATag oBody = oBuildHtml == null ? TableReport(rptDef, false, email.Title.ToString()) : oBuildHtml(report, fromDate, toDate, null); ExcelPackage oXls = oBuildXls == null ? XlsReport(rptDef, email.Title.ToString()) : oBuildXls(report, fromDate, toDate); email.ReportBody.Append(oBody); sender.Dispatch( report.Title, oReportGenerationDate, email.HtmlBody, oXls, report.ToEmail, period ); } // BuildReport
public ucReport(ReportQuery reportQuery) { _reportVM = new ReportViewModel(); _reportQuery = reportQuery; _reportVM.LoadReport(_reportQuery); DataContext = _reportVM; InitializeComponent(); }
/// <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.v201508.ReportService); // Set the file path where the report will be saved. String filePath = _T("INSERT_FILE_PATH_HERE"); // 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); ReportUtilities reportUtilities = new ReportUtilities(reportService, reportJob.id); // Set download options. ReportDownloadOptions options = new ReportDownloadOptions(); options.exportFormat = ExportFormat.CSV_DUMP; options.useGzipCompression = true; reportUtilities.reportDownloadOptions = options; // Download the report. using (ReportResponse reportResponse = reportUtilities.GetResponse()) { reportResponse.Save(filePath); } Console.WriteLine("Report saved to \"{0}\".", filePath); } catch (Exception e) { Console.WriteLine("Failed to run delivery report. Exception says \"{0}\"", e.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.v201508.ReportService); // Get the NetworkService. NetworkService networkService = (NetworkService) user.GetService( DfpService.v201508.NetworkService); // Set the file path where the report will be saved. String filePath = _T("INSERT_FILE_PATH_HERE"); // Get the root ad unit ID to filter on. String rootAdUnitId = networkService.getCurrentNetwork().effectiveRootAdUnitId; // Create statement to filter on an ancestor ad unit with the root ad unit ID to include all // ad units in the network. StatementBuilder statementBuilder = new StatementBuilder() .Where("PARENT_AD_UNIT_ID = :parentAdUnitId") .AddValue("parentAdUnitId", long.Parse(rootAdUnitId)); // Create report query. ReportQuery reportQuery = new ReportQuery(); reportQuery.dimensions = new Dimension[] {Dimension.AD_UNIT_ID, Dimension.AD_UNIT_NAME}; 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}; // Set the filter statement. reportQuery.statement = statementBuilder.ToStatement(); reportQuery.adUnitView = ReportQueryAdUnitView.HIERARCHICAL; reportQuery.dateRangeType = DateRangeType.LAST_WEEK; // Create report job. ReportJob reportJob = new ReportJob(); reportJob.reportQuery = reportQuery; try { // Run report. reportJob = reportService.runReportJob(reportJob); ReportUtilities reportUtilities = new ReportUtilities(reportService, reportJob.id); // Set download options. ReportDownloadOptions options = new ReportDownloadOptions(); options.exportFormat = ExportFormat.CSV_DUMP; options.useGzipCompression = true; reportUtilities.reportDownloadOptions = options; // Download the report. using (ReportResponse reportResponse = reportUtilities.GetResponse()) { reportResponse.Save(filePath); } Console.WriteLine("Report saved to \"{0}\".", filePath); } catch (Exception e) { Console.WriteLine("Failed to run inventory report. Exception says \"{0}\"", e.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) { // Get the LineItemService. LineItemService lineItemService = (LineItemService) user.GetService(DfpService.v201511.LineItemService); // Get the ReportService. ReportService reportService = (ReportService) user.GetService(DfpService.v201511.ReportService); try { // Set the ID of the order to get line items from. long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE")); // Set the file path where the report will be saved. String filePath = _T("INSERT_FILE_PATH_HERE"); // Sets default for page. LineItemPage page = new LineItemPage(); // Create a statement to only select line items from a given order. StatementBuilder statementBuilder = new StatementBuilder() .Where("orderId = :orderId") .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT) .AddValue("orderId", orderId); // Collect all line item custom field IDs for an order. List<long> customFieldIds = new List<long>(); do { // Get line items by statement. page = lineItemService.getLineItemsByStatement(statementBuilder.ToStatement()); // 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); } } } } } statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT); } while (statementBuilder.GetOffset() < page.totalResultSetSize); // Create statement to filter for an order. statementBuilder.RemoveLimitAndOffset(); // 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 = statementBuilder.ToStatement(); reportQuery.customFieldIds = customFieldIds.ToArray(); reportQuery.columns = new Column[] {Column.AD_SERVER_IMPRESSIONS}; reportJob.reportQuery = reportQuery; // Run report job. reportJob = reportService.runReportJob(reportJob); ReportUtilities reportUtilities = new ReportUtilities(reportService, reportJob.id); // Set download options. ReportDownloadOptions options = new ReportDownloadOptions(); options.exportFormat = ExportFormat.CSV_DUMP; options.useGzipCompression = true; reportUtilities.reportDownloadOptions = options; // Download the report. using (ReportResponse reportResponse = reportUtilities.GetResponse()) { reportResponse.Save(filePath); } Console.WriteLine("Report saved to \"{0}\".", filePath); } catch (Exception e) { Console.WriteLine("Failed to run cusom fields report. Exception says \"{0}\"", e.Message); } }