public async Task <OverallReportPortion[]> GetOverallReportPortions(AggregateOverallRequest request, Metadata headers, Models.ReportSubject subject) { AggregateOverallResponse response; switch (subject) { case Models.ReportSubject.Cards: response = await cardsClient.AggregateOverallAsync(request, headers); break; case Models.ReportSubject.Loans: response = await loansClient.AggregateOverallAsync(request, headers); break; case Models.ReportSubject.Payments: response = await paymentsClient.AggregateOverallAsync(request, headers); break; case Models.ReportSubject.Transactions: response = await transactionsClient.AggregateOverallAsync(request, headers); break; default: throw new InvalidOperationException("Unknown subject of report."); } return(response.Portions.ToArray()); }
public override async Task <AggregateOverallResponse> AggregateOverall(AggregateOverallRequest request, ServerCallContext context) { var cardsIds = cardsRepository.GetCardsIds(); var transactionsResponse = await transactionsReadClient.FilterAsync(new FilterTransactionsRequest { Cards = { cardsIds }, TimestampTo = request.TimestampTo, TimestampFrom = request.TimestampFrom }, context.RequestHeaders.SelectCustom()); var aggregations = Aggregations.CreateOverallCsvReport(new OverallReportData { Aggregations = request.Aggregations.ToArray(), Granularity = request.Granularity, Transactions = transactionsResponse.Transactions.ToArray() }); return(new AggregateOverallResponse { Portions = { aggregations } }); }
public override Task <AggregateOverallResponse> AggregateOverall(AggregateOverallRequest request, Grpc.Core.ServerCallContext context) { var filters = new Filters { TimestampFrom = request.TimestampFrom.ToDateTime(), TimestampTo = request.TimestampTo.ToDateTime() }; var transactions = transactionsRepository.GetMany(filters, 0).Select(t => mapper.Map <Transaction>(t)).ToArray(); var aggregations = Aggregations.CreateOverallCsvReport(new OverallReportData { Aggregations = request.Aggregations.ToArray(), Granularity = request.Granularity, Transactions = transactions }); return(Task.FromResult(new AggregateOverallResponse { Portions = { aggregations } })); }
public async Task <string> Overall(OverallReportRequest data) { var request = new AggregateOverallRequest { Granularity = mapper.Map <Granularity>(data.Granularity), TimestampFrom = data.TimestampFrom.ToNullableTimestamp(), TimestampTo = data.TimestampTo.ToNullableTimestamp(), Aggregations = { data.Aggregations.Select(a => mapper.Map <Aggregation>(a)) }, Subject = mapper.Map <ReportSubject>(data.Subject), }; var response = await reportsBranchClient.AggregateOverallAsync(request, HttpContext.CreateHeadersWithFlowId()); return(response.Report); }
public override async Task <AggregateOverallResponse> AggregateOverall(AggregateOverallRequest request, ServerCallContext context) { var headers = context.RequestHeaders.SelectCustom(); Transaction[] transactions; switch (request.Subject) { case ReportSubject.Cards: transactions = await dataFetcher.GetCardsTransactions(headers, request.TimestampFrom, request.TimestampTo); break; case ReportSubject.Loans: transactions = await dataFetcher.GetLoansTransactions(headers, request.TimestampFrom, request.TimestampTo); break; case ReportSubject.Payments: transactions = await dataFetcher.GetPaymentsTransactions(headers, request.TimestampFrom, request.TimestampTo); break; case ReportSubject.Transactions: transactions = await dataFetcher.GetTransactions(headers, request.TimestampFrom, request.TimestampTo); break; default: throw new InvalidOperationException("Unknown subject of report."); } var data = new OverallReportData { From = request.TimestampFrom.ToDateTime(), To = request.TimestampTo.ToDateTime(), Granularity = request.Granularity, Subject = request.Subject, Aggregations = request.Aggregations.ToArray(), Transactions = transactions }; var report = ReportGenerator.AggregateOverall(data); return(new AggregateOverallResponse { Report = report }); }
public async Task <string> Overall(OverallReportRequest request) { var flowId = HttpContext.Items["flowId"].ToString(); var cqrsRequest = new AggregateOverallRequest { FlowId = flowId, Granularity = mapper.Map <Granularity>(request.Granularity), TimestampFrom = request.TimestampFrom.ToNullableTimestamp(), TimestampTo = request.TimestampTo.ToNullableTimestamp(), Aggregations = { request.Aggregations.Select(a => mapper.Map <Aggregation>(a)) } }; var data = await reportDataFetcher.GetOverallReportPortions(cqrsRequest, HttpContext.CreateHeadersWithFlowId(), request.Subject); var csv = ReportCsvSerializer.SerializerOverallReport(request.Subject, request.TimestampFrom, request.TimestampTo, request.Granularity, data); return(csv); }