Example #1
0
 public bool likefunction(string id, string userid, string accesstoken)
 {
     oAuthInstagram _api;
     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/", "");
     _api = oAuthInstagram.GetInstance(configi);
     LikesController objlikes = new LikesController();
     bool dd = objlikes.PostUserLike(id, userid, accesstoken);
     return dd;
 }
        public void GetInstagramFeeds(Domain.Socioboard.Domain.InstagramAccount objInsAccount)
        {
            MongoRepository instagarmCommentRepo = new MongoRepository("InstagramComment");
            MongoRepository instagramFeedRepo = new MongoRepository("InstagramFeed");
            try
            {
                GlobusInstagramLib.Instagram.Core.UsersMethods.Users userInstagram = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users();
                InstagramResponse<InstagramMedia[]> userinf2 = userInstagram.CurrentUserFeed("", "", "30", objInsAccount.AccessToken);
                InstagramResponse<Comment[]> usercmts = new InstagramResponse<Comment[]>();

                CommentController objComment = new CommentController();
                LikesController objLikes = new LikesController();
                if (userinf2 != null)
                {
                    for (int j = 0; j < userinf2.data.Count(); j++)
                    {
                        try
                        {
                            objInstagramFeed = new Domain.Socioboard.MongoDomain.InstagramFeed();
                            //objInstagramFeed.EntryDate = DateTime.Now;
                            try
                            {
                                // objInstagramFeed.Id = ObjectId.GenerateNewId();
                                objInstagramFeed.strId = ObjectId.GenerateNewId().ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FeedDate = userinf2.data[j].created_time.ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FeedId = userinf2.data[j].id;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.Type = userinf2.data[j].type.ToString();
                                if (objInstagramFeed.Type == "video")
                                {
                                    objInstagramFeed.VideoUrl = userinf2.data[j].videos.standard_resolution.url.ToString();
                                }
                            }
                            catch { } 
                            try
                            {
                                objInstagramFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.InstagramId = objInsAccount.InstagramId;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.LikeCount = userinf2.data[j].likes.count;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.CommentCount = userinf2.data[j].comments.count;
                            }
                            catch { }
                            try
                            {
                                string str = userinf2.data[j].user_has_liked.ToString();
                                if (str == "False")
                                {
                                    objInstagramFeed.IsLike = 0;
                                }
                                else { objInstagramFeed.IsLike = 1; }
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.AdminUser = userinf2.data[j].caption.from.username;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.Feed = userinf2.data[j].caption.text;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.ImageUrl = userinf2.data[j].caption.from.profile_picture;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FromId = userinf2.data[j].caption.from.id;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FeedUrl = userinf2.data[j].link;
                            }
                            catch { }
                            //try
                            //{
                            //    objInstagramFeed.UserId = objInsAccount.UserId.;
                            //}
                            //catch { }

                            var ret = instagramFeedRepo.Find<Domain.Socioboard.MongoDomain.InstagramFeed>(t => t.FeedId.Equals(objInstagramFeed.FeedId) && t.InstagramId.Equals(objInstagramFeed.InstagramId));
                            var task = Task.Run(async () =>
                            {
                                return await ret;
                            });
                            int count = task.Result.Count;

                            if (count < 1)
                            {
                                instagramFeedRepo.Add(objInstagramFeed);
                            }
                            else
                            {
                                FilterDefinition<BsonDocument> filter = new BsonDocument("FeedId", objInstagramFeed.FeedId);
                                var update = Builders<BsonDocument>.Update.Set("IsLike", objInstagramFeed.IsLike).Set("CommentCount", objInstagramFeed.CommentCount).Set("LikeCount", objInstagramFeed.LikeCount).Set("Type", objInstagramFeed.Type).Set("VideoUrl", objInstagramFeed.VideoUrl);
                                instagramFeedRepo.Update<Domain.Socioboard.MongoDomain.InstagramFeed>(update, filter);
                            }

                            //if (!objInstagramFeedRepository.checkInstagramFeedExists(userinf2.data[j].id, objInsAccount.UserId))
                            //{
                            //    objInstagramFeedRepository.addInstagramFeed(objInstagramFeed);
                            //}
                            List<Domain.Socioboard.MongoDomain.InstagramComment> lstInstagramComment = new List<Domain.Socioboard.MongoDomain.InstagramComment>();
                            usercmts = objComment.GetComment(userinf2.data[j].id, objInsAccount.AccessToken);
                            for (int cmt = 0; cmt < usercmts.data.Count(); cmt++)
                            {
                                try
                                {

                                    Domain.Socioboard.MongoDomain.InstagramComment objInstagramComment = new Domain.Socioboard.MongoDomain.InstagramComment();

                                    try
                                    {
                                        objInstagramComment.Comment = usercmts.data[cmt].text;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.CommentDate = usercmts.data[cmt].created_time.ToString();
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.CommentId = usercmts.data[cmt].id;
                                    }
                                    catch { }
                                    //try
                                    //{
                                    //    objInstagramComment.EntryDate = DateTime.UtcNow.ToString();
                                    //}
                                    //catch { }
                                    try
                                    {
                                        objInstagramComment.FeedId = userinf2.data[j].id;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.Id = ObjectId.GenerateNewId();
                                        objInstagramComment.strId = ObjectId.GenerateNewId().ToString();
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.InstagramId = objInsAccount.InstagramId;
                                    }
                                    catch { }
                                    try
                                    {
                                        // objInstagramComment.UserId = objInsAccount.UserId;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.FromName = usercmts.data[cmt].from.username;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture;
                                    }
                                    catch { }

                                    lstInstagramComment.Add(objInstagramComment);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.StackTrace);
                                }
                            }
                            instagarmCommentRepo.AddList(lstInstagramComment);

                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
        public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId)
        {

            MongoRepository instagramFeedRepo = new MongoRepository("InstagramFeed");
            string str = string.Empty;
            //GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            //oAuthInstagram _api = new oAuthInstagram();
            //_api = oAuthInstagram.GetInstance(configi);
            try
            {
                objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId);

                LikesController objlikes = new LikesController();
                int islike = Convert.ToInt32(IsLike);
                int LikeCounts = Convert.ToInt32(LikeCount);

                if (islike == 0)
                {
                    islike = 1;
                    bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts++;
                    //objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "unlike";

                }
                else
                {

                    islike = 0;
                    bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts = LikeCounts - 1;
                    //objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "like";

                }

                FilterDefinition<BsonDocument> filter = new BsonDocument("FeedId", FeedId);
                var update = Builders<BsonDocument>.Update.Set("IsLike", islike).Set("LikeCount", LikeCounts);
                instagramFeedRepo.Update<Domain.Socioboard.MongoDomain.InstagramFeed>(update, filter);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return str;
        }
        public void GetInstagramSelfFeeds(string instagramId, string accessToken)
        {
            MongoRepository instagarmCommentRepo = new MongoRepository("InstagramComment");
            MongoRepository instagramFeedRepo = new MongoRepository("InstagramFeed");
            try
            {
                GlobusInstagramLib.Instagram.Core.UsersMethods.Users userInstagram = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users();
                GlobusInstagramLib.Instagram.Core.MediaMethods.Media _Media = new GlobusInstagramLib.Instagram.Core.MediaMethods.Media();
                InstagramResponse<Comment[]> usercmts = new InstagramResponse<Comment[]>();
                CommentController objComment = new CommentController();
                LikesController objLikes = new LikesController();
                string feeds = _Media.UserResentFeeds(instagramId, accessToken);
                if (feeds != null)
                {
                    JObject feed_data = JObject.Parse(feeds);

                    foreach (var item in feed_data["data"])
                    {
                        try
                        {
                            Domain.Socioboard.MongoDomain.InstagramFeed objInstagramFeed = new Domain.Socioboard.MongoDomain.InstagramFeed();
                            try
                            {
                                objInstagramFeed.FeedDate = item["created_time"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FeedId = item["id"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.Type = item["type"].ToString();
                                if (objInstagramFeed.Type == "video")
                                {
                                    objInstagramFeed.VideoUrl = item["videos"]["standard_resolution"]["url"].ToString();
                                }
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FeedImageUrl = item["images"]["standard_resolution"]["url"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.InstagramId = instagramId;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.LikeCount = Int32.Parse(item["likes"]["count"].ToString());
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.CommentCount = Int32.Parse(item["comments"]["count"].ToString());
                            }
                            catch { }
                            try
                            {
                                string str = item["user_has_liked"].ToString();
                                if (str.ToLower() == "false")
                                {
                                    objInstagramFeed.IsLike = 0;
                                }
                                else { objInstagramFeed.IsLike = 1; }
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.AdminUser = item["user"]["username"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.Feed = item["caption"]["text"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.ImageUrl = item["user"]["profile_picture"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FromId = item["user"]["id"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FeedUrl = item["link"].ToString();
                            }
                            catch { }

                            var ret = instagramFeedRepo.Find<Domain.Socioboard.MongoDomain.InstagramFeed>(t => t.FeedId.Equals(objInstagramFeed.FeedId) && t.InstagramId.Equals(objInstagramFeed.InstagramId));
                            var task = Task.Run(async () =>
                            {
                                return await ret;
                            });
                            int count = task.Result.Count;

                            if (count < 1)
                            {
                                instagramFeedRepo.Add(objInstagramFeed);
                            }
                            else
                            {
                                FilterDefinition<BsonDocument> filter = new BsonDocument("FeedId", objInstagramFeed.FeedId);
                                var update = Builders<BsonDocument>.Update.Set("IsLike", objInstagramFeed.IsLike).Set("CommentCount", objInstagramFeed.CommentCount).Set("LikeCount", objInstagramFeed.LikeCount).Set("Type", objInstagramFeed.Type).Set("VideoUrl", objInstagramFeed.VideoUrl);
                                instagramFeedRepo.Update<Domain.Socioboard.MongoDomain.InstagramFeed>(update, filter);
                            }
                            List<Domain.Socioboard.MongoDomain.InstagramComment> lstInstagramComment = new List<Domain.Socioboard.MongoDomain.InstagramComment>();
                            usercmts = objComment.GetComment(objInstagramFeed.FeedId, accessToken);
                            for (int cmt = 0; cmt < usercmts.data.Count(); cmt++)
                            {
                                try
                                {
                                    Domain.Socioboard.MongoDomain.InstagramComment objInstagramComment = new Domain.Socioboard.MongoDomain.InstagramComment();
                                    try
                                    {
                                        objInstagramComment.Comment = usercmts.data[cmt].text;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.CommentDate = usercmts.data[cmt].created_time.ToString();
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.CommentId = usercmts.data[cmt].id;
                                    }
                                    catch { }

                                    try
                                    {
                                        objInstagramComment.FeedId = objInstagramFeed.FeedId;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.InstagramId = instagramId;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.FromName = usercmts.data[cmt].from.username;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture;
                                    }
                                    catch { }

                                    lstInstagramComment.Add(objInstagramComment);
                                }
                                catch (Exception ex)
                                {

                                }
                            }
                            instagarmCommentRepo.AddList(lstInstagramComment);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #5
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
            {
            }
          
        }
        public void GetInstagramFeeds(Domain.Myfashion.Domain.InstagramAccount objInsAccount)
        {
            int I = 0;
            try
            {
                GlobusInstagramLib.Instagram.Core.UsersMethods.Users userInstagram = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users();
                InstagramResponse<InstagramMedia[]> userinf2 = userInstagram.CurrentUserFeed("", "", "20", objInsAccount.AccessToken);
                InstagramResponse<Comment[]> usercmts = new InstagramResponse<Comment[]>();
                objInstagramComment = new Domain.Myfashion.Domain.InstagramComment();
                objInstagramFeed = new Domain.Myfashion.Domain.InstagramFeed();
                CommentController objComment = new CommentController();
                LikesController objLikes = new LikesController();
                if (userinf2 != null)
                {
                    for (int j = 0; j < userinf2.data.Count(); j++)
                    {
                        try
                        {
                            objInstagramFeed.EntryDate = DateTime.Now;
                            try
                            {
                                objInstagramFeed.FeedDate = userinf2.data[j].created_time.ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FeedId = userinf2.data[j].id;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.InstagramId = objInsAccount.InstagramId;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.LikeCount = userinf2.data[j].likes.count;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.CommentCount = userinf2.data[j].comments.count;
                            }
                            catch { }
                            try
                            {
                                string str = userinf2.data[j].user_has_liked.ToString();
                                if (str == "False")
                                {
                                    objInstagramFeed.IsLike = 0;
                                }
                                else { objInstagramFeed.IsLike = 1; }
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.AdminUser = userinf2.data[j].caption.from.username;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.Feed = userinf2.data[j].caption.text;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.ImageUrl = userinf2.data[j].caption.from.profile_picture;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FromId = userinf2.data[j].caption.from.id;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FeedUrl = userinf2.data[j].link;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.UserId = objInsAccount.UserId;
                            }
                            catch { }
                            if (!objInstagramFeedRepository.checkInstagramFeedExists(userinf2.data[j].id, objInsAccount.UserId))
                            {
                                I++;
                                objInstagramFeedRepository.addInstagramFeed(objInstagramFeed);
                                logger.Error("GetInstagramFeedsCount>>>"+I);
                            }

                            usercmts = objComment.GetComment(userinf2.data[j].id, objInsAccount.AccessToken);
                            for (int cmt = 0; cmt < usercmts.data.Count(); cmt++)
                            {
                                try
                                {
                                    try
                                    {
                                        objInstagramComment.Comment = usercmts.data[cmt].text;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.CommentDate = usercmts.data[cmt].created_time.ToString();
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.CommentId = usercmts.data[cmt].id;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.EntryDate = DateTime.Now;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.FeedId = userinf2.data[j].id;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.Id = Guid.NewGuid();
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.InstagramId = objInsAccount.InstagramId;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.UserId = objInsAccount.UserId;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.FromName = usercmts.data[cmt].from.username;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture;
                                    }
                                    catch { }
                                    if (!objInstagramCommentRepository.checkInstagramCommentExists(usercmts.data[cmt].id, objInsAccount.UserId))
                                    {
                                        objInstagramCommentRepository.addInstagramComment(objInstagramComment);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.StackTrace);
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
        public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId)
        {
            string str = string.Empty;
            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();
            _api = oAuthInstagram.GetInstance(configi);
            try
            {
                objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId));

                LikesController objlikes = new LikesController();
                int islike = Convert.ToInt32(IsLike);
                int LikeCounts = Convert.ToInt32(LikeCount);

                if (islike == 0)
                {
                    islike = 1;
                    bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts++;
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "unlike";

                }
                else
                {

                    islike = 0;
                    bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts = LikeCounts - 1;
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "like";

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return str;
        }
        public string GetIntagramImages(Domain.Myfashion.Domain.InstagramAccount objInsAccount)
        {
            {
                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();
                objInstagramComment = new Domain.Myfashion.Domain.InstagramComment();
                objInstagramFeed = new Domain.Myfashion.Domain.InstagramFeed();
                string html = string.Empty;
                int i = 0;
                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 = 0; cmt < usercmts.data.Count(); cmt++)
                            {
                                try
                                {
                                    objInstagramComment.Comment = Uri.EscapeDataString(usercmts.data[cmt].text);
                                    objInstagramComment.CommentDate = usercmts.data[cmt].created_time.ToString();
                                    objInstagramComment.CommentId = usercmts.data[cmt].id;
                                    objInstagramComment.EntryDate = DateTime.Now;
                                    objInstagramComment.FeedId = userinf2.data[j].id;
                                    objInstagramComment.Id = Guid.NewGuid();
                                    objInstagramComment.InstagramId = objInsAccount.InstagramId;
                                    objInstagramComment.UserId = objInsAccount.UserId;
                                    objInstagramComment.FromName = usercmts.data[cmt].from.full_name;
                                    objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture;
                                    if (!objInstagramCommentRepository.checkInstagramCommentExists(usercmts.data[cmt].id, objInsAccount.UserId))
                                        objInstagramCommentRepository.addInstagramComment(objInstagramComment);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.StackTrace);
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }
                            objInstagramFeed.EntryDate = DateTime.Now;
                            try
                            {
                                objInstagramFeed.FeedDate = userinf2.data[j].created_time.ToString();
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.StackTrace);
                            }
                            try
                            {
                                objInstagramFeed.FeedId = userinf2.data[j].id;
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.StackTrace);
                            }
                            try
                            {
                                objInstagramFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString();
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.StackTrace);
                            }
                            try
                            {
                                objInstagramFeed.InstagramId = objInsAccount.InstagramId;
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.StackTrace);
                            }
                            try
                            {
                                objInstagramFeed.LikeCount = userinf2.data[j].likes.count;
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.StackTrace);
                            }
                            try
                            {
                                objInstagramFeed.UserId = objInsAccount.UserId;
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.StackTrace);
                            }
                            try
                            {
                                objInstagramFeed.CommentCount = userinf2.data[j].comments.count;
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.StackTrace);
                            }
                            try
                            {
                                string str = userinf2.data[j].user_has_liked.ToString();

                                if (str == "False")
                                {
                                    objInstagramFeed.IsLike = 0;
                                }
                                else { objInstagramFeed.IsLike = 1; }
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.StackTrace);
                            }


                            try
                            {
                                objInstagramFeed.AdminUser = userinf2.data[j].caption.from.username;
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.StackTrace);
                            }


                            if (!objInstagramFeedRepository.checkInstagramFeedExists(userinf2.data[j].id, objInsAccount.UserId))
                                objInstagramFeedRepository.addInstagramFeed(objInstagramFeed);
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                        }
                        i++;
                    }
                }

                try
                {

                    userinf2 = userInstagram.CurrentUserFeed(string.Empty, string.Empty, "20", 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 = 0; cmt < usercmts.data.Count(); cmt++)
                            {
                                try
                                {
                                    objInstagramComment.Comment = Uri.EscapeDataString(usercmts.data[cmt].text);
                                    objInstagramComment.CommentDate = usercmts.data[cmt].created_time.ToString();
                                    objInstagramComment.CommentId = usercmts.data[cmt].id;
                                    objInstagramComment.EntryDate = DateTime.Now;
                                    objInstagramComment.FeedId = userinf2.data[j].id;
                                    objInstagramComment.Id = Guid.NewGuid();
                                    objInstagramComment.InstagramId = objInsAccount.InstagramId;
                                    objInstagramComment.UserId = objInsAccount.UserId;
                                    objInstagramComment.FromName = usercmts.data[cmt].from.full_name;
                                    objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture;
                                    if (!objInstagramCommentRepository.checkInstagramCommentExists(usercmts.data[cmt].id, objInsAccount.UserId))
                                        objInstagramCommentRepository.addInstagramComment(objInstagramComment);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.StackTrace);
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }
                            objInstagramFeed.EntryDate = DateTime.Now;
                            objInstagramFeed.FeedDate = userinf2.data[j].created_time.ToString();
                            objInstagramFeed.FeedId = userinf2.data[j].id;
                            objInstagramFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString();
                            objInstagramFeed.InstagramId = objInsAccount.InstagramId;
                            objInstagramFeed.LikeCount = userinf2.data[j].likes.count;
                            objInstagramFeed.CommentCount = userinf2.data[j].comments.count;
                            string str = userinf2.data[j].user_has_liked.ToString();
                            if (str == "False")
                            {
                                objInstagramFeed.IsLike = 0;
                            }
                            else { objInstagramFeed.IsLike = 1; }
                            objInstagramFeed.AdminUser = userinf2.data[j].caption.from.username + "-" + userinf2.data[j].caption.from.full_name;

                            objInstagramFeed.UserId = objInsAccount.UserId;
                            if (!objInstagramFeedRepository.checkInstagramFeedExists(userinf2.data[j].id, objInsAccount.UserId))
                                objInstagramFeedRepository.addInstagramFeed(objInstagramFeed);
                        }
                        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)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                // Session["AllHtmls"] = allhtmls;
                return totalhtml;
            }
        }
        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;

          
        }
Example #10
0
 public bool unlikefunction(string id, string userid, string accesstoken)
 {
     LikesController objlikes = new LikesController();
     bool dd = objlikes.DeleteLike(id, userid, accesstoken);
     return dd;
 }
        public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId)
        {
            string str = string.Empty;
            try
            {
                objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId));

                LikesController objlikes = new LikesController();
                int islike = Convert.ToInt32(IsLike);
                int LikeCounts = Convert.ToInt32(LikeCount);

                if (islike == 0)
                {
                    islike = 1;
                    bool dd = objlikes.PostUserLike(FeedId,objInstagramAccount.AccessToken);
                    LikeCounts++;
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "unlike";
               
                }
                else {
                    
                    islike = 0;
                    bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts = LikeCounts - 1;                   
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "like";
                
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);     
            }
            return str;
        }
Example #12
0
        public string BindData(DataTable dt)
        {
            string message = string.Empty;
            DataView dv = dt.DefaultView;
            dv.Sort = "MessageDate desc";
            DataTable sortedDT = dv.ToTable();
            int sorteddatacount = 0;
            LikesController objLikes = new LikesController();
            InstagramCommentRepository objCommentRepo = new InstagramCommentRepository();
            SocioBoard.Domain.User user = (SocioBoard.Domain.User)Session["LoggedUser"];
            foreach (DataRow row in sortedDT.Rows)
            {


                if (row["Network"].ToString() == "twitter")
                {
                    message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"messages taskable\"><section><aside><section class=\"js-avatar_tip\" data-sstip_class=\"twt_avatar_tip\">" +
                                "<a class=\"avatar_link view_profile\" href=\"javascript:void(0)\"><img id=\"formprofileurl_" + sorteddatacount + "\" onclick=\"detailsdiscoverytwitter(this.alt);\" width=\"54\" height=\"54\" border=\"0\" class=\"avatar\" src=\"" + row["FromProfileUrl"] + "\" alt=\"" + row["FromName"] + "\">" +
                                 "<article class=\"message-type-icon\"><span class=\"twitter_bm\"><img src=\"../Contents/Images/twticon.png\" width=\"16\" height=\"16\" /></span></article></a></section><ul></ul></aside><article><div class=\"\">" +
                                 "<a class=\"language\" href=\"\"></a></div><div class=\"message_actions\"><a class=\"gear_small\" href=\"#\"><span title=\"Options\" class=\"ficon\">?</span>" +
                                 "</a></div>";

                    message += "<div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-text font-14\">" + row["Message"] + "</div>" +
                                    "<section class=\"bubble-meta\">" +
                                       "<article class=\"threefourth text-overflow\">" +
                                           "<section class=\"floatleft\">" +
                                               "<a data-tip=\"View Yaroslav Lukashev's Profile\"  class=\"js-avatar_tip view_profile profile_link\" data-sstip_class=\"twt_avatar_tip\"><span id=\"network_" + sorteddatacount + "\" style=\"display:none;\">twitter</span><span style=\"display:none;\" id=\"messageid_" + sorteddatacount + "\">" + row["MessageId"] + "</span><span style=\"display:none;\" id=\"fromid_" + sorteddatacount + "\">" + row["FromId"] + "</span><span style=\"display:none;\" id=\"rowid_" + sorteddatacount + "\">" + row["ProfileId"] + "</span><span id=\"rowname_" + sorteddatacount + "\" onclick=\"detailsdiscoverytwitter(this.id);\">" + row["FromName"] + "</span>" +
                                               "</a>&nbsp;<a data-msg-time=\"1363926699000\" class=\"time\" target=\"_blank\" title=\"View message on Twitter\" href=\"#\">" + row["MessageDate"].ToString() + "</a>, <span class=\"location\" >&nbsp;</span>" +
                                    "</section></article><ul class=\"message-buttons quarter clearfix\"><li><a href=\"#\"><img src=\"../Contents/Images/replay.png\" alt=\"\" width=\"17\" height=\"24\" border=\"none\"  onclick=replyfunction(" + sorteddatacount + ") ></a></li>" +
                                    "<li><a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img src=\"../Contents/Images/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a></li>" +

                                       "</ul></section></article></section> </div>";
                }
                else if (row["Network"].ToString() == "linkedin")
                {

                    message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"messages taskable\"><section><aside><section class=\"js-avatar_tip\" data-sstip_class=\"twt_avatar_tip\">" +
                                        "<a class=\"avatar_link view_profile\" href=\"javascript:void(0)\"><img id=\"formprofileurl_" + sorteddatacount + "\" width=\"54\" height=\"54\" border=\"0\" class=\"avatar\" src=\"" + row["FromProfileUrl"] + "\" alt=\"\" onclick=\"getFacebookProfiles(this.alt);\" >" +
                                         "<article class=\"message-type-icon\"><span class=\"facebook_bm\"><img src=\"../Contents/Images/linked_25X24.png\"  width=\"16\" height=\"16\"/></span></article></a></section><ul></ul></aside><article><div class=\"\">" +
                                         "<a class=\"language\" href=\"\"></a></div><div class=\"message_actions\"><a class=\"gear_small\" href=\"#\"><span title=\"Options\" class=\"ficon\">?</span>" +
                                         "</a></div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-text font-14\">" + row["Message"] + "</div>" +
                                          "<section class=\"bubble-meta\">" +
                                             "<article class=\"threefourth text-overflow\">" +
                                                 "<section class=\"floatleft\">" +
                                                     "<a data-tip=\"View Yaroslav Lukashev's Profile\"  class=\"js-avatar_tip view_profile profile_link\"  data-sstip_class=\"twt_avatar_tip\"   ><span id=\"network_" + sorteddatacount + "\" style=\"display:none;\">facebook</span><span style=\"display:none;\" id=\"rowid_" + sorteddatacount + "\">" + row["ProfileId"] + "</span><span style=\"display:none;\" id=\"rowname_" + sorteddatacount + "\">" + row["FromName"] + "</span><span style=\"display:none;\" id=\"messageid_" + sorteddatacount + "\">" + row["MessageId"] + "</span><span style=\"display:none;\" id=\"fromid_" + sorteddatacount + "\">" + row["FromId"] + "</span><span id=\"" + row["FromId"] + "\"onclick=\"getFacebookProfiles(this.id);\" >" + row["FromName"] + "</span>" +
                                                     "</a>&nbsp;<a id=\"createdtime_" + sorteddatacount + "\" data-msg-time=\"1363926699000\" class=\"time\" target=\"_blank\" title=\"View message on Twitter\" href=\"#\">" + row["MessageDate"].ToString() + "</a><span class=\"location\">&nbsp;</span>" +
                                          "</section></article><ul class=\"message-buttons quarter clearfix\"><li><a href=\"#\"><img src=\"../Contents/Images/replay.png\" alt=\"\" width=\"17\" height=\"24\" border=\"none\" onclick=replyfunction(" + sorteddatacount + ") ></a></li>" +
                                          "<li><a  id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img src=\"../Contents/Images/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a></li>" +
                                          "<li><a id=\"savearchive_" + sorteddatacount + "\" href=\"#\" onclick=\"savearchivemsg(" + sorteddatacount + ");\"><img src=\"../Contents/Images/archive.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a></li>" +
                                            "</ul></section></article></section> </div>";

                }
                else if (row["Network"].ToString() == "facebook")
                {
                    message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"messages taskable\"><section><aside><section class=\"js-avatar_tip\" data-sstip_class=\"twt_avatar_tip\">" +
                                       "<a class=\"avatar_link view_profile\" href=\"javascript:void(0)\"><img id=\"formprofileurl_" + sorteddatacount + "\" width=\"54\" height=\"54\" border=\"0\" class=\"avatar\" src=\"" + row["FromProfileUrl"] + "\" alt=\"" + row["FromId"] + "\" onclick=\"getFacebookProfiles(this.alt);\" >" +
                                        "<article class=\"message-type-icon\"><span class=\"facebook_bm\"><img src=\"../Contents/Images/fb_icon.png\"  width=\"16\" height=\"16\"/></span></article></a></section><ul></ul></aside><article><div class=\"\">" +
                                        "<a class=\"language\" href=\"\"></a></div><div class=\"message_actions\"><a class=\"gear_small\" href=\"#\"><span title=\"Options\" class=\"ficon\">?</span>" +
                                        "</a></div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-text font-14\">" + row["Message"] + "</div>" +
                                         "<section class=\"bubble-meta\">" +
                                            "<article class=\"threefourth text-overflow\">" +
                                                "<section class=\"floatleft\">" +
                                                    "<a data-tip=\"View Yaroslav Lukashev's Profile\"  class=\"js-avatar_tip view_profile profile_link\"  data-sstip_class=\"twt_avatar_tip\"   ><span id=\"network_" + sorteddatacount + "\" style=\"display:none;\">facebook</span><span style=\"display:none;\" id=\"rowid_" + sorteddatacount + "\">" + row["ProfileId"] + "</span><span style=\"display:none;\" id=\"rowname_" + sorteddatacount + "\">" + row["FromName"] + "</span><span style=\"display:none;\" id=\"messageid_" + sorteddatacount + "\">" + row["MessageId"] + "</span><span style=\"display:none;\" id=\"fromid_" + sorteddatacount + "\">" + row["FromId"] + "</span><span id=\"" + row["FromId"] + "\"onclick=\"getFacebookProfiles(this.id);\" >" + row["FromName"] + "</span>" +
                                                    "</a>&nbsp;<a id=\"createdtime_" + sorteddatacount + "\" data-msg-time=\"1363926699000\" class=\"time\" target=\"_blank\" title=\"View message on Twitter\" href=\"#\">" + row["MessageDate"].ToString() + "</a><span class=\"location\">&nbsp;</span>" +
                                         "</section></article><ul class=\"message-buttons quarter clearfix\"><li><a href=\"#\"><img src=\"../Contents/Images/replay.png\" alt=\"\" width=\"17\" height=\"24\" border=\"none\" onclick=replyfunction(" + sorteddatacount + ") ></a></li>" +
                                         "<li><a  id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img src=\"../Contents/Images/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a></li>" +
                                         "<li><a id=\"savearchive_" + sorteddatacount + "\" href=\"#\" onclick=\"savearchivemsg(" + sorteddatacount + ");\"><img src=\"../Contents/Images/archive.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a></li>" +
                                           "</ul></section></article></section> </div>";
                }
                else if (row["Network"].ToString() == "instagram")
                {
                    message += "<div id =\"div_" + sorteddatacount + "\" class=\"instagram_img_textbg\">" +

                     "<div class=\"inst_minage_bg\"><img id=img_" + sorteddatacount + " src=\"" + row["Message"] + "\" alt=\"" + row["MessageId"] + "\" border=\"none\" width=\"240\" height=\"240\" /></div>" +
                             " <div class=\"inst_comment_bg\">" +

                               "<div class=\"inputbg\"><input id= textcomment_" + sorteddatacount + " type=\"text\" value=\"\" /></div>" +

                               "<div class=\"instg_liec_bg\">";
                    bool liked = false;
                    try
                    {
                        //liked = objLikes.LikeToggle(row["FeedId"], row["InstagramId"], item.AccessToken);
                    }
                    catch
                    {
                    }
                    if (!liked)
                    {
                        message += "<div class=\"like_btnbg\"><a id = \"" + row["MessageId"] + "\" class=\"instagram unliked_liked\" href=\"javascript:void(0);\"  onclick =\"showinsprof(this.id)\"></a></div>" +
                                    " <div class=\"comment_btnbg\"><a id=\"comment_" + sorteddatacount + "\" href=\"javascript:void(0);\"  onclick=\"showinsprof(this.id);\"></a></div>" +

                                   "</div></div>";

                    }
                    else
                    {
                        message += "<div class=\"like_btnbg\"><a id = \"" + row["MessageId"] + "\" class=\"instagram liked\" href=\"javascript:void(0);\"  onclick =\"showinsprof(this.id)\"></a></div>" +
                                    " <div class=\"comment_btnbg\"><a id=\"comment_" + sorteddatacount + "\" href=\"javascript:void(0);\"  onclick=\"showinsprof(this.id);\"></a></div>" +

                                   "</div></div>";
                    }
                    List<InstagramComment> lstcomment = objCommentRepo.getAllInstagramCommentsOfUser(user.Id, row["ProfileId"].ToString(), row["MessageId"].ToString());
                    if (lstcomment != null)
                    {
                        try
                        {
                            foreach (InstagramComment insFeed in lstcomment)
                            {
                                message += "<div class=\"instagram_comment_div\">" +
                                 "<div class=\"user_photo\"><img src=\"" + insFeed.FromProfilePic + "\" width=\"30\" height=\"30\" alt=\"\" /></div>" +
                                 "<div class=\"comment_details\">" +
                                     "<div class=\"user_name\">" + insFeed.FromName + "</div>" +
                                     " <div class=\"user_name_description\">" + insFeed.Comment + "</div>" +
                                 "</div>" +
                              "</div>";
                            }
                        }
                        catch (Exception err)
                        { }
                    }
                    //  html += "<div class=\"instagram_comment_div\">" +
                    //   "<div class=\"user_photo\"><img src=\"" + usercmts.data[n - 1].from.profile_picture + "\" width=\"30\" height=\"30\" alt=\"\" /></div>" +
                    //   "<div class=\"comment_details\">" +
                    //       "<div class=\"user_name\">" + usercmts.data[n - 1].from.username + "</div>" +
                    //       " <div class=\"user_name_description\">" + usercmts.data[n - 1].text + "</div>" +
                    //   "</div>" +
                    //"</div>" +


                    //               "<div class=\"instagram_comment_div\">" +
                    //   "<div class=\"user_photo\"><img src=\"" + usercmts.data[n - 2].from.profile_picture + "\" width=\"30\" height=\"30\" alt=\"\" /></div>" +
                    //   "<div class=\"comment_details\">" +
                    //       "<div class=\"user_name\">" + usercmts.data[n - 2].from.username + "</div>" +
                    //       " <div class=\"user_name_description\">" + usercmts.data[n - 2].text + "</div>" +
                    //   "</div>" +
                    //"</div>" +


                    //  "<div class=\"instagram_comment_div\">" +
                    //   "<div class=\"user_photo\"><img src=\"" + usercmts.data[n - 3].from.profile_picture + "\" width=\"30\" height=\"30\" alt=\"\" /></div>" +
                    //   "<div class=\"comment_details\">" +
                    //       "<div class=\"user_name\">" + usercmts.data[n - 3].from.username + "</div>" +
                    //       " <div class=\"user_name_description\">" + usercmts.data[n - 3].text + "</div>" +
                    //   "</div>" +
                    //"</div>" +
                    message += "</div>";
                }
                sorteddatacount++;
            }

            return message;


        }
Example #13
0
        void ProcessRequest()
        {
            Domain.User user = (Domain.User)Session["LoggedUser"];
            if (Request.QueryString["op"] != null)
            {
                if (Request.QueryString["op"] == "bindFeeds")
                {

                    clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();
                    string network = Request.QueryString["network"];
                        DataSet ds = clsfeedsandmess.bindFeedsIntoDataTable(user, network);
                        if (network == "facebook")
                        {
                            Session["FacebookFeedDataTable"] = ds.Tables[0];
                        }
                        else if (network == "twitter")
                        {
                            Session["TwitterFeedDataTable"] = ds.Tables[0];
                        }
                        else if (network == "linkedin")
                        {
                            Session["LinkedInFeedDataTable"] = ds.Tables[0];
                        }
                        else if (network == "instagram")
                        {
                            Session["InstagramFeedDataTable"] = ds.Tables[0];
                        }
                        string message = this.BindData(ds.Tables[0]);
                        Response.Write(message);

                }
                else if (Request.QueryString["op"] == "bindProfiles")
                {
                    int i = 0;
                    string profiles = string.Empty;
                    profiles += "<ul class=\"options_list\">";
                    string network = Request.QueryString["network"];

                    if (!string.IsNullOrEmpty(network))
                    {

                        /*facebook profiles for feeds tab*/
                        if (network == "facebook")
                        {
                            FacebookAccountRepository facerepo = new FacebookAccountRepository();
                            ArrayList alstfacebookprofiles = facerepo.getAllFacebookAccountsOfUser(user.Id);
                            foreach (FacebookAccount item in alstfacebookprofiles)
                            {
                                profiles += "<li><a id=\"greencheck_" + i + "\" ><span class=\"network_icon\">" +
                                            "<img src=\"../Contents/Images/fb_icon.png\" width=\"17\" height=\"16\" alt=\"\" /></span>" +
                                         "<span id=\"profileusername_" + i + "\" class=\"user_name\">" + item.FbUserName + "</span><input type=\"hidden\" id=\"fbhidden_" + i + "\" value=\"" + item.FbUserId + "\" /> <span id=\"checkid_" + i + "\" class=\"checkbx_green\">" +
                                             "<img id=\"checkimg_" + i + "\" src=\"../Contents/Images/msg/network_click.png\" width=\"17\" height=\"17\" alt=\"\" onclick=\"checkprofile(this.id,'feed','facebook');\" /></span>" +
                                     "</a></li> ";
                                i++;
                            }
                        }
                        else if (network == "twitter")
                        {
                            TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                            ArrayList asltwitterprofiles = twtaccountrepo.getAllTwitterAccountsOfUser(user.Id);
                            foreach (TwitterAccount item in asltwitterprofiles)
                            {
                                profiles += "<li><a id=\"greencheck_" + i + "\" ><span class=\"network_icon\">" +
                                     "<img src=\"../Contents/Images/msg/network_twt.png\" width=\"17\" height=\"16\" alt=\"\" /></span>" +
                                  "<span id=\"profileusername_" + i + "\" class=\"user_name\">" + item.TwitterScreenName + "</span> <span id=\"checkid_" + i + "\" class=\"checkbx_green\"><input type=\"hidden\" id=\"twthidden_" + i + "\" value=\"" + item.TwitterUserId + "\">" +
                                      "<img id=\"checkimg_" + i + "\" src=\"../Contents/Images/msg/network_click.png\" width=\"17\" height=\"17\" alt=\"\"  onclick=\"checkprofile(this.id,'feed','twitter');\"/></span>" +
                              "</a></li> ";
                                i++;
                            }
                        }
                        else if (network == "linkedin")
                        {
                            LinkedInAccountRepository liRepo = new LinkedInAccountRepository();
                            ArrayList asllinkedinProfiles = liRepo.getAllLinkedinAccountsOfUser(user.Id);
                            foreach (LinkedInAccount item in asllinkedinProfiles)
                            {
                                profiles += "<li><a id=\"greencheck_" + i + "\" ><span class=\"network_icon\">" +
                                     "<img src=\"../Contents/Images/msg/network_linked.png\" width=\"17\" height=\"16\" alt=\"\" /></span>" +
                                  "<span id=\"profileusername_" + i + "\" class=\"user_name\">" + item.LinkedinUserName + "</span> <span id=\"checkid_" + i + "\" class=\"checkbx_green\"><input type=\"hidden\" id=\"twthidden_" + i + "\" value=\"" + item.LinkedinUserId + "\">" +
                                      "<img id=\"checkimg_" + i + "\" src=\"../Contents/Images/msg/network_click.png\" width=\"17\" height=\"17\" alt=\"\"  onclick=\"checkprofile(this.id,'feed','linkedin');\"/></span>" +
                              "</a></li> ";
                                i++;
                            }
                            profiles += "</ul><input type=\"hidden\" id=\"profilecounter\" value=\"" + i + "\">";
                        }
                        else if (network == "instagram")
                        {
                            InstagramAccountRepository InsRepo = new InstagramAccountRepository();
                            ArrayList aslinstagramProfiles = InsRepo.getAllInstagramAccountsOfUser(user.Id);
                            foreach (InstagramAccount item in aslinstagramProfiles)
                            {
                                profiles += "<li><a id=\"greencheck_" + i + "\" ><span class=\"network_icon\">" +
                                     "<img src=\"../Contents/Images/instagram_24X24.png\" width=\"17\" height=\"16\" alt=\"\" /></span>" +
                                  "<span id=\"profileusername_" + i + "\" class=\"user_name\">" + item.InsUserName + "</span> <span id=\"checkid_" + i + "\" class=\"checkbx_green\"><input type=\"hidden\" id=\"twthidden_" + i + "\" value=\"" + item.InstagramId + "\">" +
                                      "<img id=\"checkimg_" + i + "\" src=\"../Contents/Images/msg/network_click.png\" width=\"17\" height=\"17\" alt=\"\"  onclick=\"checkprofile(this.id,'feed','instagram');\"/></span>" +
                              "</a></li> ";
                                i++;
                            }
                            profiles += "</ul><input type=\"hidden\" id=\"profilecounter\" value=\"" + i + "\">";
                        }
                            Response.Write(profiles);
                    }

                }
                else if (Request.QueryString["op"] == "IntagramProfiles")
                {
                    InstagramAccountRepository InsRepo = new InstagramAccountRepository();
                    ArrayList aslinstagramProfiles = InsRepo.getAllInstagramAccountsOfUser(user.Id);
                    string profiles = string.Empty;
                    string mediaId=Request.QueryString["mediaId"].ToString();
                    foreach (InstagramAccount item in aslinstagramProfiles)
                    {
                        profiles += " <img onclick='postLikeRequest("+ mediaId +","+ item.InstagramId +"," + item.AccessToken + ")' id='" + item.InstagramId + "' src='" + item.ProfileUrl + "'/>";
                    }
                    Response.Write(profiles);
                }
                else if (Request.QueryString["op"] == "postLike")
                {
                    LikesController objlikectr = new LikesController();
                    bool postlike= objlikectr.PostUserLike(Request.QueryString["mediaId"], Request.QueryString["InstagramId"], Request.QueryString["access"]);
                    Response.Write(postlike);
                }
                else if (Request.QueryString["op"] == "updatewallposts")
                {

                    //FacebookAccountRepository fbrepo = new FacebookAccountRepository();
                    //ArrayList alstfbaccounts = fbrepo.getAllFacebookAccountsOfUser(user.Id);
                    //foreach (FacebookAccount item in alstfbaccounts)
                    //{
                    //    FacebookClient fb = new FacebookClient(item.AccessToken);
                    //    FacebookHelper fbhelper = new FacebookHelper();
                    //    var feeds = fb.Get("/me/feed");
                    //    var home = fb.Get("me/home");
                    //    var profile = fb.Get("me");

                    //    long friendscount = 0;
                    //    try
                    //    {
                    //        dynamic friedscount = fb.Get("fql", new { q = "SELECT friend_count FROM user WHERE uid=me()" });
                    //        foreach (var friend in friedscount.data)
                    //        {
                    //            friendscount = friend.friend_count;
                    //        }
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        Console.WriteLine(ex.StackTrace);
                    //    }
                    //    fbhelper.getFacebookUserHome(home, profile);

                    //    fbhelper.getFacebookUserFeeds(feeds, profile);
                    //    fbhelper.getFacebookUserProfile(profile, item.AccessToken, friendscount, user.Id);
                    //}

                    //clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();
                    //DataSet ds = clsfeedsandmess.bindFeedsIntoDataTable(user);
                    //string message = this.BindData(ds.Tables[0]);
                    //Response.Write(message);

                }
            }
        }