Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["AdminProfile"] == null)
            {
                Response.Redirect("Default.aspx");
            }

            try
            {
                string    strUser   = string.Empty;
                ArrayList lstTwtAcc = objTwtRepo.getAllTwitterAccounts();
                foreach (TwitterAccount item in lstTwtAcc)
                {
                    //strUser += "<tr class=\"gradeX\"><td><a href=\"EditProfileDetail.aspx?id=" + item.TwitterUserId + "&type=twt&userid=" + item.UserId + "\">Edit</a></td><td>" + item.TwitterScreenName + "</td><td>Twitter</td><td>" + item.FollowersCount + "</td><td class=\"center\">" + item.IsActive + "</td></tr>";
                    strUser += "<tr class=\"gradeX\"><td><a href=\"EditProfileDetail.aspx?id=" + item.TwitterUserId + "&type=twt&userid=" + item.UserId + "\">Edit</a></td><td>" + item.TwitterScreenName + "</td><td>Twitter</td><td>" + item.FollowersCount + "</td></tr>";
                }
                ArrayList lstFBAcc = objFbRepo.getAllFacebookAccounts();
                foreach (FacebookAccount item in lstFBAcc)
                {
                    //strUser += "<tr class=\"gradeX\"><td><a href=\"EditProfileDetail.aspx?id=" + item.FbUserId + "&type=fb&userid=" + item.UserId + "\">Edit</a></td><td>" + item.FbUserName + "</td><td>Facebook</td><td>" + item.Friends + "</td><td class=\"center\">" + item.IsActive + "</td></tr>";
                    strUser += "<tr class=\"gradeX\"><td><a href=\"EditProfileDetail.aspx?id=" + item.FbUserId + "&type=fb&userid=" + item.UserId + "\">Edit</a></td><td>" + item.FbUserName + "</td><td>Facebook</td><td>" + item.Friends + "</td></tr>";
                }
                ArrayList lstliAcc = objLiRepo.getAllLinkedinAccounts();
                foreach (LinkedInAccount item in lstliAcc)
                {
                    //  strUser += "<tr class=\"gradeX\"><td><a href=\"EditProfileDetail.aspx?id=" + item.LinkedinUserId + "&type=li&userid=" + item.UserId + "\">Edit</a></td><td>" + item.LinkedinUserName + "</td><td>LinkedIn</td><td>" + item.Connections + "</td><td class=\"center\">" + item.IsActive + "</td></tr>";
                    strUser += "<tr class=\"gradeX\"><td><a href=\"EditProfileDetail.aspx?id=" + item.LinkedinUserId + "&type=li&userid=" + item.UserId + "\">Edit</a></td><td>" + item.LinkedinUserName + "</td><td>LinkedIn</td><td>" + item.Connections + "</td></tr>";
                }
                ArrayList lstInsAcc = objInsRepo.getAllInstagramAccounts();
                foreach (InstagramAccount item in lstInsAcc)
                {
                    //strUser += "<tr class=\"gradeX\"><td><a href=\"EditProfileDetail.aspx?id=" + item.InstagramId + "&type=ins&userid=" + item.UserId + "\">Edit</a></td><td>" + item.InsUserName + "</td><td>Instagram</td><td>" + item.Followers + "</td><td class=\"center\">" + item.IsActive + "</td></tr>";
                    strUser += "<tr class=\"gradeX\"><td><a href=\"EditProfileDetail.aspx?id=" + item.InstagramId + "&type=ins&userid=" + item.UserId + "\">Edit</a></td><td>" + item.InsUserName + "</td><td>Instagram</td><td>" + item.Followers + "</td></tr>";
                }
                ArrayList lstGpAcc = objgpRepo.getAllGooglePlusAccounts();
                foreach (GooglePlusAccount item in lstGpAcc)
                {
                    if (item.GpUserName != null)
                    {
                        //strUser += "<tr class=\"gradeX\"><td><a href=\"EditProfileDetail.aspx?id=" + item.GpUserId + "&type=gp&userid=" + item.UserId + "\">Edit</a></td><td>" + item.GpUserName + "</td><td>Google Plus</td><td>" + item.PeopleCount + "</td><td class=\"center\">" + item.IsActive + "</td></tr>";
                        strUser += "<tr class=\"gradeX\"><td><a href=\"EditProfileDetail.aspx?id=" + item.GpUserId + "&type=gp&userid=" + item.UserId + "\">Edit</a></td><td>" + item.GpUserName + "</td><td>Google Plus</td><td>" + item.PeopleCount + "</td></tr>";
                    }
                }
                Users.InnerHtml = strUser;
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
Exemplo n.º 2
0
        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");
            }
        }
Exemplo n.º 3
0
        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();
                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;
                    }
                }

                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.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);
                        }

                        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");
            }
        }
