예제 #1
0
        public void GetLinkedInUserProfile(dynamic data, oAuthLinkedIn _oauth, Guid user, string LinkedinUserId)
        {
            SocialProfile socioprofile = new SocialProfile();
            SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            LinkedInAccount objLinkedInAccount = new LinkedInAccount();
            LinkedInAccountRepository objLiRepo = new LinkedInAccountRepository();
            try
            {
                objLinkedInAccount.UserId = user;
                objLinkedInAccount.LinkedinUserId = data.id.ToString();
                try
                {
                    objLinkedInAccount.EmailId = data.email.ToString();
                }
                catch { }
                objLinkedInAccount.LinkedinUserName = data.first_name.ToString() + data.last_name.ToString();
                objLinkedInAccount.OAuthToken = _oauth.Token;
                objLinkedInAccount.OAuthSecret = _oauth.TokenSecret;
                objLinkedInAccount.OAuthVerifier = _oauth.Verifier;
                try
                {
                    objLinkedInAccount.ProfileImageUrl = data.picture_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedInAccount.ProfileUrl = data.profile_url.ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                objLinkedInAccount.Connections = data.connections;
                objLinkedInAccount.IsActive = true;

                socioprofile.UserId = user;
                socioprofile.ProfileType = "linkedin";
                socioprofile.ProfileId = LinkedinUserId;
                socioprofile.ProfileStatus = 1;
                socioprofile.ProfileDate = DateTime.Now;
                socioprofile.Id = Guid.NewGuid();

            }
            catch
            {
            }
            try
            {
                if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                {
                    socioprofilerepo.addNewProfileForUser(socioprofile);

                    GroupRepository objGroupRepository = new GroupRepository();
                    SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"];
                    Groups lstDetails = objGroupRepository.getGroupName(team.GroupId);
                    if (lstDetails.GroupName == "Socioboard")
                    {
                        TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
                        TeamMemberProfile teammemberprofile = new TeamMemberProfile();
                        teammemberprofile.Id = Guid.NewGuid();
                        teammemberprofile.TeamId = team.Id;
                        teammemberprofile.ProfileId = socioprofile.ProfileId;
                        teammemberprofile.ProfileType = "linkedin";
                        teammemberprofile.StatusUpdateDate = DateTime.Now;

                        objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile);

                    }

                }
                else
                {
                    socioprofile.ProfileId = data.id.ToString();
                    socioprofilerepo.updateSocialProfile(socioprofile);
                }
                if (!objLiRepo.checkLinkedinUserExists(LinkedinUserId, user))
                {
                    objLiRepo.addLinkedinUser(objLinkedInAccount);
                }
                else
                {
                    objLinkedInAccount.LinkedinUserId = LinkedinUserId;
                    objLiRepo.updateLinkedinUser(objLinkedInAccount);
                }
                // GetLinkedInFeeds(_oauth, data.id, user.Id);
            }
            catch
            {

            }
        }
예제 #2
0
        public void GetLinkedInUserProfile(dynamic data, oAuthLinkedIn _oauth, User user)
        {
            SocialProfile socioprofile = new SocialProfile();
            SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            LinkedInAccount objLinkedInAccount = new LinkedInAccount();
            LinkedInAccountRepository objLiRepo = new LinkedInAccountRepository();
            try
            {
                objLinkedInAccount.UserId = user.Id;
                objLinkedInAccount.LinkedinUserId = data.id.ToString();
                try
                {
                    objLinkedInAccount.EmailId = data.email.ToString();
                }
                catch { }
                objLinkedInAccount.LinkedinUserName = data.first_name.ToString() + data.last_name.ToString();
                objLinkedInAccount.OAuthToken = _oauth.Token;
                objLinkedInAccount.OAuthSecret = _oauth.TokenSecret;
                objLinkedInAccount.OAuthVerifier = _oauth.Verifier;
                try
                {
                    objLinkedInAccount.ProfileImageUrl = data.picture_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedInAccount.ProfileUrl = data.profile_url.ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                objLinkedInAccount.Connections = data.connections;
                objLinkedInAccount.IsActive = true;
                socioprofile.UserId = user.Id;
                socioprofile.ProfileType = "linkedin";
                socioprofile.ProfileId = data.id.ToString();
                socioprofile.ProfileStatus = 1;
                socioprofile.ProfileDate = DateTime.Now;
                socioprofile.Id = Guid.NewGuid();

            }
            catch
            {


            }


            try
            {
                if (!string.IsNullOrEmpty(objLinkedInAccount.LinkedinUserId))
                {
                    if (objLiRepo.checkLinkedinUserExists(objLinkedInAccount.LinkedinUserId,user.Id))
                    {
                        if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                        {
                            socioprofilerepo.addNewProfileForUser(socioprofile);
                        }
                        objLiRepo.updateLinkedinUser(objLinkedInAccount);
                    }
                    else
                    {
                        if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                        {
                            socioprofilerepo.addNewProfileForUser(socioprofile);
                        }
                        objLiRepo.addLinkedinUser(objLinkedInAccount);
                    }
                }
                GetLinkedInFeeds(_oauth, data.id, user.Id);

            }
            catch
            {
            }
        }