private LinkedinProfile CreateLinkedinProfile(int counterId)
        {
            var linkedinProfile = new LinkedinProfile(counterId.ToString(), "barak", "A", "B", "", new List <string>()
            {
                "C"
            },
                                                      new List <Experience>()
            {
                new Experience()
                {
                    CompanyName = "C",
                    Description = "hey",
                    Position    = "T",
                    StartTime   = DateTime.Now,
                    EndTime     = DateTime.Now
                }
            }, new List <School>()
            {
                new School()
                {
                    Title = "SA", DegreeName = "BA", Summary = "HAHA"
                }
            });

            return(linkedinProfile);
        }
Esempio n. 2
0
        public async Task <IEnumerable <LinkedinProfile> > GetLinkedinProfiles()
        {
            LinkedinProfile        linkedinProfile  = null;
            List <LinkedinProfile> linkedinProfiles = new List <LinkedinProfile>();
            string comandtext = "select * from Monitoring.dbo.LinkedinProfile";

            using (SqlConnection sqlConnection = new SqlConnection(connectionString))
            {
                await sqlConnection.OpenAsync();

                SqlCommand sqlCommand = new SqlCommand(comandtext, sqlConnection);
                using (SqlDataReader reader = sqlCommand.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        linkedinProfile = new LinkedinProfile
                        {
                            Id        = (int)reader["id"],
                            Username  = reader["UserName"] as string,
                            FullName  = reader["FullName"] as string,
                            Specialty = reader["Specialty"] as string,
                            Location  = reader["Location"] as string
                        };
                        linkedinProfiles.Add(linkedinProfile);
                    }
                }
                return(linkedinProfiles);
            }
        }
        public async Task <ActionResult <LinkedinProfile> > PostLinkedinProfile(LinkedinProfile linkedinProfile)
        {
            _context.LinkedinProfile.Add(linkedinProfile);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLinkedinProfile", new { id = linkedinProfile.Id }, linkedinProfile));
        }
        public void InsertProfile(LinkedinProfile profile)
        {
            CheckInitalization();

            var jsonProfile = new JsonLinkedinProfile(profile);

            lock (_lockObj)
            {
                _linkedinDatabase.BeginTransaction();

                try
                {
                    _linkedinDatabase.Profiles.InsertOrUpdate(jsonProfile);

                    var dynamicParameters = new DynamicParameters();
                    dynamicParameters.Add("@param", profile.Id);

                    _linkedinDatabase.Query("delete from PersonToSkill where Id = @param", dynamicParameters);
                    foreach (var skill in profile.Skills)
                    {
                        _linkedinDatabase.PersonToSkill.Insert(new PersonToSkill(profile.Id, skill));
                    }

                    _linkedinDatabase.CommitTransaction();
                }
                catch (Exception)
                {
                    //TODO: logs.
                    _linkedinDatabase.RollbackTransaction();
                    throw;
                }
            }
        }
        public async Task <IActionResult> PutLinkedinProfile(int id, LinkedinProfile linkedinProfile)
        {
            if (id != linkedinProfile.Id)
            {
                return(BadRequest());
            }

            _context.Entry(linkedinProfile).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LinkedinProfileExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 6
0
        // GET api/Linkediner/barakar
        public IHttpActionResult Get(string id)
        {
            LinkedinProfile profile = _accessor.GetProfile(id);

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

            return(Json(profile));
        }
Esempio n. 7
0
        public JsonLinkedinProfile(LinkedinProfile profile)
        {
            Id       = profile.Id;
            Name     = profile.Name;
            Title    = profile.Title;
            Position = profile.Position;
            Summary  = profile.Summary;

            Skills     = JsonConvert.SerializeObject(profile.Skills);
            Experience = JsonConvert.SerializeObject(profile.Experience);
            Education  = JsonConvert.SerializeObject(profile.Education);
        }
Esempio n. 8
0
        // POST api/Linkediner
        public IHttpActionResult Post([FromBody] string value)
        {
            if (!IsValidUri(value))
            {
                return(BadRequest("invalid public linkedin URI"));
            }

            var             id      = value.Split('/').Last();
            LinkedinProfile profile = null;

            var task = Task.Run(async() =>
            {
                var sourceCode = await _fetcher.Fetch(value).ConfigureAwait(false);

                profile = _parser.ParseProfile(id, sourceCode);

                _accessor.InsertProfile(profile);
            });

            Task.WaitAny(task);
            return(Created(id, profile));
        }
Esempio n. 9
0
 public UyeModel Post(LinkedinProfile value)
 {
     return(islem.LinkedinGirisi(value));
 }
Esempio n. 10
0
        /// <summary>
        /// Get profile model from HTML content
        /// </summary>
        /// <param name="content">HTML content</param>
        /// <returns>LinkedinProfile</returns>
        public LinkedinProfile GetProfile(string content)
        {
            var document        = new HtmlDocument();
            var linkedinProfile = new LinkedinProfile();

            try
            {
                document.LoadHtml(content);
                var fullName           = document.DocumentNode.SelectSingleNode(".//h1[starts-with(@class,'pv-top-card-section__name')]")?.InnerText;
                var specialty          = document.DocumentNode.SelectSingleNode(".//h2[starts-with(@class,'pv-top-card-section__headline')]")?.InnerText;
                var location           = document.DocumentNode.SelectSingleNode(".//h3[starts-with(@class,'pv-top-card-section__location')]")?.InnerText;
                var company            = document.DocumentNode.SelectSingleNode(".//span[@class='lt-line-clamp__line lt-line-clamp__line--last']")?.InnerText;
                var education          = document.DocumentNode.SelectSingleNode(".//span[starts-with(@class,'pv-top-card-v2-section__entity-name pv-top-card-v2-section__school-name')]")?.InnerText;
                var connectionCountStr = document.DocumentNode.SelectSingleNode(".//span[starts-with(@class,'pv-top-card-v2-section__entity-name pv-top-card-v2-section__connections')]")?.InnerText;
                var imageUrlArray      = document.DocumentNode.SelectSingleNode(".//div[starts-with(@class,'pv-top-card-section__photo presence-entity__image')]")?.GetAttributeValue("style", "")?.Split(new[] { "url(&quot;" }, StringSplitOptions.RemoveEmptyEntries);
                var imageUrl           = imageUrlArray?.Count() == 0 || imageUrlArray == null ? null : imageUrlArray?.ElementAt(1)?.TrimEnd(';', ')', ';');
                linkedinProfile.FullName  = StringBeauty(fullName);
                linkedinProfile.Specialty = StringBeauty(specialty);
                linkedinProfile.Location  = StringBeauty(location);
                linkedinProfile.Company   = StringBeauty(company);
                linkedinProfile.Education = StringBeauty(education);
                int.TryParse(StringBeauty(connectionCountStr?.Replace("connections", "")?.Replace("+", "")), out var conCountInt);
                linkedinProfile.ConnectionCount = conCountInt;
                linkedinProfile.ImageUrl        = HtmlDecode(imageUrl);
            }
            catch (Exception e)
            {
                Logger.Error(e, MethodBase.GetCurrentMethod().Name);
            }

            var experienceSection = document.DocumentNode.SelectSingleNode(".//section[@id='experience-section']");

            if (experienceSection != null)
            {
                var companyCollection = experienceSection.SelectNodes(".//div[starts-with(@class,'pv-entity__summary-info')]");
                if (companyCollection != null)
                {
                    linkedinProfile.LinkedinExperiences = new List <LinkedinExperience>();
                    foreach (var experince in companyCollection)
                    {
                        try
                        {
                            var linkedinExperience = new LinkedinExperience();
                            var title           = experince.SelectSingleNode(".//h3")?.InnerText?.Replace("Title", "");
                            var companyName     = experince.SelectSingleNode(".//span[@class='pv-entity__secondary-title']")?.InnerText;
                            var range           = experince.SelectSingleNode(".//h4[starts-with(@class,'pv-entity__date-range')]")?.SelectNodes(".//span")?.Last()?.InnerText;
                            var locationCompany = experince.SelectSingleNode(".//h4[starts-with(@class,'pv-entity__location')]")?.SelectNodes(".//span")?.Last()?.InnerText;

                            linkedinExperience.Title    = StringBeauty(title);
                            linkedinExperience.Company  = StringBeauty(companyName);
                            linkedinExperience.Time     = StringBeauty(range);
                            linkedinExperience.Location = StringBeauty(locationCompany);

                            linkedinProfile.LinkedinExperiences.Add(linkedinExperience);
                        }
                        catch (Exception e)
                        {
                            Logger.Error(e, MethodBase.GetCurrentMethod().Name);
                        }
                    }
                }
            }
            var educationSection = document.DocumentNode.SelectSingleNode(".//section[@id='education-section']");

            if (educationSection != null)
            {
                var educationCollection = educationSection.SelectNodes(".//div[starts-with(@class,'pv-entity__summary-info')]");
                if (educationCollection != null)
                {
                    linkedinProfile.LinkedinEducations = new List <LinkedinEducation>();
                    foreach (var education in educationCollection)
                    {
                        try
                        {
                            var linkedinEducation = new LinkedinEducation();
                            var university        = education.SelectSingleNode(".//h3")?.InnerText;
                            linkedinEducation.Name = HtmlDecode(StringBeauty(university));
                            var titleCol = education.SelectNodes(".//span[starts-with(@class,'pv-entity__comma-item')]")?.Select(x => x.InnerText);
                            if (titleCol != null)
                            {
                                var title = StringBeauty(string.Join(" of ", titleCol));
                                linkedinEducation.Title = title;
                            }

                            var range = education.SelectSingleNode(".//p[starts-with(@class,'pv-entity__dates')]")?.SelectNodes(".//time")?.Select(x => x?.InnerText);
                            if (range != null)
                            {
                                var dateRange = string.Join(" - ", range);
                                linkedinEducation.Time = StringBeauty(dateRange);
                            }

                            linkedinProfile.LinkedinEducations.Add(linkedinEducation);
                        }
                        catch (Exception e)
                        {
                            Logger.Error(e, MethodBase.GetCurrentMethod().Name);
                        }
                    }
                }
            }
            var skillSection = document.DocumentNode.SelectSingleNode(".//section[starts-with(@class,'pv-profile-section pv-skill-categories-section')]");

            if (skillSection != null)
            {
                var skillCollection = skillSection.SelectNodes(".//div[@class='pv-skill-category-entity__skill-wrapper tooltip-container']");
                if (skillCollection != null)
                {
                    linkedinProfile.LinkedinSkills = new List <LinkedinSkill>();
                    foreach (var skillItem in skillCollection)
                    {
                        var linkedinSkill = new LinkedinSkill();
                        try
                        {
                            var skillName   = skillItem.SelectSingleNode(".//p[starts-with(@class,'pv-skill-category-entity__name')]")?.InnerText;
                            var uproveCount = skillItem.SelectSingleNode(".//span[starts-with(@class,'pv-skill-category-entity__endorsement-count')]")?.InnerText;
                            linkedinSkill.Name = StringBeauty(skillName);
                            int.TryParse(StringBeauty(uproveCount), out var uproveInt);
                            linkedinSkill.EndorsedCount = uproveInt;

                            linkedinProfile.LinkedinSkills.Add(linkedinSkill);
                        }
                        catch (Exception e)
                        {
                            Logger.Error(e, MethodBase.GetCurrentMethod().Name);
                        }
                    }
                }
            }
            var interestsSection = document.DocumentNode.SelectSingleNode(".//section[starts-with(@class,'pv-profile-section pv-interests-section')]");

            if (interestsSection != null)
            {
                var interestsCollection = interestsSection.SelectNodes(".//div[@class='pv-entity__summary-info ember-view']");
                if (interestsCollection != null)
                {
                    linkedinProfile.LinkedinInterests = new List <LinkedinInterest>();
                    foreach (var interesItem in interestsCollection)
                    {
                        try
                        {
                            var linkedinInterest = new LinkedinInterest();

                            var name           = interesItem.SelectSingleNode(".//span[@class='pv-entity__summary-title-text']")?.InnerText;
                            var followersCount = interesItem.SelectSingleNode(".//p[starts-with(@class,'pv-entity__follower-count')]")?.InnerText?.Replace("followers", "")?.Replace(",", "");

                            int.TryParse(StringBeauty(followersCount), out var followersInt);

                            linkedinInterest.Name           = StringBeauty(name);
                            linkedinInterest.FollowersCount = followersInt;

                            linkedinProfile.LinkedinInterests.Add(linkedinInterest);
                        }
                        catch (Exception e)
                        {
                            Logger.Error(e, MethodBase.GetCurrentMethod().Name);
                        }
                    }
                }
            }
            var accomplishmentsSection = document.DocumentNode.SelectSingleNode(".//section[starts-with(@class,'pv-profile-section pv-accomplishments-section')]");

            if (accomplishmentsSection != null)
            {
                var accomplishmentsCollection = accomplishmentsSection.SelectNodes(".//li[@class='pv-accomplishments-block__summary-list-item']");
                if (accomplishmentsCollection != null)
                {
                    linkedinProfile.LinkedinLanguages = new List <LinkedinLanguage>();
                    foreach (var accomplishmentItem in accomplishmentsCollection)
                    {
                        try
                        {
                            var linkedinInterest = new LinkedinLanguage {
                                Name = StringBeauty(accomplishmentItem.InnerText)
                            };

                            linkedinProfile.LinkedinLanguages.Add(linkedinInterest);
                        }
                        catch (Exception e)
                        {
                            Logger.Error(e, MethodBase.GetCurrentMethod().Name);
                        }
                    }
                }
            }

            try
            {
                var documentInfo       = new HtmlDocument();
                var findElementByXPath = _driver.FindElementByXPath(".//a[@data-control-name='contact_see_more']");
                findElementByXPath.Click();
                Thread.Sleep(700);
                documentInfo.LoadHtml(_driver.PageSource);
                var phone    = documentInfo.DocumentNode.SelectSingleNode(".//section[@class='pv-contact-info__contact-type ci-phone']")?.SelectSingleNode(".//span[@class='Sans-15px-black-85%']")?.InnerText;
                var email    = documentInfo.DocumentNode.SelectSingleNode(".//section[@class='pv-contact-info__contact-type ci-email']")?.SelectSingleNode(".//a[@class='pv-contact-info__contact-link Sans-15px-black-85%']")?.GetAttributeValue("href", "")?.Replace("mailto:", "");
                var birthday = documentInfo.DocumentNode.SelectSingleNode(".//section[@class='pv-contact-info__contact-type ci-birthday']")?.SelectSingleNode(".//a[@class='pv-contact-info__contact-item Sans-15px-black-85%']")?.InnerText;
                var website  = documentInfo.DocumentNode.SelectSingleNode(".//section[@class='pv-contact-info__contact-type ci-websites']")?.SelectSingleNode(".//a[starts-with(@class,'pv-contact-info__contact-link')]")?.GetAttributeValue("href", "");
                //var userName = documentInfo.DocumentNode.SelectSingleNode(".//h1[@id='pv-contact-info']")?.InnerText;


                linkedinProfile.Email    = StringBeauty(email);
                linkedinProfile.Phone    = StringBeauty(phone);
                linkedinProfile.Birthday = StringBeauty(birthday);
                linkedinProfile.Website  = StringBeauty(website);
                //linkedinProfile.Username = StringBeauty(userName);
                Thread.Sleep(250);
                var findElementByXPathClose = _driver.FindElementByXPath(".//button[@class='artdeco-dismiss']");
                findElementByXPathClose?.Click();
                Thread.Sleep(250);
            }
            catch (Exception e)
            {
                Logger.Error(e, MethodBase.GetCurrentMethod().Name);
            }
            try
            {
                var connectButton = _driver.FindElementByXPath(".//button[starts-with(@class,'pv-s-profile-actions pv-s-profile-actions--connect')]");
                connectButton?.Click();
                Thread.Sleep(1000);
                var sendNowButton = _driver.FindElementByXPath(".//button[starts-with(@class,'button-primary-large')]");
                sendNowButton?.Click();
                //pv-s-profile-actions pv-s-profile-actions--connect
            }
            catch (Exception e)
            {
                Logger.Error(e, MethodBase.GetCurrentMethod().Name);
                Console.WriteLine(e);
            }
            return(linkedinProfile);
        }
Esempio n. 11
0
 /// <summary>
 /// Update linkedin profile information
 /// </summary>
 /// <param name="linkedinProfile">Linkedin profile object</param>
 /// <param name="user">Linkedin profile in db</param>
 private static void UpdateLinkedinProfile(LinkedinProfile linkedinProfile, LinkedinProfile user)
 {
     try
     {
         if (linkedinProfile.LinkedinEducations.Count != 0 && user.LinkedinEducations.Count == 0)
         {
             user.LinkedinEducations = linkedinProfile.LinkedinEducations;
         }
         if (linkedinProfile.LinkedinExperiences.Count != 0 && user.LinkedinExperiences.Count == 0)
         {
             user.LinkedinExperiences = linkedinProfile.LinkedinExperiences;
         }
         if (linkedinProfile.LinkedinSkills.Count != 0 && user.LinkedinSkills.Count == 0)
         {
             user.LinkedinSkills = linkedinProfile.LinkedinSkills;
         }
         if (linkedinProfile.LinkedinInterests.Count != 0 && user.LinkedinInterests.Count == 0)
         {
             user.LinkedinInterests = linkedinProfile.LinkedinInterests;
         }
         if (linkedinProfile.LinkedinLanguages.Count != 0 && user.LinkedinLanguages.Count == 0)
         {
             user.LinkedinLanguages = linkedinProfile.LinkedinLanguages;
         }
         if (linkedinProfile.Birthday != null)
         {
             user.Birthday = linkedinProfile.Birthday;
         }
         if (linkedinProfile.Company != null)
         {
             user.Company = linkedinProfile.Company;
         }
         if (linkedinProfile.Connected != null)
         {
             user.Connected = linkedinProfile.Connected;
         }
         if (linkedinProfile.ConnectionCount != null)
         {
             user.ConnectionCount = linkedinProfile.ConnectionCount;
         }
         if (linkedinProfile.Email != null)
         {
             user.Email = linkedinProfile.Email;
         }
         if (linkedinProfile.FullName != null)
         {
             user.FullName = linkedinProfile.FullName;
         }
         if (linkedinProfile.Location != null)
         {
             user.Location = linkedinProfile.Location;
         }
         if (linkedinProfile.Specialty != null)
         {
             user.Specialty = linkedinProfile.Specialty;
         }
         if (linkedinProfile.ImageUrl != null)
         {
             user.ImageUrl = linkedinProfile.ImageUrl;
         }
         if (linkedinProfile.Website != null)
         {
             user.Website = linkedinProfile.Website;
         }
         if (linkedinProfile.Education != null)
         {
             user.Education = linkedinProfile.Education;
         }
         if (linkedinProfile.Phone != null)
         {
             user.Phone = linkedinProfile.Phone;
         }
         user.LastUpdate = DateTime.Now;
     }
     catch (Exception e)
     {
         Logger.Error(e, MethodBase.GetCurrentMethod().Name);
     }
 }