Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="context"></param>
        /// 
        public override void Invoke(ExchangeRuntime runtime)
        {
            if (runtime.Abort)
            {
                // runtime.Status = ExchangeEngine.
                runtime.Continue();
                return;
            }

            Stopwatch timer = new Stopwatch();
            timer.Start();

            PricingEvent @event = new PricingEvent(this.GetType().Name);
            string debtamount = runtime.GetDebtLead().CreditCardDebtAmount;
            string daysbehind = runtime.GetDebtLead().PaymentStatus;
            Console.WriteLine("amount={0}, days={1}.", debtamount, daysbehind);
            List<long> prospects = runtime.GetData(ExchangeRuntime.PROSPECTS) as List<long>;

            EntityCollection<Allocation> allocations = ExchangeService.GetAllocationPlan(prospects, debtamount, daysbehind);
            if (allocations == null)
            {
                runtime.Status = ExchangeRuntime.PENDING_MATCH;
                timer.Stop();
                @event.ElapsedTime = timer.ElapsedMilliseconds;
                runtime.AllocationCount = 0;
                runtime.AddStrategyEvent(@event);
                runtime.Continue();
                return;
            }

            List<long> distributions = new List<long>();

            foreach (Allocation prospect in allocations)
            {
                OutboundDuplicate outDupe = new OutboundDuplicate();
                outDupe.Aid = Convert.ToString(prospect.Aid);
                outDupe.Oid = Convert.ToString(prospect.OrderId);
                outDupe.Email = runtime.GetLead().Email;
                outDupe.Created = runtime.GetLead().Created;
                ExchangeService.SaveOutboundDuplicate(outDupe);

                distributions.Add(prospect.Aid);
                @event.Bids.Add(new Bid(prospect.Aid, prospect.OrderId));
            }

            if (allocations.Count() > 0)
            {
                runtime.Status = ExchangeRuntime.ACCEPTED;
            }

            timer.Stop();
            @event.ElapsedTime = timer.ElapsedMilliseconds;
            runtime.StoreData(ExchangeRuntime.DISTRIBUTIONS, distributions);
            runtime.AllocationCount = allocations.Count();
            runtime.AddStrategyEvent(@event);
            runtime.Continue();
        }
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="runtime"></param>
        /// 
        public override void Invoke(ExchangeRuntime runtime)
        {
            if (runtime.Abort)
            {
                runtime.Continue();
                return;
            }

            Stopwatch timer = new Stopwatch();
            timer.Start();

            List<long> prospects = new List<long>();
            EntityCollection<OrderStateRadius> orders = runtime.GetData(ExchangeRuntime.ORDER_STATES) as EntityCollection<OrderStateRadius>;
            OutboundDuplicateEvent @event = new OutboundDuplicateEvent(this.GetType().Name);

            foreach (OrderStateRadius radius in orders)
            {
                if (ExchangeService.IsOutboundDuplicate(runtime.GetLead().Email, radius.Aid))
                {
                    @event.Aid = radius.Aid;
                    @event.Duplicate = true;
                    continue;
                }
                prospects.Add(radius.OrderId);
            }

            timer.Stop();
            @event.ElapsedTime = timer.ElapsedMilliseconds;
            runtime.StoreData(ExchangeRuntime.PROSPECTS, prospects);
            runtime.AddStrategyEvent(@event);
            runtime.Continue();
        }
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="context"></param>
        /// 
        public override void Invoke(ExchangeRuntime runtime)
        {
            Stopwatch timer = new Stopwatch();
            timer.Start();

            DispositionTrackerEvent @event = new DispositionTrackerEvent();

            string body = runtime.GetData(DataKey) as string;
            ExchangeTracker.TrackComplete(string.Format("{0}-{1}", runtime.Vertical, runtime.VerticalType), runtime.Status, runtime, body);

            timer.Stop();
            @event.ElapsedTime = timer.ElapsedMilliseconds;
            runtime.Continue();
        }
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="runtime"></param>
        /// 
        public override void Invoke(ExchangeRuntime runtime)
        {
            Stopwatch timer = new Stopwatch();
            timer.Start();

            NotificationEvent @event = new NotificationEvent(this.GetType().Name);
            @event.From = From;
            @event.To = Recipient;
            @event.Subject = Subject;

            string body = runtime.GetData(DataKey) as string;
            EmailGateway.SendHtml(Host, From, Recipient, Subject, body);

            timer.Stop();
            @event.ElapsedTime = timer.ElapsedMilliseconds;
            runtime.AddStrategyEvent(@event);
            runtime.Continue();
        }
Exemplo n.º 5
0
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="context"></param>
        /// 
        public override void Invoke(ExchangeRuntime runtime)
        {
            CleanerEvent @event = new CleanerEvent();

            Stopwatch timer = new Stopwatch();
            timer.Start();

            XmlDocument xml = runtime.GetData(key) as XmlDocument;

            foreach (XmlNode node in xml.SelectNodes(Axis))
            {
                string targetValue = node.SelectSingleNode(Target).InnerText;

                foreach (string value in Values)
                {
                    if (value.ToLower() == targetValue.ToLower())
                    {
                        node.ParentNode.RemoveChild(node);
                        break;
                    }
                }
            }

            timer.Stop();
            @event.ElapsedTime = timer.ElapsedMilliseconds;
            runtime.Continue();
        }
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="context"></param>
        /// 
        public override void Invoke(ExchangeRuntime runtime)
        {
            if (runtime.Abort)
            {
                runtime.Continue();
                return;
            }

            Stopwatch timer = new Stopwatch();
            timer.Start();

            List<long> prospects = runtime.GetData(ExchangeRuntime.DISTRIBUTIONS) as List<long>;

            DistributionEvent @event = new DistributionEvent(this.GetType().Name);

            if (prospects != null)
            {
                foreach (long prospect in prospects)
                {
                    DeliveryQueue queue = new DeliveryQueue();
                    queue.AdvertiserId = prospect;
                    queue.Disposition = "PENDING";
                    queue.LeadId = runtime.GetLead().Id;

                    ExchangeService.SaveDeliveryQueue(queue);
                    @event.Advertisers.Add(prospect);
                }
            }

            timer.Stop();
            @event.ElapsedTime = timer.ElapsedMilliseconds;
            runtime.AddStrategyEvent(@event);
            runtime.Continue();
        }