Inheritance: MonoBehaviour
Example #1
0
        public static Funnel GetFunnel()
        {
            var funnel = new Funnel {
                Percentage = FunnelPercentage.Show, Type = FunnelType.Reverse
            };

            funnel.Item.Add(new FunnelItem
            {
                Label = "Order placed",
                Value = "502"
            });

            funnel.Item.Add(new FunnelItem
            {
                Label = "Order paid",
                Value = "311"
            });

            funnel.Item.Add(new FunnelItem
            {
                Label = "Order delivered",
                Value = "200"
            });

            return(funnel);
        }
        public Funnel DeleteFunnel(int id)
        {
            Funnel funnel = db.Funnel.Find(id);

            if (funnel == null)
            {
                _loggerService.CreateLog("Jordan", "Funnel", "Delete", string.Empty, $"Funnel {id} not found to delete.");
                return(null);
            }

            try
            {
                db.Funnel.Remove(funnel);
                db.SaveChanges();

                _loggerService.CreateLog("Jordan", "Funnel", "Delete", funnel.ToString());
            }
            catch (Exception e)
            {
                _loggerService.CreateLog("Jordan", "Funnel", "Delete", funnel.ToString(), "Error deleting Funnel: " + e.Message);
                return(null);
            }

            return(funnel);
        }
Example #3
0
    public void RefreshFunnels(Funnel funnelTouch)
    {
        int count = allFunnels.Length - RefreshCount;

        for (int i = 0; i < allFunnels.Length; i++)
        {
            refreshFunnel.Add(allFunnels[i]);
        }

        while (count > 0)
        {
            int randomValue = Random.Range(0, refreshFunnel.Count);

            if (funnelTouch == refreshFunnel[randomValue])
            {
                continue;
            }
            else
            {
                count--;
                refreshFunnel.RemoveAt(randomValue);
            }
        }

        for (int i = 0; i < refreshFunnel.Count; i++)
        {
            refreshFunnel[i].OnTouchFigure();
        }
        SpawnRandomFunnels(refreshFunnel);
        refreshFunnel.Clear();
    }
Example #4
0
 /// <summary>
 /// Creates a new Bloom Filter.
 /// </summary>
 public BloomFilter(BitArray bits, int numOfHashFunctions, Funnel <T> funnel, Stratagy strategy)
 {
     this.bits = bits;
     this.numOfHashFunctions = numOfHashFunctions;
     this.funnel             = funnel;
     this.strategy           = strategy;
 }
Example #5
0
 private void butFunnel_Click(object sender, RoutedEventArgs e)
 {
     Reset(ChartType.Funnel);
     modelChart            = Funnel.Create();
     controller.ChartModel = modelChart;
     RenderChart();
 }
Example #6
0
        public FunnelChart(ChartView BaseChart)
        {
            funnel = new Funnel();
            var    = new Variables.Variables();

            for (int i = 0; i < var.GetValorFunnelLabels.Length; i++)
            {
                funnel.Add(var.GetValorsFunnel[i, 0], var.GetValorsFunnel[i, 1], var.GetValorFunnelLabels[i], var.GetPaletteBasic[0]);
            }
            funnel.Marks.Visible    = true;
            funnel.Marks.TailStyle  = MarksTail.None;
            funnel.Marks.Color      = Xamarin.Forms.Color.White;
            funnel.Marks.Font.Color = Xamarin.Forms.Color.Black;
            funnel.Marks.Font.Size  = 14;

            funnel.AboveColor      = var.GetPaletteBasic[2];
            funnel.WithinColor     = var.GetPaletteBasic[1];
            funnel.BelowColor      = var.GetPaletteBasic[0];
            funnel.DifferenceLimit = 50;

            BaseChart.Chart.Series.Add(funnel);

            BaseChart.Chart.Axes.Left.SetMinMax(BaseChart.Chart.Axes.Left.MinYValue, BaseChart.Chart.Axes.Left.MaxYValue);
            BaseChart.Chart.Axes.Bottom.SetMinMax(BaseChart.Chart.Axes.Bottom.MinXValue, BaseChart.Chart.Axes.Bottom.MaxXValue);

            BaseChart.Chart.Axes.Left.Visible   = false;
            BaseChart.Chart.Axes.Bottom.Visible = false;

            BaseChart.Chart.Title.Text = "Market quota";

            BaseChart.Chart.Legend.LegendStyle = LegendStyles.Values;
            BaseChart.Chart.Legend.TextAlign   = TextAlignment.Start;
            BaseChart.Chart.Legend.TextStyle   = LegendTextStyles.Plain;
        }
