/// <summary>
        /// Creates and stores the given singular form.
        /// </summary>
        /// <param name="key">A named key representing this value. Should represent the named variable given for value, and should be unique for the whole project.</param>
        /// <param name="value">The value for this key.</param>
        public GenericString(string key, string value)
        {
            this.key  = key;
            this.data = value;

            TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);

            this.timestamp = (long)t.TotalMilliseconds;

            Metrics.AddData(this);
        }
        /// <summary>
        /// Increments the given key on the server, creating it if it exists.
        /// </summary>
        /// <param name="key">A named key representing this value. Should represent the named variable given for value, and should be unique for the whole project.</param>
        /// <param name="value">The value to add to this key.</param>
        public GenericIncrement(string key, int incrementAmount)
        {
            this.key  = key;
            this.data = incrementAmount;

            TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);

            this.timestamp = (long)t.TotalMilliseconds;

            Metrics.AddData(this);
        }
Example #3
0
        /// <summary>
        /// Creates and stores the given array.
        /// </summary>
        /// <param name="key">A named key representing this value. Should represent the named variable given for array, and should be unique for the whole project.</param>
        /// <param name="array">The value for this key.</param>
        public GenericList(string key, List <string> value)
        {
            this.key = key;

            //TODO AddRange or simply make data equal to array?
            data.AddRange(value);

            TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);

            this.timestamp = (long)t.TotalMilliseconds;

            Metrics.AddData(this);
        }
Example #4
0
        public async Task <JObject> PostOpportunity(string msgHeader, string leadId, string opportunityStatusName)
        {
            string statusId = await GetStatusId(opportunityStatusName);

            JObject opportunityObj = new JObject
            {
                ["note"]       = msgHeader,
                ["lead_id"]    = leadId,
                ["confidence"] = 0
            };

            if (!string.IsNullOrEmpty(statusId))
            {
                opportunityObj.Add("status_id", statusId);
            }

            HttpResponseMessage response;

            try
            {
                response = await _client.PostAsJsonAsync("https://api.close.com/api/v1/opportunity/", opportunityObj, GlobalVars.CLOSE_TOKEN);

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new CloseConnectionException();
                }

                Metrics.AddData(new MetricDatum
                {
                    MetricName   = "PostedJobs",
                    Value        = 1,
                    Unit         = StandardUnit.Count,
                    TimestampUtc = DateTime.UtcNow,
                    Dimensions   = new List <Dimension>
                    {
                        new Dimension
                        {
                            Name  = "PostedJobs",
                            Value = "1"
                        }
                    }
                });
            }
            catch
            {
                throw new CloseConnectionException();
            }

            return(await response.Content.ReadAsJsonAsync <JObject>());
        }
Example #5
0
        public async Task <JObject> PostLead(string leadName)
        {
            JObject leadObj = new JObject
            {
                ["name"] = leadName
            };

            HttpResponseMessage response;

            try
            {
                response = await _client.PostAsJsonAsync("https://api.close.com/api/v1/lead/", leadObj, GlobalVars.CLOSE_TOKEN);

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new CloseConnectionException();
                }

                Metrics.AddData(new MetricDatum
                {
                    MetricName   = "PostedLeads",
                    Value        = 1,
                    Unit         = StandardUnit.Count,
                    TimestampUtc = DateTime.UtcNow,
                    Dimensions   = new List <Dimension>
                    {
                        new Dimension
                        {
                            Name  = "PostedLeads",
                            Value = "1"
                        }
                    }
                });
            }
            catch
            {
                throw new CloseConnectionException();
            }

            return(await response.Content.ReadAsJsonAsync <JObject>());
        }
Example #6
0
        public void InsertEdges(ICollection <ICollection <Skill> > jobPostsSkills)
        {
            int count = 0;

            foreach (var jobPostSkills in jobPostsSkills)
            {
                Skill[] skills = jobPostSkills.ToArray();
                //string[] skillsStreing = jobPostSkills.Select(x=>x.Name).ToArray();
                //Console.WriteLine("[{0}]", string.Join(", ", skillsStreing));

                for (int i = 0; i < skills.Length - 1; i++)
                {
                    for (int j = i + 1; j < skills.Length; j++)
                    {
                        // find vertices with the same skill name from the graph
                        var v1 = _graph.V().HasLabel("skill").Has("name", skills[i].Name).Next();
                        var v2 = _graph.V().HasLabel("skill").Has("name", skills[j].Name).Next();

                        // insert biderectional edges between 2 skills
                        // set initial edge weight count to 0
                        _graph.V(v2).As("v2").V(v1).As("v1").Not(__.Both("weight").Where(P.Eq("v2")))
                        .AddE("weight").Property("count", 0).From("v2").To("v1").OutV()
                        .AddE("weight").Property("count", 0).From("v1").To("v2").Iterate();

                        // increase edge weight count when 2 skills are found in the same job post
                        _graph.V(v1).BothE().Where(__.BothV().HasId(v2.Id))
                        .Property("count", __.Union <int>(__.Values <int>("count"), __.Constant(skills[i].Weight)).Sum <int>()).Next();

                        count++;
                    }
                }
            }

            Metrics.AddData(new MetricDatum
            {
                MetricName   = "PropertiesUpdated",
                Value        = count,
                Unit         = StandardUnit.Count,
                TimestampUtc = DateTime.UtcNow
            });
        }
Example #7
0
        public void InsertNodes(List <Skill> skills)
        {
            foreach (var skill in skills)
            {
                if (_nodes.ContainsKey(skill.Name))
                {
                    continue;
                }

                var node = _graph.V().Has("skill", "name", skill.Name).Fold().Coalesce <Vertex>(__.Unfold <Vertex>(), _graph.AddV("skill").Property("name", skill.Name).Property("category", skill.Category)).Next();
                _nodes.Add(skill.Name, node);
            }

            Metrics.AddData(new MetricDatum
            {
                MetricName   = "NodesAdded",
                Value        = _nodes.Count,
                Unit         = StandardUnit.Count,
                TimestampUtc = DateTime.UtcNow
            });
        }