Beispiel #1
0
 public void Handle(ConversionData conversionData)
 {
     using (_oenConnection = ConnectToOEN())
     {
         SaveRevenue(conversionData);
     }
 }
Beispiel #2
0
        private void SaveRevenue(ConversionData conversion) 
        {
            var revenue = GetRevenue(conversion.BatchId.Value, conversion.ListId.Value, conversion.SubscriberId.Value);
            var campaignType = GetCampaignTypeForBatch(conversion.BatchId.Value);

            // Don't add revenu for CPM conversions.
            if (campaignType == CampaignType.CPM)
            {
                _logger.Info("Ignoring CPM conversion {0}", conversion);
                return;
            }
             
            conversion.Amount = ConvertPublisherRevenueToWhiteDeliveryRevenue(conversion.Amount);

            if (revenue == null)
            {
                InsertRevenue(new RevenueDTO
                {
                    Batch_id = conversion.BatchId.Value,
                    List_id = conversion.ListId.Value,
                    Subscriber_id = conversion.SubscriberId.Value,
                    Revenue = (decimal?)conversion.Amount,
                    Offer_id = conversion.Offer,
                    OfferAmount = null,
                    date_created = DateTime.Now
                });

                _logger.Info("Created revenue for conversion: {0}", conversion);
            }
            else
            {
                revenue.Revenue = (decimal?)conversion.Amount;
                revenue.date_modified = DateTime.Now;
                UpdateRevenue(revenue);
                _logger.Info("Updated revenue for conversion: {0}", conversion);
            }
        }
Beispiel #3
0
        private ConversionData GetConversionDataFromQuerystring()
        {
            var data = new ConversionData();
            var query = Request.GetQueryNameValuePairs();

            var dp1 = query.FirstOrDefault(x => x.Key == settings.ConversionDP1Field);
            var amount = query.FirstOrDefault(x => x.Key == settings.ConversionAmountField);
            var offer = query.FirstOrDefault(x => x.Key == settings.ConversionOfferField);

            if (string.IsNullOrEmpty(dp1.Value) || string.IsNullOrEmpty(amount.Value) || string.IsNullOrEmpty(offer.Value))
                return data;

            data.Amount = ParseAmount(amount.Value);
            data.Offer = ParseInt(offer.Value);

            var parts = dp1.Value.Split('-');

            if (parts.Length != 3)
                return data;

            // batch-subscriber-list
            data.BatchId = ParseInt(parts[0]);
            data.SubscriberId = ParseInt(parts[1]);
            data.ListId = ParseInt(parts[2]);

            return data;
        }
Beispiel #4
0
 private void Publish(ConversionData conversion)
 {
     bus.Publish(conversion, "conversion");
 }
Beispiel #5
0
 private void ProcessConversion(ConversionData conversion)
 {
     new ConversionHandler(_logger, _settings).Handle(conversion);
 }