public string contactSearchTwitter(string keyword) { List <Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List <Domain.Socioboard.Domain.DiscoverySearch>(); string profileid = string.Empty; try { oAuthTwitter oauth = new oAuthTwitter(); Twitter obj = new Twitter(); TwitterAccountRepository twtAccRepo = new TwitterAccountRepository(); ArrayList alst = twtAccRepo.getAllTwitterAccounts(); foreach (Domain.Socioboard.Domain.TwitterAccount item in alst) { oauth.AccessToken = item.OAuthToken; oauth.AccessTokenSecret = item.OAuthSecret; oauth.TwitterUserId = item.TwitterUserId; oauth.TwitterScreenName = item.TwitterScreenName; obj.SetCofigDetailsForTwitter(oauth); if (this.CheckTwitterToken(oauth, keyword)) { break; } } Users twtUser = new Users(); JArray twitterSearchResult = twtUser.Get_Users_Search(oauth, keyword, "20"); foreach (var item in twitterSearchResult) { try { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.FromId = item["screen_name"].ToString(); objDiscoverySearch.FromName = item["screen_name"].ToString(); objDiscoverySearch.SearchKeyword = keyword; lstDiscoverySearch.Add(objDiscoverySearch); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } return(new JavaScriptSerializer().Serialize(lstDiscoverySearch)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Please try Again")); } }
public string DiscoverySearchTwitter(string UserId, string keyword) { List <Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List <Domain.Socioboard.Domain.DiscoverySearch>(); string profileid = string.Empty; try { oAuthTwitter oauth = new oAuthTwitter(); Twitter obj = new Twitter(); TwitterAccountRepository twtAccRepo = new TwitterAccountRepository(); List <Domain.Socioboard.Domain.TwitterAccount> alst = twtAccRepo.getTwtAccount(); try { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.SearchKeyword = keyword; objDiscoverySearch.Network = "twitter"; objDiscoverySearch.Id = Guid.NewGuid(); objDiscoverySearch.UserId = Guid.Parse(UserId); if (!dissearchrepo.isKeywordPresentforNetwork(objDiscoverySearch.SearchKeyword, objDiscoverySearch.Network)) { dissearchrepo.addNewSearchResult(objDiscoverySearch); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } foreach (Domain.Socioboard.Domain.TwitterAccount item in alst) { oauth.AccessToken = item.OAuthToken; oauth.AccessTokenSecret = item.OAuthSecret; oauth.TwitterUserId = item.TwitterUserId; oauth.TwitterScreenName = item.TwitterScreenName; obj.SetCofigDetailsForTwitter(oauth); try { Users _Users = new Users(); JArray _AccountVerify = _Users.Get_Account_Verify_Credentials(oauth); string id = _AccountVerify["id_str"].ToString(); break; } catch (Exception ex) { } //if (this.CheckTwitterToken(oauth, keyword)) //{ // break; //} } Search search = new Search(); JArray twitterSearchResult = search.Get_Search_Tweets(oauth, keyword); foreach (var item in twitterSearchResult) { var results = item["statuses"]; foreach (var chile in results) { try { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.CreatedTime = Utility.ParseTwitterTime(chile["created_at"].ToString().TrimStart('"').TrimEnd('"'));; objDiscoverySearch.EntryDate = DateTime.Now; objDiscoverySearch.FromId = chile["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); objDiscoverySearch.FromName = chile["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); objDiscoverySearch.ProfileImageUrl = chile["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); objDiscoverySearch.SearchKeyword = keyword; objDiscoverySearch.Network = "twitter"; objDiscoverySearch.Message = chile["text"].ToString().TrimStart('"').TrimEnd('"'); objDiscoverySearch.MessageId = chile["id_str"].ToString().TrimStart('"').TrimEnd('"'); objDiscoverySearch.Id = Guid.NewGuid(); objDiscoverySearch.UserId = Guid.Parse(UserId); lstDiscoverySearch.Add(objDiscoverySearch); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } return(new JavaScriptSerializer().Serialize(lstDiscoverySearch)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Please try Again")); } }
public string ProfilesConnected(string UserId) { try { Guid userid = Guid.Parse(UserId); SocialProfilesRepository socialRepo = new SocialProfilesRepository(); List <Domain.Socioboard.Domain.SocialProfile> lstsocioprofile = socialRepo.getAllSocialProfilesOfUser(userid); List <profileConnected> lstProfile = new List <profileConnected>(); foreach (Domain.Socioboard.Domain.SocialProfile sp in lstsocioprofile) { profileConnected pc = new profileConnected(); pc.Id = sp.Id; pc.ProfileDate = sp.ProfileDate; pc.ProfileId = sp.ProfileId; pc.ProfileStatus = sp.ProfileStatus; pc.ProfileType = sp.ProfileType; pc.UserId = sp.UserId; if (sp.ProfileType == "facebook") { try { FacebookAccountRepository objFbAccRepo = new FacebookAccountRepository(); Domain.Socioboard.Domain.FacebookAccount objFbAcc = objFbAccRepo.getUserDetails(sp.ProfileId); pc.ProfileName = objFbAcc.FbUserName; pc.ProfileImgUrl = "http://graph.facebook.com/" + sp.ProfileId + "/picture?type=small"; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "twitter") { try { TwitterAccountRepository objTwtAccRepo = new TwitterAccountRepository(); Domain.Socioboard.Domain.TwitterAccount objTwtAcc = objTwtAccRepo.getUserInfo(sp.ProfileId); pc.ProfileName = objTwtAcc.TwitterScreenName; pc.ProfileImgUrl = objTwtAcc.ProfileImageUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "instagram") { try { InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository(); Domain.Socioboard.Domain.InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountById(sp.ProfileId); pc.ProfileName = objInsAcc.InsUserName; pc.ProfileImgUrl = objInsAcc.ProfileUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "linkedin") { try { LinkedInAccountRepository objLiAccRepo = new LinkedInAccountRepository(); Domain.Socioboard.Domain.LinkedInAccount objLiAcc = objLiAccRepo.getLinkedinAccountDetailsById(sp.ProfileId); pc.ProfileName = objLiAcc.LinkedinUserName; pc.ProfileImgUrl = objLiAcc.ProfileImageUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "googleplus") { try { GooglePlusAccountRepository objGpAccRepo = new GooglePlusAccountRepository(); Domain.Socioboard.Domain.GooglePlusAccount objGpAcc = objGpAccRepo.getUserDetails(sp.ProfileId); pc.ProfileName = objGpAcc.GpUserName; pc.ProfileImgUrl = objGpAcc.GpProfileImage; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "tumblr") { try { TumblrAccountRepository objTumblrAccountRepository = new TumblrAccountRepository(); Domain.Socioboard.Domain.TumblrAccount objTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(sp.ProfileId); pc.ProfileName = objTumblrAccount.tblrUserName; pc.ProfileImgUrl = objTumblrAccount.tblrProfilePicUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "youtube") { try { YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository(); Domain.Socioboard.Domain.YoutubeAccount objYoutubeAccount = objYoutubeAccountRepository.getYoutubeAccountDetailsById(sp.ProfileId); pc.ProfileName = objYoutubeAccount.Ytusername; pc.ProfileImgUrl = objYoutubeAccount.Ytprofileimage; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } lstProfile.Add(pc); } return(new JavaScriptSerializer().Serialize(lstProfile)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Please Try Again")); } }