/// <getTeamMemberProfile>
        /// Get TeamMember Profile
        /// </summary>
        /// <param name="Teamid">Team id.(Guid)</param>
        /// <param name="ProfileId">Profile id.(string)</param>
        /// <returns>>Return the object of TeamMemberProfile class with value.(Domain.TeamMemberProfile)</returns>
        public Domain.Socioboard.Domain.TeamMemberProfile getTeamMemberProfile(Guid Teamid, string ProfileId)
        {
            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        //Proceed action, to get details of team profile.
                        NHibernate.IQuery query = session.CreateQuery("from TeamMemberProfile where TeamId = :teamid and ProfileId = :profileid");
                        query.SetParameter("teamid", Teamid);
                        query.SetParameter("profileid", ProfileId);
                        Domain.Socioboard.Domain.TeamMemberProfile alstFBAccounts = query.UniqueResult <Domain.Socioboard.Domain.TeamMemberProfile>();

                        return(alstFBAccounts);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(null);
                    }
                } //End Transaction
            }     //End Session
        }
 /// <deleteTeamMember>
 /// Delete profile of TeamMember
 /// </summary>
 /// <param name="team">Set the team id and prfile id of team in a TeamMemberProfile Class Property and Pass the Object of TeamMemberProfile Class.(Domein.TeamMemberProfile)</param>
 /// <returns>Return 1 for successfully delete and 0 for failed.(int)</returns>
 public int deleteTeamMember(Domain.Socioboard.Domain.TeamMemberProfile team)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 //Proceed action, to deleting team profile by id and team id.
                 NHibernate.IQuery query = session.CreateQuery("delete from TeamMemberProfile where TeamId = :teamid and ProfileId = :profileid")
                                           .SetParameter("teamin", team.TeamId)
                                           .SetParameter("profileid", team.ProfileId);
                 int isUpdated = query.ExecuteUpdate();
                 transaction.Commit();
                 return(isUpdated);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(0);
             }
         } //End Transaction
     }     //End Session
 }
Example #3
0
        public static List <Domain.Socioboard.Domain.TeamMemberProfile> GetUserTeamMemberProfiles()
        {
            User objUser = (User)System.Web.HttpContext.Current.Session["User"];
            List <Domain.Socioboard.Domain.TeamMemberProfile> lstTeamMemberProfile = new List <Domain.Socioboard.Domain.TeamMemberProfile>();

            Api.Team.Team objApiTeam = new Api.Team.Team();
            string        groupid    = System.Web.HttpContext.Current.Session["group"].ToString();
            JObject       team       = JObject.Parse(objApiTeam.GetTeamByGroupId(System.Web.HttpContext.Current.Session["group"].ToString()));

            Api.TeamMemberProfile.TeamMemberProfile objApiTeamMemberProfile = new Api.TeamMemberProfile.TeamMemberProfile();
            JArray TeamMemberProfiles = JArray.Parse(objApiTeamMemberProfile.GetTeamMemberProfilesByTeamId(Convert.ToString(team["Id"])));

            foreach (var item in TeamMemberProfiles)
            {
                try
                {
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = GetTeamMemberProfileFromJObject(item);
                    lstTeamMemberProfile.Add(objTeamMemberProfile);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    //return null;
                }
            }
            return(lstTeamMemberProfile);
        }
Example #4
0
        public static Dictionary <Domain.Socioboard.Domain.TeamMemberProfile, object> GetUserProfilesccordingToGroup()
        {
            User objUser = (User)System.Web.HttpContext.Current.Session["User"];
            Dictionary <Domain.Socioboard.Domain.TeamMemberProfile, object> dict_TeamMember = new Dictionary <Domain.Socioboard.Domain.TeamMemberProfile, object>();

            Api.Team.Team objApiTeam = new Api.Team.Team();
            JObject       team       = JObject.Parse(objApiTeam.GetTeamByGroupId(System.Web.HttpContext.Current.Session["group"].ToString()));

            Api.TeamMemberProfile.TeamMemberProfile objApiTeamMemberProfile = new Api.TeamMemberProfile.TeamMemberProfile();
            JArray TeamMemberProfiles = JArray.Parse(objApiTeamMemberProfile.GetTeamMemberProfilesByTeamId(Convert.ToString(team["Id"])));

            foreach (var item in TeamMemberProfiles)
            {
                try
                {
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = GetTeamMemberProfileFromJObject(item);

                    ISocialSiteAccount       objISocialSiteAccount       = GetSocialAccountFromTeamMemberProfile(objUser, objTeamMemberProfile);
                    SocialSiteAccountFactory objSocialSiteAccountFactory = new SocialSiteAccountFactory(objTeamMemberProfile.ProfileType);
                    dict_TeamMember.Add(objTeamMemberProfile, objISocialSiteAccount);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    //return null;
                }
            }
            return(dict_TeamMember);
        }
 /// <updateTeamMember>
 /// Update TeamMember details
 /// </summary>
 /// <param name="team">Set Values in a TeamMemberProfile Class Property and Pass the Object of TeamMemberProfile Class.(Domein.TeamMemberProfile)</param>
 public void updateTeamMember(Domain.Socioboard.Domain.TeamMemberProfile team)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 //Proceed action, to update details of team member profile.
                 session.CreateQuery("Update TeamMemberProfile set Status =:status,StatusUpdateDate =:statusdate where TeamId = :teamid and  ProfileId = :profileId")
                 .SetParameter("status", team.Status)
                 .SetParameter("statusdate", team.StatusUpdateDate)
                 .SetParameter("teamid", team.TeamId)
                 .SetParameter("profileId", team.ProfileId)
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         } //End Transaction
     }     //End Session
 }
        public string getInstagramData(string UserId, string InstagramId)
        {
            Guid userId = Guid.Parse(UserId);
            InstagramAccountRepository objInstagramAccountRepository = new InstagramAccountRepository();
            //LinkedInAccountRepository objLinkedInAccountRepository = new LinkedInAccountRepository();

            Domain.Socioboard.Domain.InstagramAccount objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, userId);
            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();
            _api = oAuthInstagram.GetInstance(configi);
            //GetIntagramImages(objInstagramAccount);
            
            GetInstagramFeeds(objInstagramAccount);
            GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken);
            GetInstagramFollowing(objInstagramAccount.UserId.ToString(), objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 0);
            GetInstagramFollower(objInstagramAccount.UserId.ToString(), objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 0);
            GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 0);
            GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken);
            //GetInstagramUserPosts(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken);
            #region UpdateTeammemberprofile
            Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
            objTeamMemberProfile.ProfileName = objInstagramAccount.InsUserName;
            objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl;
            objTeamMemberProfile.ProfileId = objInstagramAccount.InstagramId;
            objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
            #endregion
            return "Instagram Info is Updated successfully";
        }
Example #7
0
        public string getTumblrData(string UserId, string Tumblrid)
        {
            Guid         userId           = Guid.Parse(UserId);
            oAuthTumbler Obj_oAuthTumbler = new oAuthTumbler();

            oAuthTumbler.TumblrConsumerKey     = ConfigurationManager.AppSettings["TumblrClientKey"];
            oAuthTumbler.TumblrConsumerSecret  = ConfigurationManager.AppSettings["TumblrClientSec"];
            Obj_oAuthTumbler.TumblrCallBackUrl = ConfigurationManager.AppSettings["TumblrCallBackURL"];
            TumblrAccountRepository objTumblrAccountRepository = new TumblrAccountRepository();

            Domain.Socioboard.Domain.TumblrAccount ObjTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(Tumblrid, userId);
            #region UpdateTeammemberprofile
            Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
            objTeamMemberProfile.ProfileName   = ObjTumblrAccount.tblrUserName;
            objTeamMemberProfile.ProfilePicUrl = ObjTumblrAccount.tblrProfilePicUrl;
            objTeamMemberProfile.ProfileId     = ObjTumblrAccount.tblrUserName;
            objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
            #endregion
            oAuthTumbler.TumblrToken       = ObjTumblrAccount.tblrAccessToken;
            oAuthTumbler.TumblrTokenSecret = ObjTumblrAccount.tblrAccessTokenSecret;
            KeyValuePair <string, string> LoginDetails = new KeyValuePair <string, string>(ObjTumblrAccount.tblrAccessToken, ObjTumblrAccount.tblrAccessTokenSecret);
            AddTunblrFeeds(UserId, LoginDetails, ObjTumblrAccount.tblrUserName);
            Domain.Socioboard.Domain.TumblrFeed tumblrTumblrFeed = new Domain.Socioboard.Domain.TumblrFeed();
            TumblrFeedRepository.Add(tumblrTumblrFeed);
            return("Tumblr info is updated successfully");
            //Obj_oAuthTumbler.TumblrOAuthVerifier=ObjTumblrAccount.tbl
        }
Example #8
0
 private static Domain.Socioboard.Domain.TeamMemberProfile GetTeamMemberProfileFromJObject(JToken item)
 {
     Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
     objTeamMemberProfile.Id               = Guid.Parse(Convert.ToString(item["Id"]));
     objTeamMemberProfile.TeamId           = Guid.Parse(Convert.ToString(item["TeamId"]));
     objTeamMemberProfile.ProfileId        = Convert.ToString(item["ProfileId"]);
     objTeamMemberProfile.ProfileType      = Convert.ToString(item["ProfileType"]);
     objTeamMemberProfile.Status           = Convert.ToInt16(Convert.ToString(item["Status"]));
     objTeamMemberProfile.StatusUpdateDate = Convert.ToDateTime(Convert.ToString(item["StatusUpdateDate"]));
     return(objTeamMemberProfile);
 }
Example #9
0
        public string getLinkedInData(string UserId, string LinkedinId)
        {
            string ret = string.Empty;

            try
            {
                Guid userId = Guid.Parse(UserId);
                //oAuthTwitter OAuth = new oAuthTwitter(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"]);

                oAuthLinkedIn Linkedin_Oauth = new oAuthLinkedIn();
                Linkedin_Oauth.ConsumerKey    = ConfigurationManager.AppSettings["LiApiKey"];
                Linkedin_Oauth.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"];
                LinkedInAccountRepository objLinkedInAccountRepository = new LinkedInAccountRepository();
                LinkedInAccount           LinkedAccount;
                LinkedInAccountRepository linkedinAccRepo = new LinkedInAccountRepository();
                if (linkedinAccRepo.checkLinkedinUserExists(LinkedinId, Guid.Parse(UserId)))
                {
                    LinkedAccount = linkedinAccRepo.getUserInformation(Guid.Parse(UserId), LinkedinId);
                    #region UpdateTeammemberprofile
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                    objTeamMemberProfile.ProfileName   = LinkedAccount.LinkedinUserName;
                    objTeamMemberProfile.ProfilePicUrl = LinkedAccount.ProfileImageUrl;
                    objTeamMemberProfile.ProfileId     = LinkedAccount.LinkedinUserId;
                    objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
                    #endregion
                }
                else
                {
                    LinkedAccount = linkedinAccRepo.getUserInformation(LinkedinId);
                    #region UpdateTeammemberprofile
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                    objTeamMemberProfile.ProfileName   = LinkedAccount.LinkedinUserName;
                    objTeamMemberProfile.ProfilePicUrl = LinkedAccount.ProfileImageUrl;
                    objTeamMemberProfile.ProfileId     = LinkedAccount.LinkedinUserId;
                    objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
                    #endregion
                }

                Linkedin_Oauth.Token       = LinkedAccount.OAuthToken;
                Linkedin_Oauth.TokenSecret = LinkedAccount.OAuthSecret;
                Linkedin_Oauth.Verifier    = LinkedAccount.OAuthVerifier;
                GetUserProfile(Linkedin_Oauth, LinkedAccount.LinkedinUserId, userId);
                GetLinkedInFeeds(Linkedin_Oauth, LinkedinId, userId);
                GetLinkedUserUpdatesNew(Linkedin_Oauth, LinkedinId, userId);
                return("linkedin Info Updated");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }


            return(ret);
        }
Example #10
0
 private static Domain.Socioboard.Domain.TeamMemberProfile GetTeamMemberProfileFromJObject(JToken item)
 {
     Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
     objTeamMemberProfile.Id = Guid.Parse(Convert.ToString(item["Id"]));
     objTeamMemberProfile.TeamId = Guid.Parse(Convert.ToString(item["TeamId"]));
     objTeamMemberProfile.ProfileId = Convert.ToString(item["ProfileId"]);
     objTeamMemberProfile.ProfileType = Convert.ToString(item["ProfileType"]);
     objTeamMemberProfile.Status = Convert.ToInt16(Convert.ToString(item["Status"]));
     objTeamMemberProfile.StatusUpdateDate = Convert.ToDateTime(Convert.ToString(item["StatusUpdateDate"]));
     return objTeamMemberProfile;
 }
Example #11
0
        public string getTumblrData(string UserId, string Tumblrid)
        {
            try
            {
                Guid         userId           = Guid.Parse(UserId);
                oAuthTumbler Obj_oAuthTumbler = new oAuthTumbler();
                oAuthTumbler.TumblrConsumerKey     = ConfigurationManager.AppSettings["TumblrClientKey"];
                oAuthTumbler.TumblrConsumerSecret  = ConfigurationManager.AppSettings["TumblrClientSec"];
                Obj_oAuthTumbler.TumblrCallBackUrl = ConfigurationManager.AppSettings["TumblrCallBackURL"];
                TumblrAccountRepository objTumblrAccountRepository      = new TumblrAccountRepository();
                Domain.Socioboard.Domain.TumblrAccount ObjTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(Tumblrid, userId);

                oAuthTumbler.TumblrToken       = ObjTumblrAccount.tblrAccessToken;
                oAuthTumbler.TumblrTokenSecret = ObjTumblrAccount.tblrAccessTokenSecret;
                KeyValuePair <string, string> LoginDetails = new KeyValuePair <string, string>(ObjTumblrAccount.tblrAccessToken, ObjTumblrAccount.tblrAccessTokenSecret);
                JObject profile = new JObject();
                try
                {
                    profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null));
                }
                catch (Exception ex)
                {
                }

                #region UpdateTumblrAccount
                string tumblrnameold = ObjTumblrAccount.tblrUserName;
                ObjTumblrAccount.tblrUserName      = profile["response"]["user"]["name"].ToString();
                ObjTumblrAccount.tblrProfilePicUrl = "http://api.tumblr.com/v2/blog/" + objTumblrAccount.tblrUserName + ".tumblr.com/avatar";
                objTumblrAccountRepository.UpdateTumblrAccount(ObjTumblrAccount, tumblrnameold);
                #endregion

                #region UpdateTeammemberprofile
                Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                objTeamMemberProfile.ProfileName   = ObjTumblrAccount.tblrUserName;
                objTeamMemberProfile.ProfilePicUrl = ObjTumblrAccount.tblrProfilePicUrl;
                objTeamMemberProfile.ProfileId     = ObjTumblrAccount.tblrUserName;
                objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
                #endregion

                AddTunblrFeeds(UserId, LoginDetails, ObjTumblrAccount.tblrUserName);
            }
            catch (Exception ex)
            {
                logger.Error("GetTumblrData => " + ex.Message);
            }
            //Domain.Socioboard.Domain.TumblrFeed tumblrTumblrFeed = new Domain.Socioboard.Domain.TumblrFeed();
            //TumblrFeedRepository.Add(tumblrTumblrFeed);
            return("Tumblr info is updated successfully");
            //Obj_oAuthTumbler.TumblrOAuthVerifier=ObjTumblrAccount.tbl
        }
 /// <addNewTeamMember>
 /// Add New TeamMember
 /// </summary>
 /// <param name="team">Set Values in a TeamMemberProfile Class Property and Pass the Object of TeamMemberProfile Class.(Domein.TeamMemberProfile)</param>
 public void addNewTeamMember(Domain.Socioboard.Domain.TeamMemberProfile team)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action , to save new team member profile.
             session.Save(team);
             transaction.Commit();
         } //End Transaction
     }     //End Session
 }
Example #13
0
        public void AddTeamMembers(string groupid, string teamid)
        {
            List <Domain.Socioboard.Domain.GroupProfile> lstGroupProfile = objGroupProfileRepository.GetAllGroupProfiles(Guid.Parse(groupid));

            foreach (var GroupProfile in lstGroupProfile)
            {
                objTeamMemberProfile                  = new Domain.Socioboard.Domain.TeamMemberProfile();
                objTeamMemberProfile.Id               = Guid.NewGuid();
                objTeamMemberProfile.TeamId           = Guid.Parse(teamid);
                objTeamMemberProfile.ProfileId        = GroupProfile.ProfileId;
                objTeamMemberProfile.ProfileType      = GroupProfile.ProfileType;
                objTeamMemberProfile.Status           = 1;
                objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
            }
        }
