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="context"></param>
        /// 
        public override void Invoke(ExchangeRuntime runtime)
        {
            Stopwatch timer = new Stopwatch();
            timer.Start();

            string xml = ExchangeTracker.CreateSoapMessage(runtime);

            XslCompiledTransform transformer = new XslCompiledTransform();
            transformer.Load(template);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            StringWriter writer = new StringWriter();
            XmlTextWriter xmlWriter = new XmlTextWriter(writer);
            transformer.Transform(doc, xmlWriter);
            string result = writer.ToString();

            runtime.StoreData(ResultKey, result);

            TransformerEvent @event = new TransformerEvent(this.GetType().Name);
            @event.Template = template;
            @event.Result = result;
            timer.Stop();
            @event.ElapsedTime = timer.ElapsedMilliseconds;
            runtime.AddStrategyEvent(@event);
            runtime.Continue();
        }
 /// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="runtime"></param>
 /// 
 public override void Invoke(ExchangeRuntime runtime)
 {
     DebtLeadType lead = runtime.GetLeadType() as DebtLeadType;
     runtime.StoreData(ExchangeRuntime.LEAD_TYPE, ExchangeTranslator.Assign(lead));
 }
Exemplo n.º 4
0
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="context"></param>
        /// 
        public override void Invoke(ExchangeRuntime runtime)
        {
            if (runtime.Abort)
            {
                runtime.Continue();
                return;
            }

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

            EntityCollection<OrderStateRadius> radius = ExchangeService.GetOrderStateRadiusByState(runtime.GetLead().State);

            if (radius.Count() == 0)
            {
                runtime.PendingMatch = true;
                return;
            }

            DistanceEvent @event = new DistanceEvent(this.GetType().Name);
            @event.State = runtime.GetLead().State;

            foreach (OrderStateRadius state in radius)
            {
                // @event.Orders.Add(state.OrderId);
                @event.BidOrders.Add(new Bid(state.Aid, state.OrderId));
            }

            timer.Stop();
            @event.ElapsedTime = timer.ElapsedMilliseconds;
            runtime.StoreData(ExchangeRuntime.ORDER_STATES, radius);
            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();
        }