Exemple #1
0
        /// <summary>
        /// Generates transaction report for Rewardnetwork between the given dates
        /// </summary>
        /// <param name="startDate">Start date for the transaction report</param>
        /// <param name="endDate">End date for the transaction report exclusive</param>
        public void GenerateReportForDays(DateTime startDate, DateTime endDate)
        {
            DateTime reportDate = startDate.AddDays(1);

            //Get all the transactions till the end date
            while (reportDate <= endDate)
            {
                //Get all transactions from db
                var result = RedeemedDealOperations.GetRedeemedDealTransactionInfosByDate(startDate, endDate);

                if (result == ResultCode.Success)
                {
                    List <RedeemedDealTransactionInfo> lstTransactionInfos =
                        (List <RedeemedDealTransactionInfo>)RedeemedDealOperations.Context[Key.RedeemedDealInfo];

                    List <string> lstDealGuids =
                        lstTransactionInfos.Select(redeemDealTransactionInfo => redeemDealTransactionInfo.DealId.ToString())
                        .ToList();

                    //Filter out only RN transactions
                    Dictionary <string, DotM.DataContracts.Deal> dealIdsToProviderId = GetRewardNetworkDeals(lstDealGuids);

                    Collection <TransactionRecord> lstTransactionRecords = GetTransactionRecords(lstTransactionInfos,
                                                                                                 dealIdsToProviderId);

                    //Generate the report as per RN specification
                    Tuple <string, string> reportTuple = TransactionReportBuilder.Build(lstTransactionRecords, startDate);

                    //Upload the report to RN FTP
                    UploadReport(reportTuple);

                    //Update the last successful run date in the context. This will eventually be persisted in the scheduler job details, so that we know the start date for the next run
                    Context[Key.RewardNetworkReportLastRunDate] = startDate;

                    startDate  = startDate.AddDays(1);
                    reportDate = reportDate.AddDays(1);
                }
            }
        }
 internal SearchCriteriaBuilder(TransactionReportBuilder <TResult> reportBuilder)
 {
     _reportBuilder = reportBuilder;
 }