Exemplo n.º 4
0
        public string getresults(string keyword)
        {
            User   user      = (User)Session["LoggedUser"];
            int    i         = 0;
            string searchRes = string.Empty;

            if (!string.IsNullOrEmpty(keyword))
            {
                DiscoverySearch           dissearch     = new DiscoverySearch();
                DiscoverySearchRepository dissearchrepo = new DiscoverySearchRepository();

                //Get data from Database if present, against the specified keyword
                List <DiscoverySearch> discoveryList = dissearchrepo.getResultsFromKeyword(keyword);

                if (discoveryList.Count == 0) //if no data, get the data for specified keyword from social media apis
                {
                    #region Twitter

                    try
                    {
                        oAuthTwitter oauth = new oAuthTwitter();
                        oauth.ConsumerKey       = ConfigurationManager.AppSettings["consumerKey"].ToString();
                        oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"].ToString();
                        oauth.CallBackUrl       = ConfigurationManager.AppSettings["callbackurl"].ToString();
                        TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                        ArrayList alst = twtAccRepo.getAllTwitterAccounts();
                        foreach (TwitterAccount item in alst)
                        {
                            oauth.AccessToken       = item.OAuthToken;
                            oauth.AccessTokenSecret = item.OAuthSecret;
                            oauth.TwitterUserId     = item.TwitterUserId;
                            oauth.TwitterScreenName = item.TwitterScreenName;
                            if (TwitterHelper.CheckTwitterToken(oauth, keyword))
                            {
                                break;
                            }
                            else
                            {
                            }
                        }

                        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
                                {
                                    dissearch.CreatedTime     = SocioBoard.Helper.Extensions.ParseTwitterTime(chile["created_at"].ToString().TrimStart('"').TrimEnd('"'));;
                                    dissearch.EntryDate       = DateTime.Now;
                                    dissearch.FromId          = chile["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                                    dissearch.FromName        = chile["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                                    dissearch.ProfileImageUrl = chile["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                                    dissearch.SearchKeyword   = txtSearchText.Text;
                                    dissearch.Network         = "twitter";
                                    dissearch.Message         = chile["text"].ToString().TrimStart('"').TrimEnd('"');
                                    dissearch.MessageId       = chile["id_str"].ToString().TrimStart('"').TrimEnd('"');
                                    dissearch.Id     = Guid.NewGuid();
                                    dissearch.UserId = user.Id;

                                    string postID  = chile["id"].ToString();
                                    string postURL = "https://twitter.com/" + dissearch.FromName + "/status/" + postID;

                                    if (!dissearchrepo.isKeywordPresent(dissearch.SearchKeyword, dissearch.MessageId))
                                    {
                                        dissearchrepo.addNewSearchResult(dissearch);
                                    }

                                    searchRes += this.BindData(dissearch, i, postURL);


                                    i++;
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.StackTrace);
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }
                    #endregion
                    #region Facebook
                    try
                    {
                        #region FacebookSearch
                        int    j           = 0;
                        string accesstoken = string.Empty;
                        FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                        ArrayList asltFbAccount             = fbAccRepo.getAllFacebookAccounts();
                        foreach (FacebookAccount item in asltFbAccount)
                        {
                            accesstoken = item.AccessToken;
                            if (FacebookHelper.CheckFacebookToken(accesstoken, txtSearchText.Text))
                            {
                                break;
                            }
                        }

                        string facebookSearchUrl = "https://graph.facebook.com/search?q=" + txtSearchText.Text + " &type=post&access_token=" + accesstoken;
                        var    facerequest       = (HttpWebRequest)WebRequest.Create(facebookSearchUrl);
                        facerequest.Method = "GET";
                        string outputface = string.Empty;
                        using (var response = facerequest.GetResponse())
                        {
                            using (var stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252)))
                            {
                                outputface = stream.ReadToEnd();
                            }
                        }
                        if (!outputface.StartsWith("["))
                        {
                            outputface = "[" + outputface + "]";
                        }


                        JArray facebookSearchResult = JArray.Parse(outputface);

                        foreach (var item in facebookSearchResult)
                        {
                            var data = item["data"];

                            foreach (var chile in data)
                            {
                                try
                                {
                                    dissearch.CreatedTime     = DateTime.Parse(chile["created_time"].ToString());
                                    dissearch.EntryDate       = DateTime.Now;
                                    dissearch.FromId          = chile["from"]["id"].ToString();
                                    dissearch.FromName        = chile["from"]["name"].ToString();
                                    dissearch.ProfileImageUrl = "http://graph.facebook.com/" + chile["from"]["id"] + "/picture?type=small";
                                    dissearch.SearchKeyword   = txtSearchText.Text;
                                    dissearch.Network         = "facebook";
                                    dissearch.Message         = chile["message"].ToString();
                                    dissearch.MessageId       = chile["id"].ToString();
                                    dissearch.Id     = Guid.NewGuid();
                                    dissearch.UserId = user.Id;

                                    string postURL = "https://www.facebook.com/" + dissearch.MessageId;

                                    if (!dissearchrepo.isKeywordPresent(dissearch.SearchKeyword, dissearch.MessageId))
                                    {
                                        dissearchrepo.addNewSearchResult(dissearch);
                                    }
                                    searchRes += this.BindData(dissearch, i, postURL);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.StackTrace);
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }
                    #endregion

                    #endregion
                }
                else // if data is there, bind data from databse
                {
                    foreach (DiscoverySearch item in discoveryList)
                    {
                        string postURL = string.Empty;
                        if (item.Network == "facebook")
                        {
                            postURL = "https://www.facebook.com/" + item.MessageId;;
                        }
                        else if (item.Network == "twitter")
                        {
                            postURL = "https://twitter.com/" + item.FromName + "/status/" + item.MessageId;
                        }

                        searchRes += this.BindData(item, i, postURL);
                        i++;
                    }
                }
            }
            return(searchRes);
        }