Example #7
0
    public static bool CalculatePath(Vector3 sourcePosition, Vector3 targetPosition, List <Vector3> outPath)
    {
        outPath.Clear();

        TNavNode sourceNode = GetNode(sourcePosition);
        TNavNode targetNode = GetNode(targetPosition);

        if (sourceNode != null && targetNode != null)
        {
            if (sourceNode == targetNode)
            {
                outPath.Add(sourcePosition);
                outPath.Add(targetPosition);
            }
            else
            {
                TNavMesh.Reset();
                sourceNode.position = sourcePosition;
                targetNode.position = targetPosition;
                if (TNavMesh.finder.FindPath(sourceNode, targetNode, TNavMesh.pathNodes))
                {
                    var portals = CalculatePortals(targetPosition);
                    Funnel.StringPull(sourcePosition, targetPosition, portals, outPath);
                }
            }
        }

        return(false);
    }
Example #8
0
 public Funnel Funnel()
 {
     if (funnel == null)
     {
         funnel = new series.Funnel();
     }
     return(funnel);
 }
        public Funnel GetFunnelById(int id)
        {
            Funnel funnel = db.Funnel.Find(id);

            _loggerService.CreateLog("Jordan", "Funnel", "Get By Id", id.ToString(), $"Results found: {funnel != null}");

            return(funnel);
        }
Example #10
0
        public IHttpActionResult GetById(int id)
        {
            _loggerService.CreateLog(_user, "API", "FunnelController", "Funnel", "Get By Id", id.ToString(), null);

            Funnel funnel = _funnelRepository.GetFunnelById(id);

            if (funnel == null)
            {
                return(NotFound());
            }

            return(Ok(funnel));
        }
Example #11
0
        public void Can_serialize_funnel_objects()
        {
            var target = new Funnel();

            target
            .Add("STEP 1", 1600)
            .Add("STEP 2", 1400)
            .Add("STEP 3", 1200)
            .Add("STEP 4", 900)
            .Add("STEP 5", 600)
            .Add("STEP 6", 330);

            string result = Serializer.Serialize(target);

            result.Should().NotBeNullOrEmpty();
        }
        public Funnel InsertFunnel(Funnel funnel)
        {
            try
            {
                funnel.CreatedDateTime = DateTime.Now;
                db.Funnel.Add(funnel);
                db.SaveChanges();

                _loggerService.CreateLog("Jordan", "Funnel", "Create", funnel.ToString());

                return(funnel);
            }
            catch (Exception e)
            {
                _loggerService.CreateLog("Jordan", "Funnel", "Create", funnel.ToString(), "Error creating this record: " + e.Message);
                return(null);
            }
        }