Example #14
0
        public string getInstagramData(string UserId, string InstagramId)
        {
            Guid userId = Guid.Parse(UserId);
            InstagramAccountRepository objInstagramAccountRepository = new InstagramAccountRepository();

            //LinkedInAccountRepository objLinkedInAccountRepository = new LinkedInAccountRepository();

            Domain.Socioboard.Domain.InstagramAccount          objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, userId);
            GlobusInstagramLib.Authentication.ConfigurationIns configi             = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();

            _api = oAuthInstagram.GetInstance(configi);
            GetIntagramImages(objInstagramAccount);
            #region UpdateTeammemberprofile
            Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
            objTeamMemberProfile.ProfileName   = objInstagramAccount.InsUserName;
            objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl;
            objTeamMemberProfile.ProfileId     = objInstagramAccount.InstagramId;
            objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
            #endregion
            return("Instagram Info is Updated successfully");
        }
Example #15
0
        public string AddLinkedinAccount(string oauth_token, string oauth_verifier, string reuqestTokenSecret, string consumerKey, string consumerSecret, string UserId, string GroupId)
        {
            try
            {
                logger.Error("AddLinkedinAccount()");

                System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;

                string ret = string.Empty;
                LinkedInProfile objProfile = new LinkedInProfile();
                LinkedInProfile.UserProfile objUserProfile = new LinkedInProfile.UserProfile();
                objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                oAuthLinkedIn _oauth = new oAuthLinkedIn();
                objLinkedInAccount = new LinkedInAccount();
                #region Get linkedin Profile data from Api
                try
                {
                    _oauth.ConsumerKey = consumerKey;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                try
                {
                    _oauth.ConsumerSecret = consumerSecret;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                try
                {
                    _oauth.Token = oauth_token;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                try
                {
                    _oauth.TokenSecret = reuqestTokenSecret;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                try
                {
                    _oauth.Verifier = oauth_verifier;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                try
                {
                    _oauth.AccessTokenGet(oauth_token);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);

                }
                try
                {
                    objUserProfile = objProfile.GetUserProfile(_oauth);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                #endregion
                dynamic data = objUserProfile;
                try
                {
                    #region LinkedInAccount
                    objLinkedInAccount.UserId = Guid.Parse(UserId);
                    objLinkedInAccount.LinkedinUserId = data.id.ToString();
                    try
                    {
                        objLinkedInAccount.EmailId = data.email.ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    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 (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    try
                    {
                        objLinkedInAccount.ProfileUrl = data.profile_url.ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    #endregion
                    #region SocialProfiles
                    try
                    {
                        objLinkedInAccount.Connections = data.connections;
                        objLinkedInAccount.IsActive = true;
                        objSocialProfile.UserId = Guid.Parse(UserId);
                        objSocialProfile.ProfileType = "linkedin";
                        objSocialProfile.ProfileId = data.id.ToString();
                        objSocialProfile.ProfileStatus = 1;
                        objSocialProfile.ProfileDate = DateTime.Now;
                        objSocialProfile.Id = Guid.NewGuid();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                    #endregion SocialProfiles
                    #region Add TeamMemberProfile
                    try
                    {
                        Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                        objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                        objTeamMemberProfile.Id = Guid.NewGuid();
                        objTeamMemberProfile.TeamId = objTeam.Id;
                        objTeamMemberProfile.Status = 1;
                        objTeamMemberProfile.ProfileType = "linkedin";
                        objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                        objTeamMemberProfile.ProfileId = objLinkedInAccount.LinkedinUserId;
                        objTeamMemberProfile.ProfileName = objLinkedInAccount.LinkedinUserName;
                        objTeamMemberProfile.ProfilePicUrl = objLinkedInAccount.ProfileImageUrl;

                    }
                    catch (Exception ex)
                    {
                       logger.Error(ex.Message);
                    }
                    #endregion

                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                }
                try
                {
                    if (!objLinkedInAccountRepository.checkLinkedinUserExists(objLinkedInAccount.LinkedinUserId, Guid.Parse(UserId)))
                    {
                        objLinkedInAccountRepository.addLinkedinUser(objLinkedInAccount);
                        ret = "LinkedIn Account Added Successfully";
                    }
                    else
                    {
                        ret = "LinkedIn Account Already Exist";
                    }
                    if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                    {
                        objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    }
                    if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedInAccount.LinkedinUserId))
                    {
                        objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    }

                    #region Add LinkedIn Feeds
                    LinkedInNetwork objln = new LinkedInNetwork();
                    List<LinkedInNetwork.Network_Updates> userUPdate = objln.GetNetworkUpdates(_oauth, 20);
                    foreach (var item in userUPdate)
                    {
                        try
                        {
                            objLinkedInFeed = new Domain.Socioboard.Domain.LinkedInFeed();
                            objLinkedInFeed.Feeds = item.Message;
                            objLinkedInFeed.FromId = item.PersonId;
                            objLinkedInFeed.FromName = item.PersonFirstName + " " + item.PersonLastName;
                            objLinkedInFeed.FeedsDate = Convert.ToDateTime(item.DateTime);
                            objLinkedInFeed.EntryDate = DateTime.Now;
                            objLinkedInFeed.ProfileId = objLinkedInAccount.LinkedinUserId;
                            objLinkedInFeed.Type = item.UpdateType;
                            objLinkedInFeed.UserId = Guid.Parse(UserId);
                            objLinkedInFeed.FromPicUrl = item.PictureUrl;
                            objLinkedInFeed.ImageUrl = item.ImageUrl;
                            objLinkedInFeed.FromUrl = item.url;
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                        }
                        if (!objLinkedInFeedRepository.checkLinkedInFeedExists(objLinkedInFeed.FeedId, Guid.Parse(UserId)))
                        {

                            objLinkedInFeedRepository.addLinkedInFeed(objLinkedInFeed);
                        }
                    }
                    #endregion


                    #region Add LinkedIn UserUpdates
                    GlobusLinkedinLib.App.Core.LinkedInUser l = new GlobusLinkedinLib.App.Core.LinkedInUser();
                    List<Domain.Socioboard.Domain.LinkedIn_Update_Messages> lst_Messages = l.GetUserUpdateNew(_oauth, objLinkedInAccount.LinkedinUserId, 10);
                    foreach (var item_Messages in lst_Messages)
                    {
                        try
                        {
                            objLinkedInMessage = new Domain.Socioboard.Domain.LinkedInMessage();
                            objLinkedInMessage.Id = Guid.NewGuid();
                            objLinkedInMessage.Message = item_Messages.Message;
                            objLinkedInMessage.ProfileId = item_Messages.ProfileId;
                            objLinkedInMessage.ProfileName = item_Messages.ProfileName;
                            objLinkedInMessage.CreatedDate = Convert.ToDateTime(item_Messages.CreatedDate);
                            objLinkedInMessage.EntryDate = DateTime.Now;
                            objLinkedInMessage.Type = item_Messages.Type;
                            objLinkedInMessage.UserId = Guid.Parse(UserId);
                            objLinkedInMessage.ImageUrl = item_Messages.ImageUrl;
                            objLinkedInMessage.FeedId = item_Messages.FeedId;
                            objLinkedInMessage.ProfileUrl = item_Messages.ProfileUrl;
                            objLinkedInMessage.Comments = item_Messages.Comments;
                            objLinkedInMessage.Likes = item_Messages.Likes;
                            objLinkedInMessage.ProfileImageUrl = item_Messages.ProfileImageUrl;
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                        }
                        if (!objLinkedInMessageRepository.checkLinkedInMessageExists(objLinkedInAccount.LinkedinUserId, objLinkedInMessage.FeedId, Guid.Parse(UserId)))
                        {
                            objLinkedInMessageRepository.addLinkedInMessage(objLinkedInMessage);
                        }
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                }
                return "";
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                return "";
            }
        }
        public void GetPageProfile(dynamic data, oAuthLinkedIn _OAuth, string UserId, string CompanyPageId, string GroupId)
        {
            Domain.Socioboard.Domain.SocialProfile socioprofile = new Domain.Socioboard.Domain.SocialProfile();
            SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            Domain.Socioboard.Domain.LinkedinCompanyPage objLinkedincmpnypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
            LinkedinCompanyPageRepository objLinkedCmpnyPgeRepo = new LinkedinCompanyPageRepository();
            try
            {
                objLinkedincmpnypage.UserId = Guid.Parse(UserId);
                try
                {
                    objLinkedincmpnypage.LinkedinPageId = data.Pageid.ToString();
                }
                catch
                {
                }
                objLinkedincmpnypage.Id = Guid.NewGuid();
                try
                {
                    objLinkedincmpnypage.EmailDomains = data.EmailDomains.ToString();
                }
                catch { }
                objLinkedincmpnypage.LinkedinPageName = data.name.ToString();
                objLinkedincmpnypage.OAuthToken = _OAuth.Token;
                objLinkedincmpnypage.OAuthSecret = _OAuth.TokenSecret;
                objLinkedincmpnypage.OAuthVerifier = _OAuth.Verifier;
                try
                {
                    objLinkedincmpnypage.Description = data.description.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.FoundedYear = data.founded_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EndYear = data.end_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Locations = data.locations.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Specialties = data.Specialties.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.WebsiteUrl = data.website_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Status = data.status.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EmployeeCountRange = data.employee_count_range.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Industries = data.industries.ToString();
                }
                catch { }
                try
                {
                    string NuberOfFollower = data.num_followers.ToString();
                    objLinkedincmpnypage.NumFollowers = Convert.ToInt16(NuberOfFollower);
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.CompanyType = data.company_type.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.LogoUrl = data.logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.SquareLogoUrl = data.square_logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.BlogRssUrl = data.blog_rss_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.UniversalName = data.universal_name.ToString();
                }
                catch { }
                #region SocialProfiles
                socioprofile.UserId = Guid.Parse(UserId);
                socioprofile.ProfileType = "linkedincompanypage";
                socioprofile.ProfileId = data.Pageid.ToString(); ;
                socioprofile.ProfileStatus = 1;
                socioprofile.ProfileDate = DateTime.Now;
                socioprofile.Id = Guid.NewGuid();
                #endregion

                #region TeamMemberProfile
                Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                objTeamMemberProfile.Id = Guid.NewGuid();
                objTeamMemberProfile.TeamId = objTeam.Id;
                objTeamMemberProfile.Status = 1;
                objTeamMemberProfile.ProfileType = "linkedincompanypage";
                objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                objTeamMemberProfile.ProfileId = socioprofile.ProfileId;
                #endregion
            }
            catch
            {
            }
            try
            {
                if (!objSocialProfilesRepository.checkUserProfileExist(socioprofile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(socioprofile);
                }
                if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedincmpnypage.LinkedinPageId))
                {
                    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                }
                if (!objLinkedCmpnyPgeRepo.checkLinkedinPageExists(CompanyPageId, Guid.Parse(UserId)))
                {
                    objLinkedCmpnyPgeRepo.addLinkenCompanyPage(objLinkedincmpnypage);
                }
                else
                {
                    objLinkedincmpnypage.LinkedinPageId = CompanyPageId;
                    objLinkedCmpnyPgeRepo.updateLinkedinPage(objLinkedincmpnypage);
                }
            }
            catch
            {

            }

        }
        public void getFacebookUserProfile(dynamic data, string accesstoken, long friends, Guid user)
        {
            SocialProfile socioprofile = new SocialProfile();
            //SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            Api.SocialProfile.SocialProfile ApiObjSocialProfile = new Api.SocialProfile.SocialProfile();
            FacebookAccount fbAccount = new FacebookAccount();
            //FacebookAccountRepository fbrepo = new FacebookAccountRepository();
            Api.FacebookFeed.FacebookFeed ApiObjFacebookFeed = new Api.FacebookFeed.FacebookFeed();
            try
            {
                try
                {
                    fbAccount.AccessToken = accesstoken;
                }
                catch
                {
                }
                try
                {
                    fbAccount.EmailId = data["email"].ToString();
                }
                catch
                {
                }
                try
                {
                    fbAccount.FbUserId = data["id"].ToString();
                }
                catch
                {
                }

                try
                {
                    fbAccount.ProfileUrl = data["link"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }


                try
                {
                    fbAccount.FbUserName = data["name"].ToString();
                }
                catch
                {
                }
                try
                {
                    fbAccount.Friends = Convert.ToInt32(friends);
                }
                catch
                {
                }
                try
                {
                    fbAccount.Id = Guid.NewGuid();
                }
                catch
                {
                }
                fbAccount.IsActive = 1;
                try
                {
                    if (HttpContext.Current.Session["fbSocial"] != null)
                    {
                        if (HttpContext.Current.Session["fbSocial"] == "p")
                        {
                            //FacebookClient fbClient = new FacebookClient(accesstoken);
                            //int fancountPage = 0;
                            //dynamic fancount = fbClient.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + fbAccount.FbUserId });
                            //foreach (var friend in fancount.data)
                            //{
                            //    fancountPage = friend.fan_count;

                            //}
                            //fbAccount.Friends = Convert.ToInt32(fancountPage);
                            fbAccount.Type = "page";
                        }
                        else
                        {
                            fbAccount.Type = "account";
                        }
                        fbAccount.UserId = user;
                    }

                    if (HttpContext.Current.Session["UserAndGroupsForFacebook"] != null)
                    {
                        try
                        {
                            fbAccount.UserId = user;
                            fbAccount.Type = "account";
                        }
                        catch (Exception ex)
                        {

                        }
                    }
                }
                catch
                {
                }

                #region unused
                //if (HttpContext.Current.Session["login"] != null)
                //{
                //    if (HttpContext.Current.Session["login"].ToString().Equals("facebook"))
                //    {
                //        User usr = new User();
                //        UserRepository userrepo = new UserRepository();
                //        Registration regObject = new Registration();
                //        usr.AccountType = "free";
                //        usr.CreateDate = DateTime.Now;
                //        usr.ExpiryDate = DateTime.Now.AddMonths(1);
                //        usr.Id = Guid.NewGuid();
                //        usr.UserName = data["name"].ToString();
                //        usr.Password = regObject.MD5Hash(data["name"].ToString());
                //        usr.EmailId = data["email"].ToString();
                //        usr.UserStatus = 1;
                //        if (!userrepo.IsUserExist(data["email"].ToString()))
                //        {
                //            UserRepository.Add(usr);
                //        }
                //    }
                //} 
                #endregion
                try
                {
                    socioprofile.UserId = user;
                }
                catch
                {
                }
                try
                {
                    socioprofile.ProfileType = "facebook";
                }
                catch
                {
                }
                try
                {
                    socioprofile.ProfileId = data["id"].ToString();
                }
                catch
                {
                }
                try
                {
                    socioprofile.ProfileStatus = 1;
                }
                catch
                {
                }
                try
                {
                    socioprofile.ProfileDate = DateTime.Now;
                }
                catch
                {
                }
                try
                {
                    socioprofile.Id = Guid.NewGuid();
                }
                catch
                {
                }
                if (HttpContext.Current.Session["fbSocial"] != null)
                {
                    if (HttpContext.Current.Session["fbSocial"] == "p")
                    {

                        HttpContext.Current.Session["fbpagedetail"] = fbAccount;
                    }
                    else
                    {
                        if (!fbrepo.checkFacebookUserExists(fbAccount.FbUserId, user))
                        {
                            fbrepo.addFacebookUser(fbAccount);
                            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 = fbAccount.FbUserId;
                                    teammemberprofile.ProfileType = "facebook";
                                    teammemberprofile.StatusUpdateDate = DateTime.Now;

                                    objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile);

                                }




                            }
                            else
                            {
                                socioprofilerepo.updateSocialProfile(socioprofile);
                            }

                           

                        }
                        else
                        {
                            HttpContext.Current.Session["alreadyexist"] = fbAccount;
                            fbrepo.updateFacebookUser(fbAccount);
                            if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                            {
                                socioprofilerepo.addNewProfileForUser(socioprofile);
                            }
                            else
                            {
                                socioprofilerepo.updateSocialProfile(socioprofile);
                            }
                        }

                    }
                }

                if (HttpContext.Current.Session["UserAndGroupsForFacebook"] != null)
                {
                    if (HttpContext.Current.Session["UserAndGroupsForFacebook"].ToString() == "facebook")
                    {
                        try
                        {
                            if (!fbrepo.checkFacebookUserExists(fbAccount.FbUserId, user))
                            {
                                fbrepo.addFacebookUser(fbAccount);
                                if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                                {
                                    socioprofilerepo.addNewProfileForUser(socioprofile);
                                }
                                else
                                {
                                    socioprofilerepo.updateSocialProfile(socioprofile);
                                }
                            }
                            else
                            {
                                fbrepo.updateFacebookUser(fbAccount);
                                if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                                {
                                    socioprofilerepo.addNewProfileForUser(socioprofile);
                                }
                                else
                                {
                                    socioprofilerepo.updateSocialProfile(socioprofile);
                                }
                            
                            }
                            if (HttpContext.Current.Session["GroupName"] != null)
                            {
                                GroupProfile groupprofile = new GroupProfile();
                                GroupProfileRepository groupprofilerepo = new GroupProfileRepository();
                                Groups group = (Groups)HttpContext.Current.Session["GroupName"];
                                groupprofile.Id = Guid.NewGuid();
                                groupprofile.GroupOwnerId = user;
                                groupprofile.ProfileId = socioprofile.ProfileId;
                                groupprofile.ProfileType = "facebook";
                                groupprofile.GroupId = group.Id;
                                groupprofile.EntryDate = DateTime.Now;
                                if (!groupprofilerepo.checkGroupProfileExists(user, group.Id, groupprofile.ProfileId))
                                {
                                    groupprofilerepo.AddGroupProfile(groupprofile);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
        public string GetFacebookData(string FbId, string UserId)
        {
            string ret = string.Empty;
            long friendscount = 0;
            try
            {
                Domain.Socioboard.Domain.FacebookAccount objFacebookAccount = new Domain.Socioboard.Domain.FacebookAccount();
                if (objFacebookAccountRepository.checkFacebookUserExists(FbId, Guid.Parse(UserId)))
                {
                    objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FbId, Guid.Parse(UserId));
                }
                else
                {
                    objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FbId);
                }


                FacebookClient fb = new FacebookClient();
                string profileId = string.Empty;
                string accessToken = objFacebookAccount.AccessToken;
                dynamic profile = null;
                dynamic friends = null;
                if (accessToken != null)
                {
                    fb.AccessToken = accessToken;
                    try
                    {
                        profile = fb.Get("v2.0/me");

                    }
                    catch (Exception ex)
                    {
                        string errormssg = ex.Message;
                        if (errormssg.Contains("changed the password"))
                        {
                            UpdateSocialprofileStatus(UserId, FbId);
                            objFacebookAccount.IsActive = 2;
                            UpdateFacebookAccount(objFacebookAccount);
                        }
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        return "Token Expired";
                    }
                    try
                    {
                        friends = fb.Get("v2.0/me/friends");

                    }
                    catch (Exception ex)
                    {
                        string errormssg = ex.Message;
                        if (errormssg.Contains("changed the password"))
                        {
                            UpdateSocialprofileStatus(UserId, FbId);
                        }
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        return "Token Expired";
                    }

                    try
                    {
                        friendscount = Convert.ToInt16(friends["summary"]["total_count"].ToString());
                        objFacebookAccount.Friends = Convert.ToInt32(friendscount);
                    }
                    catch (Exception ex)
                    {
                        //try
                        //{
                        //    dynamic frndscount = fb.Get("fql", new { q = "SELECT friend_count FROM user WHERE uid=me()" });

                        //    foreach (var friend in frndscount.data)
                        //    {
                        //        frndscount = friend.friend_count;
                        //    }
                        //    friendscount = Convert.ToInt16(frndscount);
                        //}
                        //catch (Exception exx)
                        //{
                        //    friendscount = 0;
                        //    logger.Error(exx.Message);
                        //    logger.Error(exx.StackTrace);
                        //}
                        friendscount = 0;
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                    }

                    try
                    {
                        objFacebookAccount.FbUserName = (Convert.ToString(profile["name"]));
                    }
                    catch { }

                    if (objFacebookAccountRepository.checkFacebookUserExists(Convert.ToString(profile["id"]), Guid.Parse(UserId)))
                    {
                        #region Update FacebookAccount
                        UpdateFacebookAccount(objFacebookAccount);
                        #endregion
                        #region UpdateTeammemberprofile
                        Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                        objTeamMemberProfile.ProfileName = objFacebookAccount.FbUserName;
                        objTeamMemberProfile.ProfilePicUrl = "http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small";
                        objTeamMemberProfile.ProfileId = objFacebookAccount.FbUserId;
                        objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
                        #endregion

                        #region UpdateFacebook FanPge
                        Domain.Socioboard.Domain.FacebookFanPage objFacebookFanPage = new Domain.Socioboard.Domain.FacebookFanPage();
                        FacebookFanPageRepository objFacebookFanPageRepository = new FacebookFanPageRepository();
                        objFacebookFanPage.Id = Guid.NewGuid();
                        objFacebookFanPage.UserId = Guid.Parse(UserId);
                        objFacebookFanPage.ProfilePageId = FbId;
                        objFacebookFanPage.FanpageCount = friendscount.ToString();
                        objFacebookFanPage.EntryDate = DateTime.Now;
                        objFacebookFanPageRepository.addFacebookUser(objFacebookFanPage);
                        #endregion

                        #region Add Facebook Feeds
                        //AddFacebookFeeds(UserId, fb, profile);
                        AddFacebookFeedsWithPagination(UserId, fb, profile);
                        #endregion
                        #region Add Facebook User Home
                        AddFacebookUserHome(UserId, fb, profile);
                        #endregion
                        #region Add Facebook User Inbox Message
                        AddFacebookMessageWithPagination(UserId, fb, profile);
                        #endregion
                        #region Add Facebook User Notifications
                        // getUserNotifications(UserId, fb, profile);
                        #endregion
                        ret = "Facebook info Updated Successfully";
                    }
                    else
                    {
                        ret = "Account already Exist !";
                    }
                }
                return new JavaScriptSerializer().Serialize(ret);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
        public string AddFacebookAccount(string code, string UserId, string GroupId)
        {
            string ret = string.Empty;
            string client_id = ConfigurationManager.AppSettings["ClientId"];
            string redirect_uri = ConfigurationManager.AppSettings["RedirectUrl"];
            string client_secret = ConfigurationManager.AppSettings["ClientSecretKey"];
            long friendscount = 0;
            try
            {
                FacebookClient fb = new FacebookClient();
                string profileId = string.Empty;
                Dictionary<string, object> parameters = new Dictionary<string, object>();
                parameters.Add("client_id", client_id);
                parameters.Add("redirect_uri", redirect_uri);
                parameters.Add("client_secret", client_secret);
                parameters.Add("code", code);
                JsonObject fbaccess_token = null;
                try
                {
                    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
                    fbaccess_token = (JsonObject)fb.Get("/oauth/access_token", parameters);

                }
                catch (Exception ex)
                {

                    try
                    {
                        fbaccess_token = (JsonObject)fb.Get("/oauth/access_token", parameters);
                    }
                    catch (Exception ex1)
                    {
                        return "issue_access_token";
                    }
                }

                string accessToken = fbaccess_token["access_token"].ToString();
                if (accessToken != null)
                {
                    fb.AccessToken = accessToken;
                    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
                    dynamic profile = fb.Get("v2.0/me");
                    dynamic friends = fb.Get("v2.0/me/friends");
                    try
                    {
                        friendscount = Convert.ToInt16(friends["summary"]["total_count"].ToString());
                    }
                    catch (Exception ex)
                    {
                        //try
                        //{
                        //    dynamic frndscount = fb.Get("fql", new { q = "SELECT friend_count FROM user WHERE uid=me()" });

                        //    foreach (var friend in frndscount.data)
                        //    {
                        //        frndscount = friend.friend_count;
                        //    }
                        //    friendscount = Convert.ToInt16(frndscount);
                        //}
                        //catch (Exception ex)
                        //{
                        //    friendscount = 0;
                        //    logger.Error(ex.Message);
                        //    logger.Error(ex.StackTrace);
                        //}

                        friendscount = 0;
                        logger.Error("friendscount >> " + ex.Message);
                        logger.Error("friendscount >> " + ex.StackTrace);
                        logger.Error("friendscount >> " + friends.ToString());
                        logger.Error("friendscount >> " + friends["paging"]["next"].ToString());
                    }
                    if (!objFacebookAccountRepository.checkFacebookUserExists(Convert.ToString(profile["id"]), Guid.Parse(UserId)))
                    {
                        #region Add FacebookAccount
                        objFacebookAccount = new Domain.Socioboard.Domain.FacebookAccount();
                        objFacebookAccount.Id = Guid.NewGuid();
                        objFacebookAccount.FbUserId = (Convert.ToString(profile["id"]));
                        objFacebookAccount.FbUserName = (Convert.ToString(profile["name"]));
                        objFacebookAccount.AccessToken = accessToken;
                        objFacebookAccount.Friends = Convert.ToInt16(friendscount);
                        try
                        {
                            objFacebookAccount.EmailId = (Convert.ToString(profile["email"]));
                        }
                        catch (Exception ex)
                        {

                        }
                        objFacebookAccount.Type = "account";
                        objFacebookAccount.ProfileUrl = (Convert.ToString(profile["link"]));
                        objFacebookAccount.IsActive = 1;
                        objFacebookAccount.UserId = Guid.Parse(UserId);
                        objFacebookAccountRepository.addFacebookUser(objFacebookAccount);
                        #endregion
                        #region Add TeamMemberProfile
                        Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                        Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                        objTeamMemberProfile.Id = Guid.NewGuid();
                        objTeamMemberProfile.TeamId = objTeam.Id;
                        objTeamMemberProfile.Status = 1;
                        objTeamMemberProfile.ProfileType = "facebook";
                        objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                        objTeamMemberProfile.ProfileId = Convert.ToString(profile["id"]);
                        objTeamMemberProfile.ProfileName = (Convert.ToString(profile["name"]));
                        objTeamMemberProfile.ProfilePicUrl = "http://graph.facebook.com/" + objTeamMemberProfile.ProfileId + "/picture?type=small";
                        objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                        #endregion
                        #region SocialProfile
                        Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                        objSocialProfile.Id = Guid.NewGuid();
                        objSocialProfile.ProfileType = "facebook";
                        objSocialProfile.ProfileId = (Convert.ToString(profile["id"]));
                        objSocialProfile.UserId = Guid.Parse(UserId);
                        objSocialProfile.ProfileDate = DateTime.Now;
                        objSocialProfile.ProfileStatus = 1;
                        #endregion
                        if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                        {
                            objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                        }
                        #region Add Facebook Feeds
                        AddFacebookFeeds(UserId, fb, profile);
                        #endregion
                        #region Add Facebook User Home
                        AddFacebookUserHome(UserId, fb, profile);
                        #endregion
                        #region Add Facebook User Inbox Message
                        //AddFacebookMessage(UserId, fb, profile);
                        AddFacebookMessageWithPagination(UserId, fb, profile);
                        #endregion
                        #region Add Facebook Stats
                        AddFacebookStats(UserId, fb, profile);
                        #endregion
                        //getUserNotifications(UserId, fb, profile);
                        ret = "Account Added Successfully";

                        ret = new JavaScriptSerializer().Serialize(objFacebookAccount);

                    }
                    else
                    {
                        objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(Convert.ToString(profile["id"]), Guid.Parse(UserId));
                        if (objFacebookAccount.IsActive == 2)
                        {
                            objFacebookAccount.IsActive = 1;
                            objFacebookAccount.AccessToken = accessToken;
                            objFacebookAccountRepository.updateFacebookUser(objFacebookAccount);

                            Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                            objSocialProfile.Id = Guid.NewGuid();
                            objSocialProfile.ProfileType = "facebook";
                            objSocialProfile.ProfileId = objFacebookAccount.FbUserId;
                            objSocialProfile.UserId = Guid.Parse(UserId);
                            objSocialProfile.ProfileDate = DateTime.Now;
                            objSocialProfile.ProfileStatus = 1;
                            objSocialProfilesRepository.updateSocialProfileStatus(objSocialProfile);
                            ret = "Account Updated successfully !";
                        }
                        else
                        {
                            ret = "Account already Exist !";
                        }

                    }
                }
                //return new JavaScriptSerializer().Serialize(ret);
                return ret;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
Example #20
0
        public string AddTwitterAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string requestToken, string requestSecret, string requestVerifier)
        {
            try
            {
                System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;

                string ret = string.Empty;
                Users userinfo = new Users();
                oAuthTwitter OAuth = new oAuthTwitter(client_id, client_secret, redirect_uri);
                OAuth.AccessToken = requestToken;
                OAuth.AccessTokenSecret = requestVerifier;
                OAuth.AccessTokenGet(requestToken, requestVerifier);
                JArray profile = userinfo.Get_Users_LookUp_ByScreenName(OAuth, OAuth.TwitterScreenName);

                if (profile!=null)
                {
                    logger.Error("Twitter.asmx >> AddTwitterAccount >> Twitter profile : " + profile); 
                }
                else
                {
                    logger.Error("Twitter.asmx >> AddTwitterAccount >> NULL Twitter profile : " + profile); 
                }

                objTwitterAccount = new Domain.Socioboard.Domain.TwitterAccount();
                TwitterUser twtuser;
                foreach (var item in profile)
                {
                    #region Add Twitter Account
                    try
                    {
                        objTwitterAccount.FollowingCount = Convert.ToInt32(item["friends_count"].ToString());
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterAccount.FollowersCount = Convert.ToInt32(item["followers_count"].ToString());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    objTwitterAccount.Id = Guid.NewGuid();
                    objTwitterAccount.IsActive = true;
                    objTwitterAccount.OAuthSecret = OAuth.AccessTokenSecret;
                    objTwitterAccount.OAuthToken = OAuth.AccessToken;
                    try
                    {
                        objTwitterAccount.ProfileImageUrl = item["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);

                    }
                    try
                    {
                        objTwitterAccount.ProfileUrl = string.Empty;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterAccount.TwitterUserId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception er)
                    {
                        try
                        {
                            objTwitterAccount.TwitterUserId = item["id"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                        }
                        Console.WriteLine(er.StackTrace);

                    }

                    try
                    {
                        objTwitterAccount.TwitterScreenName = item["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    objTwitterAccount.UserId = Guid.Parse(UserId);
                    #endregion
                    if (!objTwitterAccountRepository.checkTwitterUserExists(objTwitterAccount.TwitterUserId, Guid.Parse(UserId)))
                    {
                        objTwitterAccountRepository.addTwitterkUser(objTwitterAccount);
                        #region Add TeamMemberProfile
                        Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                        Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                        objTeamMemberProfile.Id = Guid.NewGuid();
                        objTeamMemberProfile.TeamId = objTeam.Id;
                        objTeamMemberProfile.Status = 1;
                        objTeamMemberProfile.ProfileType = "twitter";
                        objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                        objTeamMemberProfile.ProfileId = objTwitterAccount.TwitterUserId;

                        objTeamMemberProfile.ProfileName = objTwitterAccount.TwitterScreenName;
                        objTeamMemberProfile.ProfilePicUrl = objTwitterAccount.ProfileImageUrl;

                        objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                        #endregion
                        #region SocialProfile
                        Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                        objSocialProfile.Id = Guid.NewGuid();
                        objSocialProfile.ProfileType = "twitter";
                        objSocialProfile.ProfileId = objTwitterAccount.TwitterUserId;
                        objSocialProfile.UserId = Guid.Parse(UserId);
                        objSocialProfile.ProfileDate = DateTime.Now;
                        objSocialProfile.ProfileStatus = 1;
                        #endregion
                        #region Add Twitter Stats
                        if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                        {
                            objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                        }
                        objTwitterStats = new Domain.Socioboard.Domain.TwitterStats();
                        Random rNum = new Random();
                        objTwitterStats.Id = Guid.NewGuid();
                        objTwitterStats.TwitterId = objTwitterAccount.TwitterUserId;
                        objTwitterStats.UserId = Guid.Parse(UserId);
                        objTwitterStats.FollowingCount = objTwitterAccount.FollowingCount;
                        objTwitterStats.FollowerCount = objTwitterAccount.FollowersCount;
                        objTwitterStats.Age1820 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.Age2124 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.Age2534 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.Age3544 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.Age4554 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.Age5564 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.Age65 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.EntryDate = DateTime.Now;
                        if (!objTwtstats.checkTwitterStatsExists(objTwitterAccount.TwitterUserId, Guid.Parse(UserId)))
                        {
                            objTwtstats.addTwitterStats(objTwitterStats);
                        }
                        #endregion
                        ret = "Account Added Successfully";
                    }
                    else
                    {
                        ret = "Account already Exist !";
                    }
                }
                #region Add Twitter Messages
                twtuser = new TwitterUser();
                try
                {
                    TimeLine tl = new TimeLine();
                    JArray data = null;
                    try
                    {
                        data = tl.Get_Statuses_Mentions_Timeline(OAuth);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        logger.Error("tl.Get_Statuses_Mentions_Timeline ex.StackTrace >> " + ex.StackTrace);
                        logger.Error("tl.Get_Statuses_Mentions_Timeline ex.Message >> " + ex.Message);
                    }
                    objTwitterMessage = new Domain.Socioboard.Domain.TwitterMessage();
                    foreach (var item in data)
                    {
                        objTwitterMessage.UserId = Guid.Parse(UserId);
                        objTwitterMessage.Type = "twt_mentions";
                        objTwitterMessage.Id = Guid.NewGuid();

                        try
                        {
                            objTwitterMessage.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.MessageDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"'));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.TwitterMsg = item["text"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        try
                        {
                            objTwitterMessage.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        try
                        {
                            objTwitterMessage.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        try
                        {
                            objTwitterMessage.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        try
                        {
                            objTwitterMessage.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        try
                        {
                            objTwitterMessage.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        } try
                        {
                            objTwitterMessage.ProfileId = objTwitterAccount.TwitterUserId;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.ScreenName = item["user"]["screen_name"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        try
                        {
                            objTwitterMessage.EntryDate = DateTime.Now;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        if (!objTwitterMessageRepository.checkTwitterMessageExists(objTwitterMessage.MessageId))
                        {
                            objTwitterMessageRepository.addTwitterMessage(objTwitterMessage);
                        }

                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                    logger.Error("tl.Get_Statuses_Mentions_Timeline ex.StackTrace >> " + ex.StackTrace);
                    logger.Error("tl.Get_Statuses_Mentions_Timeline ex.Message >> " + ex.Message);
                }
                #endregion
                #region Add User Retweet
                twtuser = new TwitterUser();
                try
                {
                    JArray Retweet = null;
                    try
                    {
                        Retweet = twtuser.GetStatuses_Retweet_Of_Me(OAuth);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        logger.Error("twtuser.GetStatuses_Retweet_Of_Me ex.StackTrace >> " + ex.StackTrace);
                        logger.Error("twtuser.GetStatuses_Retweet_Of_Me ex.Message >> " + ex.Message);
                    }
                    objTwitterMessage = new Domain.Socioboard.Domain.TwitterMessage();
                    foreach (var item in Retweet)
                    {
                        objTwitterMessage.UserId = Guid.Parse(UserId);
                        objTwitterMessage.Type = "twt_retweets";
                        objTwitterMessage.Id = Guid.NewGuid();

                        try
                        {
                            objTwitterMessage.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.MessageDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"'));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.TwitterMsg = item["text"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        try
                        {
                            objTwitterMessage.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        try
                        {
                            objTwitterMessage.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        try
                        {
                            objTwitterMessage.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        try
                        {
                            objTwitterMessage.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        try
                        {
                            objTwitterMessage.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        } try
                        {
                            objTwitterMessage.ProfileId = objTwitterAccount.TwitterUserId;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        } try
                        {
                            objTwitterMessage.EntryDate = DateTime.Now;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        if (!objTwitterMessageRepository.checkTwitterMessageExists(objTwitterMessage.MessageId))
                        {
                            objTwitterMessageRepository.addTwitterMessage(objTwitterMessage);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                    logger.Error("twtuser.GetStatuses_Retweet_Of_Me ex.StackTrace >> " + ex.StackTrace);
                    logger.Error("twtuser.GetStatuses_Retweet_Of_Me ex.Message >> " + ex.Message);
                }
                #endregion
                #region Add User Tweets
                try
                {

                    JArray Timeline = twtuser.GetStatuses_User_Timeline(OAuth);
                    TwitterMessageRepository twtmsgrepo = new TwitterMessageRepository();
                    TwitterMessage twtmsg = new TwitterMessage();
                    foreach (var item in Timeline)
                    {
                        objTwitterMessage.UserId = Guid.Parse(UserId);
                        objTwitterMessage.Type = "twt_usertweets";
                        try
                        {
                            objTwitterMessage.TwitterMsg = item["text"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.ScreenName = objTwitterAccount.TwitterScreenName;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.ProfileId = objTwitterAccount.TwitterUserId;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.MessageDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"'));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.Id = Guid.NewGuid();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterMessage.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        objTwitterMessage.EntryDate = DateTime.Now;
                        try
                        {
                            objTwitterMessage.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        if (!objTwitterMessageRepository.checkTwitterMessageExists(objTwitterMessage.MessageId))
                        {
                            objTwitterMessageRepository.addTwitterMessage(objTwitterMessage);
                        }

                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                    logger.Error("twtuser.GetStatuses_User_Timeline ex.StackTrace >> " + ex.StackTrace);
                    logger.Error("twtuser.GetStatuses_User_Timeline ex.Message >> " + ex.Message);
                }
                #endregion
                #region Add Twitter User Feed

                twtuser = new TwitterUser();
                try
                {
                    JArray Home_Timeline = twtuser.GetStatuses_Home_Timeline(OAuth);
                    objTwitterFeed = new Domain.Socioboard.Domain.TwitterFeed();
                    foreach (var item in Home_Timeline)
                    {
                        objTwitterFeed.UserId = Guid.Parse(UserId);
                        objTwitterFeed.Type = "twt_feeds";
                        try
                        {
                            objTwitterFeed.Feed = item["text"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterFeed.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterFeed.ScreenName = objTwitterAccount.TwitterScreenName;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterFeed.ProfileId = objTwitterAccount.TwitterUserId;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterFeed.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterFeed.FeedDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"'));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterFeed.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterFeed.Id = Guid.NewGuid();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
<<<<<<< HEAD
                        try
                        {
                            objTwitterFeed.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            objTwitterFeed.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"');
=======
                        try
                        {
                            objTwitterFeed.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
>>>>>>> e052534b7a2a3744cad9dddbc3c6acccf394ca7b
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
<<<<<<< HEAD
=======
                            objTwitterFeed.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
>>>>>>> e052534b7a2a3744cad9dddbc3c6acccf394ca7b
                            objTwitterFeed.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        objTwitterFeed.EntryDate = DateTime.Now;
                        try
                        {
                            objTwitterFeed.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        if (!objTwitterFeedRepository.checkTwitterFeedExists(objTwitterFeed.MessageId))
                        {
                            try
                            {
                                objTwitterFeedRepository.addTwitterFeed(objTwitterFeed);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                                Console.WriteLine(ex.StackTrace);
                            }
                        }
                        // Edited by Antima[20/12/2014]

                        SentimentalAnalysis _SentimentalAnalysis = new SentimentalAnalysis();
                        FeedSentimentalAnalysisRepository _FeedSentimentalAnalysisRepository = new FeedSentimentalAnalysisRepository();
                        try
                        {
                            if (_FeedSentimentalAnalysisRepository.checkFeedExists(objTwitterFeed.ProfileId.ToString(), Guid.Parse(UserId), objTwitterFeed.Id.ToString()))
                            {
                                if (!string.IsNullOrEmpty(objTwitterFeed.Feed))
                                {
                                    string Network = "twitter";
                                    _SentimentalAnalysis.GetPostSentimentsFromUclassify(Guid.Parse(UserId), objTwitterFeed.ProfileId, objTwitterFeed.MessageId, objTwitterFeed.Feed, Network);
                                }
                            }
                        }
                        catch (Exception)
                        {

                        }
                    }
                }
        public string AddFacebookGroupsInfo(string userid, string fbgroupid, string accessToken, string groupId, string email, string fbgroupname)
        {
            string ret = string.Empty;
            try
            {
                FacebookClient fb = new FacebookClient();

                if (accessToken != null)
                {
                    fb.AccessToken = accessToken;
                    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
                    dynamic profile = fb.Get("v2.0/me");

                    #region Add FacebookAccount
                    objFacebookAccount = new Domain.Socioboard.Domain.FacebookAccount();
                    objFacebookAccount.Id = Guid.NewGuid();
                    objFacebookAccount.FbUserId = fbgroupid;
                    objFacebookAccount.FbUserName = fbgroupname;
                    objFacebookAccount.AccessToken = accessToken;
                    objFacebookAccount.Friends = 0;
                    objFacebookAccount.EmailId = email;
                    objFacebookAccount.Type = "group";
                    objFacebookAccount.ProfileUrl = (Convert.ToString(profile["link"]));
                    objFacebookAccount.IsActive = 2;
                    objFacebookAccount.UserId = Guid.Parse(userid);
                    if (!objFacebookAccountRepository.checkFacebookUserExists(objFacebookAccount.FbUserId, objFacebookAccount.UserId))
                    {
                        objFacebookAccountRepository.addFacebookUser(objFacebookAccount);
                    }
                    //objFacebookAccountRepository.addFacebookUser(objFacebookAccount);
                    #endregion
                    #region SocialProfile
                    Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                    objSocialProfile.Id = Guid.NewGuid();
                    objSocialProfile.ProfileType = "facebook_group";
                    objSocialProfile.ProfileId = fbgroupid;
                    objSocialProfile.UserId = Guid.Parse(userid);
                    objSocialProfile.ProfileDate = DateTime.Now;
                    objSocialProfile.ProfileStatus = 1;
                    if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                    {
                        objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    }
                    #endregion
                    #region Add TeamMemberProfile
                    Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(groupId));
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                    objTeamMemberProfile.Id = Guid.NewGuid();
                    objTeamMemberProfile.TeamId = objTeam.Id;
                    objTeamMemberProfile.Status = 1;
                    objTeamMemberProfile.ProfileType = "facebook_group";
                    objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                    objTeamMemberProfile.ProfileId = fbgroupid;
                    if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objTeamMemberProfile.ProfileId))
                    {
                        objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    }

                    #endregion
                    #region Add Facebook Feeds
                    AddFacebookFeeds(userid, fb, profile);
                    #endregion

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return ret;
        }
Example #22
0
        public string AddTumblrAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            string ret = string.Empty;
            string AccessTokenResponse = string.Empty;

            try
            {
                oAuthTumbler requestHelper = new oAuthTumbler();
                oAuthTumbler.TumblrConsumerKey    = client_id;
                oAuthTumbler.TumblrConsumerSecret = client_secret;
                requestHelper.TumblrCallBackUrl   = redirect_uri;
                AccessTokenResponse = requestHelper.GetAccessToken(oAuthTumbler.TumblrToken, code);
                logger.Error(AccessTokenResponse);

                string[] tokens = AccessTokenResponse.Split('&'); //extract access token & secret from response
                logger.Error(tokens);
                string accessToken = tokens[0].Split('=')[1];
                logger.Error(accessToken);
                string accessTokenSecret = tokens[1].Split('=')[1];
                logger.Error(accessTokenSecret);

                KeyValuePair <string, string> LoginDetails = new KeyValuePair <string, string>(accessToken, accessTokenSecret);

                JObject profile = new JObject();
                try
                {
                    profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null));
                }
                catch (Exception ex)
                {
                }


                #region Add Tumblr Account
                objTumblrAccount                       = new Domain.Socioboard.Domain.TumblrAccount();
                objTumblrAccount.Id                    = Guid.NewGuid();
                objTumblrAccount.tblrUserName          = profile["response"]["user"]["name"].ToString();
                objTumblrAccount.UserId                = Guid.Parse(UserId);
                objTumblrAccount.tblrAccessToken       = accessToken;
                objTumblrAccount.tblrAccessTokenSecret = accessTokenSecret;
                objTumblrAccount.tblrProfilePicUrl     = "http://api.tumblr.com/v2/blog/" + objTumblrAccount.tblrUserName + ".tumblr.com/avatar";//profile["response"]["user"]["name"].ToString();
                objTumblrAccount.IsActive              = 1;
                if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount))
                {
                    TumblrAccountRepository.Add(objTumblrAccount);

                    #region Add Socialprofiles
                    objSocialProfile               = new Domain.Socioboard.Domain.SocialProfile();
                    objSocialProfile.Id            = Guid.NewGuid();
                    objSocialProfile.UserId        = Guid.Parse(UserId);
                    objSocialProfile.ProfileId     = profile["response"]["user"]["name"].ToString();
                    objSocialProfile.ProfileType   = "tumblr";
                    objSocialProfile.ProfileDate   = DateTime.Now;
                    objSocialProfile.ProfileStatus = 1;
                    if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                    {
                        objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    }
                    #endregion

                    #region Add TeamMemeberProfile
                    Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                    objTeamMemberProfile.Id               = Guid.NewGuid();
                    objTeamMemberProfile.TeamId           = objTeam.Id;
                    objTeamMemberProfile.Status           = 1;
                    objTeamMemberProfile.ProfileType      = "tumblr";
                    objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                    objTeamMemberProfile.ProfileId        = objTumblrAccount.tblrUserName;

                    //Modified [13-02-15]
                    objTeamMemberProfile.ProfilePicUrl = objTumblrAccount.tblrProfilePicUrl;
                    objTeamMemberProfile.ProfileName   = objTumblrAccount.tblrUserName;

                    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    #endregion
                }
                #endregion


                //if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeam.Id, objTumblrAccount.tblrUserName))
                //{
                //    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                //}

                #region Add Tumblr Feeds
                AddTunblrFeeds(UserId, LoginDetails, profile["response"]["user"]["name"].ToString());
                #endregion
            }
            catch (Exception ex)
            {
                logger.Error("AddTumblrAccount => " + ex.StackTrace);
            }
            return(ret);
        }
Example #23
0
        public String getTwitterData(string UserId, string twitterid)
        {
            string ret = string.Empty;
            try
            {
                System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;

                Guid userId = Guid.Parse(UserId);
                oAuthTwitter OAuth = new oAuthTwitter(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"]);
                TwitterAccountRepository objTwtRepo = new TwitterAccountRepository();


                List<Domain.Socioboard.Domain.TwitterAccount> lstTwitterAccount = objTwtRepo.getAllTwitterAccountsOfUser(userId);
                foreach (Domain.Socioboard.Domain.TwitterAccount itemTwt in lstTwitterAccount)
                {
                    string profileId = string.Empty;

                    OAuth.AccessToken = itemTwt.OAuthToken;
                    OAuth.AccessTokenSecret = itemTwt.OAuthSecret;

                    getUserProile(OAuth, itemTwt.TwitterUserId, userId);
                    //getUserTweets(OAuth, itemTwt.TwitterScreenName, itemTwt.TwitterUserId, userId);
                    getUserTweets(OAuth, itemTwt.TwitterScreenName, itemTwt.TwitterUserId, userId, itemTwt);
                    gettwitterengagement(OAuth, userId, itemTwt);
                    getUserFeed(OAuth, itemTwt.TwitterScreenName, itemTwt.TwitterUserId, userId);

                    getTwitterDirectMessageSent(UserId, OAuth);
                    getTwittwrDirectMessageRecieved(OAuth, UserId);
                    getUserMentions(OAuth, itemTwt.TwitterUserId, Guid.Parse(UserId));
                    getUserFollowersData(OAuth, itemTwt.TwitterScreenName, itemTwt.TwitterUserId, Guid.Parse(UserId));
                    getUserRetweet(OAuth, itemTwt.TwitterUserId, Guid.Parse(UserId));

                    #region UpdateTeammemberprofile
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                    objTeamMemberProfile.ProfileName = itemTwt.TwitterScreenName;
                    objTeamMemberProfile.ProfilePicUrl = itemTwt.ProfileImageUrl;
                    objTeamMemberProfile.ProfileId = itemTwt.TwitterUserId;
                    objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
                    #endregion
                    Domain.Socioboard.Domain.TwitterAccount _TwitterAccount = objTwtRepo.GetUserInformation(itemTwt.UserId, itemTwt.TwitterUserId);
                    if (_TwitterAccount != null)
                        getTwitterStats(_TwitterAccount);
                }
                return "twitter Info Updated Successfully";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return ret;

        }
Example #24
0
        public string getTumblrData(string UserId, string Tumblrid)
        {
            Guid userId = Guid.Parse(UserId);
            oAuthTumbler Obj_oAuthTumbler = new oAuthTumbler();
            oAuthTumbler.TumblrConsumerKey = ConfigurationManager.AppSettings["TumblrClientKey"];
            oAuthTumbler.TumblrConsumerSecret = ConfigurationManager.AppSettings["TumblrClientSec"];
            Obj_oAuthTumbler.TumblrCallBackUrl = ConfigurationManager.AppSettings["TumblrCallBackURL"];
            TumblrAccountRepository objTumblrAccountRepository = new TumblrAccountRepository();
            Domain.Socioboard.Domain.TumblrAccount ObjTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(Tumblrid, userId);
            #region UpdateTeammemberprofile
            Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
            objTeamMemberProfile.ProfileName = ObjTumblrAccount.tblrUserName;
            objTeamMemberProfile.ProfilePicUrl = ObjTumblrAccount.tblrProfilePicUrl;
            objTeamMemberProfile.ProfileId = ObjTumblrAccount.tblrUserName;
            objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
            #endregion
            oAuthTumbler.TumblrToken = ObjTumblrAccount.tblrAccessToken;
            oAuthTumbler.TumblrTokenSecret = ObjTumblrAccount.tblrAccessTokenSecret;
            KeyValuePair<string, string> LoginDetails = new KeyValuePair<string, string>(ObjTumblrAccount.tblrAccessToken, ObjTumblrAccount.tblrAccessTokenSecret);
            AddTunblrFeeds(UserId, LoginDetails, ObjTumblrAccount.tblrUserName);
            Domain.Socioboard.Domain.TumblrFeed tumblrTumblrFeed = new Domain.Socioboard.Domain.TumblrFeed();
            TumblrFeedRepository.Add(tumblrTumblrFeed);
            return "Tumblr info is updated successfully";
            //Obj_oAuthTumbler.TumblrOAuthVerifier=ObjTumblrAccount.tbl

        }
Example #25
0
        public string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            string         ret      = string.Empty;
            oAuthInstagram objInsta = new oAuthInstagram();

            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();

            _api = oAuthInstagram.GetInstance(configi);
            AccessToken access = new AccessToken();

            access = _api.AuthGetAccessToken(code);
            #region InstagramAccount
            UserController objusercontroller = new UserController();
            InstagramResponse <GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token);
            objInstagramAccount             = new Domain.Socioboard.Domain.InstagramAccount();
            objInstagramAccount.AccessToken = access.access_token;
            objInstagramAccount.InstagramId = access.user.id;
            objInstagramAccount.ProfileUrl  = access.user.profile_picture;
            objInstagramAccount.InsUserName = access.user.username;
            objInstagramAccount.TotalImages = objuser.data.counts.media;
            objInstagramAccount.FollowedBy  = objuser.data.counts.followed_by;
            objInstagramAccount.Followers   = objuser.data.counts.follows;
            objInstagramAccount.UserId      = Guid.Parse(UserId);
            #endregion


            if (!objInstagramAccountRepository.checkInstagramUserExists(objInstagramAccount.InstagramId, Guid.Parse(UserId)))
            {
                objInstagramAccountRepository.addInstagramUser(objInstagramAccount);
                #region Add TeamMemberProfile
                Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                objTeamMemberProfile.Id               = Guid.NewGuid();
                objTeamMemberProfile.TeamId           = objTeam.Id;
                objTeamMemberProfile.Status           = 1;
                objTeamMemberProfile.ProfileType      = "instagram";
                objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                objTeamMemberProfile.ProfileId        = objInstagramAccount.InstagramId;

                //Modified [13-02-15]
                objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl;
                objTeamMemberProfile.ProfileName   = objInstagramAccount.InsUserName;

                objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                #endregion
                #region SocialProfile
                Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                objSocialProfile.Id            = Guid.NewGuid();
                objSocialProfile.ProfileType   = "instagram";
                objSocialProfile.ProfileId     = objInstagramAccount.InstagramId;
                objSocialProfile.UserId        = Guid.Parse(UserId);
                objSocialProfile.ProfileDate   = DateTime.Now;
                objSocialProfile.ProfileStatus = 1;
                #endregion
                #region Add SocialProfile
                if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                }

                #endregion
                ret = "Account Added Successfully";
            }
            else
            {
                ret = "Account already Exist !";
            }

            GetIntagramImages(objInstagramAccount);
            return(ret);
        }
Example #26
0
 // [WebMethod]
 //[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
 public void AddTeamMembers(string groupid, string teamid)
 {
     List<Domain.Socioboard.Domain.GroupProfile> lstGroupProfile = objGroupProfileRepository.GetAllGroupProfiles(Guid.Parse(groupid));
     foreach (var GroupProfile in lstGroupProfile)
     {
         objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
         objTeamMemberProfile.Id = Guid.NewGuid();
         objTeamMemberProfile.TeamId = Guid.Parse(teamid);
         objTeamMemberProfile.ProfileId = GroupProfile.ProfileId;
         objTeamMemberProfile.ProfileType = GroupProfile.ProfileType;
         objTeamMemberProfile.Status = 1;
         objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
         objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
     }
 }
Example #27
0
         public string getLinkedInData(string UserId, string LinkedinId)
         {
             string ret = string.Empty;
             try
             {
                 Guid userId = Guid.Parse(UserId);
                 //oAuthTwitter OAuth = new oAuthTwitter(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"]);

                 oAuthLinkedIn Linkedin_Oauth = new oAuthLinkedIn();
                 Linkedin_Oauth.ConsumerKey = ConfigurationManager.AppSettings["LiApiKey"];
                 Linkedin_Oauth.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"];
                 LinkedInAccountRepository objLinkedInAccountRepository = new LinkedInAccountRepository();
                 LinkedInAccount LinkedAccount;
                 LinkedInAccountRepository linkedinAccRepo = new LinkedInAccountRepository();
                 if (linkedinAccRepo.checkLinkedinUserExists(LinkedinId, Guid.Parse(UserId)))
                 {
                     LinkedAccount = linkedinAccRepo.getUserInformation(Guid.Parse(UserId), LinkedinId);
                     #region UpdateTeammemberprofile
                     Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                     objTeamMemberProfile.ProfileName = LinkedAccount.LinkedinUserName;
                     objTeamMemberProfile.ProfilePicUrl = LinkedAccount.ProfileImageUrl;
                     objTeamMemberProfile.ProfileId = LinkedAccount.LinkedinUserId;
                     objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
                     #endregion
                 }
                 else
                 {
                     LinkedAccount = linkedinAccRepo.getUserInformation(LinkedinId);
                     #region UpdateTeammemberprofile
                     Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                     objTeamMemberProfile.ProfileName = LinkedAccount.LinkedinUserName;
                     objTeamMemberProfile.ProfilePicUrl = LinkedAccount.ProfileImageUrl;
                     objTeamMemberProfile.ProfileId = LinkedAccount.LinkedinUserId;
                     objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
                     #endregion
                 }

                 Linkedin_Oauth.Token = LinkedAccount.OAuthToken;
                 Linkedin_Oauth.TokenSecret = LinkedAccount.OAuthSecret;
                 Linkedin_Oauth.Verifier = LinkedAccount.OAuthVerifier;
                 GetUserProfile(Linkedin_Oauth, LinkedAccount.LinkedinUserId, userId);
                 GetLinkedInFeeds(Linkedin_Oauth, LinkedinId, userId);
                 GetLinkedUserUpdatesNew(Linkedin_Oauth, LinkedinId, userId);
                 return "linkedin Info Updated";
             }
             catch (Exception ex)
             {
                 
                 Console.WriteLine(ex.StackTrace);
             }


             return ret;
         }
        public void GetPageProfile(dynamic data, oAuthLinkedIn _OAuth, string UserId, string CompanyPageId, string GroupId)
        {
            Domain.Socioboard.Domain.SocialProfile socioprofile = new Domain.Socioboard.Domain.SocialProfile();
            SocialProfilesRepository socioprofilerepo           = new SocialProfilesRepository();

            Domain.Socioboard.Domain.LinkedinCompanyPage objLinkedincmpnypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
            LinkedinCompanyPageRepository objLinkedCmpnyPgeRepo = new LinkedinCompanyPageRepository();

            try
            {
                objLinkedincmpnypage.UserId = Guid.Parse(UserId);
                try
                {
                    objLinkedincmpnypage.LinkedinPageId = data.Pageid.ToString();
                }
                catch
                {
                }
                objLinkedincmpnypage.Id = Guid.NewGuid();
                try
                {
                    objLinkedincmpnypage.EmailDomains = data.EmailDomains.ToString();
                }
                catch { }
                objLinkedincmpnypage.LinkedinPageName = data.name.ToString();
                objLinkedincmpnypage.OAuthToken       = _OAuth.Token;
                objLinkedincmpnypage.OAuthSecret      = _OAuth.TokenSecret;
                objLinkedincmpnypage.OAuthVerifier    = _OAuth.Verifier;
                try
                {
                    objLinkedincmpnypage.Description = data.description.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.FoundedYear = data.founded_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EndYear = data.end_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Locations = data.locations.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Specialties = data.Specialties.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.WebsiteUrl = data.website_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Status = data.status.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EmployeeCountRange = data.employee_count_range.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Industries = data.industries.ToString();
                }
                catch { }
                try
                {
                    string NuberOfFollower = data.num_followers.ToString();
                    objLinkedincmpnypage.NumFollowers = Convert.ToInt16(NuberOfFollower);
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.CompanyType = data.company_type.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.LogoUrl = data.logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.SquareLogoUrl = data.square_logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.BlogRssUrl = data.blog_rss_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.UniversalName = data.universal_name.ToString();
                }
                catch { }
                #region SocialProfiles
                socioprofile.UserId        = Guid.Parse(UserId);
                socioprofile.ProfileType   = "linkedincompanypage";
                socioprofile.ProfileId     = data.Pageid.ToString();;
                socioprofile.ProfileStatus = 1;
                socioprofile.ProfileDate   = DateTime.Now;
                socioprofile.Id            = Guid.NewGuid();
                #endregion

                #region TeamMemberProfile
                Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                objTeamMemberProfile                  = new Domain.Socioboard.Domain.TeamMemberProfile();
                objTeamMemberProfile.Id               = Guid.NewGuid();
                objTeamMemberProfile.TeamId           = objTeam.Id;
                objTeamMemberProfile.Status           = 1;
                objTeamMemberProfile.ProfileType      = "linkedincompanypage";
                objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                objTeamMemberProfile.ProfileId        = socioprofile.ProfileId;
                #endregion
            }
            catch
            {
            }
            try
            {
                if (!objSocialProfilesRepository.checkUserProfileExist(socioprofile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(socioprofile);
                }
                if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedincmpnypage.LinkedinPageId))
                {
                    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                }
                if (!objLinkedCmpnyPgeRepo.checkLinkedinPageExists(CompanyPageId, Guid.Parse(UserId)))
                {
                    objLinkedCmpnyPgeRepo.addLinkenCompanyPage(objLinkedincmpnypage);
                }
                else
                {
                    objLinkedincmpnypage.LinkedinPageId = CompanyPageId;
                    objLinkedCmpnyPgeRepo.updateLinkedinPage(objLinkedincmpnypage);
                }
            }
            catch
            {
            }
        }
        public string AddFacebookPagesInfo(string userid, string profileId, string accessToken, string groupId, string email)
        {
            string ret = string.Empty;
            try
            {
                FacebookClient fb = new FacebookClient();
                fb.AccessToken = accessToken;
                int fancountPage = 0;
                try
                {
                    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
                    //dynamic fancount = fb.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + profileId });
                    //foreach (var friend in fancount.data)
                    //{
                    //    fancountPage = Convert.ToInt32(friend.fan_count);
                    //}

                    // dynamic friends = fb.Get("v2.0/me/friends");
                    dynamic friends = fb.Get("v2.0/" + profileId);
                    //fancountPage = Convert.ToInt16(friends["summary"]["total_count"].ToString());
                    fancountPage = Convert.ToInt32(friends["likes"].ToString());

                }
                catch (Exception)
                {
                    fancountPage = 0;
                }

                if (accessToken != null)
                {
                    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;

                    dynamic profile = fb.Get("v2.0/me");

                    #region Add FacebookAccount
                    objFacebookAccount = new Domain.Socioboard.Domain.FacebookAccount();
                    objFacebookAccount.Id = Guid.NewGuid();
                    objFacebookAccount.FbUserId = (Convert.ToString(profile["id"]));
                    objFacebookAccount.FbUserName = (Convert.ToString(profile["name"]));
                    objFacebookAccount.AccessToken = accessToken;
                    objFacebookAccount.Friends = Convert.ToInt32(fancountPage);
                    objFacebookAccount.EmailId = email;
                    objFacebookAccount.Type = "Page";
                    objFacebookAccount.ProfileUrl = (Convert.ToString(profile["link"]));
                    objFacebookAccount.IsActive = 1;
                    objFacebookAccount.UserId = Guid.Parse(userid);
                    if (!objFacebookAccountRepository.checkFacebookUserExists(objFacebookAccount.FbUserId, objFacebookAccount.UserId))
                    {
                        objFacebookAccountRepository.addFacebookUser(objFacebookAccount);
                    }

                    #endregion
                    #region SocialProfile
                    Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                    objSocialProfile.Id = Guid.NewGuid();
                    objSocialProfile.ProfileType = "facebook_page";
                    objSocialProfile.ProfileId = (Convert.ToString(profile["id"]));
                    objSocialProfile.UserId = Guid.Parse(userid);
                    objSocialProfile.ProfileDate = DateTime.Now;
                    objSocialProfile.ProfileStatus = 1;
                    if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                    {
                        objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    }
                    #endregion
                    #region Add TeamMemberProfile
                    Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(groupId));
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                    objTeamMemberProfile.Id = Guid.NewGuid();
                    objTeamMemberProfile.TeamId = objTeam.Id;
                    objTeamMemberProfile.Status = 1;
                    objTeamMemberProfile.ProfileType = "facebook_page";
                    objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                    objTeamMemberProfile.ProfileId = Convert.ToString(profile["id"]);

                    objTeamMemberProfile.ProfileName = objFacebookAccount.FbUserName;
                    objTeamMemberProfile.ProfilePicUrl = "http://graph.facebook.com/" + objTeamMemberProfile.ProfileId + "/picture?type=small";

                    if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objTeamMemberProfile.ProfileId))
                    {
                        objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    }

                    #endregion
                    #region Add Facebook Feeds
                    AddFacebookFeeds(userid, fb, profile);
                    #endregion
                    #region AddFacebook FanPge
                    Domain.Socioboard.Domain.FacebookFanPage objFacebookFanPage = new Domain.Socioboard.Domain.FacebookFanPage();
                    FacebookFanPageRepository objFacebookFanPageRepository = new FacebookFanPageRepository();
                    objFacebookFanPage.Id = Guid.NewGuid();
                    objFacebookFanPage.UserId = Guid.Parse(userid);
                    objFacebookFanPage.ProfilePageId = (Convert.ToString(profile["id"]));
                    objFacebookFanPage.FanpageCount = fancountPage.ToString();
                    objFacebookFanPage.EntryDate = DateTime.UtcNow;
                    objFacebookFanPageRepository.addFacebookUser(objFacebookFanPage);
                    #endregion

                    AddFbPagePost(userid, accessToken, profileId);
                    getPageConversations(userid, fb, profile);
                    GetFacebookPageFeed(accessToken, profileId);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return ret;
        }
Example #30
0
        public string getTumblrData(string UserId, string Tumblrid)
        {
            try
            {
                Guid userId = Guid.Parse(UserId);
                oAuthTumbler Obj_oAuthTumbler = new oAuthTumbler();
                oAuthTumbler.TumblrConsumerKey = ConfigurationManager.AppSettings["TumblrClientKey"];
                oAuthTumbler.TumblrConsumerSecret = ConfigurationManager.AppSettings["TumblrClientSec"];
                Obj_oAuthTumbler.TumblrCallBackUrl = ConfigurationManager.AppSettings["TumblrCallBackURL"];
                TumblrAccountRepository objTumblrAccountRepository = new TumblrAccountRepository();
                Domain.Socioboard.Domain.TumblrAccount ObjTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(Tumblrid, userId);

                oAuthTumbler.TumblrToken = ObjTumblrAccount.tblrAccessToken;
                oAuthTumbler.TumblrTokenSecret = ObjTumblrAccount.tblrAccessTokenSecret;
                KeyValuePair<string, string> LoginDetails = new KeyValuePair<string, string>(ObjTumblrAccount.tblrAccessToken, ObjTumblrAccount.tblrAccessTokenSecret);
                JObject profile = new JObject();
                try
                {
                    profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null));
                }
                catch (Exception ex)
                {
                }

                #region UpdateTumblrAccount
                string tumblrnameold = ObjTumblrAccount.tblrUserName;
                ObjTumblrAccount.tblrUserName = profile["response"]["user"]["name"].ToString();
                ObjTumblrAccount.tblrProfilePicUrl = "http://api.tumblr.com/v2/blog/" + objTumblrAccount.tblrUserName + ".tumblr.com/avatar";
                objTumblrAccountRepository.UpdateTumblrAccount(ObjTumblrAccount, tumblrnameold);
                #endregion

                #region UpdateTeammemberprofile
                Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                objTeamMemberProfile.ProfileName = ObjTumblrAccount.tblrUserName;
                objTeamMemberProfile.ProfilePicUrl = ObjTumblrAccount.tblrProfilePicUrl;
                objTeamMemberProfile.ProfileId = ObjTumblrAccount.tblrUserName;
                objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
                #endregion

                AddTunblrFeeds(UserId, LoginDetails, ObjTumblrAccount.tblrUserName);
            }
            catch (Exception ex)
            {
                logger.Error("GetTumblrData => " + ex.Message);
            }
            //Domain.Socioboard.Domain.TumblrFeed tumblrTumblrFeed = new Domain.Socioboard.Domain.TumblrFeed();
            //TumblrFeedRepository.Add(tumblrTumblrFeed);
            return "Tumblr info is updated successfully";
            //Obj_oAuthTumbler.TumblrOAuthVerifier=ObjTumblrAccount.tbl

        }
        public string AddFacebookPagesByUrl(string userid, string profileId, string groupId, string name)
        {
            logger.Error("AddFacebookPagesByUrllllllll");
            logger.Error(userid + ", " + profileId + ", " + groupId + ", " + name);
            string ret = string.Empty;
            FacebookAccount _FacebookAccount = new FacebookAccount();
            // string token = _FacebookAccount.getFbToken();
            //string token = "CAAKYvwDVmnUBACyqUsvADWoAfBYTxi0kbz2gcw0sDWbBVJCXmIUG6rGez4BFSCE4hKV8eNE86eCD2iOwEWADvYuNlYupZCL4WUAGhFmRIZA6nTkdUOFeiUVHuri571QxhZA3YfSk5YkjhYy81pYtPj9FNM2mENtjCWRr5tN9zWZAKpUkw3gzsXRuEH9ZBTBwZD";
            string token = ConfigurationManager.AppSettings["AccessToken1"].ToString();
            try
            {
                #region fancount
                FacebookClient fb = new FacebookClient();
                fb.AccessToken = token;
                int fancountPage = 0;
                try
                {
                    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
                    //dynamic fancount = fb.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + profileId });
                    //foreach (var friend in fancount.data)
                    //{
                    //    fancountPage = Convert.ToInt32(friend.fan_count);
                    //}

                    //dynamic friends = fb.Get("v2.0/me/friends");
                    //fancountPage = Convert.ToInt16(friends["summary"]["total_count"].ToString());
                    dynamic friends = fb.Get("v2.0/" + profileId);
                    fancountPage = Convert.ToInt32(friends["likes"].ToString());

                }
                catch (Exception)
                {
                    fancountPage = 0;
                    //fb.AccessToken = "CAAKYvwDVmnUBAFvCcZCQDL53q82jfR5mvgF2whNsFHgR4NmeSSUeRVpdEUpcVVgK1ERs2GZCNhJAwRHtq6MEWiRtBQnxBmZAML6dnwgpsCbjUmyT7ws6EKZBxuWbxhJqjeNCsxhac00b3L9Bf7LLlYa3PG94Uouj7vXZAZC6djZCme5BuszE3vibNFLKQqaLcgZD";
                    fb.AccessToken = ConfigurationManager.AppSettings["AccessToken2"].ToString();
                    try
                    {
                        System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
                        //dynamic fancount = fb.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + profileId });
                        //foreach (var friend in fancount.data)
                        //{
                        //    fancountPage = Convert.ToInt32(friend.fan_count);
                        //}
                        //dynamic friends = fb.Get("v2.0/me/friends");
                        //fancountPage = Convert.ToInt16(friends["summary"]["total_count"].ToString());
                        dynamic friends = fb.Get("v2.0/" + profileId);
                        fancountPage = Convert.ToInt32(friends["likes"].ToString());
                    }
                    catch (Exception ex)
                    {
                        logger.Error("fancount : " + ex.Message);
                    }
                }
                #endregion


                #region Add FacebookAccount
                objFacebookAccount = new Domain.Socioboard.Domain.FacebookAccount();
                objFacebookAccount.Id = Guid.NewGuid();
                objFacebookAccount.FbUserId = profileId;
                objFacebookAccount.FbUserName = name;
                objFacebookAccount.AccessToken = "";
                objFacebookAccount.Friends = Convert.ToInt32(fancountPage);
                objFacebookAccount.EmailId = "";
                objFacebookAccount.Type = "Page";
                objFacebookAccount.ProfileUrl = "";
                objFacebookAccount.IsActive = 1;
                objFacebookAccount.UserId = Guid.Parse(userid);
                if (!objFacebookAccountRepository.checkFacebookUserExists(objFacebookAccount.FbUserId, objFacebookAccount.UserId))
                {
                    objFacebookAccountRepository.addFacebookUser(objFacebookAccount);
                }

                #endregion
                #region SocialProfile
                Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                objSocialProfile.Id = Guid.NewGuid();
                objSocialProfile.ProfileType = "facebook_page";
                objSocialProfile.ProfileId = profileId;
                objSocialProfile.UserId = Guid.Parse(userid);
                objSocialProfile.ProfileDate = DateTime.Now;
                objSocialProfile.ProfileStatus = 1;
                if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                }
                #endregion
                #region Add TeamMemberProfile
                Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(groupId));
                Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                objTeamMemberProfile.Id = Guid.NewGuid();
                objTeamMemberProfile.TeamId = objTeam.Id;
                objTeamMemberProfile.Status = 1;
                objTeamMemberProfile.ProfileType = "facebook_page";
                objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                objTeamMemberProfile.ProfileId = profileId;
                objTeamMemberProfile.ProfilePicUrl = "http://graph.facebook.com/" + objTeamMemberProfile.ProfileId + "/picture?type=small"; ;
                objTeamMemberProfile.ProfileName = name;
                if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objTeamMemberProfile.ProfileId))
                {
                    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                }

                #endregion

                try
                {
                    logger.Error(" Token:" + token);
                    if (token != null)
                    {
                        FacebookClient _FacebookClient = new FacebookClient();
                        _FacebookClient.AccessToken = token;
                        dynamic profile = null;

                        try
                        {
                            profile = fb.Get("v2.0/" + profileId);
                            logger.Error("AddFacebookPagesByUrl Token 1");
                        }
                        catch (Exception ex)
                        {
                            logger.Error("fb.Get(profileId)");
                            logger.Error(ex.StackTrace);
                            Console.WriteLine(ex.StackTrace);
                            try
                            {
                                //fb.AccessToken = "CAAKYvwDVmnUBAFvCcZCQDL53q82jfR5mvgF2whNsFHgR4NmeSSUeRVpdEUpcVVgK1ERs2GZCNhJAwRHtq6MEWiRtBQnxBmZAML6dnwgpsCbjUmyT7ws6EKZBxuWbxhJqjeNCsxhac00b3L9Bf7LLlYa3PG94Uouj7vXZAZC6djZCme5BuszE3vibNFLKQqaLcgZD";
                                fb.AccessToken = ConfigurationManager.AppSettings["AccessToken2"].ToString();
                                profile = fb.Get("v2.0/" + profileId);
                                logger.Error("AddFacebookPagesByUrl Token 2");
                            }
                            catch (Exception ex2)
                            {
                                try
                                {
                                    //fb.AccessToken = "CAAKYvwDVmnUBAAR2O9hxFkHzfNG8H6KbQLaiGFMRshJkbttdzhDeprklcb1yaV0rwtC7N8Xz1rsL1cykiRv2ouXtBUFxvOZCNnpFELnQGFV8jGUWjm1GYsZA40IKAORLGoAcSaa2lJkuuSoLBksB8LFPHI4cqW7VVqxgDwZCRwObxqR4Qp9QEDHxa7j1yoZD";
                                    fb.AccessToken = ConfigurationManager.AppSettings["AccessToken3"].ToString();
                                    profile = fb.Get("v2.0/" + profileId);
                                    logger.Error("AddFacebookPagesByUrl Token 3");
                                }
                                catch (Exception ex3)
                                {
                                    try
                                    {
                                        //fb.AccessToken = "CAAKYvwDVmnUBAFtZB8pvVrqYQonmq7MD90oNdoipDc0Te4onP2XlbZAYT4bzOZAKTr8jdhw0P1PclgLOtVxJ9g2qx4vxZAzh2CXqXAZBZAZBwkgWIVjc2B4rcXAp6O5B3gXqd8Ko5ITL9VCZCMOkMZCPc1hBsp0n8zgPt6e3Dd0vaodPBS8nMz7RD";
                                        fb.AccessToken = ConfigurationManager.AppSettings["AccessToken4"].ToString();
                                        profile = fb.Get("v2.0/" + profileId);
                                        logger.Error("AddFacebookPagesByUrl Token 4");
                                    }
                                    catch (Exception ex4)
                                    {
                                        logger.Error("Finally :" + fb.AccessToken);
                                        logger.Error(ex4.Message);
                                        logger.Error(ex4.Message);

                                    }
                                }
                            }
                        }

                        try
                        {
                            //Edited by Sumit Gupta [10/27/2014]
                            //AddFacebookStats(userid, _FacebookClient, profile);
                            AddFacebookStats(userid, fb, profile);
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                            Console.WriteLine(ex.StackTrace);
                        }

                        //Edited by Sumit Gupta [10/29/2014]
                        AddFbPagePost(userid, fb.AccessToken, profileId); // AddFbPagePost(userid, token, profileId);


                    }
                }
                catch (Exception ex)
                {
                    logger.Error("dynamic profile");
                    logger.Error(ex.StackTrace);
                    Console.WriteLine(ex.StackTrace);
                }



            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
            }
            return ret;
        }
Example #32
0
        public string AddLinkedinAccount(string oauth_token, string oauth_verifier, string reuqestTokenSecret, string consumerKey, string consumerSecret, string UserId, string GroupId)
        {
            try
            {
                logger.Error("AddLinkedinAccount()");
                string                      ret            = string.Empty;
                LinkedInProfile             objProfile     = new LinkedInProfile();
                LinkedInProfile.UserProfile objUserProfile = new LinkedInProfile.UserProfile();
                objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                oAuthLinkedIn _oauth = new oAuthLinkedIn();
                objLinkedInAccount = new LinkedInAccount();
                #region Get linkedin Profile data from Api
                try
                {
                    _oauth.ConsumerKey = consumerKey;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                try
                {
                    _oauth.ConsumerSecret = consumerSecret;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                try
                {
                    _oauth.Token = oauth_token;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                try
                {
                    _oauth.TokenSecret = reuqestTokenSecret;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                try
                {
                    _oauth.Verifier = oauth_verifier;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                try
                {
                    _oauth.AccessTokenGet(oauth_token);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                try
                {
                    objUserProfile = objProfile.GetUserProfile(_oauth);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                #endregion
                dynamic data = objUserProfile;
                try
                {
                    #region LinkedInAccount
                    objLinkedInAccount.UserId         = Guid.Parse(UserId);
                    objLinkedInAccount.LinkedinUserId = data.id.ToString();
                    try
                    {
                        objLinkedInAccount.EmailId = data.email.ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    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 (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    try
                    {
                        objLinkedInAccount.ProfileUrl = data.profile_url.ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    #endregion
                    #region SocialProfiles
                    try
                    {
                        objLinkedInAccount.Connections = data.connections;
                        objLinkedInAccount.IsActive    = true;
                        objSocialProfile.UserId        = Guid.Parse(UserId);
                        objSocialProfile.ProfileType   = "linkedin";
                        objSocialProfile.ProfileId     = data.id.ToString();
                        objSocialProfile.ProfileStatus = 1;
                        objSocialProfile.ProfileDate   = DateTime.Now;
                        objSocialProfile.Id            = Guid.NewGuid();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                    #endregion SocialProfiles
                    #region Add TeamMemberProfile
                    try
                    {
                        Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                        objTeamMemberProfile                  = new Domain.Socioboard.Domain.TeamMemberProfile();
                        objTeamMemberProfile.Id               = Guid.NewGuid();
                        objTeamMemberProfile.TeamId           = objTeam.Id;
                        objTeamMemberProfile.Status           = 1;
                        objTeamMemberProfile.ProfileType      = "linkedin";
                        objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                        objTeamMemberProfile.ProfileId        = objLinkedInAccount.LinkedinUserId;
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                }
                try
                {
                    if (!objLinkedInAccountRepository.checkLinkedinUserExists(objLinkedInAccount.LinkedinUserId, Guid.Parse(UserId)))
                    {
                        objLinkedInAccountRepository.addLinkedinUser(objLinkedInAccount);
                        ret = "LinkedIn Account Added Successfully";
                    }
                    else
                    {
                        ret = "LinkedIn Account Already Exist";
                    }
                    if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                    {
                        objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    }
                    if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedInAccount.LinkedinUserId))
                    {
                        objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    }

                    #region Add LinkedIn Feeds
                    LinkedInNetwork objln = new LinkedInNetwork();
                    List <LinkedInNetwork.Network_Updates> userUPdate = objln.GetNetworkUpdates(_oauth, 20);
                    foreach (var item in userUPdate)
                    {
                        try
                        {
                            objLinkedInFeed            = new Domain.Socioboard.Domain.LinkedInFeed();
                            objLinkedInFeed.Feeds      = item.Message;
                            objLinkedInFeed.FromId     = item.PersonId;
                            objLinkedInFeed.FromName   = item.PersonFirstName + " " + item.PersonLastName;
                            objLinkedInFeed.FeedsDate  = Convert.ToDateTime(item.DateTime);
                            objLinkedInFeed.EntryDate  = DateTime.Now;
                            objLinkedInFeed.ProfileId  = objLinkedInAccount.LinkedinUserId;
                            objLinkedInFeed.Type       = item.UpdateType;
                            objLinkedInFeed.UserId     = Guid.Parse(UserId);
                            objLinkedInFeed.FromPicUrl = item.PictureUrl;
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                        }
                        if (!objLinkedInFeedRepository.checkLinkedInFeedExists(objLinkedInFeed.FeedId, Guid.Parse(UserId)))
                        {
                            objLinkedInFeedRepository.addLinkedInFeed(objLinkedInFeed);
                        }
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                }
                return("");
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                return("");
            }
        }
        public string GetFacebookPageData(string FbId, string UserId)
        {
            string ret = string.Empty;
            try
            {
                Domain.Socioboard.Domain.FacebookAccount objFacebookAccount = new Domain.Socioboard.Domain.FacebookAccount();
                if (objFacebookAccountRepository.checkFacebookUserExists(FbId, Guid.Parse(UserId)))
                {
                    objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FbId, Guid.Parse(UserId));
                }
                else
                {
                    objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FbId);
                }
                FacebookClient fb = new FacebookClient();
                string profileId = string.Empty;
                string accessToken = objFacebookAccount.AccessToken;
                dynamic profile = null;
                dynamic friends = null;
                if (accessToken != null)
                {
                    fb.AccessToken = accessToken;
                    int fancountPage = 0;
                    try
                    {
                        System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
                        friends = fb.Get("v2.0/" + FbId);
                        fancountPage = Convert.ToInt16(friends["likes"].ToString());
                        objFacebookAccount.Friends = fancountPage;
                    }
                    catch (Exception)
                    {
                        fancountPage = 0;
                        UpdateSocialprofileStatus(UserId, FbId);
                        objFacebookAccount.IsActive = 2;
                        UpdateFacebookAccount(objFacebookAccount);
                    }
                    try
                    {
                        profile = fb.Get("v2.0/me");

                    }
                    catch (Exception ex)
                    {
                        string errormssg = ex.Message;
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        return "Token Expired";
                    }
                    if (objFacebookAccountRepository.checkFacebookUserExists(Convert.ToString(profile["id"]), Guid.Parse(UserId)))
                    {
                        #region Update FacebookAccount
                        UpdateFacebookAccount(objFacebookAccount);
                        #endregion
                        #region AddFacebook FanPge
                        Domain.Socioboard.Domain.FacebookFanPage objFacebookFanPage = new Domain.Socioboard.Domain.FacebookFanPage();
                        FacebookFanPageRepository objFacebookFanPageRepository = new FacebookFanPageRepository();
                        objFacebookFanPage.Id = Guid.NewGuid();
                        objFacebookFanPage.UserId = Guid.Parse(UserId);
                        objFacebookFanPage.ProfilePageId = (Convert.ToString(profile["id"]));
                        objFacebookFanPage.FanpageCount = fancountPage.ToString();
                        objFacebookFanPage.EntryDate = DateTime.Now;
                        objFacebookFanPageRepository.addFacebookUser(objFacebookFanPage);
                        #endregion
                        #region UpdateTeammemberprofile
                        Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                        objTeamMemberProfile.ProfileName = objFacebookAccount.FbUserName;
                        objTeamMemberProfile.ProfilePicUrl = "http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small";
                        objTeamMemberProfile.ProfileId = objFacebookAccount.FbUserId;
                        objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
                        #endregion

                        //getUserNotifications(UserId,fb,profile);
                        GetFacebookPageFeed(objFacebookAccount.AccessToken, objFacebookAccount.FbUserId);
                        ret = "Facebook page info Updated Successfully";
                    }
                    else
                    {
                        ret = "Account already Exist !";
                    }

                }
                return new JavaScriptSerializer().Serialize(ret);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
Example #34
0
        private static ISocialSiteAccount GetSocialAccountFromTeamMemberProfile(User objUser, Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile)
        {
            ISocialSiteAccount objSocialSiteAccount = null;

            if (objTeamMemberProfile.ProfileType == "facebook")
            {
                Api.FacebookAccount.FacebookAccount ApiobjFacebookAccount = new Api.FacebookAccount.FacebookAccount();
                objSocialSiteAccount = (FacebookAccount)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.getFacebookAccountDetailsById(objUser.Id.ToString(), objTeamMemberProfile.ProfileId.ToString()), typeof(FacebookAccount)));
            }
            else if (objTeamMemberProfile.ProfileType == "twitter")
            {
                Api.TwitterAccount.TwitterAccount ApiobjTwitterAccount = new Api.TwitterAccount.TwitterAccount();
                objSocialSiteAccount = (TwitterAccount)(new JavaScriptSerializer().Deserialize(ApiobjTwitterAccount.GetTwitterAccountDetailsById(objUser.Id.ToString(), objTeamMemberProfile.ProfileId.ToString()), typeof(TwitterAccount)));
            }
            else if (objTeamMemberProfile.ProfileType == "linkedin")
            {
                Api.LinkedinAccount.LinkedinAccount ApiobjLinkedinAccount = new Api.LinkedinAccount.LinkedinAccount();
                objSocialSiteAccount = (LinkedInAccount)(new JavaScriptSerializer().Deserialize(ApiobjLinkedinAccount.GetLinkedinAccountDetailsById(objUser.Id.ToString(), objTeamMemberProfile.ProfileId.ToString()), typeof(LinkedInAccount)));
            }
            else if (objTeamMemberProfile.ProfileType == "instagram")
            {
                Api.InstagramAccount.InstagramAccount ApiobjInstagramAccount = new Api.InstagramAccount.InstagramAccount();
                objSocialSiteAccount = (InstagramAccount)(new JavaScriptSerializer().Deserialize(ApiobjInstagramAccount.UserInformation(objUser.Id.ToString(), objTeamMemberProfile.ProfileId.ToString()), typeof(InstagramAccount)));
            }
            else if (objTeamMemberProfile.ProfileType == "youtube")
            {
                Api.YoutubeAccount.YoutubeAccount ApiobjYoutubeAccount = new Api.YoutubeAccount.YoutubeAccount();
                objSocialSiteAccount = (YoutubeAccount)(new JavaScriptSerializer().Deserialize(ApiobjYoutubeAccount.GetYoutubeAccountDetailsById(objUser.Id.ToString(), objTeamMemberProfile.ProfileId.ToString()), typeof(YoutubeAccount)));
            }
            else if (objTeamMemberProfile.ProfileType == "tumblr")
            {
                Api.TumblrAccount.TumblrAccount ApiobjTumblrAccount = new Api.TumblrAccount.TumblrAccount();
                objSocialSiteAccount = (TumblrAccount)(new JavaScriptSerializer().Deserialize(ApiobjTumblrAccount.GetTumblrAccountDetailsById(objUser.Id.ToString(), objTeamMemberProfile.ProfileId.ToString()), typeof(TumblrAccount)));
            }
            return(objSocialSiteAccount);
        }
Example #35
0
        public string AddTumblrAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            string ret = string.Empty;
            string AccessTokenResponse = string.Empty;
            try
            {
                oAuthTumbler requestHelper = new oAuthTumbler();
                oAuthTumbler.TumblrConsumerKey = client_id;
                oAuthTumbler.TumblrConsumerSecret = client_secret;
                requestHelper.TumblrCallBackUrl = redirect_uri;
                AccessTokenResponse = requestHelper.GetAccessToken(oAuthTumbler.TumblrToken, code);
                logger.Error(AccessTokenResponse);

                string[] tokens = AccessTokenResponse.Split('&'); //extract access token & secret from response
                logger.Error(tokens);
                string accessToken = tokens[0].Split('=')[1];
                logger.Error(accessToken);
                string accessTokenSecret = tokens[1].Split('=')[1];
                logger.Error(accessTokenSecret);

                KeyValuePair<string, string> LoginDetails = new KeyValuePair<string, string>(accessToken, accessTokenSecret);

                JObject profile = new JObject();
                try
                {
                    profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null));
                }
                catch (Exception ex)
                {
                }


                #region Add Tumblr Account
                objTumblrAccount = new Domain.Socioboard.Domain.TumblrAccount();
                objTumblrAccount.Id = Guid.NewGuid();
                objTumblrAccount.tblrUserName = profile["response"]["user"]["name"].ToString();
                objTumblrAccount.UserId = Guid.Parse(UserId);
                objTumblrAccount.tblrAccessToken = accessToken;
                objTumblrAccount.tblrAccessTokenSecret = accessTokenSecret;
                objTumblrAccount.tblrProfilePicUrl = "http://api.tumblr.com/v2/blog/" + objTumblrAccount.tblrUserName + ".tumblr.com/avatar";//profile["response"]["user"]["name"].ToString();
                objTumblrAccount.IsActive = 1;
                if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount))
                {
                    TumblrAccountRepository.Add(objTumblrAccount);

                    #region Add Socialprofiles
                    objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                    objSocialProfile.Id = Guid.NewGuid();
                    objSocialProfile.UserId = Guid.Parse(UserId);
                    objSocialProfile.ProfileId = profile["response"]["user"]["name"].ToString();
                    objSocialProfile.ProfileType = "tumblr";
                    objSocialProfile.ProfileDate = DateTime.Now;
                    objSocialProfile.ProfileStatus = 1;
                    if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                    {
                        objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    }
                    #endregion

                    #region Add TeamMemeberProfile
                    Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                    objTeamMemberProfile.Id = Guid.NewGuid();
                    objTeamMemberProfile.TeamId = objTeam.Id;
                    objTeamMemberProfile.Status = 1;
                    objTeamMemberProfile.ProfileType = "tumblr";
                    objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                    objTeamMemberProfile.ProfileId = objTumblrAccount.tblrUserName;

                    //Modified [13-02-15]
                    objTeamMemberProfile.ProfilePicUrl = objTumblrAccount.tblrProfilePicUrl;
                    objTeamMemberProfile.ProfileName = objTumblrAccount.tblrUserName;

                    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    #endregion
                }
                #endregion

              
                //if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeam.Id, objTumblrAccount.tblrUserName))
                //{
                //    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                //}

                #region Add Tumblr Feeds
                AddTunblrFeeds(UserId, LoginDetails, profile["response"]["user"]["name"].ToString());
                #endregion

            }
            catch (Exception ex)
            {
                logger.Error("AddTumblrAccount => "+ex.StackTrace);
            }
            return ret;
        }
        public string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            string ret = string.Empty;
            oAuthInstagram objInsta = new oAuthInstagram();
            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();
            _api = oAuthInstagram.GetInstance(configi);
            AccessToken access = new AccessToken();
            access = _api.AuthGetAccessToken(code);

            logger.Error("AddInstagramAccount == >>" + access.user.id + "===" + access.access_token);


            UserController objusercontroller = new UserController();
            try
            {
                #region InstagramAccount
                InstagramResponse<GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token);

                objInstagramAccount = new Domain.Socioboard.Domain.InstagramAccount();
                objInstagramAccount.AccessToken = access.access_token;
                objInstagramAccount.InstagramId = access.user.id;
                try
                {
                    objInstagramAccount.ProfileUrl = access.user.profile_picture;
                }
                catch (Exception ex)
                {
                    logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.InsUserName = access.user.username;
                }
                catch (Exception ex)
                {
                    logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.TotalImages = objuser.data.counts.media;
                }
                catch (Exception ex)
                {
                    logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.FollowedBy = objuser.data.counts.followed_by;
                }
                catch (Exception ex)
                {
                    logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.Followers = objuser.data.counts.follows;
                }
                catch (Exception ex)
                {
                    logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                objInstagramAccount.UserId = Guid.Parse(UserId);
                #endregion


                if (!objInstagramAccountRepository.checkInstagramUserExists(objInstagramAccount.InstagramId, Guid.Parse(UserId)))
                {
                    objInstagramAccountRepository.addInstagramUser(objInstagramAccount);
                    #region Add TeamMemberProfile
                    Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                    objTeamMemberProfile.Id = Guid.NewGuid();
                    objTeamMemberProfile.TeamId = objTeam.Id;
                    objTeamMemberProfile.Status = 1;
                    objTeamMemberProfile.ProfileType = "instagram";
                    objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                    objTeamMemberProfile.ProfileId = objInstagramAccount.InstagramId;

                    //Modified [13-02-15]
                    objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl;
                    objTeamMemberProfile.ProfileName = objInstagramAccount.InsUserName;

                    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    #endregion
                    #region SocialProfile
                    Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                    objSocialProfile.Id = Guid.NewGuid();
                    objSocialProfile.ProfileType = "instagram";
                    objSocialProfile.ProfileId = objInstagramAccount.InstagramId;
                    objSocialProfile.UserId = Guid.Parse(UserId);
                    objSocialProfile.ProfileDate = DateTime.Now;
                    objSocialProfile.ProfileStatus = 1;
                    #endregion
                    #region Add SocialProfile
                    if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                    {
                        objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    }

                    #endregion
                    ret = "Account Added Successfully";
                }
                else
                {
                    ret = "Account already Exist !";
                }

                //GetIntagramImages(objInstagramAccount);
                GetInstagramFeeds(objInstagramAccount);

                GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken);
                GetInstagramFollowing(objInstagramAccount.UserId.ToString(), objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1);
                GetInstagramFollower(objInstagramAccount.UserId.ToString(), objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1);
                GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1);
                GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken);
                //GetInstagramUserPosts(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            return ret;
        }
Example #37
0
        public string AddTwitterAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string requestToken, string requestSecret, string requestVerifier)
        {
            try
            {
                System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;

                string ret = string.Empty;
                Users userinfo = new Users();
                oAuthTwitter OAuth = new oAuthTwitter(client_id, client_secret, redirect_uri);
                OAuth.AccessToken = requestToken;
                OAuth.AccessTokenSecret = requestVerifier;
                OAuth.AccessTokenGet(requestToken, requestVerifier);
                JArray profile = userinfo.Get_Users_LookUp_ByScreenName(OAuth, OAuth.TwitterScreenName);

                if (profile != null)
                {
                    logger.Error("Twitter.asmx >> AddTwitterAccount >> Twitter profile : " + profile);
                }
                else
                {
                    logger.Error("Twitter.asmx >> AddTwitterAccount >> NULL Twitter profile : " + profile);
                }

                objTwitterAccount = new Domain.Socioboard.Domain.TwitterAccount();
                TwitterUser twtuser;
                foreach (var item in profile)
                {
                    #region Add Twitter Account
                    try
                    {
                        objTwitterAccount.FollowingCount = Convert.ToInt32(item["friends_count"].ToString());
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterAccount.FollowersCount = Convert.ToInt32(item["followers_count"].ToString());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    objTwitterAccount.Id = Guid.NewGuid();
                    objTwitterAccount.IsActive = true;
                    objTwitterAccount.OAuthSecret = OAuth.AccessTokenSecret;
                    objTwitterAccount.OAuthToken = OAuth.AccessToken;
                    try
                    {
                        objTwitterAccount.ProfileImageUrl = item["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);

                    }
                    try
                    {
                        objTwitterAccount.ProfileUrl = string.Empty;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterAccount.TwitterUserId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception er)
                    {
                        try
                        {
                            objTwitterAccount.TwitterUserId = item["id"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                        }
                        Console.WriteLine(er.StackTrace);

                    }

                    try
                    {
                        objTwitterAccount.TwitterScreenName = item["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    objTwitterAccount.UserId = Guid.Parse(UserId);
                    #endregion
                    if (!objTwitterAccountRepository.checkTwitterUserExists(objTwitterAccount.TwitterUserId, Guid.Parse(UserId)))
                    {
                        objTwitterAccountRepository.addTwitterkUser(objTwitterAccount);
                        #region Add TeamMemberProfile
                        Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                        Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                        objTeamMemberProfile.Id = Guid.NewGuid();
                        objTeamMemberProfile.TeamId = objTeam.Id;
                        objTeamMemberProfile.Status = 1;
                        objTeamMemberProfile.ProfileType = "twitter";
                        objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                        objTeamMemberProfile.ProfileId = objTwitterAccount.TwitterUserId;

                        objTeamMemberProfile.ProfileName = objTwitterAccount.TwitterScreenName;
                        objTeamMemberProfile.ProfilePicUrl = objTwitterAccount.ProfileImageUrl;

                        objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                        #endregion
                        #region SocialProfile
                        Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                        objSocialProfile.Id = Guid.NewGuid();
                        objSocialProfile.ProfileType = "twitter";
                        objSocialProfile.ProfileId = objTwitterAccount.TwitterUserId;
                        objSocialProfile.UserId = Guid.Parse(UserId);
                        objSocialProfile.ProfileDate = DateTime.Now;
                        objSocialProfile.ProfileStatus = 1;
                        #endregion
                        #region Add Twitter Stats
                        if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                        {
                            objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                        }
                        objTwitterStats = new Domain.Socioboard.Domain.TwitterStats();
                        Random rNum = new Random();
                        objTwitterStats.Id = Guid.NewGuid();
                        objTwitterStats.TwitterId = objTwitterAccount.TwitterUserId;
                        objTwitterStats.UserId = Guid.Parse(UserId);
                        objTwitterStats.FollowingCount = objTwitterAccount.FollowingCount;
                        objTwitterStats.FollowerCount = objTwitterAccount.FollowersCount;
                        objTwitterStats.Age1820 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.Age2124 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.Age2534 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.Age3544 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.Age4554 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.Age5564 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.Age65 = rNum.Next(objTwitterAccount.FollowersCount);
                        objTwitterStats.EntryDate = DateTime.Now;
                        if (!objTwtstats.checkTwitterStatsExists(objTwitterAccount.TwitterUserId, Guid.Parse(UserId)))
                        {
                            objTwtstats.addTwitterStats(objTwitterStats);
                        }
                        #endregion

                        #region AddTwitterFollowerCount
                        Domain.Socioboard.Domain.TwitterAccountFollowers objTwitterAccountFollowers = new Domain.Socioboard.Domain.TwitterAccountFollowers();
                        TwitterAccountFollowersRepository objTwitterAccountFollowersRepository = new TwitterAccountFollowersRepository();
                        objTwitterAccountFollowers.Id = Guid.NewGuid();
                        objTwitterAccountFollowers.UserId = Guid.Parse(UserId);
                        objTwitterAccountFollowers.EntryDate = DateTime.Now;
                        objTwitterAccountFollowers.FollowingsCount = Convert.ToInt32(item["friends_count"].ToString());
                        objTwitterAccountFollowers.FollowersCount = Convert.ToInt32(item["followers_count"].ToString());
                        try
                        {
                            objTwitterAccountFollowers.ProfileId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                        }
                        catch (Exception er)
                        {
                            try
                            {
                                objTwitterAccountFollowers.ProfileId = item["id"].ToString().TrimStart('"').TrimEnd('"');
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.StackTrace);
                            }
                            Console.WriteLine(er.StackTrace);

                        }
                        objTwitterAccountFollowersRepository.addTwitterAccountFollower(objTwitterAccountFollowers);
                        #endregion

                        ret = "Account Added Successfully";
                    }
                    else
                    {
                        ret = "Account already Exist !";
                    }
                }
                getTwitterMessages(UserId, OAuth);

                getUserRetweets(UserId, OAuth);


                //edited by avinash[24-03-15]

                getTwitterEngagement(UserId, OAuth);

                getUserTweets(UserId, OAuth);

                getTwitterFeeds(UserId, OAuth);

                getTwitterDirectMessageSent(UserId, OAuth);
                getTwittwrDirectMessageRecieved(OAuth,UserId);
                getUserMentions(OAuth, objTwitterAccount.TwitterUserId, Guid.Parse(UserId));
                getUserFollowers(OAuth, objTwitterAccount.TwitterScreenName, objTwitterAccount.TwitterUserId, Guid.Parse(UserId));
                getUserRetweet(OAuth, objTwitterAccount.TwitterUserId, Guid.Parse(UserId));

                //return ret;
                return new JavaScriptSerializer().Serialize(objTwitterAccount);
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                return "";
            }
        }
Example #38
0
        public string AddYoutubeAccountwithLogin(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string access_token)
        {
            #region Local variables Inisitalisation
            string            ret                  = string.Empty;
            string            objRefresh           = string.Empty;
            string            refreshToken         = string.Empty;
            oAuthTokenYoutube ObjoAuthTokenYoutube = new oAuthTokenYoutube();
            oAuthToken        objToken             = new oAuthToken();
            Domain.Socioboard.Domain.YoutubeAccount objYoutubeAccount = new Domain.Socioboard.Domain.YoutubeAccount();
            Domain.Socioboard.Domain.YoutubeChannel objYoutubeChannel;
            YoutubeChannelRepository objYoutubeChannelRepository = new YoutubeChannelRepository();
            YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository();
            #endregion
            #region Get user Profile and Add Youtube Account
            JArray userinfo = new JArray();
            try
            {
                userinfo = objToken.GetUserInfo("me", access_token.ToString());
            }
            catch (Exception ex)
            {
            }
            foreach (var itemEmail in userinfo)
            {
                try
                {
                    objYoutubeAccount.Id       = Guid.NewGuid();
                    objYoutubeAccount.Ytuserid = itemEmail["id"].ToString();
                    objYoutubeAccount.Emailid  = itemEmail["email"].ToString();
                    try
                    {
                        objYoutubeAccount.Ytusername = itemEmail["given_name"].ToString();
                    }
                    catch (Exception ex)
                    {
                        objYoutubeAccount.Ytusername = itemEmail["name"].ToString();
                    }
                    objYoutubeAccount.Ytprofileimage = itemEmail["picture"].ToString();
                    objYoutubeAccount.Accesstoken    = access_token;
                    objYoutubeAccount.Refreshtoken   = refreshToken;
                    objYoutubeAccount.Isactive       = 1;
                    objYoutubeAccount.Entrydate      = DateTime.Now;
                    objYoutubeAccount.UserId         = Guid.Parse(UserId);
                    if (!objYoutubeAccountRepository.checkYoutubeUserExists(objYoutubeAccount))
                    {
                        YoutubeAccountRepository.Add(objYoutubeAccount);
                        ret = "Account Added Successfully";
                    }
                    else
                    {
                        ret = "Account already Exist !";
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }


            #endregion
            #region Add Youtube Channels
            GlobusGooglePlusLib.Youtube.Core.Channels ObjChannel = new GlobusGooglePlusLib.Youtube.Core.Channels();
            JArray objarray = new JArray();
            try
            {
                string  part         = (oAuthTokenYoutube.Parts.contentDetails.ToString() + "," + oAuthTokenYoutube.Parts.statistics.ToString());
                string  Value        = ObjChannel.Get_Channel_List(access_token, part, 50, true);
                JObject UserChannels = JObject.Parse(@Value);
                objarray = (JArray)UserChannels["items"];
            }
            catch (Exception ex)
            {
            }

            foreach (var item in objarray)
            {
                objYoutubeChannel = new Domain.Socioboard.Domain.YoutubeChannel();
                try
                {
                    objYoutubeChannel.Id               = Guid.NewGuid();
                    objYoutubeChannel.Channelid        = item["id"].ToString();
                    objYoutubeChannel.Likesid          = item["contentDetails"]["relatedPlaylists"]["likes"].ToString();
                    objYoutubeChannel.Favoritesid      = item["contentDetails"]["relatedPlaylists"]["favorites"].ToString();
                    objYoutubeChannel.Uploadsid        = item["contentDetails"]["relatedPlaylists"]["uploads"].ToString();
                    objYoutubeChannel.Watchhistoryid   = item["contentDetails"]["relatedPlaylists"]["watchHistory"].ToString();
                    objYoutubeChannel.Watchlaterid     = item["contentDetails"]["relatedPlaylists"]["watchLater"].ToString();
                    objYoutubeChannel.Googleplususerid = objYoutubeAccount.Ytuserid;
                    objYoutubeChannel.UserId           = Guid.Parse(UserId);
                    try
                    {
                        string viewcnt = item["statistics"]["viewCount"].ToString();
                        objYoutubeChannel.ViewCount = Convert.ToInt32(viewcnt);
                        string videocnt = item["statistics"]["videoCount"].ToString();
                        objYoutubeChannel.VideoCount = Convert.ToInt32(videocnt);
                        string commentcnt = item["statistics"]["commentCount"].ToString();
                        objYoutubeChannel.CommentCount = Convert.ToInt32(commentcnt);
                        string Subscribercnt = item["statistics"]["subscriberCount"].ToString();
                        objYoutubeChannel.SubscriberCount = Convert.ToInt32(Subscribercnt);
                        try
                        {
                            string str = item["statistics"]["hiddenSubscriberCount"].ToString();
                            if (str == "false")
                            {
                                objYoutubeChannel.HiddenSubscriberCount = 0;
                            }
                            else
                            {
                                objYoutubeChannel.HiddenSubscriberCount = 1;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                if (!objYoutubeChannelRepository.checkYoutubeChannelExists(objYoutubeChannel.Channelid, Guid.Parse(UserId)))
                {
                    YoutubeChannelRepository.Add(objYoutubeChannel);
                }
            }
            #endregion
            #region Add TeamMemberProfile
            Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
            Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
            objTeamMemberProfile.Id               = Guid.NewGuid();
            objTeamMemberProfile.TeamId           = objTeam.Id;
            objTeamMemberProfile.Status           = 1;
            objTeamMemberProfile.ProfileType      = "youtube";
            objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
            objTeamMemberProfile.ProfileId        = objYoutubeAccount.Ytuserid;

            objTeamMemberProfile.ProfileName   = objYoutubeAccount.Ytusername;
            objTeamMemberProfile.ProfilePicUrl = objYoutubeAccount.Ytprofileimage;

            if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeam.Id, objYoutubeAccount.Ytuserid))
            {
                objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
            }
            #endregion
            #region SocialProfile
            Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
            objSocialProfile.Id            = Guid.NewGuid();
            objSocialProfile.ProfileType   = "youtube";
            objSocialProfile.ProfileId     = objYoutubeAccount.Ytuserid;
            objSocialProfile.UserId        = Guid.Parse(UserId);
            objSocialProfile.ProfileDate   = DateTime.Now;
            objSocialProfile.ProfileStatus = 1;
            if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
            {
                objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
            }
            #endregion
            return(ret);
        }
Example #39
0
        public string AddYoutubeAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            #region Local variables Inisitalisation
            string ret = string.Empty;
            string objRefresh = string.Empty;
            string refreshToken = string.Empty;
            string access_token = string.Empty;
            oAuthTokenYoutube ObjoAuthTokenYoutube = new oAuthTokenYoutube();
            oAuthToken objToken = new oAuthToken();
            Domain.Socioboard.Domain.YoutubeAccount objYoutubeAccount = new Domain.Socioboard.Domain.YoutubeAccount();
            Domain.Socioboard.Domain.YoutubeChannel objYoutubeChannel;
            YoutubeChannelRepository objYoutubeChannelRepository = new YoutubeChannelRepository();
            YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository();
            #endregion
            #region Get AccessToken and RefreshToken
            objToken.ConsumerKey = client_id;
            objToken.ConsumerSecret = client_secret;
            try
            {
                objRefresh = ObjoAuthTokenYoutube.GetRefreshToken(code, client_id, client_secret, redirect_uri);
                logger.Error("Abhay: ObjoAuthTokenYoutube()");
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
            }
            JObject objaccesstoken = JObject.Parse(objRefresh);
            try
            {
                refreshToken = objaccesstoken["refresh_token"].ToString();

            }
            catch (Exception ex)
            {
                access_token = objaccesstoken["access_token"].ToString();
                ObjoAuthTokenYoutube.RevokeToken(access_token);
                Console.WriteLine(ex.StackTrace);
                return "Refresh Token Not Found";
            }

            try
            {

                access_token = objaccesstoken["access_token"].ToString();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);

            }
            #endregion
            #region Get user Profile and Add Youtube Account
            JArray userinfo = new JArray();
            try
            {
                userinfo = objToken.GetUserInfo("me", access_token.ToString());
            }
            catch (Exception ex)
            {
            }
            foreach (var itemEmail in userinfo)
            {
                try
                {
                    objYoutubeAccount.Id = Guid.NewGuid();
                    objYoutubeAccount.Ytuserid = itemEmail["id"].ToString();
                    objYoutubeAccount.Emailid = itemEmail["email"].ToString();
                    try
                    {
                        objYoutubeAccount.Ytusername = itemEmail["given_name"].ToString();
                    }
                    catch (Exception ex)
                    {
                        objYoutubeAccount.Ytusername = itemEmail["name"].ToString();
                    }
                    objYoutubeAccount.Ytprofileimage = itemEmail["picture"].ToString();
                    objYoutubeAccount.Accesstoken = access_token;
                    objYoutubeAccount.Refreshtoken = refreshToken;
                    objYoutubeAccount.Isactive = 1;
                    objYoutubeAccount.Entrydate = DateTime.Now;
                    objYoutubeAccount.UserId = Guid.Parse(UserId);
                    if (!objYoutubeAccountRepository.checkYoutubeUserExists(objYoutubeAccount))
                    {
                        YoutubeAccountRepository.Add(objYoutubeAccount);
                        ret = "Account Added Successfully";
                    }
                    else
                    {
                        ret = "Account already Exist !";
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

            }


            #endregion
            #region Add Youtube Channels
            GlobusGooglePlusLib.Youtube.Core.Channels ObjChannel = new GlobusGooglePlusLib.Youtube.Core.Channels();
            JArray objarray = new JArray();
            try
            {
                string part = (oAuthTokenYoutube.Parts.contentDetails.ToString() + "," + oAuthTokenYoutube.Parts.statistics.ToString());
                string Value = ObjChannel.Get_Channel_List(access_token, part, 50, true);
                JObject UserChannels = JObject.Parse(@Value);
                objarray = (JArray)UserChannels["items"];
            }
            catch (Exception ex)
            {
            }

            foreach (var item in objarray)
            {
                objYoutubeChannel = new Domain.Socioboard.Domain.YoutubeChannel();
                try
                {
                    objYoutubeChannel.Id = Guid.NewGuid();
                    objYoutubeChannel.Channelid = item["id"].ToString();
                    objYoutubeChannel.Likesid = item["contentDetails"]["relatedPlaylists"]["likes"].ToString();
                    objYoutubeChannel.Favoritesid = item["contentDetails"]["relatedPlaylists"]["favorites"].ToString();
                    objYoutubeChannel.Uploadsid = item["contentDetails"]["relatedPlaylists"]["uploads"].ToString();
                    objYoutubeChannel.Watchhistoryid = item["contentDetails"]["relatedPlaylists"]["watchHistory"].ToString();
                    objYoutubeChannel.Watchlaterid = item["contentDetails"]["relatedPlaylists"]["watchLater"].ToString();
                    objYoutubeChannel.Googleplususerid = objYoutubeAccount.Ytuserid;
                    objYoutubeChannel.UserId = Guid.Parse(UserId);
                    try
                    {
                        string viewcnt = item["statistics"]["viewCount"].ToString();
                        objYoutubeChannel.ViewCount = Convert.ToInt32(viewcnt);
                        string videocnt = item["statistics"]["videoCount"].ToString();
                        objYoutubeChannel.VideoCount = Convert.ToInt32(videocnt);
                        string commentcnt = item["statistics"]["commentCount"].ToString();
                        objYoutubeChannel.CommentCount = Convert.ToInt32(commentcnt);
                        string Subscribercnt = item["statistics"]["subscriberCount"].ToString();
                        objYoutubeChannel.SubscriberCount = Convert.ToInt32(Subscribercnt);
                        try
                        {
                            string str = item["statistics"]["hiddenSubscriberCount"].ToString();
                            if (str == "false")
                            {
                                objYoutubeChannel.HiddenSubscriberCount = 0;
                            }
                            else
                            {
                                objYoutubeChannel.HiddenSubscriberCount = 1;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                if (!objYoutubeChannelRepository.checkYoutubeChannelExists(objYoutubeChannel.Channelid, Guid.Parse(UserId)))
                {
                    YoutubeChannelRepository.Add(objYoutubeChannel);
                }
            }
            #endregion
            #region Add TeamMemberProfile
            Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
            Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
            objTeamMemberProfile.Id = Guid.NewGuid();
            objTeamMemberProfile.TeamId = objTeam.Id;
            objTeamMemberProfile.Status = 1;
            objTeamMemberProfile.ProfileType = "youtube";
            objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
            objTeamMemberProfile.ProfileId = objYoutubeAccount.Ytuserid;

            objTeamMemberProfile.ProfileName = objYoutubeAccount.Ytusername;
            objTeamMemberProfile.ProfilePicUrl = objYoutubeAccount.Ytprofileimage;

            if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeam.Id, objYoutubeAccount.Ytuserid))
            {
                objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
            }
            #endregion
            #region SocialProfile
            Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
            objSocialProfile.Id = Guid.NewGuid();
            objSocialProfile.ProfileType = "youtube";
            objSocialProfile.ProfileId = objYoutubeAccount.Ytuserid;
            objSocialProfile.UserId = Guid.Parse(UserId);
            objSocialProfile.ProfileDate = DateTime.Now;
            objSocialProfile.ProfileStatus = 1;
            if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
            {
                objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
            }
            #endregion
            return ret;
        }
         public string AddLinkedinAccountNew(string UserId, string GroupId, string Code)
         {
             oAuthLinkedIn _oauth = new oAuthLinkedIn();
             string access_token_Url = "https://www.linkedin.com/uas/oauth2/accessToken";
             string access_token_postData = "grant_type=authorization_code&code=" + Code + "&redirect_uri=" + "http%3a%2f%2flocalhost%3a9821%2fLinkedinManager%2fLinkedinRedirect" + "&client_id=754ysxdp72ulk5&client_secret=vbU52SjK7xS6cT8H";
             LinkedInProfile.UserProfile objUserProfile = new LinkedInProfile.UserProfile();
             string token = _oauth.APIWebRequest("POST", access_token_Url, access_token_postData);
             var oathtoken = JObject.Parse(token);
             _oauth.Token = oathtoken["access_token"].ToString().TrimStart('"').TrimEnd('"');
             LinkedInProfile objProfile = new LinkedInProfile();
              string ret = string.Empty;
             #region Get linkedin Profile data from Api
             try
             {
                 _oauth.ConsumerKey = "754ysxdp72ulk5";
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
                 logger.Error(ex.Message);
             }
            
             try
             {
                 _oauth.ConsumerSecret = "vbU52SjK7xS6cT8H";
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
                 logger.Error(ex.Message);
             }
             try
             {
                 objUserProfile = objProfile.GetUserProfile(_oauth);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
                 logger.Error(ex.Message);
             }
             #endregion
              dynamic data = objUserProfile;
                try
                {
                    #region LinkedInAccount
                    objLinkedInAccount.UserId = Guid.Parse(UserId);
                    objLinkedInAccount.LinkedinUserId = data.id.ToString();
                    try
                    {
                        objLinkedInAccount.EmailId = data.email.ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    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 (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    try
                    {
                        objLinkedInAccount.ProfileUrl = data.profile_url.ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    #endregion
                    #region SocialProfiles
                    try
                    {
                        objLinkedInAccount.Connections = data.connections;
                        objLinkedInAccount.IsActive = true;
                        objSocialProfile.UserId = Guid.Parse(UserId);
                        objSocialProfile.ProfileType = "linkedin";
                        objSocialProfile.ProfileId = data.id.ToString();
                        objSocialProfile.ProfileStatus = 1;
                        objSocialProfile.ProfileDate = DateTime.Now;
                        objSocialProfile.Id = Guid.NewGuid();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                    #endregion SocialProfiles
                    #region Add TeamMemberProfile
                    try
                    {
                        Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                        objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                        objTeamMemberProfile.Id = Guid.NewGuid();
                        objTeamMemberProfile.TeamId = objTeam.Id;
                        objTeamMemberProfile.Status = 1;
                        objTeamMemberProfile.ProfileType = "linkedin";
                        objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                        objTeamMemberProfile.ProfileId = objLinkedInAccount.LinkedinUserId;
                        objTeamMemberProfile.ProfileName = objLinkedInAccount.LinkedinUserName;
                        objTeamMemberProfile.ProfilePicUrl = objLinkedInAccount.ProfileImageUrl;

                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                    #endregion

                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                }
                try
                {
                    if (!objLinkedInAccountRepository.checkLinkedinUserExists(objLinkedInAccount.LinkedinUserId, Guid.Parse(UserId)))
                    {
                        objLinkedInAccountRepository.addLinkedinUser(objLinkedInAccount);
                        ret = "LinkedIn Account Added Successfully";
                    }
                    else
                    {
                        ret = "LinkedIn Account Already Exist";
                    }
                    if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                    {
                        objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    }
                    if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedInAccount.LinkedinUserId))
                    {
                        objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    }

                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                }
                return "";
            }