Esempio n. 1
0
        public string GetInstagramFeeds(string UserId, string InstagramId)
        {
            try
            {

                InstagramFeedRepository objInsFeedRepo = new InstagramFeedRepository();
                List<InstagramFeed> lstInsFeed = objInsFeedRepo.getAllInstagramFeedsOfUser(Guid.Parse(UserId), InstagramId);
                return new JavaScriptSerializer().Serialize(lstInsFeed);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return null;
            }
        }
Esempio n. 2
0
        public void getIntagramImages(object instaId)
        {
            Guid instaid = (Guid)instaId;

            InstagramAccountRepository objIns = new InstagramAccountRepository();
            InstagramResponse<GlobusInstagramLib.App.Core.User[]> userinf = new InstagramResponse<GlobusInstagramLib.App.Core.User[]>();
            InstagramResponse<GlobusInstagramLib.App.Core.User[]> userinf1 = new InstagramResponse<GlobusInstagramLib.App.Core.User[]>();
            InstagramResponse<InstagramMedia[]> userinf2 = new InstagramResponse<InstagramMedia[]>();
            InstagramResponse<Comment[]> usercmts = new InstagramResponse<Comment[]>();
            MediaController objMedia = new MediaController();
            CommentController objComment = new CommentController();
            LikesController objLikes = new LikesController();
            InstagramFeedRepository objInsFeedRepo = new InstagramFeedRepository();
            InstagramFeed objFeed = new InstagramFeed();
            InstagramComment objinsComment = new InstagramComment();
            InstagramCommentRepository objInsRepo = new InstagramCommentRepository();
            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = oAuthInstagram.GetInstance(configi);
            ArrayList aslt = objIns.getAllInstagramAccountsOfUser(instaid);
            string html = string.Empty;
            int i = 0;
            // string[] allhtmls = new string[aslt.Count];
            string[] allhtmls = new string[0];
            int countofimages = 0;
            foreach (InstagramAccount item in aslt)
            {

                try
                {
                    GlobusInstagramLib.Instagram.Core.UsersMethods.Users userInstagram = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users();
                    try
                    {
                        userinf2 = userInstagram.UserRecentMedia(item.InstagramId, string.Empty, string.Empty, "20", string.Empty, string.Empty, item.AccessToken);

                    }
                    catch { }


                }
                catch { }



                if (userinf2 != null)
                {
                    for (int j = 0; j < userinf2.data.Count(); j++)
                    {
                        try
                        {
                            usercmts = objComment.GetComment(userinf2.data[j].id, item.AccessToken);
                            bool liked = false;
                            try
                            {
                                liked = objLikes.LikeToggle(userinf2.data[j].id, item.InstagramId, item.AccessToken);
                            }
                            catch
                            {
                            }
                            int n = usercmts.data.Count();
                            for (int cmt = 0; cmt < usercmts.data.Count(); cmt++)
                            {
                                objinsComment.Comment = usercmts.data[cmt].text;
                                objinsComment.CommentDate = usercmts.data[cmt].created_time.ToString();
                                objinsComment.CommentId = usercmts.data[cmt].id;
                                objinsComment.EntryDate = DateTime.Now.ToString();
                                objinsComment.FeedId = userinf2.data[j].id;
                                objinsComment.Id = Guid.NewGuid();
                                objinsComment.InstagramId = item.InstagramId;
                                objinsComment.UserId = item.UserId;
                                objinsComment.FromName = usercmts.data[cmt].from.full_name;
                                objinsComment.FromProfilePic = usercmts.data[cmt].from.profile_picture;
                                if (!objInsRepo.checkInstagramCommentExists(usercmts.data[cmt].id, item.UserId))
                                    objInsRepo.addInstagramComment(objinsComment);
                            }
                            objFeed.EntryDate = DateTime.Now;
                            objFeed.FeedDate = userinf2.data[j].created_time.ToString();
                            objFeed.FeedId = userinf2.data[j].id;
                            objFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString();
                            objFeed.InstagramId = item.InstagramId;
                            objFeed.LikeCount = userinf2.data[j].likes.count;
                            objFeed.UserId = item.UserId;
                            if (!objInsFeedRepo.checkInstagramFeedExists(userinf2.data[j].id, item.UserId))
                                objInsFeedRepo.addInstagramFeed(objFeed);


                        }
                        catch
                        {
                        }
                        i++;

                    }
                }
                i++;
           //     allhtmls[countofimages] = html;
                html = string.Empty;
                countofimages++;
                break;
            }
            string totalhtml = string.Empty;
            try
            {
                for (int k = 0; k < countofimages; k++)
                {
                    totalhtml = totalhtml + allhtmls[k];
                }
            }
            catch
            {
            }
          
        }
