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 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); }
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); }
public string AddGPlusAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code) { string ret = string.Empty; string objRefresh = string.Empty; string refreshToken = string.Empty; string access_token = string.Empty; try { oAuthTokenGPlus ObjoAuthTokenGPlus = new oAuthTokenGPlus(); oAuthToken objToken = new oAuthToken(); objToken.ConsumerKey = client_id; objToken.ConsumerSecret = client_secret; try { objRefresh = ObjoAuthTokenGPlus.GetRefreshToken(code, client_id, client_secret, redirect_uri); logger.Error("vikash: ObjoAuthTokenGPlus()"); } catch (Exception ex) { } JObject objaccesstoken = JObject.Parse(objRefresh); try { refreshToken = objaccesstoken["refresh_token"].ToString(); } catch (Exception ex) { access_token = objaccesstoken["access_token"].ToString(); ObjoAuthTokenGPlus.RevokeToken(access_token); Console.WriteLine(ex.StackTrace); ret = "Refresh Token Not Found"; return(ret); } try { access_token = objaccesstoken["access_token"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } JArray userinfo = new JArray(); try { userinfo = objToken.GetUserInfo("self", access_token.ToString()); } catch (Exception ex) { } Domain.Socioboard.Domain.GooglePlusAccount _GooglePlusAccount = new Domain.Socioboard.Domain.GooglePlusAccount(); foreach (var itemuserinfo in userinfo) { try { _GooglePlusAccount.Id = Guid.NewGuid(); _GooglePlusAccount.GpUserId = itemuserinfo["id"].ToString(); _GooglePlusAccount.GpUserName = itemuserinfo["name"].ToString(); _GooglePlusAccount.GpProfileImage = itemuserinfo["picture"].ToString(); _GooglePlusAccount.IsActive = 1; _GooglePlusAccount.ProfileType = "gplus"; _GooglePlusAccount.AccessToken = access_token; _GooglePlusAccount.RefreshToken = refreshToken; _GooglePlusAccount.EmailId = itemuserinfo["email"].ToString(); _GooglePlusAccount.UserId = Guid.Parse(UserId); _GooglePlusAccount.EntryDate = DateTime.Now; } catch (Exception ex) { logger.Error("AddGPlusAccount => GooglePlusAccount =>" + ex.Message); } } #region Get_InYourCircles try { string _InyourCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleList.Replace("[userId]", _GooglePlusAccount.GpUserId).Replace("[collection]", "visible") + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), access_token); JObject J_InyourCircles = JObject.Parse(_InyourCircles); _GooglePlusAccount.InYourCircles = Convert.ToInt32(J_InyourCircles["totalItems"].ToString()); } catch (Exception ex) { _GooglePlusAccount.InYourCircles = 0; } #endregion #region Get_HaveYouInCircles try { string _HaveYouInCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleProfile + _GooglePlusAccount.GpUserId + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), access_token); JObject J_HaveYouInCircles = JObject.Parse(_HaveYouInCircles); _GooglePlusAccount.HaveYouInCircles = Convert.ToInt32(J_HaveYouInCircles["circledByCount"].ToString()); } catch (Exception ex) { _GooglePlusAccount.HaveYouInCircles = 0; } #endregion #region Add GPlusAccount if (!objGooglePlusAccountRepository.checkGooglePlusUserExists(_GooglePlusAccount.GpUserId, _GooglePlusAccount.UserId)) { objGooglePlusAccountRepository.addGooglePlusUser(_GooglePlusAccount); #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 = "gplus"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = _GooglePlusAccount.GpUserId; objTeamMemberProfile.ProfilePicUrl = _GooglePlusAccount.GpProfileImage; objTeamMemberProfile.ProfileName = _GooglePlusAccount.GpUserName; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "gplus"; objSocialProfile.ProfileId = _GooglePlusAccount.GpUserId; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #endregion ret = "Account Added Successfully"; } else { ret = "Account already Exist !"; } #endregion GetUserActivities(UserId, _GooglePlusAccount.GpUserId, access_token); return(new JavaScriptSerializer().Serialize(_GooglePlusAccount)); } catch (Exception ex) { logger.Error(ex.Message); return(""); } }
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 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 AddWordpressAccount(string code, string UserId, string GroupId) { WordpressAccountRepository objWPAccountRepo = new WordpressAccountRepository(); Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile(); Domain.Socioboard.Domain.WordpressAccount objWordpressAccount = new Domain.Socioboard.Domain.WordpressAccount(); string client_id = ConfigurationManager.AppSettings["WordpessClientID"]; string redirect_uri = ConfigurationManager.AppSettings["WordpessCallBackURL"]; string client_secret = ConfigurationManager.AppSettings["WordpessClientSecret"]; oAuthWordpress _oAuth = new oAuthWordpress(); _oAuth.client_id = client_id; _oAuth.client_secret = client_secret; _oAuth.redirect_uri = redirect_uri; _oAuth.code = code; string postdata = _oAuth.PostDataToGetAccessToken(); try { string _token = _oAuth.APIWebRequest(Globals._TokenUrl, postdata); string access_token = JObject.Parse(_token)["access_token"].ToString(); _oAuth.access_token = access_token; //string postdata1 = _oAuth.PostDataToGetAccessToken(); //string _me = _oAuth.APIWebRequest(Globals._UserInfo, postdata1); string userinfo = _oAuth.APIWebRequestToGetUserInfo(Globals._UserInfo); JObject WP_User = JObject.Parse(userinfo); #region AddWPAccount objWordpressAccount.Id = Guid.NewGuid(); objWordpressAccount.WpUserId = WP_User["ID"].ToString(); objWordpressAccount.WpUserName = WP_User["username"].ToString(); objWordpressAccount.DisplayName = WP_User["display_name"].ToString(); objWordpressAccount.EmailId = WP_User["email"].ToString(); objWordpressAccount.PrimaryBlogId = WP_User["primary_blog"].ToString(); objWordpressAccount.TokenSiteId = WP_User["token_site_id"].ToString(); objWordpressAccount.UserAvtar = WP_User["avatar_URL"].ToString(); objWordpressAccount.ProfileUrl = WP_User["profile_URL"].ToString(); objWordpressAccount.SiteCount = Int32.Parse(WP_User["site_count"].ToString()); objWordpressAccount.UserId = Guid.Parse(UserId); objWordpressAccount.AccessToken = access_token; if (!objWPAccountRepo.IsProfileAllreadyExist(objWordpressAccount.UserId, objWordpressAccount.WpUserId)) { objWPAccountRepo.AddWordpressAccount(objWordpressAccount); } #endregion #region AddTeamMemberProfiles Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.ProfileId = WP_User["ID"].ToString(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.ProfileType = "wordpress"; objTeamMemberProfile.Status = 1; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; if (!objTeamMemberProfileRepo.checkTeamMemberProfile(objTeam.Id, objTeamMemberProfile.ProfileId)) { objTeamMemberProfileRepo.addNewTeamMember(objTeamMemberProfile); } #endregion #region AddSocialProfile Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileType = "wordpress"; objSocialProfile.ProfileId = WP_User["ID"].ToString(); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } GetUserSites(UserId, objWordpressAccount.WpUserId); //GetUsersofblog(UserId,objWordpressAccount.WpUserId); #endregion } catch (Exception ex) { } return(""); }
public string AddAnalyticsProfiles(string GAProfiles, string UserId, string GroupId) { try { Analytics _Analytics = new Analytics(); List <Domain.Socioboard.Helper.GoogleAnalyticsProfiles> lstGoogleAnalyticsProfiles = (List <Domain.Socioboard.Helper.GoogleAnalyticsProfiles>) new JavaScriptSerializer().Deserialize(GAProfiles, typeof(List <Domain.Socioboard.Helper.GoogleAnalyticsProfiles>)); Domain.Socioboard.Domain.GoogleAnalyticsAccount _GoogleAnalyticsAccount; foreach (var item in lstGoogleAnalyticsProfiles) { try { _GoogleAnalyticsAccount = new Domain.Socioboard.Domain.GoogleAnalyticsAccount(); _GoogleAnalyticsAccount.UserId = Guid.Parse(UserId); _GoogleAnalyticsAccount.EmailId = item.EmailId; _GoogleAnalyticsAccount.GaAccountId = item.AccountId; _GoogleAnalyticsAccount.GaAccountName = item.AccountName; _GoogleAnalyticsAccount.GaWebPropertyId = item.WebPropertyId; _GoogleAnalyticsAccount.GaProfileId = item.ProfileId; _GoogleAnalyticsAccount.GaProfileName = item.ProfileName; _GoogleAnalyticsAccount.AccessToken = item.AccessToken; _GoogleAnalyticsAccount.RefreshToken = item.RefreshToken; _GoogleAnalyticsAccount.WebsiteUrl = item.WebsiteUrl; string visits = string.Empty; string pageviews = string.Empty; try { string analytics = _Analytics.getAnalyticsData(item.ProfileId, "ga:visits,ga:pageviews", DateTime.UtcNow.AddDays(-7).ToString("yyyy-MM-dd"), DateTime.UtcNow.ToString("yyyy-MM-dd"), item.AccessToken); JObject JData = JObject.Parse(analytics); visits = JData["totalsForAllResults"]["ga:visits"].ToString(); pageviews = JData["totalsForAllResults"]["ga:pageviews"].ToString(); } catch (Exception ex) { visits = "0"; pageviews = "0"; } _GoogleAnalyticsAccount.Views = Double.Parse(pageviews); _GoogleAnalyticsAccount.Visits = Double.Parse(visits); _GoogleAnalyticsAccount.ProfilePicUrl = ConfigurationManager.AppSettings["DomainName"] + "/Themes/" + ConfigurationManager.AppSettings["DefaultGroupName"] + "/Contents/img/analytics_img.png"; _GoogleAnalyticsAccount.IsActive = true; _GoogleAnalyticsAccount.EntryDate = DateTime.UtcNow; if (!_GoogleAnalyticsAccountRepository.checkGoogelAnalyticsUserExists(item.ProfileId, item.AccountId, Guid.Parse(UserId))) { _GoogleAnalyticsAccountRepository.Add(_GoogleAnalyticsAccount); } #region TeamMemberProfile Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); if (!grpProfileRepo.checkProfileExistsingroup(Guid.Parse(GroupId), item.ProfileId)) { //Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile(); //objTeamMemberProfile.ProfileId = item.ProfileId; //objTeamMemberProfile.ProfileName = item.ProfileName; //objTeamMemberProfile.ProfilePicUrl = ConfigurationManager.AppSettings["DomainName"] + "/Themes/Socioboard/Contents/img/analytics_img.png"; //objTeamMemberProfile.ProfileType = "googleanalytics"; //objTeamMemberProfile.Status = 1; //objTeamMemberProfile.StatusUpdateDate = DateTime.Now; //objTeamMemberProfile.TeamId = objTeam.Id; //objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile(); grpProfile.Id = Guid.NewGuid(); grpProfile.EntryDate = DateTime.UtcNow; grpProfile.GroupId = Guid.Parse(GroupId); grpProfile.GroupOwnerId = Guid.Parse(UserId); grpProfile.ProfileId = item.ProfileId; grpProfile.ProfileType = "googleanalytics"; grpProfile.ProfileName = item.ProfileName; grpProfile.ProfilePic = ConfigurationManager.AppSettings["DomainName"] + "/Themes/" + ConfigurationManager.AppSettings["DefaultGroupName"] + "/Contents/img/analytics_img.png"; grpProfileRepo.AddGroupProfile(grpProfile); } #endregion #region SocialProfile Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile(); objSocialProfile.ProfileType = "googleanalytics"; objSocialProfile.ProfileId = item.ProfileId; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #endregion } catch (Exception ex) { logger.Error("AddAnalyticsProfiles = > " + ex.Message); } } } catch (Exception ex) { logger.Error("AddAnalyticsProfiles = > " + ex.Message); } return("added successfully"); }