Example #13
0
        public IHttpActionResult Insert(Funnel funnel)
        {
            _loggerService.CreateLog(_user, "API", "FunnelController", "Funnel", "Insert", funnel.ToString(), null);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var createdFunnel = _funnelRepository.InsertFunnel(funnel);

            if (createdFunnel == null)
            {
                BadRequest("There was a problem inserting your record. Please try again.");
            }

            return(Created($"api/funnel?id={createdFunnel.Id}", createdFunnel));
        }
        /// <summary>
        /// Computes all requests.
        /// </summary>
        public void Execute()
        {
            //TODO: Make it paralleled.
            var funnel = new Funnel();

            foreach (var request in requests.Values)
            {
                var facePath = FaceAStar.FindFacePath(request, layers[request.layer]);
                if (facePath != null)
                {
                    request.facePath = facePath?.ToArray();
                    if (request.pathType != PathfindingRequest.PathType.FaceOnly)
                    {
                        Vector3 ensuredGoal = EnsurePoint(request.endPosition, facePath[facePath.Count - 1]);
                        if (facePath.Count == 1)
                        {
                            request.path = new Vector3[] { request.startPosition, ensuredGoal };
                        }
                        else
                        {
                            var channel = CellPathToChannel(facePath, request.startPosition, ensuredGoal, request.radius);
                            if (request.pathType == PathfindingRequest.PathType.Optimized)
                            {
                                request.path = funnel.Calculate3DPath(channel, false);
                            }
                            else if (request.pathType == PathfindingRequest.PathType.Exact)
                            {
                                request.path = funnel.Calculate3DPath(channel, true);
                            }
                            else
                            {
                                Debug.LogError("Not supported path type (?). " + request.pathType);
                            }
                        }
                    }
                }
                request.status = PathfindingRequest.Status.Finished;
            }
        }
        public Funnel UpdateFunnel(Funnel updatedFunnel)
        {
            var currentFunnel = db.Funnel.Find(updatedFunnel.Id);

            if (currentFunnel == null)
            {
                _loggerService.CreateLog("Jordan", "Funnel", "Update", string.Empty, $"Funnel {updatedFunnel.Id} not found to update.");
                return(null);
            }

            if (updatedFunnel.Name != null)
            {
                currentFunnel.Name = updatedFunnel.Name;
            }

            currentFunnel.Archived         = updatedFunnel.Archived;
            currentFunnel.ModifiedDateTime = DateTime.Now;

            db.Entry(currentFunnel).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException e)
            {
                _loggerService.CreateLog("Jordan", "Funnel", "Update", currentFunnel.ToString(), "Error updating Funnel: " + e.Message);
                return(null);
            }
            catch (Exception e)
            {
                _loggerService.CreateLog("Jordan", "Funnel", "Update", currentFunnel.ToString(), "Error updating Funnel: " + e.Message);
                return(null);
            }

            _loggerService.CreateLog("Jordan", "Funnel", "Update", currentFunnel.ToString());
            return(currentFunnel);
        }
Example #16
0
        public IHttpActionResult Update(int id, Funnel funnel)
        {
            _loggerService.CreateLog(_user, "API", "FunnelController", "Funnel", "Update", funnel.ToString(), null);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != funnel.Id)
            {
                return(BadRequest("The Id's do not match"));
            }

            var updatedFunnel = _funnelRepository.UpdateFunnel(funnel);

            if (updatedFunnel == null)
            {
                return(BadRequest("There was a problem updating your record. Please try again"));
            }

            return(Ok($"api/funnel?id={funnel.Id}"));
        }