Esempio n. 3
0
        public string DeleteAllUsersByCreateDate(string date)
        {
            int i = 0;
            int count = 0;
            UserRepository objUserRepository = new UserRepository();
            List<User> lstuser = objUserRepository.GetAllUsersByCreateDate(date);
            ArchiveMessageRepository objArchiveMessageRepository = new ArchiveMessageRepository();
            DiscoverySearchRepository objDiscoverySearchRepository = new DiscoverySearchRepository();
            DraftsRepository objDraftsRepository = new DraftsRepository();
            FacebookAccountRepository objFacebookAccountRepository = new FacebookAccountRepository();
            FacebookFeedRepository objFacebookFeedRepository = new FacebookFeedRepository();
            FacebookInsightPostStatsRepository objFacebookInsightPostStatsRepository = new FacebookInsightPostStatsRepository();
            FacebookInsightStatsRepository objFacebookInsightStatsRepository = new FacebookInsightStatsRepository();
            FacebookMessageRepository objFacebookMessageRepository = new FacebookMessageRepository();
            FacebookStatsRepository objFacebookStatsRepository = new FacebookStatsRepository();
            GoogleAnalyticsAccountRepository objGoogleAnalyticsAccountRepository = new GoogleAnalyticsAccountRepository();
            GoogleAnalyticsStatsRepository objGoogleAnalyticsStatsRepository = new GoogleAnalyticsStatsRepository();
            GooglePlusAccountRepository objGooglePlusAccountRepository = new GooglePlusAccountRepository();
            GooglePlusActivitiesRepository objGooglePlusActivitiesRepository = new GooglePlusActivitiesRepository();
            GroupProfileRepository objGroupProfileRepository = new GroupProfileRepository();
            GroupRepository objGroupRepository = new GroupRepository();
            InstagramAccountRepository objInstagramAccountRepository = new InstagramAccountRepository();
            InstagramCommentRepository objInstagramCommentRepository = new InstagramCommentRepository();
            InstagramFeedRepository objInstagramFeedRepository = new InstagramFeedRepository();
            LinkedInAccountRepository objLinkedInAccountRepository = new LinkedInAccountRepository();
            LinkedInFeedRepository objLinkedInFeedRepository = new LinkedInFeedRepository();
            LogRepository objLogRepository = new LogRepository();
            RssFeedsRepository objRssFeedsRepository = new RssFeedsRepository();
            RssReaderRepository objRssReaderRepository = new RssReaderRepository();
            ScheduledMessageRepository objScheduledMessageRepository = new ScheduledMessageRepository();
            SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();
            TaskCommentRepository objTaskCommentRepository = new TaskCommentRepository();
            TaskRepository objTaskRepository = new TaskRepository();
            TeamRepository objTeamRepository = new TeamRepository();
            TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
            TwitterAccountRepository objTwitterAccountRepository = new TwitterAccountRepository();
            TwitterDirectMessageRepository objTwitterDirectMessageRepository = new TwitterDirectMessageRepository();
            TwitterFeedRepository objTwitterFeedRepository = new TwitterFeedRepository();
            TwitterMessageRepository objTwitterMessageRepository = new TwitterMessageRepository();
            TwitterStatsRepository objTwitterStatsRepository = new TwitterStatsRepository();
            UserActivationRepository objUserActivationRepository = new UserActivationRepository();
            UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository();






            count = lstuser.Count();


            foreach (var item in lstuser)
            {
                i++;
                try
                {

                    if (item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**")
                    {

                    }
                    else
                    {
                        objArchiveMessageRepository.DeleteArchiveMessageByUserid(item.Id);
                        objDiscoverySearchRepository.DeleteDiscoverySearchByUserid(item.Id);
                        objDraftsRepository.DeleteDraftsByUserid(item.Id);
                        objFacebookAccountRepository.DeleteFacebookAccountByUserid(item.Id);
                        objFacebookFeedRepository.DeleteFacebookFeedByUserid(item.Id);
                        objFacebookInsightPostStatsRepository.DeleteFacebookInsightPostStatsByUserid(item.Id);
                        objFacebookInsightStatsRepository.DeleteFacebookInsightStatsByUserid(item.Id);
                        objFacebookMessageRepository.DeleteFacebookMessageByUserid(item.Id);
                        objFacebookStatsRepository.DeleteFacebookStatsByUserid(item.Id);
                        objGoogleAnalyticsAccountRepository.DeleteGoogleAnalyticsAccountByUserid(item.Id);
                        objGoogleAnalyticsStatsRepository.DeleteGoogleAnalyticsStatsByUserid(item.Id);
                        objGooglePlusAccountRepository.DeleteGooglePlusAccountByUserid(item.Id);
                        objGooglePlusActivitiesRepository.DeleteGooglePlusActivitiesByUserid(item.Id);
                        objGroupProfileRepository.DeleteGroupProfileByUserid(item.Id);
                        objGroupRepository.DeleteGroupsByUserid(item.Id);
                        objInstagramAccountRepository.DeleteInstagramAccountByUserid(item.Id);
                        objInstagramCommentRepository.DeleteInstagramCommentByUserid(item.Id);
                        objInstagramFeedRepository.DeleteInstagramFeedByUserid(item.Id);
                        objLinkedInAccountRepository.DeleteLinkedInAccountByUserid(item.Id);
                        objLinkedInFeedRepository.DeleteLinkedInFeedByUserid(item.Id);
                        objLogRepository.DeleteLogByUserid(item.Id);
                        objRssFeedsRepository.DeleteRssFeedsByUserid(item.Id);
                        objRssReaderRepository.DeleteRssReaderByUserid(item.Id);
                        objScheduledMessageRepository.DeleteScheduledMessageByUserid(item.Id);
                        objSocialProfilesRepository.DeleteSocialProfileByUserid(item.Id);
                        objTaskCommentRepository.DeleteTaskCommentByUserid(item.Id);
                        objTaskRepository.DeleteTasksByUserid(item.Id);
                        objTeamRepository.DeleteTeamByUserid(item.Id);
                        objTeamMemberProfileRepository.DeleteTeamMemberProfileByUserid(item.Id);
                        objTwitterAccountRepository.DeleteTwitterAccountByUserid(item.Id);
                        objTwitterDirectMessageRepository.DeleteTwitterDirectMessagesByUserid(item.Id);
                        objTwitterFeedRepository.DeleteTwitterFeedByUserid(item.Id);
                        objTwitterMessageRepository.DeleteTwitterMessageByUserid(item.Id);
                        objTwitterStatsRepository.DeleteTwitterStatsByUserid(item.Id);
                        objUserActivationRepository.DeleteUserActivationByUserid(item.Id);
                        objUserPackageRelationRepository.DeleteuserPackageRelationByUserid(item.Id);
                        objUserRepository.DeleteUserByUserid(item.Id);
                    }
                }
                catch (Exception ex)
                {

                    Console.WriteLine(ex.Message);
                }
            }
           return i +" "+count;
        }
Esempio n. 4
0
        public string getIntagramImages( InstagramAccount objInsAccount)
        {
            InstagramAccountRepository objIns = new InstagramAccountRepository();
            InstagramResponse<GlobusInstagramLib.App.Core.User[]> userinf = new InstagramResponse<GlobusInstagramLib.App.Core.User[]>();
            InstagramResponse<GlobusInstagramLib.App.Core.User[]> userinf1 = new InstagramResponse<GlobusInstagramLib.App.Core.User[]>();
            InstagramResponse<InstagramMedia[]> userinf2 = new InstagramResponse<InstagramMedia[]>();
            InstagramResponse<Comment[]> usercmts = new InstagramResponse<Comment[]>();
            MediaController objMedia = new MediaController();
            CommentController objComment = new CommentController();
            LikesController objLikes = new LikesController();
            InstagramFeedRepository objInsFeedRepo = new InstagramFeedRepository();
            InstagramFeed objFeed = new InstagramFeed();
            InstagramComment objinsComment = new InstagramComment();
            InstagramCommentRepository objInsRepo = new InstagramCommentRepository();
          //  ArrayList aslt = objIns.getAllInstagramAccountsOfUser(instaid);
            string html = string.Empty;
            int i = 0;
            // string[] allhtmls = new string[aslt.Count];
            string[] allhtmls = new string[0];
            int countofimages = 0;
            GlobusInstagramLib.Instagram.Core.UsersMethods.Users userInstagram = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users();
                    try
                    {
                        userinf2 = userInstagram.UserRecentMedia(objInsAccount.InstagramId,string.Empty,string.Empty,"20",string.Empty,string.Empty,objInsAccount.AccessToken);

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


                    if (userinf2 != null)
                    {
                        for (int j = 0; j < userinf2.data.Count(); j++)
                        {
                            try
                            {
                                usercmts = objComment.GetComment(userinf2.data[j].id,objInsAccount.AccessToken);
                                bool liked = false;
                                try
                                {
                                    liked = objLikes.LikeToggle(userinf2.data[j].id, objInsAccount.InstagramId, objInsAccount.AccessToken);
                                }
                                catch(Exception ex)
                                {
                                    logger.Error(ex.StackTrace);
                                }
                                int n = usercmts.data.Count();
                                for (int cmt = usercmts.data.Count() - 1; cmt > usercmts.data.Count() - 3; cmt--)
                                {
                                    try
                                    {
                                        objinsComment.Comment = usercmts.data[cmt].text;
                                        objinsComment.CommentDate = usercmts.data[cmt].created_time.ToString();
                                        objinsComment.CommentId = usercmts.data[cmt].id;
                                        objinsComment.EntryDate = DateTime.Now.ToString();
                                        objinsComment.FeedId = userinf2.data[j].id;
                                        objinsComment.Id = Guid.NewGuid();
                                        objinsComment.InstagramId = objInsAccount.InstagramId;
                                        objinsComment.UserId = objInsAccount.UserId;
                                        objinsComment.FromName = usercmts.data[cmt].from.full_name;
                                        objinsComment.FromProfilePic = usercmts.data[cmt].from.profile_picture;
                                        if (!objInsRepo.checkInstagramCommentExists(usercmts.data[cmt].id, objInsAccount.UserId))
                                            objInsRepo.addInstagramComment(objinsComment);
                                    }
                                    catch (Exception ex)
                                    {
                                        logger.Error(ex.StackTrace);
                                        Console.WriteLine(ex.StackTrace);
                                    }
                                }
                                objFeed.EntryDate = DateTime.Now;
                                objFeed.FeedDate = userinf2.data[j].created_time.ToString();
                                objFeed.FeedId = userinf2.data[j].id;
                                objFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString();
                                objFeed.InstagramId = objInsAccount.InstagramId;
                                objFeed.LikeCount = userinf2.data[j].likes.count;
                                objFeed.UserId = objInsAccount.UserId;
                                if (!objInsFeedRepo.checkInstagramFeedExists(userinf2.data[j].id, objInsAccount.UserId))
                                    objInsFeedRepo.addInstagramFeed(objFeed);


                            }
                            catch(Exception ex)
                            {
                                logger.Error(ex.StackTrace);
                            }
                            i++;

                        }
                    }
                    i++;
                
            
            string totalhtml = string.Empty;
            try
            {
                for (int k = 0; k < countofimages; k++)
                {
                    totalhtml = totalhtml + allhtmls[k];
                }
            }
            catch(Exception ex)
            {
                logger.Error(ex.StackTrace);

            }
            Session["AllHtmls"] = allhtmls;
            return totalhtml;

          
        }
Esempio n. 5
0
        public void ProcessRequest()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["op"]))
            {
                SocioBoard.Domain.User user = (SocioBoard.Domain.User)Session["LoggedUser"];
                if (Request.QueryString["op"] == "networkprofiles")
                {
                    #region NetworkProfiles
                    string profiles = string.Empty;
                    if (Request.QueryString["network"] == "facebook")
                    {
                        ArrayList alstfacebook = null;
                        if (Session["facebooktotalprofiles"] == null)
                        {
                            FacebookAccountRepository faceaccrepo = new FacebookAccountRepository();
                            alstfacebook = faceaccrepo.getFacebookAccountsOfUser(user.Id);
                            Session["facebooktotalprofiles"] = alstfacebook;
                        }
                        else
                        {
                            alstfacebook = (ArrayList)Session["facebooktotalprofiles"];
                        }

                        if (alstfacebook.Count == 0)
                        {
                            profiles += "<li><a  href=\"#\" class=\"active\">No Records Found</a> </li>";
                        }
                        else
                        {
                            foreach (FacebookAccount item in alstfacebook)
                            {
                                profiles += "<li><a id=\"lifb_" + item.FbUserId + "\" href=\"#\" onclick=\"facebookdetails('" + item.FbUserId + "');\" class=\"active\">" + item.FbUserName + "</a> </li>";
                            }
                        }

                    }
                    else if (Request.QueryString["network"] == "twitter")
                    {
                        ArrayList alsttwitter = null;

                        if (Session["twittertotalprofiles"] == null)
                        {
                            TwitterAccountRepository twtaccrepo = new TwitterAccountRepository();
                            alsttwitter = twtaccrepo.getAllTwitterAccountsOfUser(user.Id);
                            Session["twittertotalprofiles"] = alsttwitter;
                        }
                        else
                        {
                            alsttwitter = (ArrayList)Session["twittertotalprofiles"];
                        }

                        if (alsttwitter.Count == 0)
                        {
                            profiles += "<li><a  href=\"#\" class=\"active\">No Records Found</a> </li>";
                        }
                        else
                        {

                            foreach (TwitterAccount item in alsttwitter)
                            {
                                profiles += "<li><a id=\"litwt_" + item.TwitterUserId + "\" href=\"#\" onclick=\"twitterdetails('" + item.TwitterUserId + "');\" class=\"active\">" + item.TwitterScreenName + "</a> </li>";
                            }
                        }
                    }
                    else if (Request.QueryString["network"] == "linkedin")
                    {
                        ArrayList alstlinklist = null;
                        if (Session["linkedintotalprofiles"] == null)
                        {
                            LinkedInAccountRepository linkaccrepo = new LinkedInAccountRepository();
                            alstlinklist = linkaccrepo.getAllLinkedinAccountsOfUser(user.Id);
                        }
                        else
                        {
                            alstlinklist = (ArrayList)Session["linkedintotalprofiles"];
                        }
                        if (alstlinklist.Count == 0)
                        {
                            profiles += "<li><a  href=\"#\" class=\"active\">No Records Found</a> </li>";
                        }
                        else
                        {
                            foreach (LinkedInAccount item in alstlinklist)
                            {
                                profiles += "<li><a id=\"lilin_" + item.LinkedinUserId + "\" href=\"#\" onclick=\"linkedindetails('" + item.LinkedinUserId + "');\" class=\"active\">" + item.LinkedinUserName + "</a> </li>";
                            }
                        }
                    }
                    else if (Request.QueryString["network"] == "instagram")
                    {
                        ArrayList alstinstagram = null;
                        if (Session["instagramtotalprofiles"] == null)
                        {
                            InstagramAccountRepository insaccrepo = new InstagramAccountRepository();
                            alstinstagram = insaccrepo.getAllInstagramAccountsOfUser(user.Id);
                            Session["instagramtotalprofiles"] = alstinstagram;
                        }
                        else
                        {
                            alstinstagram = (ArrayList)Session["instagramtotalprofiles"];
                        }
                        if (alstinstagram.Count == 0)
                        {
                            profiles += "<li><a  href=\"#\" class=\"active\">No Records Found</a> </li>";
                        }
                        else
                        {
                            foreach (InstagramAccount item in alstinstagram)
                            {
                                profiles += "<li><a id=\"liins_" + item.InstagramId + "\" href=\"#\" onclick=\"Instagramdetails('" + item.InstagramId + "');\" class=\"active\">" + item.InsUserName + "</a> </li>";
                            }
                        }

                    }
                    Response.Write(profiles);
                    #endregion
                }
                else if (Request.QueryString["op"] == "facebookwallposts")
                {
                    string messages = string.Empty;
                    string profileid = string.Empty;
                    string load = Request.QueryString["load"];
                    //Session[""] = profileid;
                    if (load == "first")
                    {
                        profileid = Request.QueryString["profileid"];
                        Session["FacebookProfileIdForFeeds"] = profileid;
                        facebookwallcount = 0;
                    }
                    else
                    {
                        profileid = (string)Session["FacebookProfileIdForFeeds"];
                        facebookwallcount = facebookwallcount + 10;
                    }

                    FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository();
                    FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();

                    List<FacebookMessage> lsgfbmsgs = fbmsgrepo.getAllWallpostsOfProfile(profileid, facebookwallcount);

                    UrlExtractor urlext = new UrlExtractor();
                    foreach (FacebookMessage item in lsgfbmsgs)
                    {
                        try
                        {

                            string[] str = urlext.splitUrlFromString(item.Message);
                            messages += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + item.FromProfileUrl + "\" onclick=\"getFacebookProfiles('" + item.FromId + "');\">" +
                                                         "</div><div class=\"pull-left feedcontent\">" +
                                                            "<a href=\"#\" class=\"feednm\" onclick=\"getFacebookProfiles('" + item.FromId + "');\">" + item.FromName + "</a> <span>" + item.MessageDate +
                                                                " </span>" +
                                                             "<p>";

                            if (!string.IsNullOrEmpty(item.Picture))
                            {
                                //string largeimage = item.Picture.Replace("_s.jpg","_n.jpg");

                                messages += "<img src=\"" + item.Picture + "\" alt=\"\" onclick=\"fbimage('" + item.Picture + "');\" /><br/>";
                            }

                            foreach (string substritem in str)
                            {
                                if (!string.IsNullOrEmpty(substritem))
                                {
                                    if (substritem.Contains("http"))
                                    {
                                        messages += "<a target=\"_blank\" href=\"" + substritem + "\">" + substritem + "</a>";
                                    }
                                    else
                                    {
                                        messages += substritem;
                                    }
                                }
                            }

                            messages += "</p>" +
                                        "<a class=\"retweets\" href=\"#\">" +
                                        "</a><p><span onclick=\"facebookLike('" + item.FbLike + "','" + profileid + "','" + item.MessageId + "')\" id=\"likefb_" + item.MessageId + "\" class=\"like\">Like</span><span id=\"commentfb_" + item.MessageId + "\" onclick=\"commentText('"+item.MessageId+"');\" class=\"comment\">Comment</span></p>" +
                                        "<p><input id=\"textfb_"+item.MessageId+"\" type=\"text\" class=\"put_comments\"></p>"+
                                      "<p><span onclick=\"commentFB('"+item.MessageId+"','"+profileid+"')\" id=\"okfb_"+item.MessageId+"\" class=\"ok\">ok</span><span id=\"cancelfb_"+item.MessageId+"\" onclick=\"cancelFB('"+item.MessageId+"');\" class=\"cancel\"> cancel</span></p>"+
                                        "</div>" +
                                        "</li>";
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }
                    Response.Write(messages);
                }
                else if (Request.QueryString["op"] == "fblike")
                {
                    try
                    {
                        //System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
                        //string line = "";
                        //line = sr.ReadToEnd();
                        //JObject jo = JObject.Parse(line);
                        //string accesstoken = Server.UrlDecode((string)jo["access"]);
                        //string id = Server.UrlDecode((string)jo["fbid"]);
                        string profileid = Request.QueryString["profileid"];
                        FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                        FacebookAccount fbAccount = fbAccRepo.getFacebookAccountDetailsById(profileid, user.Id);
                        string id = Request.QueryString["fbid"];
                        FacebookClient fbClient = new FacebookClient(fbAccount.AccessToken);
                        var s = fbClient.Post(id + "/likes",null);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                }
                else if (Request.QueryString["op"] == "fbcomment")
                {
                    string profileid = Request.QueryString["profileid"];
                    string message = Request.QueryString["message"];
                    FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                    FacebookAccount fbAccount = fbAccRepo.getFacebookAccountDetailsById(profileid, user.Id);
                    string id = Request.QueryString["fbid"];
                    FacebookClient fbClient = new FacebookClient(fbAccount.AccessToken);
                    var args = new Dictionary<string, object>();
                    args["message"] = message;
                    var s = fbClient.Post(id+"/comments",args);

                }
                else if (Request.QueryString["op"] == "twitternetworkdetails")
                {
                    string messages = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    TwitterFeedRepository fbmsgrepo = new TwitterFeedRepository();
                    List<TwitterFeed> lsgfbmsgs = fbmsgrepo.getTwitterFeedOfProfile(profileid);
                    UrlExtractor urlext = new UrlExtractor();
                    foreach (TwitterFeed item in lsgfbmsgs)
                    {
                        try
                        {
                            messages += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + item.FromProfileUrl + "\" onclick=\"detailsprofile('" + item.FromId + "');\">" +
                                                         "</div><div class=\"pull-left feedcontent\">" +
                                                            "<a href=\"#\" class=\"feednm\" onclick=\"detailsprofile('" + item.FromId + "');\">" + item.FromName + "</a> <span>" + item.FeedDate +
                                                                " </span>" +
                                                             "<p>";

                            string[] str = urlext.splitUrlFromString(item.Feed);

                            foreach (string substritem in str)
                            {
                                if (!string.IsNullOrEmpty(substritem))
                                {
                                    if (substritem.Contains("http"))
                                    {
                                        messages += "<a target=\"_blank\" href=\"" + substritem + "\">" + substritem + "</a>";
                                    }
                                    else
                                    {
                                        messages += substritem;
                                    }
                                }
                            }

                            messages += "</p>" +
                                   "<a class=\"retweets\" href=\"#\">" +
                                /*"<img alt=\"\" src=\"../contents/img/admin/arrow.png\">*/"</a><span></span>" +
                               "</div>" +
                           "</li>";
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }
                    Response.Write(messages);

                }
                else if (Request.QueryString["op"] == "scheduler")
                {
                    #region Schduler
                    string message = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    string network = Request.QueryString["network"];

                    if (network == "facebook")
                    {
                        ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository();
                        List<ScheduledMessage> lstschmsg = schmsgrepo.getAllMessagesOfUser(user.Id, profileid);

                        if (lstschmsg.Count != 0)
                        {
                            foreach (ScheduledMessage item in lstschmsg)
                            {
                                FacebookAccountRepository faceaccrepo = new FacebookAccountRepository();
                                FacebookAccount faceacc = faceaccrepo.getFacebookAccountDetailsById(profileid, user.Id);
                                try
                                {
                                    message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                 "</div><div class=\"pull-left feedcontent\">" +
                                                                    "<a href=\"#\" class=\"feednm\">" + faceacc.FbUserName + "</a> <span>" + item.ScheduleTime +
                                                                        " </span>" +
                                                                     "<p>" + item.ShareMessage + "</p>" +
                                                                     "<a class=\"retweets\" href=\"#\">" +
                                                                      "</a><span></span>" +
                                                                 "</div>" +
                                                             "</li>";
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

                            }
                        }
                        else
                        {
                            message = "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                    "</div><div class=\"pull-left feedcontent\">" +
                                                                       "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                           " </span>" +
                                                                        "<p>No Scheduled Messages</p>" +
                                                                        "<a class=\"retweets\" href=\"#\">" +
                                                                         "</a><span></span>" +
                                                                    "</div>" +
                                                                "</li>";
                        }

                    }
                    else if (network == "twitter")
                    {
                        ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository();
                        List<ScheduledMessage> lstschmsg = schmsgrepo.getAllMessagesOfUser(user.Id, profileid);

                        if (lstschmsg.Count != 0)
                        {
                            foreach (ScheduledMessage item in lstschmsg)
                            {
                                TwitterAccountRepository twtaccrepo = new TwitterAccountRepository();
                                TwitterAccount twtacc = twtaccrepo.getUserInformation(user.Id, profileid);
                                message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                "</div><div class=\"pull-left feedcontent\">" +
                                                                   "<a href=\"#\" class=\"feednm\">" + twtacc.TwitterScreenName + "</a> <span>" + item.ScheduleTime +
                                                                       " </span>" +
                                                                    "<p>" + item.ShareMessage + "</p>" +
                                                                    "<a class=\"retweets\" href=\"#\">" +
                                                                     "</a><span></span>" +
                                                                "</div>" +
                                                            "</li>";
                            }
                        }
                        else
                        {
                            message = "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                  "</div><div class=\"pull-left feedcontent\">" +
                                                                     "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                         " </span>" +
                                                                      "<p>No Scheduled Messages</p>" +
                                                                      "<a class=\"retweets\" href=\"#\">" +
                                                                       "</a><span></span>" +
                                                                  "</div>" +
                                                              "</li>";
                        }
                    }
                    else if (network == "linkedin")
                    {
                        ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository();
                        List<ScheduledMessage> lstschmsg = schmsgrepo.getAllMessagesOfUser(user.Id, profileid);

                        if (lstschmsg.Count != 0)
                        {
                            foreach (ScheduledMessage item in lstschmsg)
                            {
                                LinkedInAccountRepository linkedinrepo = new LinkedInAccountRepository();
                                LinkedInAccount linkedacc = linkedinrepo.getUserInformation(user.Id, profileid);
                                message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                    "</div><div class=\"pull-left feedcontent\">" +
                                                                       "<a href=\"#\" class=\"feednm\">" + linkedacc.LinkedinUserName + "</a> <span>" + item.ScheduleTime +
                                                                           " </span>" +
                                                                        "<p>" + item.ShareMessage + "</p>" +
                                                                        "<a class=\"retweets\" href=\"#\">" +
                                                                         "</a><span></span>" +
                                                                    "</div>" +
                                                                "</li>";
                            }
                        }
                        else
                        {
                            message = "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                 "</div><div class=\"pull-left feedcontent\">" +
                                                                    "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                        " </span>" +
                                                                     "<p>No Scheduled Messages</p>" +
                                                                     "<a class=\"retweets\" href=\"#\">" +
                                                                      "</a><span></span>" +
                                                                 "</div>" +
                                                             "</li>";

                        }

                    }

                    Response.Write(message);
                    #endregion
                }
                else if (Request.QueryString["op"] == "facebookfeeds")
                {
                    string message = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    FacebookAccountRepository faceaccrepo = new FacebookAccountRepository();
                    FacebookAccount faceaac = faceaccrepo.getFacebookAccountDetailsById(profileid, user.Id);
                    FacebookFeedRepository facefeedrepo = new FacebookFeedRepository();
                    List<FacebookFeed> lstfbfeed = facefeedrepo.getAllFacebookUserFeeds(profileid);
                    UrlExtractor urlext = new UrlExtractor();
                    foreach (FacebookFeed item in lstfbfeed)
                    {
                        message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"https://www.facebook.com/" + item.ProfileId + "/picture?type=small\" onclick=\"getFacebookProfiles('" + item.FromId + "');\">" +
                                                                 "</div><div class=\"pull-left feedcontent\">" +
                                                                    "<a href=\"#\" class=\"feednm\" onclick=\"getFacebookProfiles('" + item.FromId + "');\">" + faceaac.FbUserName + "</a> <span>" + item.FeedDate +
                                                                        " </span>" +
                                                                     "<p>";

                        string[] str = urlext.splitUrlFromString(item.FeedDescription);

                        foreach (string substritem in str)
                        {
                            if (!string.IsNullOrEmpty(substritem))
                            {
                                if (substritem.Contains("http"))
                                {
                                    message += "<a target=\"_blank\" href=\"" + substritem + "\">" + substritem + "</a>";
                                }
                                else
                                {
                                    message += substritem;
                                }
                            }
                        }

                        message += "</p>" +
                                     "<a class=\"retweets\" href=\"#\">" +
                                      "</a><span></span>" +
                                 "</div>" +
                             "</li>";
                    }
                    Response.Write(message);
                }
                else if (Request.QueryString["op"] == "twitterfeeds")
                {
                    string message = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    TwitterMessageRepository twtmsgreop = new TwitterMessageRepository();
                    List<TwitterMessage> lstmsg = twtmsgreop.getAllTwitterMessagesOfProfile(profileid);
                    //TwitterFeedRepository twtmsgrepo = new TwitterFeedRepository();
                    //List<TwitterFeed>  lstfeed =  twtmsgrepo.getTwitterFeedOfProfile(profileid);
                    UrlExtractor urlext = new UrlExtractor();
                    foreach (TwitterMessage item in lstmsg)
                    {
                        try
                        {
                            message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + item.FromProfileUrl + "\" onclick=\"detailsprofile('" + item.FromId + "');\">" +
                                                         "</div><div class=\"pull-left feedcontent\">" +
                                                            "<a href=\"#\" class=\"feednm\" onclick=\"detailsprofile('" + item.FromId + "');\">" + item.FromName + "</a> <span>" + item.MessageDate +
                                                                " </span>" +
                                                             "<p>";

                            string[] str = urlext.splitUrlFromString(item.TwitterMsg);

                            foreach (string substritem in str)
                            {
                                if (!string.IsNullOrEmpty(substritem))
                                {
                                    if (substritem.Contains("http"))
                                    {
                                        message += "<a target=\"_blank\" href=\"" + substritem + "\">" + substritem + "</a>";
                                    }
                                    else
                                    {
                                        message += substritem;
                                    }
                                }
                            }
                            message += "</p>" +
                                                              "<a class=\"retweets\" href=\"#\">" +
                                /*"<img alt=\"\" src=\"../Contents/img/admin/arrow.png\">*/"</a><span></span>" +
                                                          "</div>" +
                                                      "</li>";
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }
                    Response.Write(message);
                }
                else if (Request.QueryString["op"] == "linkedinwallposts")
                {
                    string message = string.Empty;
                    string profileid = Request.QueryString["profileid"];

                    LinkedInFeedRepository linkedinfeedrepo = new LinkedInFeedRepository();
                    List<LinkedInFeed> lstfeed = linkedinfeedrepo.getAllLinkedInFeedsOfProfile(profileid);

                    if (lstfeed != null)
                    {
                        if (lstfeed.Count != 0)
                        {
                            foreach (LinkedInFeed item in lstfeed)
                            {
                                message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + item.FromPicUrl + "\">" +
                                                               "</div><div class=\"pull-left feedcontent\">" +
                                                                  "<a href=\"#\" class=\"feednm\">" + item.FromName + "</a> <span>" + item.FeedsDate +
                                                                      " </span>" +
                                                                   "<p>" + item.Feeds + "</p>" +
                                                                   "<a class=\"retweets\" href=\"#\">" +
                                                                   "</a><span></span>" +
                                                               "</div>" +
                                                           "</li>";
                            }
                        }
                        else
                        {
                            message = "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                   "</div><div class=\"pull-left feedcontent\">" +
                                                                      "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                          " </span>" +
                                                                       "<p>No Messages Found</p>" +
                                                                       "<a class=\"retweets\" href=\"#\">" +
                                                                        "</a><span></span>" +
                                                                   "</div>" +
                                                               "</li>";
                        }
                    }
                    Response.Write(message);

                }
                else if (Request.QueryString["op"] == "linkedinfeeds")
                {
                    string profileid = Request.QueryString["profileid"];
                    LinkedInAccountRepository linkedinAccRepo = new LinkedInAccountRepository();
                    LinkedInAccount linkacc = linkedinAccRepo.getUserInformation(user.Id, profileid);
                    oAuthLinkedIn oauthlin = new oAuthLinkedIn();
                    oauthlin.ConsumerKey = ConfigurationManager.AppSettings["LiApiKey"];
                    oauthlin.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"];
                    oauthlin.FirstName = linkacc.LinkedinUserName;
                    oauthlin.Id = linkacc.LinkedinUserId;
                    oauthlin.Token = linkacc.OAuthToken;
                    oauthlin.TokenSecret = linkacc.OAuthSecret;
                    oauthlin.Verifier = linkacc.OAuthVerifier;

                    LinkedInUser l = new LinkedInUser();
                    List<LinkedInUser.User_Updates> lst = l.GetUserUpdates(oauthlin, linkacc.LinkedinUserId, 10);
                    string message = string.Empty;
                    if (lst.Count != 0)
                    {
                        foreach (LinkedInUser.User_Updates item in lst)
                        {
                            try
                            {
                                string picurl = string.Empty;
                                if (string.IsNullOrEmpty(item.PictureUrl))
                                {
                                    picurl = "../Contents/img/blank_img.png";
                                }
                                else
                                {
                                    picurl = item.PictureUrl;
                                }
                                message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + picurl + "\">" +
                                                                       "</div><div class=\"pull-left feedcontent\">" +
                                                                          "<a href=\"#\" class=\"feednm\">" + item.PersonFirstName + " " + item.PersonLastName + "</a> <span>" + item.DateTime +
                                                                              " </span>" +
                                                                           "<p>" + item.Message + "</p>" +
                                                                           "<a class=\"retweets\" href=\"#\">" +
                                                                           "</a><span></span>" +
                                                                       "</div>" +
                                                                   "</li>";
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                            }

                        }
                    }
                    else
                    {
                        message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                                             "</div><div class=\"pull-left feedcontent\">" +
                                                                                                "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                                                    " </span>" +
                                                                                                 "<p>No Messages Found</p>" +
                                                                                                 "<a class=\"retweets\" href=\"#\">" +
                                                                                                  "</a><span></span>" +
                                                                                             "</div>" +
                                                                                         "</li>";
                    }
                    Response.Write(message);
                }
                else if (Request.QueryString["op"] == "facebookapi")
                {
                    try
                    {
                        string profileid = Request.QueryString["profileid"];
                        FacebookAccountRepository facerepo = new FacebookAccountRepository();
                        FacebookAccount faceaccount = facerepo.getFacebookAccountDetailsById(profileid, user.Id);
                        FacebookHelper fbhelper = new FacebookHelper();
                        FacebookClient fbclient = new FacebookClient(faceaccount.AccessToken);
                        dynamic profile = fbclient.Get("me");
                        var feeds = fbclient.Get("/me/feed");
                        var home = fbclient.Get("me/home");
                        fbhelper.getFacebookUserFeeds(feeds, profile);
                        fbhelper.getFacebookUserHome(home, profile);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                    }
                }
                else if (Request.QueryString["op"] == "twitterapi")
                {
                    string profileid = Request.QueryString["profileid"];
                    TwitterAccountRepository twtAccountRepo = new TwitterAccountRepository();
                    TwitterAccount twtAccount = twtAccountRepo.getUserInformation(user.Id, profileid);
                    oAuthTwitter oAuth = new oAuthTwitter();
                    TwitterHelper twthelper = new TwitterHelper();
                    oAuth.AccessToken = twtAccount.OAuthToken;
                    oAuth.AccessTokenSecret = twtAccount.OAuthSecret;
                    twthelper.SetCofigDetailsForTwitter(oAuth);
                    oAuth.TwitterScreenName = twtAccount.TwitterScreenName;
                    oAuth.TwitterUserId = twtAccount.TwitterUserId;
                    twthelper.getUserTweets(oAuth, twtAccount, user.Id);
                    twthelper.getUserFeed(oAuth, twtAccount, user.Id);
                    twthelper.getSentDirectMessages(oAuth, twtAccount, user.Id);
                    twthelper.getReTweetsOfUser(oAuth, twtAccount, user.Id);

                }
                else if (Request.QueryString["op"] == "instagramlike")
                {
                    string mediaid = Request.QueryString["mediaid"];
                    bool b = this.likefunction(mediaid, Request.QueryString["userid"], Request.QueryString["access"]);
                }
                else if (Request.QueryString["op"] == "instagramunlike")
                {
                    string mediaid = Request.QueryString["mediaid"];
                    bool b = this.unlikefunction(mediaid, Request.QueryString["userid"], Request.QueryString["access"]);

                }
                else if (Request.QueryString["op"] == "instagramimages")
                {
                    if (Request.QueryString["loadtime"] != "first")
                    {
                        instagramcount = instagramcount + 10;
                    }
                    else
                    {
                        instagramcount = 0;
                    }

                    InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository();
                    InstagramFeedRepository objInsFeedRepo = new InstagramFeedRepository();
                    InstagramFeed objInsFeed = new InstagramFeed();
                    InstagramCommentRepository objInsCmtRepo = new InstagramCommentRepository();
                    List<SocioBoard.Domain.InstagramComment> lstInsCmt = new List<SocioBoard.Domain.InstagramComment>();

                    string strInsImage = string.Empty;

                    try
                    {
                        string profileid = Request.QueryString["profileid"];
                        InstagramAccount insaccount = objInsAccRepo.getInstagramAccountDetailsById(profileid, user.Id);
                        List<InstagramFeed> lstInsFeed = objInsFeedRepo.getAllInstagramFeedsOfUser(user.Id, profileid, instagramcount);
                        if (lstInsFeed.Count != 0)
                        {
                            strInsImage += "<div class=\"feedcontainer\">";
                            foreach (InstagramFeed feed in lstInsFeed)
                            {

                                try
                                {
                                    lstInsCmt = objInsCmtRepo.getAllInstagramCommentsOfUser(user.Id, profileid, feed.FeedId);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                    Console.WriteLine(ex.Message);
                                }
                                try
                                {
                                    strInsImage += "<div class=\"span3\" class=\"row-fluid\"><div class=\"span12 box whitebg feedwrap\"><div class=\"topicon\"><div class=\"pull-left\">" +

                                                                    "</div><div class=\"pull-right\" id=\"like\"><a title=\"\" href=\"#\" onClick=\"insUser('" + feed.FeedId + "','" + insaccount.AccessToken + "')\" ><img id=\"heartEmpty_" + feed.FeedId + "\" width=\"14\" alt=\"\" src=\"../Contents/img/admin/heart-empty.png\"  style=\"margin-top: 9px;\"></a><a title=\"\" href=\"#\"><img width=\"14\" alt=\"\" src=\"../Contents/img/admin/speech-bubble-left.png\"  style=\"margin-top: 9px;\"></a>" +
                                                                    "</div></div><div class=\"pic\"><img alt=\"\" src=\"" + feed.FeedImageUrl + "\"></div><div class=\"desc\"><p></p><span class=\"pull-left span3\">" +
                                                                    "<img width=\"12\" alt=\"\" src=\"../Contents/img/admin/heart-empty.png\"> " + feed.LikeCount + "</span><span class=\"pull-left span3\"><img width=\"12\" alt=\"\" src=\"../Contents/img/admin/speech-bubble-left.png\"> "+ lstInsCmt.Count +"</span><div class=\"clearfix\"></div>";

                                    foreach (InstagramComment insCmt in lstInsCmt)
                                    {
                                        try
                                        {
                                            strInsImage += "<div class=\"userprof\"><div class=\"pull-left\"><a href=\"#\">" +
                                              "<img width=\"36\" alt=\"\" src=\"" + insCmt.FromProfilePic + "\"></a></div><div class=\"pull-left descr\"><p>" + insCmt.Comment + "</p>" +
                                               "<span class=\"usert\">" + DateExtension.ToDateTime(DateTime.Now, (long)Convert.ToDouble(insCmt.CommentDate)) + "</span></div></div>";

                                        }
                                        catch (Exception ex)
                                        {
                                            logger.Error(ex.Message);
                                            Console.WriteLine(ex.Message);
                                        }

                                    }

                                    strInsImage += "</div></div></div>";
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                    Console.WriteLine(ex.Message);
                                }
                            }
                            strInsImage += "</div>";
                        }
                        else
                        {
                            if (instagramcount == 0)
                            {
                                strInsImage = "<div class=\"grid\"><div class=\"box whitebg feedwrap\">" +
                                             "<div class=\"topicon\"><div class=\"pull-left\"></div><div class=\"pull-right\">" +
                                 "<a href=\"#\" title=\"\"></a><a href=\"#\" title=\"\"></a></div></div><div class=\"pic\">" +
                                 "<img src=\"../Contents/img/no_image_found.png\" alt=\"\"></div><div class=\"desc\"><p></p></div></div></div>";
                            }
                        }

                        Response.Write(strInsImage);

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

                }
                else if (Request.QueryString["op"] == "instagramApi")
                {
                    try
                    {
                        InstagramManager insManager = new InstagramManager();
                        string profileid = Request.QueryString["profileid"];
                        InstagramAccountRepository insAccRepo = new InstagramAccountRepository();
                        InstagramAccount instagramAccount = insAccRepo.getInstagramAccountDetailsById(profileid, user.Id);
                        insManager.getIntagramImages(instagramAccount);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                    }
                }

            }
        }
Esempio n. 6
0
        public void ProcessRequest()
        {
            SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
            TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
            TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
            FacebookAccountRepository facerepo = new FacebookAccountRepository();
            LinkedInAccountRepository linkaccrepo = new LinkedInAccountRepository();
            InstagramAccountRepository insaccrepo = new InstagramAccountRepository();
            TumblrAccountRepository tumblraccrepo = new TumblrAccountRepository();
            TumblrFeedRepository objTumblrFeedRepository = new TumblrFeedRepository();
            YoutubeAccountRepository ytaccrepo = new YoutubeAccountRepository();
            YoutubeChannelRepository ytrchannelrpo = new YoutubeChannelRepository();


            if (!string.IsNullOrEmpty(Request.QueryString["op"]))
            {
                SocioBoard.Domain.User user = (SocioBoard.Domain.User)Session["LoggedUser"];
                if (Request.QueryString["op"] == "networkprofiles")
                {
                    #region NetworkProfiles
                    string profiles = string.Empty;
                    List<TeamMemberProfile> allprofiles = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id);

                    int facebookcount = 0;
                    int twittercount = 0;
                    int linkedincount = 0;
                    int instagramcount = 0;
                    int tumblrcount = 0;
                    int youtubecount = 0;
                    int totalcounts = 0;

                    foreach (TeamMemberProfile items in allprofiles)
                    {
                        totalcounts++;

                        if (Request.QueryString["network"] == "facebook")
                        {

                            if (items.ProfileType == "facebook")
                            {
                                facebookcount++;
                                FacebookAccount faceaccount = facerepo.getFacebookAccountDetailsById(items.ProfileId);
                                if (faceaccount.Type != "page")
                                {
                                    profiles += "<li><a id=\"lifb_" + faceaccount.FbUserId + "\" href=\"#\" onclick=\"facebookdetails('" + faceaccount.FbUserId + "');\" class=\"active\">" + faceaccount.FbUserName + "</a> </li>";
                                }
                            }
                            if (totalcounts == allprofiles.Count)
                            {
                                if (facebookcount == 0)
                                { profiles = "<li>No Records Found !</li>"; }

                            }

                        }

                        else if (Request.QueryString["network"] == "twitter")
                        {
                            if (items.ProfileType == "twitter")
                            {
                                twittercount++;
                                TwitterAccount twtaccount = twtaccountrepo.getUserInformation(items.ProfileId);

                                profiles += "<li><a id=\"litwt_" + twtaccount.TwitterUserId + "\" href=\"#\" onclick=\"twitterdetails('" + twtaccount.TwitterUserId + "');\" class=\"active\">" + twtaccount.TwitterScreenName + "</a> </li>";
                            }
                            if (totalcounts == allprofiles.Count)
                            {
                                if (twittercount == 0)
                                { profiles = "<li>No Records Found !</li>"; }

                            }

                        }

                        else if (Request.QueryString["network"] == "linkedin")
                        {
                            if (items.ProfileType == "linkedin")
                            {
                                linkedincount++;
                                LinkedInAccount linkedinaccount = linkaccrepo.getLinkedinAccountDetailsById(items.ProfileId);

                                profiles += "<li><a id=\"lilin_" + linkedinaccount.LinkedinUserId + "\" href=\"#\" onclick=\"linkedindetails('" + linkedinaccount.LinkedinUserId + "');\" class=\"active\">" + linkedinaccount.LinkedinUserName + "</a> </li>";
                            }
                            if (totalcounts == allprofiles.Count)
                            {
                                if (linkedincount == 0)
                                { profiles = "<li>No Records Found !</li>"; }

                            }


                        }

                        else if (Request.QueryString["network"] == "tumblr")
                        {
                            if (items.ProfileType == "tumblr")
                            {
                                tumblrcount++;
                                TumblrAccount tumblraccount = tumblraccrepo.getTumblrAccountDetailsById(items.ProfileId);

                                profiles += "<li><a id=\"lilin_" + tumblraccount.tblrUserName + "\" href=\"#\" onclick=\"tumblrdetails('" + tumblraccount.tblrUserName + "');\" class=\"active\">" + tumblraccount.tblrUserName + "</a> </li>";
                            }
                            if (totalcounts == allprofiles.Count)
                            {
                                if (tumblrcount == 0)
                                { profiles = "<li>No Records Found !</li>"; }

                            }
                        }


                        else if (Request.QueryString["network"] == "youtube")
                        {
                            if (items.ProfileType == "youtube")
                            {
                                youtubecount++;
                                YoutubeAccount youtubeaccount = ytaccrepo.getYoutubeAccountDetailsById(items.ProfileId);

                                profiles += "<li><a id=\"lilin_" + youtubeaccount.Ytusername + "\" href=\"#\" onclick=\"youtubedetails('" + youtubeaccount.Ytuserid + "','" + youtubeaccount.Refreshtoken + "');\" class=\"active\">" + youtubeaccount.Ytusername + "</a> </li>";
                            }
                            if (totalcounts == allprofiles.Count)
                            {
                                if (youtubecount == 0)
                                { profiles = "<li>No Records Found !</li>"; }

                            }
                        }





                        else if (Request.QueryString["network"] == "instagram")
                        {
                            if (items.ProfileType == "instagram")
                            {
                                instagramcount++;
                                InstagramAccount alstinstagram = insaccrepo.getInstagramAccountDetailsById(items.ProfileId);

                                profiles += "<li><a id=\"liins_" + alstinstagram.InstagramId + "\" href=\"#\" onclick=\"Instagramdetails('" + alstinstagram.InstagramId + "');\" class=\"active\">" + alstinstagram.InsUserName + "</a> </li>";
                            }
                            if (totalcounts == allprofiles.Count)
                            {
                                if (instagramcount == 0)
                                { profiles = "<li>No Records Found !</li>"; }
                            }
                        }

                    }

                    Response.Write(profiles);
                    #endregion
                }


                else if (Request.QueryString["op"] == "facebookwallposts")
                {
                    #region facebookwallposts
                    string messages = string.Empty;
                    string profileid = string.Empty;
                    string load = Request.QueryString["load"];
                    //Session[""] = profileid;
                    if (load == "first")
                    {
                        profileid = Request.QueryString["profileid"];
                        Session["FacebookProfileIdForFeeds"] = profileid;
                        facebookwallcount = 0;
                    }
                    else
                    {
                        profileid = (string)Session["FacebookProfileIdForFeeds"];
                        facebookwallcount = facebookwallcount + 10;
                    }


                    FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository();
                    FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();

                    List<FacebookMessage> lsgfbmsgs = fbmsgrepo.getAllWallpostsOfProfile(profileid, facebookwallcount);

                    UrlExtractor urlext = new UrlExtractor();
                    foreach (FacebookMessage item in lsgfbmsgs)
                    {
                        try
                        {

                            string[] str = urlext.splitUrlFromString(item.Message);
                            messages += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + item.FromProfileUrl + "\" onclick=\"getFacebookProfiles('" + item.FromId + "');\">" +
                                                         "</div><div class=\"pull-left feedcontent\">" +
                                //"<a href=\"#\" class=\"feednm\" onclick=\"getFacebookProfiles('" + item.FromId + "');\">" + item.FromName + "</a> <span>" + item.MessageDate +
                                                            "<a target=\"_blank\" href=\"http://www.facebook.com/" + item.FromId + "\" class=\"feednm\">" + item.FromName + "</a> <span>" + item.MessageDate +
                                                                " </span>" +
                                                             "<p>";

                            if (!string.IsNullOrEmpty(item.Picture))
                            {
                                //string largeimage = item.Picture.Replace("_s.jpg","_n.jpg");

                                messages += "<img src=\"" + item.Picture + "\" alt=\"\" onclick=\"fbimage('" + item.Picture + "');\" /><br/>";
                            }

                            foreach (string substritem in str)
                            {
                                try
                                {
                                    if (!string.IsNullOrEmpty(substritem))
                                    {
                                        if (substritem.Contains("http"))
                                        {
                                            messages += "<a target=\"_blank\" href=\"" + substritem + "\">" + substritem + "</a>";
                                        }
                                        else
                                        {
                                            string hrefPost = string.Empty;

                                            try
                                            {
                                                hrefPost = "https://www.facebook.com/" + item.FromId + "/posts/" + item.MessageId.Replace(item.FromId, string.Empty).Replace("_", string.Empty).Trim();

                                            }
                                            catch (Exception ex)
                                            {
                                                Console.WriteLine("Error : " + ex.StackTrace);

                                            }
                                            if (!string.IsNullOrEmpty(hrefPost))
                                            {
                                                messages += "<a target=\"_blank\" href=\"" + hrefPost + "\">" + substritem + "</a>";//substritem;
                                            }
                                            else
                                            {
                                                messages += substritem;

                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine("Error : " + ex.StackTrace);

                                }
                            }

                            //    messages += "</p>" +
                            //                "<a class=\"retweets\" href=\"#\">" +
                            //                "</a><p><span onclick=\"facebookLike('" + item.FbLike + "','" + profileid + "','" + item.MessageId + "')\" id=\"likefb_" + item.MessageId + "\" class=\"like\">Like</span><span id=\"commentfb_" + item.MessageId + "\" onclick=\"commentText('" + item.MessageId + "');\" class=\"comment\">Comment</span></p>" +
                            //                "<p class=\"commeent_box\"><input id=\"textfb_" + item.MessageId + "\" type=\"text\" class=\"put_comments\"></p>" +
                            //              "<p><span onclick=\"commentFB('" + item.MessageId + "','" + profileid + "')\" id=\"okfb_" + item.MessageId + "\" class=\"ok\">ok</span><span id=\"cancelfb_" + item.MessageId + "\" onclick=\"cancelFB('" + item.MessageId + "');\" class=\"cancel\"> cancel</span></p>" +
                            //                "</div>" +
                            //                "</li>";
                            //}



                            //messages += "</p>" +
                            //           "<a class=\"retweets\" href=\"#\">" +
                            //           "</a><p><span onclick=\"facebookShare('" + profileid + "','" + item.MessageId + "')\" id=\"likefb_" + item.MessageId + "\" class=\"like\">Share</span><span onclick=\"facebookLike('" + item.FbLike + "','" + profileid + "','" + item.MessageId + "')\" id=\"likefb_" + item.MessageId + "\" class=\"like\">Like</span><span id=\"commentfb_" + item.MessageId + "\" onclick=\"commentText('" + item.MessageId + "');\" class=\"comment\">Comment</span></p>" +
                            //           "<p class=\"commeent_box\"><input id=\"textfb_" + item.MessageId + "\" type=\"text\" class=\"put_comments\"></p>" +
                            //         "<p><span onclick=\"commentFB('" + item.MessageId + "','" + profileid + "')\" id=\"okfb_" + item.MessageId + "\" class=\"ok\">ok</span><span id=\"cancelfb_" + item.MessageId + "\" onclick=\"cancelFB('" + item.MessageId + "');\" class=\"cancel\"> cancel</span></p>" +
                            //           "</div>" +
                            //           "</li>";

                            messages += "</p>" +
                                     "<a class=\"retweets\" href=\"#\">" +
                                     "</a><p><span onclick=\"facebookLike('" + item.FbLike + "','" + profileid + "','" + item.MessageId + "')\" id=\"likefb_" + item.MessageId + "\" class=\"like\">Like</span><span id=\"commentfb_" + item.MessageId + "\" onclick=\"commentText('" + item.MessageId + "');\" class=\"comment\">Comment</span></p>" +
                                     "<p class=\"commeent_box\"><input id=\"textfb_" + item.MessageId + "\" type=\"text\" class=\"put_comments\"></p>" +
                                   "<p><span onclick=\"commentFB('" + item.MessageId + "','" + profileid + "')\" id=\"okfb_" + item.MessageId + "\" class=\"ok\">ok</span><span id=\"cancelfb_" + item.MessageId + "\" onclick=\"cancelFB('" + item.MessageId + "');\" class=\"cancel\"> cancel</span></p>" +
                                     "</div>" +
                                     "</li>";
                        }




                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }
                    Response.Write(messages);
                    #endregion
                }
                else if (Request.QueryString["op"] == "fblike")
                {
                    #region fblikes
                    try
                    {
                        //System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
                        //string line = "";
                        //line = sr.ReadToEnd();
                        //JObject jo = JObject.Parse(line);
                        //string accesstoken = Server.UrlDecode((string)jo["access"]);
                        //string id = Server.UrlDecode((string)jo["fbid"]);
                        string profileid = Request.QueryString["profileid"];
                        FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                        FacebookAccount fbAccount = fbAccRepo.getFacebookAccountDetailsById(profileid, user.Id);
                        string id = Request.QueryString["fbid"];
                        FacebookClient fbClient = new FacebookClient(fbAccount.AccessToken);
                        var s = fbClient.Post(id + "/likes", null);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                    #endregion
                }


                else if (Request.QueryString["op"] == "fbshare")
                {
                    try
                    {
                        string profileid = Request.QueryString["profileid"];
                        string id = Request.QueryString["msgid"];
                        FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                        FacebookAccount fbAccount = fbAccRepo.getFacebookAccountDetailsById(profileid);
                        FacebookClient fbClient = new FacebookClient(fbAccount.AccessToken);
                        var s = fbClient.Post(id + "/sharedposts", null);

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }



                else if (Request.QueryString["op"] == "fbcomment")
                {
                    #region fbcomment
                    string profileid = Request.QueryString["profileid"];
                    string message = Request.QueryString["message"];
                    FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                    FacebookAccount fbAccount = fbAccRepo.getFacebookAccountDetailsById(profileid, user.Id);
                    string id = Request.QueryString["fbid"];
                    FacebookClient fbClient = new FacebookClient(fbAccount.AccessToken);
                    var args = new Dictionary<string, object>();
                    args["message"] = message;
                    var s = fbClient.Post(id + "/comments", args);

                    #endregion
                }
                else if (Request.QueryString["op"] == "twitternetworkdetails")
                {
                    #region twitternetworkdetails
                    string messages = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    TwitterFeedRepository fbmsgrepo = new TwitterFeedRepository();
                    List<TwitterFeed> lsgfbmsgs = fbmsgrepo.getTwitterFeedOfProfile(profileid);
                    UrlExtractor urlext = new UrlExtractor();
                    foreach (TwitterFeed item in lsgfbmsgs)
                    {
                        try
                        {
                            messages += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + item.FromProfileUrl + "\" onclick=\"detailsdiscoverytwitter('" + item.FromId + "');\">" +
                                                         "</div><div class=\"pull-left feedcontent\">" +
                                                            "<a href=\"#\" class=\"feednm\" onclick=\"detailsdiscoverytwitter('" + item.FromId + "');\">" + item.FromName + "</a> <span>" + item.FeedDate +
                                                                " </span>" +
                                                             "<p>";

                            string[] str = urlext.splitUrlFromString(item.Feed);

                            foreach (string substritem in str)
                            {
                                try
                                {
                                    if (!string.IsNullOrEmpty(substritem))
                                    {
                                        if (substritem.Contains("http"))
                                        {
                                            messages += "<a target=\"_blank\" href=\"" + substritem + "\">" + substritem + "</a>";
                                        }
                                        else
                                        {
                                            string hrefPost = string.Empty;

                                            try
                                            {
                                                //https://twitter.com/265982289/status/431552741341941760
                                                hrefPost = "https://twitter.com/" + item.FromId + "/status/" + item.MessageId.Replace(item.FromId, string.Empty).Replace("_", string.Empty).Trim();

                                            }
                                            catch (Exception ex)
                                            {
                                                Console.WriteLine("Error : " + ex.StackTrace);

                                            }
                                            if (!string.IsNullOrEmpty(hrefPost))
                                            {
                                                messages += "<a target=\"_blank\" href=\"" + hrefPost + "\">" + substritem + "</a>";//substritem;
                                            }
                                            else
                                            {
                                                messages += substritem;

                                            }
                                        }
                                    }
                                }
                                catch (Exception)
                                {

                                }
                            }

                            messages += "</p>" +
                                   "<a class=\"retweets\" href=\"#\">" +
                                /*"<img alt=\"\" src=\"../contents/img/admin/arrow.png\">*/"</a><span></span>" +
                               "</div>" +
                           "</li>";
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }
                    Response.Write(messages);
                    #endregion
                }
                else if (Request.QueryString["op"] == "scheduler")
                {
                    #region Schduler
                    string message = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    string network = Request.QueryString["network"];

                    if (network == "facebook")
                    {
                        ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository();
                        List<ScheduledMessage> lstschmsg = schmsgrepo.getAllMessagesOfUser(profileid);

                        if (lstschmsg.Count != 0)
                        {
                            foreach (ScheduledMessage item in lstschmsg)
                            {
                                try
                                {
                                    FacebookAccountRepository faceaccrepo = new FacebookAccountRepository();
                                    FacebookAccount faceacc = faceaccrepo.getFacebookAccountDetailsById(profileid);
                                    try
                                    {
                                        message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\"  src=\"https://graph.facebook.com/" + item.ProfileId + "/picture?type=small\">" +
                                                                     "</div><div class=\"pull-left feedcontent\">" +
                                                                        "<a href=\"#\" class=\"feednm\">" + faceacc.FbUserName + "</a> <span>" + item.ScheduleTime +
                                                                            " </span>" +
                                                                         "<p>" + item.ShareMessage + "</p>" +
                                                                         "<a class=\"retweets\" href=\"#\">" +
                                                                          "</a><span></span>" +
                                                                     "</div>" +
                                                                 "</li>";
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

                            }
                        }
                        else
                        {
                            message = "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                    "</div><div class=\"pull-left feedcontent\">" +
                                                                       "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                           " </span>" +
                                                                        "<p>No Scheduled Messages</p>" +
                                                                        "<a class=\"retweets\" href=\"#\">" +
                                                                         "</a><span></span>" +
                                                                    "</div>" +
                                                                "</li>";
                        }



                    }
                    else if (network == "twitter")
                    {
                        ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository();
                        List<ScheduledMessage> lstschmsg = schmsgrepo.getAllMessagesOfUser(profileid);

                        if (lstschmsg.Count != 0)
                        {
                            foreach (ScheduledMessage item in lstschmsg)
                            {
                                try
                                {
                                    TwitterAccountRepository twtaccrepo = new TwitterAccountRepository();
                                    TwitterAccount twtacc = twtaccrepo.getUserInformation(profileid);
                                    message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\"  src=\"" + twtacc.ProfileImageUrl + "\">" +
                                                                    "</div><div class=\"pull-left feedcontent\">" +
                                                                       "<a href=\"#\" class=\"feednm\">" + twtacc.TwitterScreenName + "</a> <span>" + item.ScheduleTime +
                                                                           " </span>" +
                                                                        "<p>" + item.ShareMessage + "</p>" +
                                                                        "<a class=\"retweets\" href=\"#\">" +
                                                                         "</a><span></span>" +
                                                                    "</div>" +
                                                                "</li>";
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }
                            }
                        }
                        else
                        {
                            message = "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                  "</div><div class=\"pull-left feedcontent\">" +
                                                                     "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                         " </span>" +
                                                                      "<p>No Scheduled Messages</p>" +
                                                                      "<a class=\"retweets\" href=\"#\">" +
                                                                       "</a><span></span>" +
                                                                  "</div>" +
                                                              "</li>";
                        }
                    }
                    else if (network == "linkedin")
                    {
                        ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository();
                        List<ScheduledMessage> lstschmsg = schmsgrepo.getAllMessagesOfUser(profileid);

                        if (lstschmsg.Count != 0)
                        {
                            foreach (ScheduledMessage item in lstschmsg)
                            {
                                try
                                {
                                    LinkedInAccountRepository linkedinrepo = new LinkedInAccountRepository();
                                    LinkedInAccount linkedacc = linkedinrepo.getUserInformation(profileid);
                                    message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\"  src=\"" + linkedacc.ProfileImageUrl + "\">" +
                                                                        "</div><div class=\"pull-left feedcontent\">" +
                                                                           "<a href=\"#\" class=\"feednm\">" + linkedacc.LinkedinUserName + "</a> <span>" + item.ScheduleTime +
                                                                               " </span>" +
                                                                            "<p>" + item.ShareMessage + "</p>" +
                                                                            "<a class=\"retweets\" href=\"#\">" +
                                                                             "</a><span></span>" +
                                                                        "</div>" +
                                                                    "</li>";
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine("Error : " + ex.StackTrace);

                                }
                            }
                        }
                        else
                        {
                            message = "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                 "</div><div class=\"pull-left feedcontent\">" +
                                                                    "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                        " </span>" +
                                                                     "<p>No Scheduled Messages</p>" +
                                                                     "<a class=\"retweets\" href=\"#\">" +
                                                                      "</a><span></span>" +
                                                                 "</div>" +
                                                             "</li>";

                        }

                    }




                    Response.Write(message);
                    #endregion
                }
                else if (Request.QueryString["op"] == "facebookfeeds")
                {
                    #region facebookfeeds
                    string message = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    FacebookAccountRepository faceaccrepo = new FacebookAccountRepository();
                    FacebookAccount faceaac = faceaccrepo.getFacebookAccountDetailsById(profileid);
                    FacebookFeedRepository facefeedrepo = new FacebookFeedRepository();
                    List<FacebookFeed> lstfbfeed = facefeedrepo.getAllFacebookUserFeeds(profileid);
                    UrlExtractor urlext = new UrlExtractor();
                    foreach (FacebookFeed item in lstfbfeed)
                    {
                        try
                        {
                            message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"https://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" onclick=\"getFacebookProfiles('" + item.FromId + "');\">" +
                                                                                     "</div><div class=\"pull-left feedcontent\">" +
                                                                                        "<a href=\"#\" class=\"feednm\" onclick=\"getFacebookProfiles('" + item.FromId + "');\">" + faceaac.FbUserName + "</a> <span>" + item.FeedDate +
                                                                                            " </span>" +
                                                                                         "<p>";

                            string[] str = urlext.splitUrlFromString(item.FeedDescription);

                            foreach (string substritem in str)
                            {
                                try
                                {
                                    if (!string.IsNullOrEmpty(substritem))
                                    {
                                        if (substritem.Contains("http"))
                                        {
                                            message += "<a target=\"_blank\" href=\"" + substritem + "\">" + substritem + "</a>";
                                        }
                                        else
                                        {
                                            string hrefPost = string.Empty;

                                            try
                                            {
                                                hrefPost = "https://www.facebook.com/" + item.FromId + "/posts/" + item.FeedId.Replace(item.FromId, string.Empty).Replace("_", string.Empty).Trim();

                                            }
                                            catch (Exception ex)
                                            {
                                                Console.WriteLine("Error : " + ex.StackTrace);

                                            }
                                            if (!string.IsNullOrEmpty(hrefPost))
                                            {
                                                message += "<a target=\"_blank\" href=\"" + hrefPost + "\">" + substritem + "</a>";//substritem;
                                            }
                                            else
                                            {
                                                message += substritem;

                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine("Error : " + ex.StackTrace);

                                }
                            }


                            message += "</p>" +
                                         "<a class=\"retweets\" href=\"#\">" +
                                          "</a><span></span>" +
                                     "</div>" +
                                 "</li>";
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error : " + ex.StackTrace);

                        }
                    }
                    Response.Write(message);
                    #endregion
                }
                else if (Request.QueryString["op"] == "twitterfeeds")
                {
                    #region twitternfeeds
                    string message = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    TwitterMessageRepository twtmsgreop = new TwitterMessageRepository();
                    List<TwitterMessage> lstmsg = twtmsgreop.getAllTwitterMessagesOfProfile(profileid);
                    //TwitterFeedRepository twtmsgrepo = new TwitterFeedRepository();
                    //List<TwitterFeed>  lstfeed =  twtmsgrepo.getTwitterFeedOfProfile(profileid);
                    UrlExtractor urlext = new UrlExtractor();
                    foreach (TwitterMessage item in lstmsg)
                    {
                        try
                        {
                            message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + item.FromProfileUrl + "\" onclick=\"detailsdiscoverytwitter('" + item.FromId + "');\">" +
                                                         "</div><div class=\"pull-left feedcontent\">" +
                                                            "<a href=\"#\" class=\"feednm\" onclick=\"detailsdiscoverytwitter('" + item.FromId + "');\">" + item.FromName + "</a> <span>" + item.MessageDate +
                                                                " </span>" +
                                                             "<p>";

                            string[] str = urlext.splitUrlFromString(item.TwitterMsg);

                            foreach (string substritem in str)
                            {
                                try
                                {
                                    if (!string.IsNullOrEmpty(substritem))
                                    {
                                        if (substritem.Contains("http"))
                                        {
                                            message += "<a target=\"_blank\" href=\"" + substritem + "\">" + substritem + "</a>";
                                        }
                                        else
                                        {
                                            string hrefPost = string.Empty;

                                            try
                                            {
                                                //https://twitter.com/265982289/status/431552741341941760

                                                hrefPost = "https://twitter.com/" + item.FromId + "/status/" + item.MessageId.Replace(item.FromId, string.Empty).Replace("_", string.Empty).Trim();

                                            }
                                            catch (Exception ex)
                                            {
                                                Console.WriteLine("Error : " + ex.StackTrace);

                                            }
                                            if (!string.IsNullOrEmpty(hrefPost))
                                            {
                                                message += "<a target=\"_blank\" href=\"" + hrefPost + "\">" + substritem + "</a>";//substritem;
                                            }
                                            else
                                            {
                                                message += substritem;

                                            }
                                        }
                                    }
                                }
                                catch (Exception)
                                {

                                }
                            }
                            message += "</p>" +
                                                              "<a class=\"retweets\" href=\"#\">" +
                                /*"<img alt=\"\" src=\"../Contents/img/admin/arrow.png\">*/"</a><span></span>" +
                                                          "</div>" +
                                                      "</li>";
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }
                    Response.Write(message);
                    #endregion
                }
                else if (Request.QueryString["op"] == "linkedinwallposts")
                {
                    #region linkedinwallposts
                    string message = string.Empty;
                    string profileid = Request.QueryString["profileid"];

                    LinkedInFeedRepository linkedinfeedrepo = new LinkedInFeedRepository();
                    List<LinkedInFeed> lstfeed = linkedinfeedrepo.getAllLinkedInFeedsOfProfile(profileid);





                    if (lstfeed != null)
                    {
                        if (lstfeed.Count != 0)
                        {
                            if (lstfeed.Count > 500)
                            {
                                int check = 0;
                                foreach (LinkedInFeed item in lstfeed)
                                {

                                    string PicUrl = string.Empty;
                                    if (string.IsNullOrEmpty(item.FromPicUrl))
                                    {
                                        PicUrl = "../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        PicUrl = item.FromPicUrl;
                                    }






                                    check++;
                                    try
                                    {
                                        message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + PicUrl + "\">" +
                                                                                              "</div><div class=\"pull-left feedcontent\">" +
                                                                                                 "<a style=\"cursor:default\" class=\"feednm\">" + item.FromName + "</a> <span>" + item.FeedsDate +
                                                                                                     " </span>" +
                                                                                                   " <a href=\"#\">" + item.Feeds + "</a>"+
                                                                                                  "<a class=\"retweets\" href=\"#\">" +
                                                                                                  "</a><span></span>" +
                                                                                              "</div>" +
                                                                                          "</li>";
                                    }
                                    catch (Exception ex)
                                    {
                                        logger.Error(ex.Message);
                                        Console.WriteLine(ex.Message);
                                    }
                                    if (check == 500)
                                    {
                                        break;
                                    }
                                }
                            }
                            else
                            {

                                foreach (LinkedInFeed item in lstfeed)
                                {
                                    try
                                    {
                                        string PicUrl = string.Empty;
                                        if (string.IsNullOrEmpty(item.FromPicUrl))
                                        {
                                            PicUrl = "../Contents/img/blank_img.png";
                                        }
                                        else
                                        {
                                            PicUrl = item.FromPicUrl;
                                        }





                                        message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + PicUrl + "\">" +
                                                                                              "</div><div class=\"pull-left feedcontent\">" +
                                                                                                 "<a style=\"cursor:default\" class=\"feednm\">" + item.FromName + "</a> <span>" + item.FeedsDate +
                                                                                                     " </span>" +
                                                                                                  " <a href=\"#\">" + item.Feeds + "</a>" +
                                                                                                  "<a class=\"retweets\" href=\"#\">" +
                                                                                                  "</a><span></span>" +
                                                                                              "</div>" +
                                                                                          "</li>";
                                    }
                                    catch (Exception ex)
                                    {
                                        logger.Error(ex.Message);
                                        Console.WriteLine(ex.Message);
                                    }
                                }
                            }
                        }
                        else
                        {
                            message = "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                   "</div><div class=\"pull-left feedcontent\">" +
                                                                      "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                          " </span>" +
                                                                       "<p>No Messages Found</p>" +
                                                                       "<a class=\"retweets\" href=\"#\">" +
                                                                        "</a><span></span>" +
                                                                   "</div>" +
                                                               "</li>";
                        }
                    }
                    Response.Write(message);
                    #endregion
                }

                else if (Request.QueryString["op"] == "tumblrimages")
                {

                    #region tumblrBlog
                    string messages = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(profileid);
                    List<TumblrFeed> lstfeed = objTumblrFeedRepository.getFeedOfProfile(profileid);

                    string strTumblrImage = string.Empty;
                    string image = string.Empty;
                    try
                    {

                        if (lstfeed.Count != 0)
                        {


                            strTumblrImage += "<div class=\"feedcontainer\"><div class=\"pull-left span\"><div id=\"tumblrcontents\">" +
                       "<a href=\"#\"><img onClick=\"Bpopup()\" src=\"../Contents/img/share.png\" width=\"20\" title=\"Share Content\" /></a>" +
                    "</div></div>";


                            foreach (TumblrFeed feed in lstfeed)
                            {
                                if (string.IsNullOrEmpty(feed.imageurl))
                                {
                                    image = "../../Contents/img/admin/Demo-Image.png";


                                }
                                else
                                {
                                    image = feed.imageurl;
                                }



                                try
                                {
                                    //    strTumblrImage += "<div class=\"span3\" class=\"row-fluid\"><div class=\"span box whitebg tumb_bg feedwrap\"><div class=\"tumb_title\"><span class=\"tumb_span\">" + feed.blogname+ "</span></div><div class=\"pic tumb_pic\"><img onclick=\"tumblrimage('" + feed.imageurl + "')\" alt=\"\" src=\"" + image + "\"></div><div class=\"topicon\">" +
                                    //"<div class=\"pull-right\" id=\"like\"><a title=\"\" href=\"#\" onClick=\"LikePic('" + feed.ProfileId + "','" + feed.Id + "','" + objTumblrAccount.tblrAccessToken + "','" + objTumblrAccount.tblrAccessTokenSecret + "','" + feed.liked + "','" + feed.notes + "')\" >" + getlike(feed.liked, feed.ProfileId) + "</a><a title=\"\" href=\"#\"><img onClick=\"UnfollowBlog('" + feed.ProfileId + "','" + feed.Id + "','" + objTumblrAccount.tblrAccessToken + "','" + objTumblrAccount.tblrAccessTokenSecret + "','" + feed.blogname + "')\"   width=\"14\" alt=\"\" src=\"../Contents/img/admin/speech-bubble-left.png\"  style=\"margin-top: 9px;\"></a>" +
                                    //"</div></div><div class=\"desc\"><p></p><span class=\"pull-left pics_space span4\">" +
                                    //"<img width=\"12\" alt=\"\" src=\"../Contents/img/admin/dil.png\"> " + feed.notes + "</span><div class=\"clearfix\">" +
                                    //"<div class=\"tumb_description\"><p class=\"feed_slug\"><strong>" + feed.slug + "</strong></p><p class=\"teaser\">" + feed.description + "</p></div></div>";





                                    strTumblrImage += "<div class=\"span3\" class=\"row-fluid\"><div class=\"span box whitebg tumb_bg feedwrap\"><div class=\"tumb_title\"><span class=\"tumb_span\">" + feed.blogname + "</span></div><div class=\"pic tumb_pic\"><img onclick=\"tumblrimage('" + feed.imageurl + "')\" alt=\"\" src=\"" + image + "\"></div><div class=\"topicon\">" +
                                                                    "<div class=\"pull-right\" id=\"like\"><a title=\"\" href=\"#\" onClick=\"LikePic('" + feed.ProfileId + "','" + feed.Id + "','" + objTumblrAccount.tblrAccessToken + "','" + objTumblrAccount.tblrAccessTokenSecret + "','" + feed.liked + "','" + feed.notes + "')\" >" + getlike(feed.liked, feed.ProfileId) + "</a><a title=\"\" href=\"#\"><img onClick=\"UnfollowBlog('" + feed.ProfileId + "','" + feed.Id + "','" + objTumblrAccount.tblrAccessToken + "','" + objTumblrAccount.tblrAccessTokenSecret + "','" + feed.blogname + "')\"   width=\"14\" alt=\"\" src=\"../Contents/img/admin/speech-bubble-left.png\"  style=\"margin-top: 9px;\"></a>" +
                                                                    "</div></div><div class=\"desc\"><p></p><span class=\"pull-left pics_space span4\">" +
                                                                    "<img width=\"12\" alt=\"\" src=\"../Contents/img/admin/dil.png\"> " + feed.notes + "</span><div class=\"clearfix\">" +
                                                                    "<div class=\"tumb_description\"><p class=\"feed_slug\"><strong>" + feed.slug + "</strong></p><p class=\"teaser\">" + feed.description + "</p></div></div>";





                                    strTumblrImage += "</div></div></div>";
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                    Console.WriteLine(ex.Message);
                                }
                            }
                            strTumblrImage += "</div>";
                        }
                        else
                        {
                            if (instagramcount == 0)
                            {
                                strTumblrImage = "<div class=\"grid\"><div class=\"box whitebg feedwrap\">" +
                                             "<div class=\"topicon\"><div class=\"pull-left\"></div><div class=\"pull-right\">" +
                                 "<a href=\"#\" title=\"\"></a><a href=\"#\" title=\"\"></a></div></div><div class=\"pic\">" +
                                 "<img src=\"../Contents/img/no_image_found.png\" alt=\"\"></div><div class=\"desc\"><p></p></div></div></div>";
                            }
                        }


                        Response.Write(strTumblrImage);


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



                    #endregion
                }
                //VIDEOS
                else if (Request.QueryString["op"] == "youtubechannel")
                {
                    #region youtube_channel
                    string thumbnail = string.Empty;
                    string videoid = string.Empty;
                    string strYoutubechanell = string.Empty;
                    string GooglePlusUserId = Request.QueryString["profileid"];
                    string accesstoken = Request.QueryString["accesstoken"];
                    oAuthTokenYoutube objoAuthTokenYoutube = new oAuthTokenYoutube();
                    string finaltoken = objoAuthTokenYoutube.GetAccessToken(accesstoken);
                    string strfinaltoken = string.Empty;


                    try
                    {

                        if (!finaltoken.StartsWith("["))
                            finaltoken = "[" + finaltoken + "]";
                        JArray objArray = JArray.Parse(finaltoken);


                        foreach (var item in objArray)
                        {
                            try
                            {
                                strfinaltoken = item["access_token"].ToString();
                                break;
                            }
                            catch (Exception ex)
                            {
                                //logger.Error(ex.StackTrace);
                                Console.WriteLine(ex.StackTrace);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        //logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }


                    YoutubeChannel objChnnelData = ytrchannelrpo.getYoutubeChannelDetailsById(GooglePlusUserId);
                    PlaylistItems objPlaylistItems = new PlaylistItems();
                    string objDetails = objPlaylistItems.Get_PlaylistItems_List(strfinaltoken, GlobusGooglePlusLib.Authentication.oAuthTokenYoutube.Parts.snippet.ToString(), objChnnelData.Uploadsid);

                    JObject obj = JObject.Parse(objDetails);

                    JArray array = (JArray)obj["items"];


                    //strYoutubechanell = " <div class=\"row\"> ";

                    int rowCount = 0;
                    int columnCount = 0;

                    //strYoutubechanell = "<div class=\"row top_select\"> <div class=\"pull-left\"><a href=\"#\"><div class=\"YtIns\">Hello</div></a></div> <div class=\"pull-right\"><select class=\"form-control\" onchange=\"dropDownChange(this,'" + GooglePlusUserId + "','" + accesstoken + "')\"><option>Video</option> <option>Play list</option> <option>Activities</option></select></div></div><div class=\"container yt_details\">";
                    //strYoutubechanell = "<div class=\"row\">  <div class=\"pull-right\"><select class=\"form-control\" onchange=\"dropDownChange(this,'" + GooglePlusUserId + "','" + accesstoken + "')\"><option>Video</option> <option>Play list</option> <option>Activities</option></select></div></div>";
                    strYoutubechanell = "<div class=\"row top_select\"> <div class=\"pull-left\"><a href=\"#\"><div class=\"YtIns\"></div></a></div> <div class=\"pull-right\">"
                                        + "<ul class=\"nav nav-tabs\"><li class=\"active\"><a href=\"#VIDEO\" onclick=\"dropDownChange(this,'" + GooglePlusUserId + "','" + accesstoken + "')\" data-toggle=\"tab\">VIDEO</a></li><li><a href=\"#ACT\" onclick=\"dropDownChange(this,'" + GooglePlusUserId + "','" + accesstoken + "')\" data-toggle=\"tab\">ACTIVITES</a></li><li>"
                    + "<a href=\"#SUB\" onclick=\"dropDownChange(this,'" + GooglePlusUserId + "','" + accesstoken + "')\" data-toggle=\"tab\">SUBSCRIBTIONS</a></li></ul></div></div><div class=\"tab-content yt_details_container\"><div class=\"tab-pane active\" id=\"ACT\">"
                    + "<div class=\"container yt_details\">";



                    string strYoutubechanell1 = string.Empty;

                    foreach (var item in array)
                    {
                        columnCount++;
                        try
                        {
                            thumbnail = item["snippet"]["thumbnails"]["maxres"]["url"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        if (string.IsNullOrEmpty(thumbnail))
                        {
                            try
                            {
                                thumbnail = item["snippet"]["thumbnails"]["high"]["url"].ToString();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                            }
                        }

                        try
                        {
                            videoid = item["snippet"]["resourceId"]["videoId"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }


                        string viewCount = string.Empty;
                        string likeCount = string.Empty;
                        string dislikeCount = string.Empty;
                        string favoriteCount = string.Empty;
                        string commentCount = string.Empty;
                        if (!string.IsNullOrEmpty(videoid))
                        {

                            try
                            {
                                GlobusGooglePlusLib.Youtube.Core.Video ObjClsVideo = new Video();

                                string videoDetails = ObjClsVideo.Get_VideoDetails_byId(videoid, strfinaltoken, "snippet,statistics");

                                JObject JobjvideoDetails = JObject.Parse(videoDetails);

                                var JArrvideoDetails = (JArray)(JobjvideoDetails["items"]);

                                foreach (var DataVal in JArrvideoDetails)
                                {
                                    viewCount = DataVal["statistics"]["viewCount"].ToString();
                                    likeCount = DataVal["statistics"]["likeCount"].ToString();
                                    dislikeCount = DataVal["statistics"]["dislikeCount"].ToString();
                                    favoriteCount = DataVal["statistics"]["favoriteCount"].ToString();
                                    commentCount = DataVal["statistics"]["commentCount"].ToString();
                                    break;
                                }


                            }
                            catch (Exception)
                            {
                            }

                        }


                        //strYoutubechanell1 += "<div class=\"span4\">" +
                        //                    "<div class=\"well\">" +
                        //                     "<div class=\"video-containers thumbnail\">" +
                        //                     "<img onclick=\"youtubevideo('" + videoid + "')\" alt=\"\" src=\"" + thumbnail + "\">" +
                        //                     "</div><span class=\"pull-left\"><a href=\"#\"> &nbsp;<i class=\"icon-eye-open\"></i></a>" +
                        //                     "</span></div></div>";

                        strYoutubechanell1 += "<div class=\"span3\">" +
                                            "<div class=\"span box whitebg tumb_bg\">" +
                                             "<div class=\"yt_title\"></div><div class=\"video-containers thumbnail\">" +
                                             "<img onclick=\"youtubevideo('" + videoid + "')\" alt=\"\" src=\"" + thumbnail + "\">" +
                                             "</div><div class=\"icons\" style=\"width: 225px; float: left;\"><span class=\"span6 pull-left\">" +
                                             "<a href=\"#\" style=\"float: left;\"> &nbsp;<i style=\"color: green;\" class=\"icon-hand-up\"></i></a><span class=\"pull-left\">" + likeCount + "</span></a><a href=\"#\" style=\"float: left;\"> &nbsp;<i style=\"color: red;\" class=\"icon-hand-down\"></i><span>" + dislikeCount + "</span>" +
                                             "</a></span><span class=\"pull-right\"><a href=\"#\"> &nbsp;<i style=\"color: red;\" class=\"icon-eye-open\"></i><span>" + viewCount + "</span></a></span></div><div class=\"yt_description\"></div></div></div>";


                        try
                        {

                            if (rowCount == 3)
                            {
                                //strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div></div></div>";
                                strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div>";
                                strYoutubechanell1 = string.Empty;
                                rowCount = 0;
                            }
                            else
                            {
                                rowCount++;
                            }
                            if (!strYoutubechanell.Contains(strYoutubechanell1) && array.Count == columnCount)
                            {
                                //strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div></div>";
                                strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div>";
                            }

                        }
                        catch (Exception)
                        {

                        }



                        //strYoutubechanell += "<div class=\"span3\" class=\"row-fluid\"><div class=\"span12 box whitebg feedwrap\"><div class=\"topicon\"><div class=\"pull-left\">" +

                        //                                        "</div><div class=\"pull-right\" id=\"like\"><a title=\"\" href=\"#\" onClick=\"LikePic()\" ></a><a title=\"\" href=\"#\"></a>" +
                        //                                        "</div></div><div class=\"pic\"><img onclick=\"youtubevideo('" + videoid + "')\" alt=\"\" src=\"" + thumbnail + "\"></div><div class=\"desc\"><p></p><span class=\"pull-left span3\">" +
                        //                                        "<img width=\"12\" alt=\"\" src=\"../Contents/img/admin/dil.png\"></span><div class=\"clearfix\">" +
                        //                                        "</div>";



                        //strYoutubechanell += "</div></div></div>";



                    }

                    Response.Write("<div id=\"ACT\" class=\"tab-pane active\"><div class=\"container yt_details\">" + strYoutubechanell + "\"</div></div>");

                    #endregion
                }

                //ACTIVITIES
                else if (Request.QueryString["op"] == "youtubeactivity")
                {
                    #region youtube_ACTIVITIES

                    string strYoutubechanell = string.Empty;
                    string GooglePlusUserId = Request.QueryString["profileid"];
                    string accesstoken = Request.QueryString["accesstoken"];
                    oAuthTokenYoutube objoAuthTokenYoutube = new oAuthTokenYoutube();
                    string finaltoken = objoAuthTokenYoutube.GetAccessToken(accesstoken);
                    string strfinaltoken = string.Empty;

                    try
                    {

                        if (!finaltoken.StartsWith("["))
                            finaltoken = "[" + finaltoken + "]";
                        JArray objArray = JArray.Parse(finaltoken);


                        foreach (var item in objArray)
                        {
                            try
                            {

                                strfinaltoken = item["access_token"].ToString();

                                break;

                            }
                            catch (Exception ex)
                            {
                                //logger.Error(ex.StackTrace);
                                Console.WriteLine(ex.StackTrace);

                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        //logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }


                    YoutubeChannel objChnnelData = ytrchannelrpo.getYoutubeChannelDetailsById(GooglePlusUserId);
                    GlobusGooglePlusLib.Youtube.Core.Activities objActivities = new Activities();
                    string objDetails = objActivities.Get_All_Activities(strfinaltoken, oAuthTokenYoutube.Parts.snippet, true, 50);

                    JObject obj = JObject.Parse(objDetails);

                    JArray array = (JArray)obj["items"];

                    int rowCount = 0;
                    int columnCount = 0;

                    strYoutubechanell = "";

                    string strYoutubechanell1 = string.Empty;

                    foreach (var item in array)
                    {
                        string title = string.Empty;
                        string description = string.Empty;
                        string thumbnail = string.Empty;
                        string videoid = string.Empty;

                        columnCount++;

                        #region << Title >>

                        try
                        {
                            title = item["snippet"]["title"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        #endregion

                        #region << Description >>

                        try
                        {
                            description = item["snippet"]["description"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        #endregion

                        #region  << Thumbnail >>

                        try
                        {
                            thumbnail = item["snippet"]["thumbnails"]["maxres"]["url"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        if (string.IsNullOrEmpty(thumbnail))
                        {

                            try
                            {
                                thumbnail = item["snippet"]["thumbnails"]["high"]["url"].ToString();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                            }
                        }
                        #endregion

                        try
                        {
                            videoid = item["snippet"]["resourceId"]["videoId"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }


                        string viewCount = string.Empty;
                        string likeCount = string.Empty;
                        string dislikeCount = string.Empty;
                        string favoriteCount = string.Empty;
                        string commentCount = string.Empty;
                        if (!string.IsNullOrEmpty(videoid))
                        {

                            try
                            {
                                GlobusGooglePlusLib.Youtube.Core.Video ObjClsVideo = new Video();

                                string videoDetails = ObjClsVideo.Get_VideoDetails_byId(videoid, strfinaltoken, "snippet,statistics");

                                JObject JobjvideoDetails = JObject.Parse(videoDetails);

                                var JArrvideoDetails = (JArray)(JobjvideoDetails["items"]);

                                foreach (var DataVal in JArrvideoDetails)
                                {
                                    viewCount = DataVal["statistics"]["viewCount"].ToString();
                                    likeCount = DataVal["statistics"]["likeCount"].ToString();
                                    dislikeCount = DataVal["statistics"]["dislikeCount"].ToString();
                                    favoriteCount = DataVal["statistics"]["favoriteCount"].ToString();
                                    commentCount = DataVal["statistics"]["commentCount"].ToString();
                                    break;
                                }


                            }
                            catch (Exception)
                            {
                            }

                        }


                        if (string.IsNullOrEmpty(title) && thumbnail.EndsWith("hq1.jpg") && string.IsNullOrEmpty(videoid) && string.IsNullOrEmpty(description))
                        {
                            continue;
                        }



                        strYoutubechanell1 += "<div class=\"span3\">" +
                                              "<div class=\"span box whitebg tumb_bg\">" +
                                             "<div class=\"yt_title\">" + title + "</div><div class=\"video-containers thumbnail\">" +
                                             "<img onclick=\"youtubevideo('" + videoid + "')\" alt=\"\" src=\"" + thumbnail + "\">" +
                                             "</div><div class=\"yt_description\">" + description + "</div></div></div>";



                        try
                        {
                            if (rowCount == 3)
                            {
                                strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div>";
                                strYoutubechanell1 = string.Empty;
                                rowCount = 0;
                            }
                            else
                            {
                                rowCount++;
                            }
                            if (!strYoutubechanell.Contains(strYoutubechanell1) && array.Count == columnCount)
                            {
                                strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div>";
                            }
                        }
                        catch (Exception)
                        {

                        }
                    }

                    Response.Write(strYoutubechanell);

                    #endregion
                }
                //SUBSCRIBTIONS
                else if (Request.QueryString["op"] == "youtubesubscribe")
                {
                    #region youtube_SUBSCRIBE

                    string strYoutubechanell = string.Empty;
                    string GooglePlusUserId = Request.QueryString["profileid"];
                    string accesstoken = Request.QueryString["accesstoken"];
                    oAuthTokenYoutube objoAuthTokenYoutube = new oAuthTokenYoutube();
                    string finaltoken = objoAuthTokenYoutube.GetAccessToken(accesstoken);
                    string strfinaltoken = string.Empty;

                    try
                    {

                        if (!finaltoken.StartsWith("["))
                            finaltoken = "[" + finaltoken + "]";
                        JArray objArray = JArray.Parse(finaltoken);


                        foreach (var item in objArray)
                        {
                            try
                            {

                                strfinaltoken = item["access_token"].ToString();

                                break;

                            }
                            catch (Exception ex)
                            {
                                //logger.Error(ex.StackTrace);
                                Console.WriteLine(ex.StackTrace);

                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        //logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }


                    Subscriptions _Subscriptions = new Subscriptions();


                    string _strSubscriptions = _Subscriptions.Get_Subscriptions_List(strfinaltoken, oAuthTokenYoutube.Parts.snippet.ToString());

                    //YoutubeChannel objChnnelData = ytrchannelrpo.getYoutubeChannelDetailsById(GooglePlusUserId);
                    //GlobusGooglePlusLib.Youtube.Core.Activities objActivities = new Activities();
                    //string objDetails = objActivities.Get_All_Activities(strfinaltoken, oAuthTokenYoutube.Parts.snippet, true, 50);

                    JObject obj = JObject.Parse(_strSubscriptions);

                    JArray array = (JArray)obj["items"];

                    int rowCount = 0;
                    int columnCount = 0;

                    strYoutubechanell = "";

                    string strYoutubechanell1 = string.Empty;

                    foreach (var item in array)
                    {
                        string title = string.Empty;
                        string description = string.Empty;
                        string _resoucechannelId = string.Empty;
                        string thumbnail = string.Empty;

                        columnCount++;

                        #region << Title >>

                        try
                        {
                            title = item["snippet"]["title"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        #endregion

                        #region << Description >>

                        try
                        {
                            description = item["snippet"]["description"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        #endregion

                        #region  << Thumbnail >>

                        try
                        {
                            thumbnail = item["snippet"]["thumbnails"]["maxres"]["url"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        if (string.IsNullOrEmpty(thumbnail))
                        {

                            try
                            {
                                thumbnail = item["snippet"]["thumbnails"]["high"]["url"].ToString();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                            }
                        }
                        #endregion

                        try
                        {
                            _resoucechannelId = item["snippet"]["resourceId"]["channelId"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }


                        string viewCount = string.Empty;
                        string subscriberCount = string.Empty;
                        string hiddenSubscriberCount = string.Empty;
                        string videoCount = string.Empty;
                        string commentCount = string.Empty;
                        if (!string.IsNullOrEmpty(_resoucechannelId))
                        {

                            try
                            {
                                GlobusGooglePlusLib.Youtube.Core.Channels _Channels = new Channels();

                                string videoDetails = _Channels.Get_Channel_List(strfinaltoken, (oAuthTokenYoutube.Parts.snippet.ToString() + "," + oAuthTokenYoutube.Parts.statistics.ToString()), _resoucechannelId);

                                JObject JobjvideoDetails = JObject.Parse(videoDetails);

                                var JArrvideoDetails = (JArray)(JobjvideoDetails["items"]);

                                foreach (var DataVal in JArrvideoDetails)
                                {
                                    viewCount = DataVal["statistics"]["viewCount"].ToString();
                                    subscriberCount = DataVal["statistics"]["subscriberCount"].ToString();
                                    hiddenSubscriberCount = DataVal["statistics"]["hiddenSubscriberCount"].ToString();
                                    videoCount = DataVal["statistics"]["videoCount"].ToString();
                                    commentCount = DataVal["statistics"]["commentCount"].ToString();
                                    break;
                                }


                            }
                            catch (Exception)
                            {
                            }

                        }



                        //strYoutubechanell1 += "<div class=\"span3\">" +
                        //                      "<div class=\"span box whitebg tumb_bg\">" +
                        //                     "<div class=\"yt_title\">" + title + "</div><div class=\"video-containers thumbnail\">" +
                        //                     "<img onclick=\"#\" alt=\"\" src=\"" + thumbnail + "\">" +
                        //                     "</div><div class=\"icons\" style=\"width: 225px; float: left;\"><span class=\"span6 pull-left\">" +
                        //                     "<a href=\"#\" style=\"float: left;\"> &nbsp;<i style=\"color: green;\" class=\"icon-facetime-video\"></i></a>" +
                        //                     "<span class=\"pull-left\">&nbsp;" + videoCount + "</span></a><a href=\"#\" style=\"float: left;\"> &nbsp;<i style=\"color: red;\" class=\"icon-comment\"></i>" +
                        //                     "<span>&nbsp;" + commentCount + "</span></a></span><span class=\"pull-right\"><a href=\"#\"> &nbsp;<i style=\"color: red; padding-right: 5px;\" class=\"icon-eye-open\"></i><span>&nbsp;" + viewCount + "</span></a>" +
                        //                     "</span></div><div class=\"yt_description\">" + description + "</div></div></div>";


                        strYoutubechanell1 += "<div class=\"span3\">" +
                                             "<div class=\"span box whitebg tumb_bg\">" +
                                            "<div class=\"yt_title\">" + title + "</div><div class=\"video-containers thumbnail\">" +
                                            "<img onclick=\"#\" alt=\"\" src=\"" + thumbnail + "\">" +
                                            "</div><div class=\"icons\" style=\"width: 225px; float: left;\"><span class=\"span7 pull-left\">" +
                                            "<a href=\"#\" style=\"float: left;\"> &nbsp;<i style=\"color: green;\" class=\"icon-facetime-video\"></i></a>" +
                                            "<span class=\"pull-left\">&nbsp;" + ConvertMillionAndBillion(videoCount) + "</span></a><a href=\"#\" style=\"float: left;\"> &nbsp;<i style=\"color: red;\" class=\"icon-comment\"></i>" +
                                            "<span>&nbsp;" + ConvertMillionAndBillion(commentCount) + "</span></a></span><span class=\"pull-right\"><a href=\"#\"> &nbsp;<i style=\"color: red; padding-right: 5px;\" class=\"icon-eye-open\"></i><span>&nbsp;" + ConvertMillionAndBillion(viewCount) + "</span></a>" +
                                            "</span></div><div class=\"yt_description\">" + description + "</div></div></div>";


                        try
                        {
                            if (rowCount == 3)
                            {
                                strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div>";
                                strYoutubechanell1 = string.Empty;
                                rowCount = 0;
                            }
                            else
                            {
                                rowCount++;
                            }
                            if (!strYoutubechanell.Contains(strYoutubechanell1) && array.Count == columnCount)
                            {
                                strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div>";
                            }
                        }
                        catch (Exception)
                        {

                        }
                    }

                    Response.Write(strYoutubechanell);

                    #endregion
                }
                else if (Request.QueryString["op"] == "linkedinfeeds")
                {
                    #region linkedinfeeds
                    string profileid = Request.QueryString["profileid"];
                    LinkedInAccountRepository linkedinAccRepo = new LinkedInAccountRepository();
                    LinkedInAccount linkacc = linkedinAccRepo.getUserInformation(profileid);
                    oAuthLinkedIn oauthlin = new oAuthLinkedIn();
                    oauthlin.ConsumerKey = ConfigurationManager.AppSettings["LiApiKey"];
                    oauthlin.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"];
                    oauthlin.FirstName = linkacc.LinkedinUserName;
                    oauthlin.Id = linkacc.LinkedinUserId;
                    oauthlin.Token = linkacc.OAuthToken;
                    oauthlin.TokenSecret = linkacc.OAuthSecret;
                    oauthlin.Verifier = linkacc.OAuthVerifier;


                    LinkedInUser l = new LinkedInUser();
                    List<LinkedInUser.User_Updates> lst = l.GetUserUpdates(oauthlin, linkacc.LinkedinUserId, 10);
                    string message = string.Empty;
                    if (lst.Count != 0)
                    {
                        foreach (LinkedInUser.User_Updates item in lst)
                        {
                            try
                            {
                                string picurl = string.Empty;
                                if (string.IsNullOrEmpty(item.PictureUrl))
                                {
                                    picurl = "../Contents/img/blank_img.png";
                                }
                                else
                                {
                                    picurl = item.PictureUrl;
                                }
                                message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + picurl + "\">" +
                                                                       "</div><div class=\"pull-left feedcontent\">" +
                                                                          "<a href=\"" + linkacc.ProfileUrl + "\" target=\"_blank\" class=\"feednm\">" + item.PersonFirstName + " " + item.PersonLastName + "</a> <span>" + item.DateTime +
                                                                              " </span>" +
                                                                           "<p>" + item.Message + "</p>" +
                                                                           "<a class=\"retweets\" href=\"#\">" +
                                                                           "</a><span></span>" +
                                                                       "</div>" +
                                                                   "</li>";
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                            }

                        }
                    }
                    else
                    {
                        message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                                             "</div><div class=\"pull-left feedcontent\">" +
                                                                                                "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                                                    " </span>" +
                                                                                                 "<p>No Messages Found</p>" +
                                                                                                 "<a class=\"retweets\" href=\"#\">" +
                                                                                                  "</a><span></span>" +
                                                                                             "</div>" +
                                                                                         "</li>";
                    }
                    Response.Write(message);
                    #endregion
                }
                else if (Request.QueryString["op"] == "facebookapi")
                {
                    #region facebookapi
                    try
                    {
                        string profileid = Request.QueryString["profileid"];
                        // FacebookAccountRepository facerepo = new FacebookAccountRepository();
                        FacebookAccount faceaccount = facerepo.getFacebookAccountDetailsById(profileid);
                        FacebookHelper fbhelper = new FacebookHelper();
                        FacebookClient fbclient = new FacebookClient(faceaccount.AccessToken);
                        dynamic profile = fbclient.Get("me");
                        var feeds = fbclient.Get("/me/feed");
                        var home = fbclient.Get("me/home");
                        fbhelper.getFacebookUserFeeds(feeds, profile);
                        fbhelper.getFacebookUserHome(home, profile);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                    }
                    #endregion
                }
                else if (Request.QueryString["op"] == "twitterapi")
                {
                    string profileid = Request.QueryString["profileid"];
                    TwitterAccountRepository twtAccountRepo = new TwitterAccountRepository();
                    TwitterAccount twtAccount = twtAccountRepo.getUserInformation(user.Id, profileid);
                    oAuthTwitter oAuth = new oAuthTwitter();
                    TwitterHelper twthelper = new TwitterHelper();
                    oAuth.AccessToken = twtAccount.OAuthToken;
                    oAuth.AccessTokenSecret = twtAccount.OAuthSecret;
                    twthelper.SetCofigDetailsForTwitter(oAuth);
                    oAuth.TwitterScreenName = twtAccount.TwitterScreenName;
                    oAuth.TwitterUserId = twtAccount.TwitterUserId;
                    twthelper.getUserTweets(oAuth, twtAccount, user.Id);
                    twthelper.getUserFeed(oAuth, twtAccount, user.Id);
                    twthelper.getSentDirectMessages(oAuth, twtAccount, user.Id);
                    twthelper.getReTweetsOfUser(oAuth, twtAccount, user.Id);

                }
                else if (Request.QueryString["op"] == "instagramlike")
                {
                    string mediaid = Request.QueryString["mediaid"];
                    bool b = this.likefunction(mediaid, Request.QueryString["userid"], Request.QueryString["access"]);
                }
                else if (Request.QueryString["op"] == "instagramunlike")
                {
                    string mediaid = Request.QueryString["mediaid"];
                    bool b = this.unlikefunction(mediaid, Request.QueryString["userid"], Request.QueryString["access"]);

                }
                else if (Request.QueryString["op"] == "instagramimages")
                {
                    if (Request.QueryString["loadtime"] != "first")
                    {
                        instagramcount = instagramcount + 10;
                    }
                    else
                    {
                        instagramcount = 0;
                    }

                    InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository();
                    InstagramFeedRepository objInsFeedRepo = new InstagramFeedRepository();
                    InstagramFeed objInsFeed = new InstagramFeed();
                    InstagramCommentRepository objInsCmtRepo = new InstagramCommentRepository();
                    List<SocioBoard.Domain.InstagramComment> lstInsCmt = new List<SocioBoard.Domain.InstagramComment>();

                    string strInsImage = string.Empty;

                    try
                    {
                        string profileid = Request.QueryString["profileid"];
                        InstagramAccount insaccount = objInsAccRepo.getInstagramAccountDetailsById(profileid, user.Id);
                        List<InstagramFeed> lstInsFeed = objInsFeedRepo.getAllInstagramFeedsOfUser(user.Id, profileid, instagramcount);
                        if (lstInsFeed.Count != 0)
                        {
                            strInsImage += "<div class=\"feedcontainer\">";
                            foreach (InstagramFeed feed in lstInsFeed)
                            {

                                try
                                {
                                    lstInsCmt = objInsCmtRepo.getAllInstagramCommentsOfUser(user.Id, profileid, feed.FeedId);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                    Console.WriteLine(ex.Message);
                                }
                                try
                                {
                                    strInsImage += "<div class=\"span3\" class=\"row-fluid\"><div class=\"span12 box whitebg feedwrap\"><div class=\"topicon\"><div class=\"pull-left\">" +

                                                                    "</div><div class=\"pull-right\" id=\"like\"><a title=\"\" href=\"#\" onClick=\"insUser('" + feed.FeedId + "','" + insaccount.AccessToken + "')\" ><img id=\"heartEmpty_" + feed.FeedId + "\" width=\"14\" alt=\"\" src=\"../Contents/img/admin/heart-empty.png\"  style=\"margin-top: 9px;\"></a><a title=\"\" href=\"#\"><img width=\"14\" alt=\"\" src=\"../Contents/img/admin/speech-bubble-left.png\"  style=\"margin-top: 9px;\"></a>" +
                                                                    "</div></div><div class=\"pic\"><img alt=\"\" src=\"" + feed.FeedImageUrl + "\"></div><div class=\"desc\"><p></p><span class=\"pull-left span3\">" +
                                                                    "<img width=\"12\" alt=\"\" src=\"../Contents/img/admin/heart-empty.png\"> " + feed.LikeCount + "</span><span class=\"pull-left span3\"><img width=\"12\" alt=\"\" src=\"../Contents/img/admin/speech-bubble-left.png\"> " + lstInsCmt.Count + "</span><div class=\"clearfix\"></div>";

                                    foreach (InstagramComment insCmt in lstInsCmt)
                                    {
                                        try
                                        {
                                            strInsImage += "<div class=\"userprof\"><div class=\"pull-left\"><a href=\"#\">" +
                                              "<img width=\"36\" alt=\"\" src=\"" + insCmt.FromProfilePic + "\"></a></div><div class=\"pull-left descr\"><p>" + insCmt.Comment + "</p>" +
                                               "<span class=\"usert\">" + DateExtension.ToDateTime(DateTime.Now, (long)Convert.ToDouble(insCmt.CommentDate)) + "</span></div></div>";

                                        }
                                        catch (Exception ex)
                                        {
                                            logger.Error(ex.Message);
                                            Console.WriteLine(ex.Message);
                                        }

                                    }

                                    strInsImage += "</div></div></div>";
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                    Console.WriteLine(ex.Message);
                                }
                            }
                            strInsImage += "</div>";
                        }
                        else
                        {
                            if (instagramcount == 0)
                            {
                                strInsImage = "<div class=\"grid\"><div class=\"box whitebg feedwrap\">" +
                                             "<div class=\"topicon\"><div class=\"pull-left\"></div><div class=\"pull-right\">" +
                                 "<a href=\"#\" title=\"\"></a><a href=\"#\" title=\"\"></a></div></div><div class=\"pic\">" +
                                 "<img src=\"../Contents/img/no_image_found.png\" alt=\"\"></div><div class=\"desc\"><p></p></div></div></div>";
                            }
                        }


                        Response.Write(strInsImage);


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

                }
                else if (Request.QueryString["op"] == "instagramApi")
                {
                    try
                    {
                        InstagramManager insManager = new InstagramManager();
                        string profileid = Request.QueryString["profileid"];
                        InstagramAccountRepository insAccRepo = new InstagramAccountRepository();
                        InstagramAccount instagramAccount = insAccRepo.getInstagramAccountDetailsById(profileid, user.Id);
                        insManager.getIntagramImages(instagramAccount);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                    }
                }



                else if (Request.QueryString["op"] == "UnfollowTumblrBlog")
                {
                    try
                    {
                        string blogname = Request.QueryString["blogname"].ToString();
                        string profileid = Request.QueryString["profileid"];
                        string accesstoken = Request.QueryString["accesstoken"];
                        string accesstokensecret = Request.QueryString["accesstokensecret"];
                        Guid id = Guid.Parse(Request.QueryString["id"]);
                        try
                        {
                            string msg = "success";
                            BlogsFollowers objunfollowblog = new BlogsFollowers();
                            objunfollowblog.Unfollowblog(accesstoken, accesstokensecret, blogname);
                            int result = objTumblrFeedRepository.DeleteTumblrDataByProfileid(profileid, blogname);
                            Response.Write(msg);

                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }

                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                    }

                }


                else if (Request.QueryString["op"] == "tumblrTextPost")
                {

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();
                        string body = Request.QueryString["msg"].ToString();
                        string title = Request.QueryString["title"].ToString();
                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, body, title, "text");

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                }


                else if (Request.QueryString["op"] == "tumblrQuotePost")
                {

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();
                        string source = Request.QueryString["source"].ToString();
                        string quote = Request.QueryString["quote"].ToString();
                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, source, quote, "quote");


                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                }

                else if (Request.QueryString["op"] == "tumblrLinkPost")
                {

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();
                        string linkurl = Request.QueryString["linkurl"].ToString();
                        string title = Request.QueryString["title"].ToString();
                        string description = Request.QueryString["description"].ToString();
                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostdescriptionData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, linkurl, title, description, "link");


                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                }





                else if (Request.QueryString["op"] == "tumblrImagePost")
                {
                    string caption = string.Empty;

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();
                        try
                        {
                            caption = Request.QueryString["caption"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        var fi = Request.Files["file"];

                        string file = string.Empty;
                        if (fi != null)
                        {
                            var path = Server.MapPath("~/Contents/img/upload");
                            file = path + "/" + fi.FileName;
                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }
                            fi.SaveAs(file);
                        }

                        string filepath = file;

                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, caption, filepath, "photo");

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                }



                else if (Request.QueryString["op"] == "tumblrAudioPost")
                {
                    string caption = string.Empty;

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();

                        var fi = Request.Files["file"];

                        string file = string.Empty;
                        if (fi != null)
                        {
                            var path = Server.MapPath("~/Contents/img/upload");
                            file = path + "/" + fi.FileName;
                            //if (!Directory.Exists(path))
                            //{
                            //    Directory.CreateDirectory(path);
                            //}
                            //fi.SaveAs(file);
                        }

                        string filepath = file;

                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostAudioData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, filepath, "audio");

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }


                }



                else if (Request.QueryString["op"] == "tumblrVideoPost")
                {
                    string caption = string.Empty;

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();
                        string VideoUrl = Request.QueryString["VideoUrl"].ToString();
                        string VideoContent = Request.QueryString["VideoContent"].ToString();

                        var fi = Request.Files["file"];

                        string file = string.Empty;
                        if (fi != null)
                        {
                            var path = Server.MapPath("~/Contents/img/upload");
                            file = path + "/" + fi.FileName;
                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }
                            fi.SaveAs(file);
                        }

                        string filepath = file;

                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostdescriptionData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, filepath, VideoUrl, VideoContent, "video");

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }


                }

                else if (Request.QueryString["op"] == "tumblrChatPost")
                {

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();
                        string body = Request.QueryString["body"].ToString();
                        string title = Request.QueryString["title"].ToString();
                        string tag = Request.QueryString["tag"].ToString();
                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostdescriptionData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, body, title, tag, "chat");


                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                }













                else if (Request.QueryString["op"] == "LikeUnlikeTumblrImage")
                {

                    int likestatus = Convert.ToInt16(Request.QueryString["likes"]);
                    string profileid = Request.QueryString["profileid"];
                    string accesstoken = Request.QueryString["accesstoken"];
                    string accesstokensecret = Request.QueryString["accesstokensecret"];
                    Guid id = Guid.Parse(Request.QueryString["id"]);
                    int notes = Convert.ToInt16(Request.QueryString["notes"]);


                    try
                    {
                        int like = 0;
                        if (likestatus == 0)
                        {
                            like = 1;
                        }
                        int i = objTumblrFeedRepository.UpdateDashboardOfProfileLikes(profileid, id, like);

                        int s = objTumblrFeedRepository.UpdateDashboardOfProfileNotes(profileid, id, like, notes);

                        TumblrFeed obj = objTumblrFeedRepository.getFeedOfProfilebyIdProfileId(profileid, id);
                        BlogsLikes objBlogsLikes = new BlogsLikes();

                        objBlogsLikes.likeBlog(accesstoken, accesstokensecret, obj.blogId, obj.reblogkey, like);


                        //KeyValuePair<string, string> LoginDetails = new KeyValuePair<string, string>(accesstoken, accesstokensecret);
                        //var prms = new Dictionary<string, object>();
                        //prms.Add("id", obj.blogId);
                        //prms.Add("reblog_key", obj.reblogkey);
                        //var postUrl = "";

                        //if (like == 1)
                        //{
                        //    postUrl = "https://api.tumblr.com/v2/user/like/";
                        //}
                        //else
                        //{
                        //    postUrl = "https://api.tumblr.com/v2/user/unlike/";
                        //}
                        //string result = oAuthTumbler.OAuthData(postUrl, "POST", LoginDetails.Key, LoginDetails.Value, prms);

                        //string result1 = string.Empty;
                        //result1 = result;
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                    }
                }
            }
        }
        public DataSet bindFeedsIntoDataTable(User user, string network)
        {
            Messages mstable = new Messages();
            DataSet ds = DataTableGenerator.CreateDataSetForTable(mstable);



            if (!string.IsNullOrEmpty(network))
            {
                /*Facebook region*/
                if (network == "facebook")
                {
                    FacebookAccountRepository fbaccount = new FacebookAccountRepository();
                    FacebookMessageRepository fbmsg = new FacebookMessageRepository();
                    ArrayList alstfbaccount = fbaccount.getAllFacebookAccountsOfUser(user.Id);
                    foreach (FacebookAccount item in alstfbaccount)
                    {
                        List<FacebookMessage> lstfbmsg = fbmsg.getAllFacebookMessagesOfUser(user.Id, item.FbUserId);
                        foreach (FacebookMessage facebookmsg in lstfbmsg)
                        {
                            ds.Tables[0].Rows.Add(facebookmsg.ProfileId, "facebook", facebookmsg.FromId, facebookmsg.FromName, facebookmsg.FromProfileUrl, facebookmsg.MessageDate, facebookmsg.Message, facebookmsg.FbComment, facebookmsg.FbLike, facebookmsg.MessageId, facebookmsg.Type);
                        }
                    }
                }
                else if (network == "twitter")
                {
                    TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                    TwitterFeedRepository twtfeedrepo = new TwitterFeedRepository();
                    ArrayList alsttwtaccount = twtaccountrepo.getAllTwitterAccountsOfUser(user.Id);
                    foreach (TwitterAccount item in alsttwtaccount)
                    {
                        List<TwitterFeed> lsttwtmsg = twtfeedrepo.getAllTwitterFeedOfUsers(user.Id, item.TwitterUserId);
                        foreach (TwitterFeed twtmsg in lsttwtmsg)
                        {
                            ds.Tables[0].Rows.Add(twtmsg.ProfileId, "twitter", twtmsg.FromId, twtmsg.FromScreenName, twtmsg.FromProfileUrl, twtmsg.FeedDate, twtmsg.Feed, "", "", twtmsg.MessageId, twtmsg.Type);
                        }
                    }

                }
                else if (network == "linkedin")
                {
                    LinkedInAccountRepository liaccountrepo = new LinkedInAccountRepository();
                    LinkedInFeedRepository lifeedrepo = new LinkedInFeedRepository();
                    ArrayList alstliaccount = liaccountrepo.getAllLinkedinAccountsOfUser(user.Id);
                    foreach (LinkedInAccount item in alstliaccount)
                    {
                        List<LinkedInFeed> lsttwtmsg = lifeedrepo.getAllLinkedInFeedsOfUser(user.Id, item.LinkedinUserId);
                        foreach (LinkedInFeed limsg in lsttwtmsg)
                        {
                            ds.Tables[0].Rows.Add(limsg.ProfileId, "linkedin", limsg.FromId, limsg.FromName, limsg.FromPicUrl, limsg.FeedsDate, limsg.Feeds, "", "", "", limsg.Type);
                        }
                    }

                }
                else if (network == "instagram")
                {
                    InstagramAccountRepository insAccRepo = new InstagramAccountRepository();
                    InstagramFeedRepository insFeedRepo = new InstagramFeedRepository();
                    ArrayList alstlistaccount = insAccRepo.getAllInstagramAccountsOfUser(user.Id);
                    foreach (InstagramAccount item in alstlistaccount)
                    {
                        List<InstagramFeed> lstFeeed = insFeedRepo.getAllInstagramFeedsOfUser(user.Id, item.InstagramId);
                        foreach (InstagramFeed insFeed in lstFeeed)
                        {
                            ds.Tables[0].Rows.Add(insFeed.InstagramId, "instagram", "", "", "", insFeed.FeedDate, insFeed.FeedImageUrl, "", "", insFeed.FeedId, "");
                        }
                    }
                }

            }
            return ds;
        }