示例#1
0
        public string DiscoverySearchGplus(string UserId, string keyword)
        {
            List <Domain.Myfashion.Domain.DiscoverySearch> GplusDiscoverySearch = new List <Domain.Myfashion.Domain.DiscoverySearch>();
            string profileid = string.Empty;

            try
            {
                string searchResultObj = GplusDiscoverySearchHelper.GooglePlus(keyword);
                GooglePlusAccountRepository gplusAccRepo = new GooglePlusAccountRepository();
                ArrayList alst = gplusAccRepo.getAllGooglePlusAccounts();

                GlobusGooglePlusLib.Authentication.oAuthToken oauth = new GlobusGooglePlusLib.Authentication.oAuthToken();
                GooglePlusActivities obj = new GooglePlusActivities();

                JObject GplusActivities = JObject.Parse(GplusDiscoverySearchHelper.GooglePlus(keyword));

                foreach (JObject gobj in JArray.Parse(GplusActivities["items"].ToString()))
                {
                    Domain.Myfashion.Domain.DiscoverySearch gpfeed = new Domain.Myfashion.Domain.DiscoverySearch();
                    gpfeed.Id = Guid.NewGuid();

                    try
                    {
                        gpfeed.MessageId       = gobj["url"].ToString();
                        gpfeed.CreatedTime     = DateTime.Parse(gobj["published"].ToString());
                        gpfeed.Message         = gobj["title"].ToString();
                        gpfeed.FromId          = gobj["actor"]["id"].ToString();
                        gpfeed.FromName        = gobj["actor"]["displayName"].ToString();
                        gpfeed.ProfileImageUrl = gobj["actor"]["image"]["url"].ToString();
                    }
                    catch { }

                    GplusDiscoverySearch.Add(gpfeed);
                }
            }
            catch { }
            return(new JavaScriptSerializer().Serialize(GplusDiscoverySearch));
        }
        public string contactSearchTwitter(string keyword)
        {
            List<Domain.Myfashion.Domain.DiscoverySearch> lstDiscoverySearch = new List<Domain.Myfashion.Domain.DiscoverySearch>();
            string profileid = string.Empty;
            try
            {

                oAuthTwitter oauth = new oAuthTwitter();
                Twitter obj = new Twitter();

                TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                //ArrayList alst = twtAccRepo.getAllTwitterAccounts();
                List<Domain.Myfashion.Domain.TwitterAccount> alst = twtAccRepo.getTwtAccount();
                foreach (Domain.Myfashion.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;
                    //}
                }

                Users twtUser = new Users();
                JArray twitterSearchResult = twtUser.Get_Users_Search(oauth, keyword, "20");
                foreach (var item in twitterSearchResult)
                {
                    try
                    {
                        objDiscoverySearch = new Domain.Myfashion.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 contactSearchFacebook(string keyword)
        {
            List<Domain.Myfashion.Domain.DiscoverySearch> lstDiscoverySearch = new List<Domain.Myfashion.Domain.DiscoverySearch>();
            string profileid = string.Empty;
            try
            {
                FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                List<Domain.Myfashion.Domain.FacebookAccount> asltFbAccount = fbAccRepo.getFbAccounts();
                string accesstoken = string.Empty;
                foreach (Domain.Myfashion.Domain.FacebookAccount item in asltFbAccount)
                {
                    try
                    {
                        FacebookClient fb = new FacebookClient();
                        fb.AccessToken = item.AccessToken;

                        dynamic me = fb.Get("v2.0/me");
                        string id = me["id"].ToString();
                        accesstoken = item.AccessToken;
                        break;
                    }
                    catch (Exception ex)
                    {

                    }
                     
                }
                //string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &type=post&access_token=" + accesstoken + "&limit=100";
                string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &limit=20&type=user&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
                        {
                            objDiscoverySearch = new Domain.Myfashion.Domain.DiscoverySearch();
                            objDiscoverySearch.FromId = chile["id"].ToString();
                            objDiscoverySearch.FromName = chile["name"].ToString();
                            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 DiscoverySearchGplus(string UserId, string keyword)
        {
            List<Domain.Myfashion.Domain.DiscoverySearch> GplusDiscoverySearch = new List<Domain.Myfashion.Domain.DiscoverySearch>();
            string profileid = string.Empty;
            try
            {
                string searchResultObj = GplusDiscoverySearchHelper.GooglePlus(keyword);
                GooglePlusAccountRepository gplusAccRepo = new GooglePlusAccountRepository();
                ArrayList alst = gplusAccRepo.getAllGooglePlusAccounts();

                GlobusGooglePlusLib.Authentication.oAuthToken oauth = new GlobusGooglePlusLib.Authentication.oAuthToken();
                GooglePlusActivities obj = new GooglePlusActivities();

                JObject GplusActivities = JObject.Parse(GplusDiscoverySearchHelper.GooglePlus(keyword));

                foreach (JObject gobj in JArray.Parse(GplusActivities["items"].ToString()))
                {
                    Domain.Myfashion.Domain.DiscoverySearch gpfeed = new Domain.Myfashion.Domain.DiscoverySearch();
                    gpfeed.Id = Guid.NewGuid();

                    try
                    {
                        gpfeed.MessageId = gobj["url"].ToString();
                        gpfeed.CreatedTime = DateTime.Parse(gobj["published"].ToString());
                        gpfeed.Message = gobj["title"].ToString();
                        gpfeed.FromId = gobj["actor"]["id"].ToString();
                        gpfeed.FromName = gobj["actor"]["displayName"].ToString();
                        gpfeed.ProfileImageUrl = gobj["actor"]["image"]["url"].ToString();
                    }
                    catch { }

                    GplusDiscoverySearch.Add(gpfeed);
                }
            }
            catch { }
            return new JavaScriptSerializer().Serialize(GplusDiscoverySearch);
        }
        public string DiscoverySearchTwitter(string UserId, string keyword)
        {
            List<Domain.Myfashion.Domain.DiscoverySearch> lstDiscoverySearch = new List<Domain.Myfashion.Domain.DiscoverySearch>();
            string profileid = string.Empty;
            try
            {
                oAuthTwitter oauth = new oAuthTwitter();
                Twitter obj = new Twitter();

                TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                List<Domain.Myfashion.Domain.TwitterAccount> alst = twtAccRepo.getTwtAccount();
                foreach (Domain.Myfashion.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.Myfashion.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.Myfashion.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");
            }
        }
示例#6
0
        public string contactSearchTwitter(string keyword)
        {
            List <Domain.Myfashion.Domain.DiscoverySearch> lstDiscoverySearch = new List <Domain.Myfashion.Domain.DiscoverySearch>();
            string profileid = string.Empty;

            try
            {
                oAuthTwitter oauth = new oAuthTwitter();
                Twitter      obj   = new Twitter();

                TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                //ArrayList alst = twtAccRepo.getAllTwitterAccounts();
                List <Domain.Myfashion.Domain.TwitterAccount> alst = twtAccRepo.getTwtAccount();
                foreach (Domain.Myfashion.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;
                    //}
                }

                Users  twtUser             = new Users();
                JArray twitterSearchResult = twtUser.Get_Users_Search(oauth, keyword, "20");
                foreach (var item in twitterSearchResult)
                {
                    try
                    {
                        objDiscoverySearch               = new Domain.Myfashion.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"));
            }
        }
示例#7
0
        public string contactSearchFacebook(string keyword)
        {
            List <Domain.Myfashion.Domain.DiscoverySearch> lstDiscoverySearch = new List <Domain.Myfashion.Domain.DiscoverySearch>();
            string profileid = string.Empty;

            try
            {
                FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                List <Domain.Myfashion.Domain.FacebookAccount> asltFbAccount = fbAccRepo.getFbAccounts();
                string accesstoken = string.Empty;
                foreach (Domain.Myfashion.Domain.FacebookAccount item in asltFbAccount)
                {
                    try
                    {
                        FacebookClient fb = new FacebookClient();
                        fb.AccessToken = item.AccessToken;

                        dynamic me = fb.Get("v2.0/me");
                        string  id = me["id"].ToString();
                        accesstoken = item.AccessToken;
                        break;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                //string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &type=post&access_token=" + accesstoken + "&limit=100";
                string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &limit=20&type=user&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
                        {
                            objDiscoverySearch          = new Domain.Myfashion.Domain.DiscoverySearch();
                            objDiscoverySearch.FromId   = chile["id"].ToString();
                            objDiscoverySearch.FromName = chile["name"].ToString();
                            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"));
            }
        }
示例#8
0
        public string DiscoverySearchTwitter(string UserId, string keyword)
        {
            List <Domain.Myfashion.Domain.DiscoverySearch> lstDiscoverySearch = new List <Domain.Myfashion.Domain.DiscoverySearch>();
            string profileid = string.Empty;

            try
            {
                oAuthTwitter oauth = new oAuthTwitter();
                Twitter      obj   = new Twitter();

                TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                List <Domain.Myfashion.Domain.TwitterAccount> alst = twtAccRepo.getTwtAccount();
                foreach (Domain.Myfashion.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.Myfashion.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.Myfashion.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"));
            }
        }