Example #17
0
        private void GenerateEvents(Job job, MessageItem email, Funnel funnelDefinition, IReadOnlyCollection <Contact> contactsForThisEmail)
        {
            if (funnelDefinition == null)
            {
                return;
            }

            try
            {
                var contactIndex = 1;
                foreach (var contactData in contactsForThisEmail)
                {
                    if (job.JobStatus == JobStatus.Cancelling)
                    {
                        return;
                    }

                    job.Status = $"Generating events for contact {contactIndex++} of {contactsForThisEmail.Count}";

                    var events = _randomContactMessageEventsFactory.CreateRandomContactMessageEvents(contactData, funnelDefinition, email);

                    GenerateEventService.GenerateContactMessageEvents(job, events);

                    if (events.Events.Any(e => e.EventType == EventType.UnsubscribeFromAll))
                    {
                        _unsubscribeFromAllContacts.Add(events.ContactId);
                    }

                    job.CompletedEvents++;
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to generate events", ex);
                throw;
            }
        }
Example #18
0
        public static Funnel GetFunnel()
        {
            var funnel = new Funnel {Percentage = FunnelPercentage.Show, Type = FunnelType.Reverse};

            funnel.Item.Add(new FunnelItem
                                {
                                    Label = "Order placed",
                                    Value = "502"
                                });

            funnel.Item.Add(new FunnelItem
                                {
                                    Label = "Order paid",
                                    Value = "311"
                                });

            funnel.Item.Add(new FunnelItem
                                {
                                    Label = "Order delivered",
                                    Value = "200"
                                });

            return funnel;
        }
Example #19
0
 private bool RandomizeSpamComplaintEvent(Funnel funnel, List <MessageContactEvent> events)
 {
     return(_random.NextDouble() < funnel.SpamComplaints / 100d && events.All(e => e.EventType != EventType.Click));
 }
Example #20
0
 private bool RandomizeUnsubscribeEvent(Funnel funnel)
 {
     return(_random.NextDouble() < funnel.Unsubscribed / 100d);
 }
Example #21
0
    void Update()
    {
        if (!_f.IsCreated)
        {
            Debug.Log("creating");
            _f = new Funnel(64, Allocator.Persistent);
        }

        var portals = Portals.Take(Amount == 0 ? Portals.Length : math.min(Amount, Portals.Length)).ToArray();

        foreach (var portal in portals)
        {
            DebugUtil.DrawCircle(portal.position, Radius);
        }

        for (int i = 2; i < portals.Length; i++)
        {
            DebugUtil.DrawLine(portals[i - 2].position, portals[i - 1].position, Color.green);
            DebugUtil.DrawLine(portals[i - 2].position, portals[i].position);
            DebugUtil.DrawLine(portals[i - 1].position, portals[i].position);

            // if (i == 3 || i == 4)
            //     DebugUtil.DrawCircle(portals[i - 2].position.TakeXZ(), portals[i - 1].position.TakeXZ(), portals[i].position.TakeXZ(), i == 3 ? Color.black : Color.blue);
        }

        // DebugUtil.DrawLine(V0.position, Portals[0].position);
        // DebugUtil.DrawLine(V0.position, Portals[1].position);

        var l1    = portals.Select(t => t.position.xz()).ToList();
        var start = Begin.position.xz();
        var l     = new System.Collections.Generic.List <Gate>();
        var b     = true;

        for (int j = 0; j < l1.Count - 1; j++)
        {
            l.Add(b ? new Gate {
                Left = l1[j], Right = l1[j + 1]
            } : new Gate {
                Left = l1[j + 1], Right = l1[j]
            });
            b = !b;
        }

        var end = End.position.xz();
        var ll  = new List <Gate>(64, Allocator.Persistent);

        foreach (var portal in l)
        {
            ll.Add(portal);
        }

        var result = new Deque <Funnel.Node>(10, Allocator.Persistent);

        _f.GetPath(ll, start, end, Radius, result);
        _waypoints = result.Count;

        var ra = new Funnel.Node[result.Count];

        for (int i = 0; i < result.Count; i++)
        {
            ra[i] = result.FromFront(i);
        }

        _unique = ra.Distinct().Count();
        _path   = new StringBuilder().Concat(ra.SelectMany(r => new[] { r.From, r.To }));

        for (int i = 0; i < ra.Length; ++i)
        {
            DebugUtil.DrawLine(ra[i].From.ToXxY(), ra[i].To.ToXxY(), Color.red);
        }
        ll.Dispose();
        result.Dispose();
    }
Example #22
0
 public Option()
 {
     funnel = new Funnel();
 }
        private async void GenerateEvents(MessageItem email, Funnel funnelDefinition, List <ContactData> contactsForThisEmail)
        {
            if (funnelDefinition == null)
            {
                return;
            }

            var contactIndex = 1;

            foreach (var contactId in contactsForThisEmail)
            {
                _specification.Job.Status = $"Generating events for contact {contactIndex++} of {contactsForThisEmail.Count}";

                var contact = _contactService.GetContact(contactId.ContactId);
                if (contact == null)
                {
                    continue;
                }

                if (_random.NextDouble() < funnelDefinition.Bounced / 100d)
                {
                    ExmEventsGenerator.GenerateBounce(_managerRoot.Settings.BaseURL, contact.ContactId.ToID(),
                                                      email.MessageId.ToID(), email.StartTime.AddMinutes(1));
                }
                else
                {
                    var userAgent = _userAgent();
                    var geoData   = _geoData();
                    var eventDay  = _eventDay();
                    var seconds   = _random.Next(60, 86400);
                    var eventDate = email.StartTime.AddDays(eventDay).AddSeconds(seconds);

                    var spamPercentage = funnelDefinition.SpamComplaints / 100d;

                    if (_random.NextDouble() < funnelDefinition.OpenRate / 100d)
                    {
                        if (_random.NextDouble() < funnelDefinition.ClickRate / 100d)
                        {
                            spamPercentage = Math.Min(spamPercentage, 0.01);

                            var link = "/";
                            if (_goalId != null)
                            {
                                var goal = _goalId();
                                ID  goalId;
                                if (ID.TryParse(goal, out goalId) && !ID.IsNullOrEmpty(goalId))
                                {
                                    var goalItem = _db.GetItem(goalId);
                                    if (goalItem != null)
                                    {
                                        link = LinkManager.GetItemUrl(goalItem);
                                    }
                                }
                            }

                            ExmEventsGenerator.GenerateHandlerEvent(_managerRoot.Settings.BaseURL, contact.ContactId, email,
                                                                    ExmEvents.Click, eventDate, userAgent, geoData, link);
                            eventDate = eventDate.AddSeconds(_random.Next(10, 300));
                        }
                        else
                        {
                            ExmEventsGenerator.GenerateHandlerEvent(_managerRoot.Settings.BaseURL, contact.ContactId, email,
                                                                    ExmEvents.Open, eventDate, userAgent, geoData);

                            eventDate = eventDate.AddSeconds(_random.Next(10, 300));
                        }
                    }

                    if (_random.NextDouble() < spamPercentage)
                    {
                        await ExmEventsGenerator.GenerateSpamComplaint(_managerRoot.Settings.BaseURL, contact.ContactId.ToID(), email.MessageId.ToID(), "email", eventDate);

                        eventDate = eventDate.AddSeconds(_random.Next(10, 300));
                    }

                    var unsubscribePercentage = funnelDefinition.Unsubscribed / 100d;
                    if (_random.NextDouble() < unsubscribePercentage)
                    {
                        //TODO - Warning: UnsubscribeFromAll not supported
                        var       unsubscribeFromAllPercentage = 0.5;
                        ExmEvents unsubscribeEvent;

                        if (_random.NextDouble() < unsubscribeFromAllPercentage)
                        {
                            unsubscribeEvent = ExmEvents.UnsubscribeFromAll;
                            _unsubscribeFromAllContacts.Add(contact.ContactId);
                        }
                        else
                        {
                            unsubscribeEvent = ExmEvents.Unsubscribe;
                        }

                        ExmEventsGenerator.GenerateHandlerEvent(_managerRoot.Settings.BaseURL, contact.ContactId, email,
                                                                unsubscribeEvent, eventDate, userAgent, geoData);
                    }
                }
                _specification.Job.CompletedEvents++;
            }
        }
Example #24
0
        public MessageContactEvents CreateRandomContactMessageEvents(Contact contactData, Funnel funnel, MessageItem messageItem)
        {
            var messageContactEvents = new MessageContactEvents();
            var events = new List <MessageContactEvent>();

            messageContactEvents.Events      = events;
            messageContactEvents.MessageItem = messageItem;
            var randomCity = GetRandomCity();

            messageContactEvents.GeoData   = randomCity.ToWhoIsInformation();
            messageContactEvents.UserAgent = GetRandomUserAgent(randomCity);
            if (!contactData.Id.HasValue)
            {
                return(messageContactEvents);
            }

            //var contact = _contactRepository.GetContact(contactData.Id.Value);

            //if (contact == null)
            //{
            //    return messageContactEvents;
            //}
            messageContactEvents.ContactId = contactData.Id.Value;

            if (RandomizeBounceEvent(funnel))
            {
                events.Add(new MessageContactEvent
                {
                    EventTime = messageItem.StartTime,
                    EventType = EventType.Bounce
                });
            }
            else
            {
                var eventTime = GetRandomEventTime(messageItem);

                if (RandomizeOpenEvent(funnel))
                {
                    AddEventDelay(ref eventTime);
                    events.Add(new MessageContactEvent {
                        EventType = EventType.Open,
                        EventTime = eventTime
                    });

                    if (RandomizeClickEvent(funnel))
                    {
                        AddEventDelay(ref eventTime);

                        messageContactEvents.LandingPageUrl = GetRandomLandingPageUrl(messageItem);

                        events.Add(new MessageContactEvent
                        {
                            EventType = EventType.Click,
                            EventTime = eventTime
                        });
                    }
                }

                if (RandomizeSpamComplaintEvent(funnel, events))
                {
                    AddEventDelay(ref eventTime);
                    events.Add(new MessageContactEvent
                    {
                        EventType = EventType.SpamComplaint,
                        EventTime = eventTime
                    });
                }

                if (RandomizeUnsubscribeEvent(funnel))
                {
                    AddEventDelay(ref eventTime);

                    if (RandomizeUnsubscribeAllEvent(funnel))
                    {
                        events.Add(new MessageContactEvent
                        {
                            EventType = EventType.UnsubscribeFromAll,
                            EventTime = eventTime
                        });
                    }
                    else
                    {
                        events.Add(new MessageContactEvent
                        {
                            EventType = EventType.Unsubscribe,
                            EventTime = eventTime
                        });
                    }
                }
            }
            return(messageContactEvents);
        }
Example #25
0
 private bool RandomizeBounceEvent(Funnel funnel)
 {
     return(_random.NextDouble() < funnel.Bounced / 100d);
 }
Example #26
0
 private bool RandomizeOpenEvent(Funnel funnel)
 {
     return(_random.NextDouble() < funnel.OpenRate / 100d);
 }
Example #27
0
        public static void FunnelModify(Path p)
        {
            if (p.path == null || p.path.Count == 0 || p.vectorPath == null || p.vectorPath.Count == 0)
            {
                return;
            }

            List <Vector3> funnelPath = ListPool <Vector3> .Claim();

            // Split the path into different parts (separated by custom links)
            // and run the funnel algorithm on each of them in turn
            var parts = Funnel.SplitIntoParts(p);

            if (parts.Count == 0)
            {
                // As a really special case, it might happen that the path contained only a single node
                // and that node was part of a custom link (e.g added by the NodeLink2 component).
                // In that case the SplitIntoParts method will not know what to do with it because it is
                // neither a link (as only 1 of the 2 nodes of the link was part of the path) nor a normal
                // path part. So it will skip it. This will cause it to return an empty list.
                // In that case we want to simply keep the original path, which is just a single point.
                return;
            }

            for (int i = 0; i < parts.Count; i++)
            {
                var part = parts[i];
                if (!part.isLink)
                {
                    var portals = Funnel.ConstructFunnelPortals(p.path, part);
                    var result  = Funnel.Calculate(portals, true, false);
                    funnelPath.AddRange(result);
                    ListPool <Vector3> .Release(ref portals.left);

                    ListPool <Vector3> .Release(ref portals.right);

                    ListPool <Vector3> .Release(ref result);
                }
                else
                {
                    // non-link parts will add the start/end points for the adjacent parts.
                    // So if there is no non-link part before this one, then we need to add the start point of the link
                    // and if there is no non-link part after this one, then we need to add the end point.
                    if (i == 0 || parts[i - 1].isLink)
                    {
                        funnelPath.Add(part.startPoint);
                    }
                    if (i == parts.Count - 1 || parts[i + 1].isLink)
                    {
                        funnelPath.Add(part.endPoint);
                    }
                }
            }

            ListPool <Funnel.PathPart> .Release(ref parts);

            // Pool the previous vectorPath
            ListPool <Vector3> .Release(ref p.vectorPath);

            p.vectorPath = funnelPath;
        }
Example #28
0
 private bool RandomizeClickEvent(Funnel funnel)
 {
     return(_random.NextDouble() < funnel.ClickRate / 100d);
 }