public string getAllFacebookFeedsByUserIdAndProfileId(string UserId, string ProfileId)
        {
             //List<Domain.Socioboard.Domain.FacebookFeed> lstFacebookFeed=new List<Domain.Socioboard.Domain.FacebookFeed> ();
            //try
            //{
            //    if (objFacebookFeedRepository.checkFacebookUserExists(ProfileId, Guid.Parse(UserId)))
            //    {
            //        lstFacebookFeed = objFacebookFeedRepository.getAllFacebookFeeds(Guid.Parse(UserId), ProfileId);
            //    }
            //    else
            //    {
            //         lstFacebookFeed = objFacebookFeedRepository.getAllFacebookUserFeeds(ProfileId);
            //    }
            //    return new JavaScriptSerializer().Serialize(lstFacebookFeed);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return "Something Went Wrong";
            //}

            MongoRepository boardrepo = new MongoRepository("MongoFacebookFeed");
            try
            {

                var result = boardrepo.Find<MongoFacebookFeed>(t => t.UserId.Equals(UserId)&&t.ProfileId.Equals(ProfileId)).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<MongoFacebookFeed> objfbfeeds = task.Result;
                if (objfbfeeds.Count() == 0)
                {

                    result = boardrepo.Find<MongoFacebookFeed>(x => x.ProfileId.Equals(ProfileId)).ConfigureAwait(false);

                    task = Task.Run(async () =>
                    {
                        return await result;
                    });
                }
                return new JavaScriptSerializer().Serialize(objfbfeeds);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
Exemplo n.º 2
0
        public void TestGetById()
        {
            var repo = new MongoRepository<Team>(_db);
            var team = new Team()
            {
                Name = "Tom"
            };
            repo.Save(team);
            var id = team.Id;

            var teamRefresh = repo.Find(id);

            Assert.AreEqual(teamRefresh.Name, "Tom");
        }
        public static List <InstagramFeed> GetVideoPosts(string profileId, int daysCount)
        {
            var instagramFeedRepo = new MongoRepository("InstagramFeed");

            var dayStart = new DateTime(DateTime.UtcNow.AddDays(-(daysCount)).Year, DateTime.UtcNow.AddDays(-(daysCount)).Month, DateTime.UtcNow.AddDays(-(daysCount)).Day, 0, 0, 0, DateTimeKind.Utc);
            var dayEnd   = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 23, 59, 59, DateTimeKind.Utc);
            var ret      = instagramFeedRepo.Find <InstagramFeed>(t => t.InstagramId == profileId && t.FeedDate <= SBHelper.ConvertToUnixTimestamp(dayEnd) && t.FeedDate >= SBHelper.ConvertToUnixTimestamp(dayStart) && t.Type == "video");
            var task     = Task.Run(async() =>
            {
                return(await ret);
            });
            var lstInstagramFeed = task.Result.GroupBy(x => x.FeedId).Select(g => g.First()).ToList();

            return(lstInstagramFeed.ToList());
        }
        public static List <Domain.Socioboard.Models.Mongo.FacebookPagePost> getFacebookPagePostReports(string profileId, int daysCount, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
        {
            MongoRepository mongorepo = new MongoRepository("FacebookPagePost", _appSettings);

            DateTime dayStart = new DateTime(DateTime.UtcNow.AddDays(-90).Year, DateTime.UtcNow.AddDays(-90).Month, DateTime.UtcNow.AddDays(-90).Day, 0, 0, 0, DateTimeKind.Utc);
            DateTime dayEnd   = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 23, 59, 59, DateTimeKind.Utc);
            var      ret      = mongorepo.Find <Domain.Socioboard.Models.Mongo.FacebookPagePost>(t => t.PageId == profileId && (t.CreatedTime <= Helper.DateExtension.ToUnixTimestamp(dayEnd) && t.CreatedTime >= Helper.DateExtension.ToUnixTimestamp(dayStart)));
            var      task     = Task.Run(async() =>
            {
                return(await ret);
            });
            IList <Domain.Socioboard.Models.Mongo.FacebookPagePost> lstfacebookpagepost = task.Result.ToList();

            return(lstfacebookpagepost.ToList());
        }
Exemplo n.º 5
0
        //public static void CreateInstagrmaReport()
        //{
        //    while (true)
        //    {
        //        try
        //        {
        //            DatabaseRepository dbr = new DatabaseRepository();
        //            List<Domain.Socioboard.Models.Instagramaccounts> lstInsAcc = dbr.Find<Domain.Socioboard.Models.Instagramaccounts>(t => t.AccessToken != null).ToList();
        //            foreach (var item in lstInsAcc)
        //            {
        //                if (item.lastpagereportgenerated.AddHours(24) <= DateTime.UtcNow)
        //                {
        //                    CreateReports(item.InstagramId, item.Is90DayDataUpdated);
        //                    item.Is90DayDataUpdated = true;
        //                    item.lastpagereportgenerated = DateTime.UtcNow;
        //                    dbr.Update<Domain.Socioboard.Models.Instagramaccounts>(item);
        //                }
        //            }
        //            Thread.Sleep(120000);
        //        }
        //        catch (Exception ex)
        //        {
        //            Console.WriteLine("issue in web api calling" + ex.StackTrace);
        //            Thread.Sleep(600000);
        //        }
        //    }
        //}

        //public static void CreateReports(string InstagramId, bool is90daysupdated)
        //{

        //    int day = 1;
        //    if (!is90daysupdated)
        //    {
        //        day = 90;
        //    }
        //    List<Domain.Socioboard.Models.Mongo.InstagramFeed> lstGetVideoPosts = GetVideoPosts(InstagramId, day);
        //    List<Domain.Socioboard.Models.Mongo.InstagramFeed> lstGetImagePosts = GetImagePosts(InstagramId, day);
        //    Domain.Socioboard.Models.Instagramaccounts _InstagramUserDetails = GetInstagramUserDeatils(InstagramId);
        //    List<Domain.Socioboard.Models.Mongo.InstagramComment> lstGetInstagramPostComments = GetInstagramPostComments(InstagramId, day);
        //    List<Domain.Socioboard.Models.Mongo.InstagramPostLikes> lstGetInstagramPostLikes = GetInstagramPostLikes(InstagramId, day);
        //    List<Domain.Socioboard.Models.Mongo.MongoTwitterMessage> lstMongoTwitterMessage = GetInstagramFollwerFollowing(InstagramId, day);
        //    for (int i = 1; i < day; i++)
        //    {
        //        Domain.Socioboard.Models.Mongo.InstagramDailyReport _InstagramDailyReport = new Domain.Socioboard.Models.Mongo.InstagramDailyReport();
        //        double since = SBHelper.ConvertToUnixTimestamp(new DateTime(DateTime.UtcNow.AddDays(-(i)).Year, DateTime.UtcNow.AddDays(-(i)).Month, DateTime.UtcNow.AddDays(-(i)).Day, 0, 0, 0, DateTimeKind.Utc));
        //        double until = SBHelper.ConvertToUnixTimestamp(new DateTime(DateTime.UtcNow.AddDays(-i).Year, DateTime.UtcNow.AddDays(-i).Month, DateTime.UtcNow.AddDays(-i).Day, 23, 59, 59, DateTimeKind.Utc));
        //        // lstGetVideoPosts = lstGetVideoPosts.Where(t => t.FeedDate <= until && t.FeedDate >= since).ToList();
        //        //lstGetImagePosts= lstGetImagePosts.Where(t => t.FeedDate <= until && t.FeedDate >= since).ToList();
        //        //lstGetInstagramPostComments= lstGetInstagramPostComments.Where(t => t.Created_Time <= until && t.Created_Time >= since).ToList();
        //        //lstGetInstagramPostLikes= lstGetInstagramPostLikes.Where(t => t.Created_Date <= until && t.Created_Date >= since).ToList();
        //        //lstMongoTwitterMessage= lstMongoTwitterMessage.Where(t => t.messageTimeStamp <= until && t.messageTimeStamp >= since).ToList();

        //        _InstagramDailyReport.id = ObjectId.GenerateNewId();
        //        _InstagramDailyReport.date = since;
        //        _InstagramDailyReport.followcount = Convert.ToInt64(lstMongoTwitterMessage.Count(t => t.messageTimeStamp <= until && t.messageTimeStamp >= since && t.type == Domain.Socioboard.Enum.TwitterMessageType.InstagramFollower));
        //        _InstagramDailyReport.followingcount = Convert.ToInt64(lstMongoTwitterMessage.Count(t => t.messageTimeStamp <= until && t.messageTimeStamp >= since && t.type == Domain.Socioboard.Enum.TwitterMessageType.InstagramFollowing));
        //        _InstagramDailyReport.fullName = _InstagramUserDetails.InsUserName;
        //        _InstagramDailyReport.imagepost = Convert.ToInt64(lstGetImagePosts.Count(t => t.FeedDate <= until && t.FeedDate >= since));
        //        _InstagramDailyReport.instaName = _InstagramUserDetails.InsUserName;
        //        _InstagramDailyReport.mediaCount = Convert.ToInt64(lstGetVideoPosts.Count(t => t.FeedDate <= until && t.FeedDate >= since) + lstGetImagePosts.Count(t => t.FeedDate <= until && t.FeedDate >= since));
        //        _InstagramDailyReport.postcomment = Convert.ToInt64(lstGetInstagramPostComments.Count(t => t.CommentDate <= until && t.CommentDate >= since));
        //        _InstagramDailyReport.postlike = Convert.ToInt64(lstGetInstagramPostLikes.Count(t => t.Created_Date <= until && t.Created_Date >= since));
        //        _InstagramDailyReport.profileId = _InstagramUserDetails.InstagramId;
        //        _InstagramDailyReport.videopost = Convert.ToInt64(lstGetVideoPosts.Count(t => t.FeedDate <= until && t.FeedDate >= since));
        //        _InstagramDailyReport.profilePicUrl = _InstagramUserDetails.ProfileUrl;
        //        MongoRepository mongorepo = new MongoRepository("InstagramDailyReport");
        //        var ret = mongorepo.Find<Domain.Socioboard.Models.Mongo.InstagramDailyReport>(t => t.date == _InstagramDailyReport.date && t.profileId == InstagramId);
        //        var task = Task.Run(async () => {
        //            return await ret;
        //        });
        //        int count = task.Result.Count;
        //        if (count < 1)
        //        {
        //            mongorepo.Add<Domain.Socioboard.Models.Mongo.InstagramDailyReport>(_InstagramDailyReport);
        //        }
        //    }
        //}



        public static List <Domain.Socioboard.Models.Mongo.InstagramFeed> GetVideoPosts(string profileId, DateTime start, DateTime end)
        {
            MongoRepository instagramFeedRepo = new MongoRepository("InstagramFeed");

            DateTime dayStart = new DateTime(start.Year, start.Month, start.Day, 0, 0, 0, DateTimeKind.Utc);
            DateTime dayEnd   = new DateTime(end.Year, end.Month, end.Day, 23, 59, 59, DateTimeKind.Utc);
            var      ret      = instagramFeedRepo.Find <Domain.Socioboard.Models.Mongo.InstagramFeed>(t => t.InstagramId == profileId && t.FeedDate <= SBHelper.ConvertToUnixTimestamp(dayEnd) && t.FeedDate >= SBHelper.ConvertToUnixTimestamp(dayStart) && t.Type == "video");
            var      task     = Task.Run(async() =>
            {
                return(await ret);
            });
            IList <Domain.Socioboard.Models.Mongo.InstagramFeed> lstInstagramFeed = task.Result.GroupBy(x => x.FeedId).Select(g => g.First()).ToList();

            return(lstInstagramFeed.ToList());
        }
Exemplo n.º 6
0
        public static List <TwitterFan> GetTopFiveFans(string profileId, int daysCount, Helper.Cache _redisCache, Helper.AppSettings settings)
        {
            MongoRepository mongorepo = new MongoRepository("MongoTwitterMessage", settings);
            DateTime        dayStart  = new DateTime(DateTime.UtcNow.AddDays(-1 * daysCount).Year, DateTime.UtcNow.AddDays(-1 * daysCount).Month, DateTime.UtcNow.AddDays(-1 * daysCount).Day, 0, 0, 0, DateTimeKind.Utc);
            DateTime        dayEnd    = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 23, 59, 59, DateTimeKind.Utc);
            var             result    = mongorepo.Find <MongoTwitterMessage>(t => (t.messageTimeStamp > SBHelper.ConvertToUnixTimestamp(dayStart)) && (t.messageTimeStamp < SBHelper.ConvertToUnixTimestamp(dayEnd)) && t.profileId == profileId && (t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterMention || t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterRetweet));
            var             task      = Task.Run(async() =>
            {
                return(await result);
            });
            IList <Domain.Socioboard.Models.Mongo.MongoTwitterMessage> lstTwtMessages = task.Result;
            List <TwitterFan> lstTwtTopFans = lstTwtMessages.GroupBy(t => t.fromId).Select(g => new TwitterFan(g.ToList())).OrderBy(x => x.totalCount).Take(5).ToList();

            return(lstTwtTopFans);
        }
Exemplo n.º 7
0
        public static List <Domain.Socioboard.Models.Mongo.RssNewsContentsFeeds> GetRssNewsPostedFeeds(string userId, Helper.AppSettings _appSettings)
        {
            string[]        profileids     = null;
            MongoRepository _RssRepository = new MongoRepository("RssNewsContentsFeeds", _appSettings);
            List <Domain.Socioboard.Models.Mongo.RssNewsContentsFeeds> lstRss = new List <Domain.Socioboard.Models.Mongo.RssNewsContentsFeeds>();
            //List<Domain.Socioboard.Models.Groupprofiles> lstGroupprofiles = dbr.Find<Domain.Socioboard.Models.Groupprofiles>(t => t.profileOwnerId == userId).ToList();
            //profileids = lstGroupprofiles.Select(t => t.profileId).ToArray();
            var ret  = _RssRepository.Find <Domain.Socioboard.Models.Mongo.RssNewsContentsFeeds>(t => t.UserId == userId);//UserId
            var task = Task.Run(async() =>
            {
                return(await ret);
            });

            return(lstRss = task.Result.ToList());
        }
        public static string AddPageShareathon(long userId, string FacebookUrl, string FacebookPageId, string Facebookaccountid, int Timeintervalminutes, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr)
        {
            Domain.Socioboard.Models.Facebookaccounts objfacebook = Repositories.FacebookRepository.getFacebookAccount(Facebookaccountid, _redisCache, dbr);
            string pageid = Helper.FacebookHelper.GetFbPageDetails(FacebookUrl, objfacebook.AccessToken);

            string[] profileids = null;
            profileids = FacebookPageId.Split(',');
            string facebookpagename = "";

            Domain.Socioboard.Models.Mongo.PageShareathon _Shareathon = new Domain.Socioboard.Models.Mongo.PageShareathon();
            _Shareathon.Id                = ObjectId.GenerateNewId();
            _Shareathon.strId             = ObjectId.GenerateNewId().ToString();
            _Shareathon.Facebookaccountid = objfacebook.FbUserId;
            _Shareathon.Facebookusername  = objfacebook.FbUserName;
            _Shareathon.Facebookpageid    = FacebookPageId;
            _Shareathon.FacebookPageUrl   = FacebookUrl;
            _Shareathon.FacebookPageUrlId = pageid.TrimEnd(',');
            foreach (var item in profileids)
            {
                Domain.Socioboard.Models.Facebookaccounts objfacebookpage = Repositories.FacebookRepository.getFacebookAccount(item, _redisCache, dbr);
                if (objfacebookpage != null)
                {
                    facebookpagename = objfacebookpage.FbUserName + ',' + facebookpagename;
                }
            }
            _Shareathon.Facebookpagename    = facebookpagename.TrimEnd(',');
            _Shareathon.FacebookStatus      = 1;
            _Shareathon.Timeintervalminutes = Timeintervalminutes;
            _Shareathon.Userid             = userId;
            _Shareathon.Lastsharetimestamp = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
            MongoRepository _ShareathonRepository = new MongoRepository("Shareathon", _appSettings);
            var             ret  = _ShareathonRepository.Find <Domain.Socioboard.Models.Mongo.PageShareathon>(t => t.Facebookpageid == FacebookPageId && t.Facebookaccountid == Facebookaccountid && t.FacebookPageUrl == FacebookUrl && t.Userid == userId && t.FacebookStatus == 1);
            var             task = Task.Run(async() =>
            {
                return(await ret);
            });
            int count = task.Result.Count;

            if (count > 0)
            {
                return("already added");
            }
            else
            {
                _ShareathonRepository.Add(_Shareathon);
                return("added successfully");
            }
        }
Exemplo n.º 9
0
        public static void CreateReports(string profileId, DateTime date)
        {
            List <MongoTwitterMessage>        lstTwitterMessages         = TwitterReports.GetTwitterMessages(profileId, date);
            List <MongoTwitterMessage>        lstreceived                = lstTwitterMessages.Where(x => x.fromId.Contains(profileId)).ToList();
            List <MongoTwitterDirectMessages> lstTwitterDirectMessages   = TwitterReports.GetTwitterDirectMessages(profileId, date);
            List <Domain.Socioboard.Models.ScheduledMessage> lstschedule = GetScheduledMessage(profileId, date);
            MongoRepository mongorepo = new MongoRepository("MongoTwitterDailyReports");

            MongoTwitterDailyReports todayReports = new MongoTwitterDailyReports();

            todayReports.mentions     = lstTwitterMessages.Count(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterMention);
            todayReports.newFollowers = lstTwitterMessages.Count(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterFollower);
            todayReports.timeStamp    = SBHelper.ConvertToUnixTimestamp(date);
            todayReports.retweets     = lstTwitterMessages.Count(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterRetweet);
            //todayReports.newFollowing = lstTwitterMessages.Count(t=>t.type == Domain.Socioboard.Enum.TwitterMessageType.tw)
            todayReports.directMessagesReceived = lstTwitterDirectMessages.Count(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterDirectMessageReceived);
            todayReports.directMessagesSent     = lstTwitterDirectMessages.Count(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterDirectMessageSent);
            todayReports.profileId        = profileId;
            todayReports.id               = ObjectId.GenerateNewId();
            todayReports.messagesReceived = lstreceived.Count() + lstTwitterDirectMessages.Count(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterDirectMessageReceived);
            todayReports.messagesSent     = lstschedule.Count();
            DateTime dayStart = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0, DateTimeKind.Utc);
            DateTime dayEnd   = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59, DateTimeKind.Utc);
            var      result   = mongorepo.Find <MongoTwitterDailyReports>(t => t.profileId.Equals(profileId) && (t.timeStamp > SBHelper.ConvertToUnixTimestamp(dayStart)) && (t.timeStamp < SBHelper.ConvertToUnixTimestamp(dayEnd)));
            var      task     = Task.Run(async() =>
            {
                return(await result);
            });
            IList <MongoTwitterDailyReports> lstDailyReports = task.Result;

            if (lstDailyReports != null && lstDailyReports.Count() > 0)
            {
                lstDailyReports.First().mentions               = todayReports.mentions;
                lstDailyReports.First().newFollowers           = todayReports.newFollowers;
                lstDailyReports.First().newFollowing           = todayReports.newFollowing;
                lstDailyReports.First().profileId              = profileId;
                lstDailyReports.First().timeStamp              = SBHelper.ConvertToUnixTimestamp(date);
                lstDailyReports.First().directMessagesSent     = todayReports.directMessagesSent;
                lstDailyReports.First().directMessagesReceived = todayReports.directMessagesReceived;
                lstDailyReports.First().messagesReceived       = todayReports.messagesReceived;
                lstDailyReports.First().messagesSent           = todayReports.messagesSent;
                mongorepo.UpdateReplace(lstDailyReports.First(), t => t.id == lstDailyReports.First().id);
            }
            else
            {
                mongorepo.Add <MongoTwitterDailyReports>(todayReports);
            }
        }
Exemplo n.º 10
0
        public static List <Domain.Socioboard.Models.Mongo.Rss> GetRssDataByUser(long userId, long groupId, Helper.AppSettings _appSettings, DatabaseRepository dbr)
        {
            string[]        profileids     = null;
            MongoRepository _RssRepository = new MongoRepository("Rss", _appSettings);
            List <Domain.Socioboard.Models.Mongo.Rss>     lstRss           = new List <Domain.Socioboard.Models.Mongo.Rss>();
            List <Domain.Socioboard.Models.Groupprofiles> lstGroupprofiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId).ToList();

            profileids = lstGroupprofiles.Select(t => t.profileId).ToArray();
            var ret  = _RssRepository.Find <Domain.Socioboard.Models.Mongo.Rss>(t => profileids.Contains(t.ProfileId));
            var task = Task.Run(async() =>
            {
                return(await ret);
            });

            return(lstRss = task.Result.ToList());
        }
Exemplo n.º 11
0
        public void UpdateTrendsKeywordfeed()
        {
            MongoRepository mongorepo = new MongoRepository("Trendingkeyword");
            var             ret       = mongorepo.Find <Trendingkeyword>(t => t.TrendingType == Domain.Socioboard.Enum.TrendingType.twitter);
            var             task      = Task.Run(async() =>
            {
                return(await ret);
            });
            List <Trendingkeyword> lstTrendingkeyword = task.Result.ToList();

            foreach (var item in lstTrendingkeyword)
            {
                AddTwittertrendingHashTagFeeds(item.keyword, item.strId, null);
            }
            Thread.Sleep(1000 * 50);
        }
Exemplo n.º 12
0
        public static List <Domain.Socioboard.Models.Mongo.AdvanceSerachData> TwitterAdvanceRepository(Domain.Socioboard.Enum.NetworkType networkType, Helper.Cache _redisCache, Helper.AppSettings settings)
        {
            MongoRepository _RssRepository = new MongoRepository("AdvanceSerachData", settings);
            List <Domain.Socioboard.Models.Mongo.AdvanceSerachData> lstTwitter = new List <Domain.Socioboard.Models.Mongo.AdvanceSerachData>();

            var ret  = _RssRepository.Find <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(t => t.networkType == networkType);//UserId
            var task = Task.Run(async() =>
            {
                return(await ret);
            });

            lstTwitter = task.Result.ToList();
            var lstyu = lstTwitter.OrderByDescending(gp => gp.totalShareCount);

            return(lstyu.ToList());
        }
        public string FacebookFeedSentimet(string startedIndex, string count)
        {
            var ret  = FacebookFeedRepo.Find <Domain.Socioboard.Domain.MongoFacebookFeed>(t => !string.IsNullOrEmpty(t.FeedDescription));
            var task = Task.Run(async() =>
            {
                return(await ret);
            });
            IList <Domain.Socioboard.Domain.MongoFacebookFeed> _lstMongoFacebookFeed = task.Result;
            List <Domain.Socioboard.Domain.MongoFacebookFeed>  lstMongoFacebookFeed  = _lstMongoFacebookFeed.Where(t => t.Positive == 0).GroupBy(x => x.FeedId).Select(g => g.First()).ToList();

            lstMongoFacebookFeed = lstMongoFacebookFeed.OrderByDescending(t => t.FeedDate).Skip(Int32.Parse(startedIndex)).Take(Int32.Parse(count)).ToList();
            string readKeys = ConfigurationManager.AppSettings["ReadKey"];

            string[] arrReadKey = readKeys.Split(',');
            Random   r          = new Random();

            foreach (var item in lstMongoFacebookFeed)
            {
                try
                {
                    int i = r.Next(0, arrReadKey.Length);

                    string Message = item.FeedDescription;

                    var JData = GetSentiments(arrReadKey[i], Message);

                    string negative = JData["cls1"]["negative"].ToString();
                    string positive = JData["cls1"]["positive"].ToString();

                    item.Negative = double.Parse(negative, CultureInfo.InvariantCulture.NumberFormat);
                    item.Positive = double.Parse(positive, CultureInfo.InvariantCulture.NumberFormat);

                    FilterDefinition <BsonDocument> filter = new BsonDocument("FeedId", item.FeedId);
                    var update = Builders <BsonDocument> .Update.Set("Positive", item.Positive).Set("Negative", item.Negative);

                    FacebookFeedRepo.Update <Domain.Socioboard.Domain.MongoFacebookFeed>(update, filter);
                }
                catch (Exception wx)
                {
                    logger.Error(wx.StackTrace);
                    logger.Error(wx.Message);
                    return("");
                }
            }

            return("Successfully updated");
        }
Exemplo n.º 14
0
        public void Rss()
        {
            while (true)
            {
                try
                {
                    DatabaseRepository dbr = new DatabaseRepository();
                    MongoRepository    _MongoRepository = new MongoRepository("Rss");

                    var lstRssdata = dbr.Find <RssFeedUrl>(t => t.ProfileId != null && t.Keywords == null).ToList();

                    foreach (var item in lstRssdata)
                    {
                        var ret = _MongoRepository.Find <Domain.Socioboard.Models.Mongo.Rss>(t => t.RssFeedUrl == item.rssurl && t.ProfileId == item.ProfileId);

                        var task = Task.Run(async() =>
                        {
                            return(await ret);
                        });

                        var lstRss = task.Result.ToList();

                        foreach (var item_Rss in lstRss)
                        {
                            if (item.LastUpdate.AddHours(6) <= DateTime.UtcNow)
                            {
                                new Thread(delegate()
                                {
                                    RssFeed.updateRssFeeds(item_Rss);
                                }).Start();

                                Console.WriteLine(item.rssurl + "rssdata");
                                item.LastUpdate = DateTime.UtcNow;
                                dbr.Update(item);
                            }
                        }
                    }
                    Thread.Sleep(60000);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("issue while calling api");
                    Thread.Sleep(60000);
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// create an Gplus Hash Tag and fetch all feeds with hash tag and saves in Db
        /// </summary>
        /// <param name="hashTag"> hashtag needs to search.</param>
        /// <param name="boardId"> board id to which we need to add the hasttag.</param>
        /// <param name="_redisCache"> redis cache object</param>
        /// <param name="settings">Application settings class </param>
        /// <param name="_logger"> Serial log object</param>
        /// <returns> gplus hashtag id.</returns>
        public async Task <string> AddGplusHashTag(string hashTag, string boardId, Helper.Cache _redisCache, Helper.AppSettings settings, ILogger _logger)
        {
            MongoBoardGplusHashTag bgpacc = new MongoBoardGplusHashTag {
                Id = ObjectId.GenerateNewId(), strId = ObjectId.GenerateNewId().ToString(), Aboutme = string.Empty, Boardid = boardId, Circledbycount = string.Empty, Coverphotourl = string.Empty, Displayname = hashTag.ToLower(), Entrydate = DateTime.UtcNow.ToString(), Nickname = hashTag, Pageid = "tag", Pageurl = string.Empty, Plusonecount = string.Empty, Profileimageurl = string.Empty, Tagline = string.Empty
            };
            MongoRepository boardrepo = new MongoRepository("MongoBoardGplusHashTag", settings);
            IList <MongoBoardGplusHashTag> objgplusPagelist = await boardrepo.Find <MongoBoardGplusHashTag>(t => t.Displayname.Equals(hashTag.ToLower()) && t.Pageid.Equals("tag")).ConfigureAwait(false);

            if (objgplusPagelist.Count() > 0)
            {
                return(objgplusPagelist.First().strId.ToString());
            }
            await boardrepo.Add <MongoBoardGplusHashTag>(bgpacc).ConfigureAwait(false);

            //AddBoardGplusTagFeeds(hashTag, bgpacc.strId.ToString(),_redisCache,settings, _logger);
            return(bgpacc.strId.ToString());
        }
Exemplo n.º 16
0
        public static List <MongoTwitterDailyReports> GetTwitterMessageReports(long groupId, int dayCount, Helper.Cache _redisCache, Helper.AppSettings settings, Model.DatabaseRepository dbr)
        {
            List <Domain.Socioboard.Models.Groupprofiles> lstGroupprofiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter).ToList();

            string[]        profileids = lstGroupprofiles.Select(t => t.profileId).ToArray();
            MongoRepository mongorepo  = new MongoRepository("MongoTwitterDailyReports", settings);
            DateTime        dayStart   = new DateTime(DateTime.UtcNow.AddDays(-dayCount).Year, DateTime.UtcNow.AddDays(-dayCount).Month, DateTime.UtcNow.AddDays(-dayCount).Day, 0, 0, 0, DateTimeKind.Utc);
            DateTime        dayEnd     = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 23, 59, 59, DateTimeKind.Utc);
            var             result     = mongorepo.Find <MongoTwitterDailyReports>(t => profileids.Contains(t.profileId) && (t.timeStamp > SBHelper.ConvertToUnixTimestamp(dayStart)) && (t.timeStamp < SBHelper.ConvertToUnixTimestamp(dayEnd)));
            var             task       = Task.Run(async() =>
            {
                return(await result);
            });
            IList <MongoTwitterDailyReports> lstDailyReports = task.Result;

            return(lstDailyReports.ToList());
        }
Exemplo n.º 17
0
        public static List <Domain.Socioboard.Models.Listening.FaceBookGroupPost> GetFacebookGroupFeeds(string keyword, int skip, int count, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
        {
            //List<Domain.Socioboard.Models.Listening.FacebookGroupPost> iMmemFacebookGroupPost = _redisCache.Get<List<Domain.Socioboard.Models.Listening.FacebookGroupPost>>(Domain.Socioboard.Consatants.SocioboardConsts.CacheDiscoveryFacebookGroupPost + keyword);
            //if (iMmemFacebookGroupPost != null && iMmemFacebookGroupPost.Count > 0)
            //{
            //    return iMmemFacebookGroupPost;
            //}
            //else
            //{
            MongoRepository mongorepo  = new MongoRepository("FaceBookGroupPost", _appSettings);
            MongoRepository mongoreppo = new MongoRepository("GroupPostKeyWords", _appSettings);
            var             builder    = Builders <Domain.Socioboard.Models.Listening.FaceBookGroupPost> .Sort;
            var             sort       = builder.Descending(t => t.DateTimeOfPost);
            var             result     = mongorepo.FindWithRange <Domain.Socioboard.Models.Listening.FaceBookGroupPost>(t => t.Message.Contains(keyword), sort, skip, count);
            //var result = mongorepo.FindAll<Domain.Socioboard.Models.Listening.FaceBookGroupPost>();
            var task = Task.Run(async() =>
            {
                return(await result);
            });
            IList <Domain.Socioboard.Models.Listening.FaceBookGroupPost> lstFbFeeds = task.Result;

            if (lstFbFeeds.Count > 0)
            {
                // _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheDiscoveryFacebookGroupPost + keyword, lstFbFeeds.ToList());
            }
            Domain.Socioboard.Models.Mongo.GroupPostKeyWords _GroupPostKeyWords = new Domain.Socioboard.Models.Mongo.GroupPostKeyWords();
            _GroupPostKeyWords.id          = ObjectId.GenerateNewId();
            _GroupPostKeyWords.strId       = ObjectId.GenerateNewId().ToString();
            _GroupPostKeyWords.keyword     = keyword;
            _GroupPostKeyWords.createdTime = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
            var retkeyword  = mongoreppo.Find <Domain.Socioboard.Models.Mongo.GroupPostKeyWords>(t => t.keyword.Contains(keyword));
            var taskkeyword = Task.Run(async() =>
            {
                return(await retkeyword);
            });
            int countkeyword = taskkeyword.Result.Count;

            if (count < 1)
            {
                mongoreppo.Add <Domain.Socioboard.Models.Mongo.GroupPostKeyWords>(_GroupPostKeyWords);
            }
            lstFbFeeds.Select(s => { s.Message = WebUtility.HtmlDecode(s.Message); return(s); }).ToList();
            return(lstFbFeeds.ToList());
            //}
        }
Exemplo n.º 18
0
        public IActionResult GetTwitterDirectMessage(long groupId, long userId, int skip, int count)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            List <Domain.Socioboard.Models.Groupprofiles> lstGrpProfiles = Repositories.GroupProfilesRepository.getAllGroupProfiles(groupId, _redisCache, dbr);

            string[]        arrProfile = lstGrpProfiles.Select(t => t.profileId).ToArray();
            MongoRepository mongorepo  = new MongoRepository("MongoTwitterDirectMessages", _appSettings);
            var             result     = mongorepo.Find <Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages>(t => arrProfile.Contains(t.senderId) || arrProfile.Contains(t.recipientId));
            var             task       = Task.Run(async() =>
            {
                return(await result);
            });
            IList <Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages> lstTwitterTweets = task.Result;

            lstTwitterTweets = lstTwitterTweets.GroupBy(y => y.senderId, (key, g) => g.OrderByDescending(t => t.createdDate).First()).OrderByDescending(p => p.createdDate).ToList <Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages>();
            lstTwitterTweets = lstTwitterTweets.Where(t => t.profileId != null).ToList();
            return(Ok(lstTwitterTweets));
        }
Exemplo n.º 19
0
        public static long getinboxcount(long groupId, DateTime date)
        {
            DateTime           dayStart  = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0, DateTimeKind.Utc);
            DateTime           dayEnd    = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59, DateTimeKind.Utc);
            DatabaseRepository dbr       = new DatabaseRepository();
            MongoRepository    mongorepo = new MongoRepository("MongoTwitterDirectMessages");
            List <Domain.Socioboard.Models.Groupprofiles> lstgrpProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId).ToList();

            string[] lstStr = lstgrpProfiles.Select(t => t.profileId).ToArray();
            var      ret    = mongorepo.Find <Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages>(t => lstStr.Contains(t.recipientId) && t.timeStamp <= SBHelper.ConvertToUnixTimestamp(dayEnd) && t.timeStamp >= SBHelper.ConvertToUnixTimestamp(dayStart));
            var      task   = Task.Run(async() =>
            {
                return(await ret);
            });
            long TwitterIncommingMessages = task.Result.Count;

            return(TwitterIncommingMessages);
        }
Exemplo n.º 20
0
 public IActionResult ChangePasswordDetail(long userId)
 {
     try
     {
         MongoRepository    mongorepo = new MongoRepository("FacebookPasswordChangeUserDetail", _appSettings);
         DatabaseRepository dbr       = new DatabaseRepository(_logger, _env);
         List <Domain.Socioboard.Models.Facebookaccounts> datalst = dbr.Find <Facebookaccounts>(t => t.UserId == userId).ToList();
         //  Domain.Socioboard.Models.User userDet = dbr.FindSingle<User>(t => t.Id == userId);
         var result = mongorepo.Find <Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>(t => t.userId == userId && t.status == false);
         var task   = Task.Run(async() =>
         {
             return(await result);
         });
         int count = task.Result.Count;
         IList <Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail> lstfbpasschange = task.Result;
         List <Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>  lstfab          = new List <Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>();
         foreach (var lstfb in lstfbpasschange)
         {
             if (lstfb.message.Contains("password"))
             {
                 string str = lstfb.message;
                 try
                 {
                     lstfab.Add(lstfb);
                 }
                 catch (Exception ex)
                 {
                 }
             }
         }
         if (count > 0)
         {
             return(Ok(lstfab));
         }
         else
         {
             return(Ok("No Data"));
         }
     }
     catch (Exception ex)
     {
         return(NotFound());
     }
 }
Exemplo n.º 21
0
        public void SchdeuledContentFeeds()
        {
            while (true)
            {
                try
                {
                    DatabaseRepository dbr           = new DatabaseRepository();
                    MongoRepository    _lstcontent   = new MongoRepository("ContentFeedsShareathon");
                    MongoRepository    _lstcontentid = new MongoRepository("ContentStudioShareathonIdData");

                    var result = _lstcontentid.Find <Domain.Socioboard.Models.Mongo.ContentStudioShareathonIdData>(t => t.Status == false);
                    //lstScheduledMessage = lstScheduledMessage.Where(t => t.profileId.Equals("187231345114052")).ToList();
                    // var result = _lstScheduledMessage.Find<Domain.Socioboard.Models.Mongo.ContentFeedsShareathon>(t => t.status == 0);
                    // = lstScheduledMessage.GroupBy(t => t.profileId).ToList();
                    var task = Task.Run(async() =>
                    {
                        return(await result);
                    });

                    IList <Domain.Socioboard.Models.Mongo.ContentStudioShareathonIdData> lstPageShareathon = task.Result.ToList();
                    noOfthread_pageshreathon = 0;
                    foreach (ContentStudioShareathonIdData shareathon in lstPageShareathon)
                    {
                        ThreadPool.QueueUserWorkItem(new WaitCallback(ShceduleConetentStudioFeeds), new object[] { shareathon, dbr, _lstcontent });
                        Thread.Sleep(20 * 1000);
                        noOfthread_pageshreathon++;
                        Thread thread_pageshreathon = new Thread(() => ShceduleConetentStudioFeeds(new object[] { shareathon, dbr, _lstcontent }));
                        ShceduleConetentStudioFeeds(new object[] { shareathon, dbr, _lstcontent });
                        thread_pageshreathon.Start();
                        while (noOfthread_pageshreathon > 5)
                        {
                            Thread.Sleep(1 * 1000);
                        }
                        ShceduleConetentStudioFeeds(new object[] { shareathon, dbr, _lstcontent });
                    }
                    Thread.Sleep(TimeSpan.FromMinutes(1));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("issue in web api calling" + ex.StackTrace);
                    Thread.Sleep(TimeSpan.FromMinutes(1));
                }
            }
        }
Exemplo n.º 22
0
        public void ScheduleTwitterMessage()
        {
            while (true)
            {
                try
                {
                    DatabaseRepository dbr = new DatabaseRepository();
                    MongoRepository    _facebookSharefeeds = new MongoRepository("FacebookPageFeedShare");
                    var result = _facebookSharefeeds.Find <Domain.Socioboard.Models.Mongo.FacebookPageFeedShare>(t => t.socialmedia == "tw" || t.socialmedia == "lin");
                    var task   = Task.Run(async() =>
                    {
                        return(await result);
                    });
                    IList <Domain.Socioboard.Models.Mongo.FacebookPageFeedShare> lstfbpagefeeds = task.Result.ToList();

                    //lstScheduledMessage = lstScheduledMessage.Where(t => t.profileId.Contains("758233674978426880")).ToList();
                    lstfbpagefeeds.GroupBy(t => t.pageId).ToList();

                    foreach (var items in lstfbpagefeeds)
                    {
                        objSemaphore.WaitOne();
                        noOfthreadRunning++;
                        Thread thread_pageshreathon = new Thread(() => TwitterSchedulemessage(new object[] { items, dbr, _facebookSharefeeds }));
                        thread_pageshreathon.Name = "schedulemessages thread :" + noOfthreadRunning;
                        thread_pageshreathon.Start();
                        Thread.Sleep(60 * 1000);
                        //while (noOfthreadRunning > 5)
                        //{
                        //    Thread.Sleep(5 * 1000);
                        //}
                        //new Thread(delegate ()
                        //{
                        //    TwitterSchedulemessage(dbr, items);
                        //}).Start();
                    }
                    //  Thread.Sleep(TimeSpan.FromMinutes(1));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("issue in web api calling" + ex.StackTrace);
                    Thread.Sleep(60000);
                }
            }
        }
        //total subscriber
        public static List <Domain.Socioboard.Models.TotalYoutubesubscriber> GetYtTotalsubscriber(string[] channelid, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr)
        {
            List <Domain.Socioboard.Models.TotalYoutubesubscriber> lstSub = new List <Domain.Socioboard.Models.TotalYoutubesubscriber>();

            foreach (var items in channelid)
            {
                IList <Domain.Socioboard.Models.YoutubeChannel> subscriberC = dbr.Find <Domain.Socioboard.Models.YoutubeChannel>(t => t.YtubeChannelId.Equals(items));

                var           x = subscriberC;
                List <string> subscriberlist = new List <string>();
                foreach (var item in x)
                {
                    subscriberlist.Add(item.YtubeChannelId);
                }

                MongoRepository mongorepo = new MongoRepository("YoutubeReportsData", _appSettings);


                foreach (var itemss in subscriberC)
                {
                    var Result = mongorepo.Find <Domain.Socioboard.Models.Mongo.YoutubeReports>(t => t.datetime_unix < UnixTimeNows(DateTime.UtcNow) && t.datetime_unix >= UnixTimeNows(DateTime.UtcNow.AddDays(-90)) && t.channelId.Equals(itemss.YtubeChannelId));
                    var task   = Task.Run(async() =>
                    {
                        return(await Result);
                    });
                    IList <Domain.Socioboard.Models.Mongo.YoutubeReports> totallistT = task.Result;
                    var random      = new Random();
                    var randomColor = String.Format("#{0:X6}", random.Next(0x1000000));
                    Domain.Socioboard.Models.TotalYoutubesubscriber repoSub = new Domain.Socioboard.Models.TotalYoutubesubscriber();
                    int countSub     = totallistT.ToList().Sum(t => t.SubscribersGained);
                    int countsublost = totallistT.ToList().Sum(t => t.subscribersLost);
                    int totalsub     = countSub - countsublost;
                    repoSub.ChannelId         = itemss.YtubeChannelId;
                    repoSub.Channelpic        = itemss.ChannelpicUrl;
                    repoSub.colors            = Convert.ToString(randomColor);
                    repoSub.ChannelName       = itemss.YtubeChannelName;
                    repoSub.startdate         = DateTime.UtcNow;
                    repoSub.endtdate          = DateTime.UtcNow;
                    repoSub.SubscribersCounts = totalsub;
                    lstSub.Add(repoSub);
                }
            }
            return(lstSub);
        }
Exemplo n.º 24
0
        public static List <TaskCommentsViewModel> GetAllCompletedTasksOfUserAndGroup(Int64 recipientUserId, Int64 groupId, ILogger _logger, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository _dbr)
        {
            try
            {
                List <TaskCommentsViewModel> lstTaskCommentsViewModel = new List <TaskCommentsViewModel>();
                MongoRepository taskmongorepo        = new MongoRepository("Tasks", _appSettings);
                MongoRepository taskcommentmongorepo = new MongoRepository("TaskComments", _appSettings);
                var             ret  = taskmongorepo.Find <Tasks>(t => t.groupId == groupId && t.recipientUserId == recipientUserId && t.taskStatus == Domain.Socioboard.Enum.TaskStatus.Completed);
                var             task = Task.Run(async() =>
                {
                    return(await ret);
                });
                IList <Tasks> lstTask = task.Result.ToList();
                foreach (Tasks item in lstTask)
                {
                    TaskCommentsViewModel taskCommentsViewModel = new TaskCommentsViewModel();
                    var ret1  = taskcommentmongorepo.Find <TaskComments>(t => t.taskId == item.strId);
                    var task1 = Task.Run(async() =>
                    {
                        return(await ret1);
                    });
                    taskCommentsViewModel.tasks = item;
                    taskCommentsViewModel.user  = _dbr.FindSingle <User>(t => t.Id == item.senderUserId);
                    IList <TaskComments>        lstTaskComment      = task1.Result.ToList();
                    List <TaskCommentViewModel> lstCommentViewModel = new List <TaskCommentViewModel>();
                    foreach (TaskComments item1 in lstTaskComment)
                    {
                        TaskCommentViewModel commentViewModel = new TaskCommentViewModel();
                        commentViewModel.taskComments = item1;
                        commentViewModel.user         = _dbr.FindSingle <User>(t => t.Id == item1.userId);
                        lstCommentViewModel.Add(commentViewModel);
                    }

                    taskCommentsViewModel.lstTaskComments = lstCommentViewModel;
                    lstTaskCommentsViewModel.Add(taskCommentsViewModel);
                }
                return(lstTaskCommentsViewModel);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(new List <TaskCommentsViewModel>());
            }
        }
Exemplo n.º 25
0
        private List <InstagramComment> GetInstagramPostComments(string profileId, int daysCount)
        {
            var lstInstagramPostComments = new List <InstagramComment>();
            var instagramFeedRepo        = new MongoRepository("InstagramFeed");
            var dayStart = new DateTime(DateTime.UtcNow.AddDays(-(daysCount)).Year, DateTime.UtcNow.AddDays(-(daysCount)).Month, DateTime.UtcNow.AddDays(-(daysCount)).Day, 0, 0, 0, DateTimeKind.Utc);
            var dayEnd   = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 23, 59, 59, DateTimeKind.Utc);
            var ret      = instagramFeedRepo.Find <InstagramFeed>(t => t.InstagramId == profileId && t.FeedDate <= SBHelper.ConvertToUnixTimestamp(dayEnd) && t.FeedDate >= SBHelper.ConvertToUnixTimestamp(dayStart) && t.Type == "image");
            var task     = Task.Run(async() =>
            {
                return(await ret);
            });
            var lstInstagramFeed = task.Result.GroupBy(x => x.FeedId).Select(g => g.First()).ToList();

            foreach (var instagramFeedItem in lstInstagramFeed.ToList())
            {
                lstInstagramPostComments.AddRange(instagramFeedItem._InstagramComment);
            }
            return(lstInstagramPostComments.ToList());
        }
Exemplo n.º 26
0
        public static void deleteTnRChildComment(Int64 ownerIdSB, Int64 memberIdSB, Helper.AppSettings settings)
        {
            MongoRepository mongorepo = new MongoRepository("YoutubeVideosCommentsReply", settings);
            var             result    = mongorepo.Find <Domain.Socioboard.Models.Mongo.MongoYoutubeComments>(t => t.sbGrpAccessOwnerUserid == ownerIdSB && t.sbGrpMemberUserid == memberIdSB);
            var             task      = Task.Run(async() =>
            {
                return(await result);
            });

            IList <Domain.Socioboard.Models.Mongo.MongoYoutubeComments> lstyoutubeParentComment = task.Result;

            foreach (var items in lstyoutubeParentComment)
            {
                FilterDefinition <BsonDocument> filter = new BsonDocument("commentId", items.commentId);
                var update = Builders <BsonDocument> .Update.Set("sbGrpTaskAssign", false).Set("review", false);

                mongorepo.Update <Domain.Socioboard.Models.Mongo.MongoYoutubeComments>(update, filter);
            }
        }
Exemplo n.º 27
0
        public static void FetchMongoDbYtGroupsChildComments()
        {
            List <Domain.Socioboard.Models.Mongo.MongoYoutubeComments> lstfacebookfeed = new List <Domain.Socioboard.Models.Mongo.MongoYoutubeComments>();
            MongoRepository mongorepo = new MongoRepository("YoutubeVideosCommentsReply");
            var             result    = mongorepo.Find <Domain.Socioboard.Models.Mongo.MongoYoutubeComments>(t => t.active);
            var             task      = Task.Run(async() =>
            {
                return(await result);
            });
            IList <Domain.Socioboard.Models.Mongo.MongoYoutubeComments> lstFbFeeds = task.Result;

            Parallel.ForEach(
                lstFbFeeds,
                new ParallelOptions {
                MaxDegreeOfParallelism = 21
            },
                items => { updateMongoDbYtGroupsChildComments(items); }
                );
        }
Exemplo n.º 28
0
        public static Domain.Socioboard.Models.Mongo.TwitterRecentDetails GetTwitterRecentDetails(string profileId, Helper.Cache _redisCache, Helper.AppSettings settings)
        {
            MongoRepository mongorepo = new MongoRepository("TwitterRecentDetails", settings);
            var             result    = mongorepo.Find <TwitterRecentDetails>(t => t.TwitterId.Contains(profileId));
            var             task      = Task.Run(async() =>
            {
                return(await result);
            });
            IList <TwitterRecentDetails> lstTwitterRecentDetails = task.Result.ToList();

            if (lstTwitterRecentDetails.Count > 0)
            {
                return(lstTwitterRecentDetails[0]);
            }
            else
            {
                return(new TwitterRecentDetails());
            }
        }
Exemplo n.º 29
0
        public static long uniquetwitteruser(long groupId, DateTime date)
        {
            long               uniquetwitteruser = 0;
            DateTime           dayStart          = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0, DateTimeKind.Utc);
            DateTime           dayEnd            = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59, DateTimeKind.Utc);
            MongoRepository    mongorepo         = new MongoRepository("MongoTwitterMessage");
            DatabaseRepository dbr = new DatabaseRepository();
            List <Domain.Socioboard.Models.Groupprofiles> lstgrpProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId).ToList();

            string[] lstStr = lstgrpProfiles.Select(t => t.profileId).ToArray();
            var      ret    = mongorepo.Find <Domain.Socioboard.Models.Mongo.MongoTwitterMessage>(t => lstStr.Contains(t.RecipientId) && t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterFollower && t.messageTimeStamp <= SBHelper.ConvertToUnixTimestamp(dayEnd) && t.messageTimeStamp >= SBHelper.ConvertToUnixTimestamp(dayStart) && t.readStatus == 0);
            var      task   = Task.Run(async() =>
            {
                return(await ret);
            });

            uniquetwitteruser = task.Result.Count;
            return(uniquetwitteruser);
        }
        public static List <Domain.Socioboard.Models.Mongo.ElasticmailReport> getCustomElasticMailAbuseReportReportData(DateTime startdate, DateTime enddate, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
        {
            MongoRepository mongorepo = new MongoRepository("ElasticmailDailyReport", _appSettings);
            double          dayStart  = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(startdate.Date);
            double          dayEnd    = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(enddate.Date);
            var             ret       = mongorepo.Find <Domain.Socioboard.Models.Mongo.ElasticmailReport>(t => t.status == " AbuseReport " && t.time >= dayStart && t.time <= dayEnd);
            var             task      = Task.Run(async() =>
            {
                return(await ret);
            });


            if (task.Result != null)
            {
                IList <Domain.Socioboard.Models.Mongo.ElasticmailReport> lstelasticmailuser = task.Result.ToList();
                return(lstelasticmailuser.ToList());
            }
            return(new List <Domain.Socioboard.Models.Mongo.ElasticmailReport>());
        }
Exemplo n.º 31
0
        public static void CreateTodayReports(string profileId, long userId, Helper.Cache _redisCache, Helper.AppSettings settings)
        {
            List <MongoTwitterMessage>        lstTwitterMessages       = TwitterReportsRepository.GetTodayMessages(profileId, userId, _redisCache, settings);
            List <MongoTwitterDirectMessages> lstTwitterDirectMessages = TwitterReportsRepository.GetTodayDirectMessages(profileId, userId, _redisCache, settings);
            MongoRepository mongorepo = new MongoRepository("MongoTwitterDailyReports", settings);

            MongoTwitterDailyReports todayReports = new MongoTwitterDailyReports();

            todayReports.mentions     = lstTwitterMessages.Count(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterMention);
            todayReports.newFollowers = lstTwitterMessages.Count(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterFollower);
            todayReports.retweets     = lstTwitterMessages.Count(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterRetweet);
            todayReports.timeStamp    = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
            //todayReports.newFollowing = lstTwitterMessages.Count(t=>t.type == Domain.Socioboard.Enum.TwitterMessageType.)
            todayReports.directMessagesReceived = lstTwitterDirectMessages.Count(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterDirectMessageReceived);
            todayReports.directMessagesSent     = lstTwitterDirectMessages.Count(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterDirectMessageSent);
            todayReports.profileId = profileId;
            todayReports.id        = ObjectId.GenerateNewId();
            DateTime dayStart = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 0, 0, 0, DateTimeKind.Utc);
            DateTime dayEnd   = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 23, 59, 59, DateTimeKind.Utc);
            var      result   = mongorepo.Find <MongoTwitterDailyReports>(t => (t.timeStamp > SBHelper.ConvertToUnixTimestamp(dayStart)) && (t.timeStamp < SBHelper.ConvertToUnixTimestamp(dayEnd)));
            var      task     = Task.Run(async() =>
            {
                return(await result);
            });
            IList <MongoTwitterDailyReports> lstDailyReports = task.Result;

            if (lstDailyReports != null && lstDailyReports.Count() > 0)
            {
                lstDailyReports.First().mentions               = todayReports.mentions;
                lstDailyReports.First().newFollowers           = todayReports.newFollowers;
                lstDailyReports.First().newFollowing           = todayReports.newFollowing;
                lstDailyReports.First().profileId              = profileId;
                lstDailyReports.First().timeStamp              = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                lstDailyReports.First().directMessagesSent     = todayReports.directMessagesSent;
                lstDailyReports.First().directMessagesReceived = todayReports.directMessagesReceived;
                mongorepo.UpdateReplace(lstDailyReports.First(), t => t.id == lstDailyReports.First().id);
            }
            else
            {
                mongorepo.Add <MongoTwitterDailyReports>(todayReports);
            }
        }
Exemplo n.º 32
0
        public string getAllFacebookMessagesByUserIdWithRange(string UserId, string noOfDataToSkip)
        {
            //List<Domain.Socioboard.Domain.FacebookMessage> lstFacebookMessage = new List<Domain.Socioboard.Domain.FacebookMessage>();
            //try
            //{
            //    //if (objFacebookFeedRepository.checkFacebookUserExists(ProfileId, Guid.Parse(UserId)))
            //    {
            //        lstFacebookMessage = objFacebookMessageRepository.getAllFacebookMessagesOfSBUserWithRange(UserId, noOfDataToSkip);
            //    }
            //    //else
            //    //{
            //    //    lstFacebookFeed = objFacebookFeedRepository.getAllFacebookUserFeeds(ProfileId);
            //    //}
            //    return new JavaScriptSerializer().Serialize(lstFacebookMessage);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return "Something Went Wrong";
            //}


            MongoRepository boardrepo = new MongoRepository("FacebookMessage");

            try
            {
                var result = boardrepo.Find <Domain.Socioboard.MongoDomain.FacebookMessage>(t => t.UserId.Equals(UserId)).ConfigureAwait(false);

                var task = Task.Run(async() =>
                {
                    return(await result);
                });
                IList <Domain.Socioboard.MongoDomain.FacebookMessage> objfbfeeds = task.Result;

                return(new JavaScriptSerializer().Serialize(objfbfeeds.Skip(Convert.ToInt32(noOfDataToSkip)).Take(20).ToList()));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return("Something Went Wrong");
            }
        }
 public string GetInstagramFeedsComment(string UserId, string FeedId)
 {
     List<Domain.Socioboard.MongoDomain.InstagramComment> lstInstagramFeed = new List<Domain.Socioboard.MongoDomain.InstagramComment>();
     try
     {
         MongoRepository instagramCommentRepo = new MongoRepository("InstagramComment");
         var ret = instagramCommentRepo.Find<Domain.Socioboard.MongoDomain.InstagramComment>(t => t.FeedId.Equals(FeedId));
         var task = Task.Run(async () =>
             {
                 return await ret;
             });
         IList<Domain.Socioboard.MongoDomain.InstagramComment> _lstInstagramFeed = task.Result.OrderBy(x => x.CommentDate).ToList();
         lstInstagramFeed = _lstInstagramFeed.ToList();
     }
     catch (Exception ex)
     {
         lstInstagramFeed = new List<Domain.Socioboard.MongoDomain.InstagramComment>();
     }
     return new JavaScriptSerializer().Serialize(lstInstagramFeed);
 }
        public IHttpActionResult GetFacebookPostComment(string PostId)
        {
            MongoRepository fbPostRepo = new MongoRepository("FbPostComment");
            try
            {

                var result = fbPostRepo.Find<Domain.Socioboard.MongoDomain.FbPostComment>(t => t.PostId.Equals(PostId)).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<Domain.Socioboard.MongoDomain.FbPostComment> lstFbPostComments = task.Result;
                return Ok(lstFbPostComments.OrderByDescending(x => x.Commentdate).ToList());
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                return BadRequest("Something Went Wrong");
            }
        }
        public string UserHomeWithLimit(string UserId, string FacebookId, string count)
        {
            //try
            //{
            //    Guid userid = Guid.Parse(UserId);
            //    FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository();
            //    List<Domain.Socioboard.Domain.FacebookMessage> lstfbmsgs = fbmsgrepo.getFacebookUserWallPost(userid, FacebookId, Convert.ToInt32(count));
            //    return new JavaScriptSerializer().Serialize(lstfbmsgs);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return new JavaScriptSerializer().Serialize("Please Try Again");
            //    throw;
            //}
            MongoRepository boardrepo = new MongoRepository("FacebookMessage");
            try
            {

                var result = boardrepo.Find<Domain.Socioboard.MongoDomain.FacebookMessage>(t => t.UserId.Equals(UserId) && t.ProfileId.Equals(FacebookId)).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<Domain.Socioboard.MongoDomain.FacebookMessage> objfbfeeds = task.Result;
                List<Domain.Socioboard.MongoDomain.FacebookMessage> fbfeeds = objfbfeeds.OrderByDescending(x => x.MessageDate).Take(Convert.ToInt32(count)).ToList();
                return new JavaScriptSerializer().Serialize(fbfeeds);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }

        }
        public string GetFacebookMessageByMessageId(string userid, string msgid)
        {
            //Domain.Socioboard.Domain.FacebookMessage objFacebookMessage = objFacebookMessageRepository.GetFacebookMessageByMessageId(Guid.Parse(userid), msgid);
            //return new JavaScriptSerializer().Serialize(objFacebookMessage);
            MongoRepository boardrepo = new MongoRepository("FacebookMessage");
            try
            {

                var result = boardrepo.Find<Domain.Socioboard.MongoDomain.FacebookMessage>(t => t.MessageId.Equals(msgid) && t.UserId.Equals(userid)).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<Domain.Socioboard.MongoDomain.FacebookMessage> objfbfeeds = task.Result;
                return new JavaScriptSerializer().Serialize(objfbfeeds.FirstOrDefault());

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
Exemplo n.º 37
0
        public void RepositoryFindAllTest()
        {
            var target = new MongoContext();
            var repository = new MongoRepository<Employee>(target);

            var collection = repository.Find();

            Assert.IsTrue(collection.Count > 0);
        }
Exemplo n.º 38
0
        public string GetFacebookFeedWithSentiments(string userId, string profileId, string noOfDataToSkip, string count)
        {
            List<Domain.Socioboard.Domain.MongoFacebookFeed> lstDomainMongoFacebookFeed;
            string[] arrId=profileId.Split(',');
            MongoRepository boardrepo = new MongoRepository("MongoFacebookFeed");
            try
            {
                var ret = boardrepo.Find<Domain.Socioboard.Domain.MongoFacebookFeed>(t => t.UserId.Equals(userId) && arrId.Contains(t.ProfileId));
                var task = Task.Run(async () =>
                {
                    return await ret;

                });
                IList<Domain.Socioboard.Domain.MongoFacebookFeed> _lstDomainMongoFacebookFeed = task.Result;
                lstDomainMongoFacebookFeed = _lstDomainMongoFacebookFeed.Where(t => t.Positive != 0).OrderByDescending(t => t.FeedDate).Skip(Int32.Parse(noOfDataToSkip)).Take(Int32.Parse(count)).ToList();
            }
            catch (Exception ex)
            {
                lstDomainMongoFacebookFeed = new List<MongoFacebookFeed>();
            }
            return new JavaScriptSerializer().Serialize(lstDomainMongoFacebookFeed);
        }
Exemplo n.º 39
0
        public string getAllFacebookFeedsByUserIdAndProfileId1(string UserId, string ProfileId, int count)
        {
            //try
            //{
             //   List<Domain.Socioboard.Domain.FacebookFeed> lstFacebookFeed = objFacebookFeedRepository.getAllFacebookFeeds(Guid.Parse(UserId), ProfileId, count);
            //    return new JavaScriptSerializer().Serialize(lstFacebookFeed);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return "Something Went Wrong";
            //}

            MongoRepository boardrepo = new MongoRepository("MongoFacebookFeed");
            try
            {

                var result = boardrepo.Find<MongoFacebookFeed>(x => x.ProfileId.Equals(ProfileId) && x.UserId.Equals(UserId)).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<MongoFacebookFeed> objfbfeeds = task.Result;
                List<MongoFacebookFeed> fbfeeds = objfbfeeds.OrderByDescending(x => x.FeedDate).Skip(count).Take(Convert.ToInt32(10)).ToList();
                return new JavaScriptSerializer().Serialize(fbfeeds);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
        public IHttpActionResult FacebookPostsCommentsService()
        {
            Facebook.FacebookClient fb = new Facebook.FacebookClient();
            UserRepository userRepo = new UserRepository();
            FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
            Api.Socioboard.Services.Facebook fbService = new Api.Socioboard.Services.Facebook();
            List<Domain.Socioboard.Domain.User> lstUser = new List<Domain.Socioboard.Domain.User>();
            lstUser = userRepo.getAllUsers();
            foreach (var user in lstUser)
            {
                List<Domain.Socioboard.Domain.FacebookAccount> lstFacebookAccount = fbAccRepo.GetAllFacebookAccountByUserId(user.Id);

                foreach (var fbAcc in lstFacebookAccount)
                {
                    if (!string.IsNullOrEmpty(fbAcc.AccessToken))
                    {
                        fb.AccessToken = fbAcc.AccessToken;
                        MongoRepository boardrepo = new MongoRepository("MongoFacebookFeed");
                        try
                        {

                            var result = boardrepo.Find<MongoFacebookFeed>(x => x.ProfileId.Equals(fbAcc.FbUserId) && x.UserId.Equals(user.Id.ToString())).ConfigureAwait(false);

                            var task = Task.Run(async () =>
                            {
                                return await result;
                            });
                            IList<MongoFacebookFeed> objfbfeeds = task.Result;
                            if (objfbfeeds.Count() == 0)
                            {

                                result = boardrepo.Find<MongoFacebookFeed>(x => x.ProfileId.Equals(fbAcc.FbUserId)).ConfigureAwait(false);

                                task = Task.Run(async () =>
                                {
                                    return await result;
                                });
                            }
                            List<MongoFacebookFeed> fbfeeds = objfbfeeds.ToList();
                            foreach (var post in fbfeeds)
                            {
                                fbService.AddFbPostComments(post.FeedId, fb, user.Id.ToString());
                            }

                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            logger.Error(ex.StackTrace);
                            return BadRequest("Something Went Wrong");
                        }
                    }



                }



            }


            return Ok();
        }
        public string GetAllWallpostsOfProfileAccordingtoGroup(string profileid, int count, string UserId)
        {
            //try
            //{
            //    logger.Error("USING index (MessageDate_ProfileId_UserId) >> FacebookMessage.asmx");
            //    List<Domain.Socioboard.Domain.FacebookMessage> objFacebookMessage = objFacebookMessageRepository.GetAllWallpostsOfProfileAccordingtoGroup(profileid, count, Guid.Parse(UserId));
            //    return new JavaScriptSerializer().Serialize(objFacebookMessage);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return "Something Went Wrong";
            //}

            MongoRepository boardrepo = new MongoRepository("FacebookMessage");
            try
            {

                var result = boardrepo.Find<Domain.Socioboard.MongoDomain.FacebookMessage>(t => t.ProfileId.Equals(profileid) && t.UserId.Equals(UserId) && t.Type.Equals("fb_home")).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<Domain.Socioboard.MongoDomain.FacebookMessage> objfbfeeds = task.Result;
                List<Domain.Socioboard.MongoDomain.FacebookMessage> fbfeeds = objfbfeeds.OrderByDescending(t => t.MessageDate).Take(count).ToList();
                return new JavaScriptSerializer().Serialize(fbfeeds);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
        public string getAllFacebookUserFeedOfUsersByUserIdAndProfileId1WithRange(string UserId, string keyword, string ProfileId, string count)
        {
            //try
            //{
            //    List<Domain.Socioboard.Domain.FacebookMessage> lstFacebookUserFeed = objFacebookMessageRepository.getAllFacebookUserFeedOfUsersByUserIdAndProfileId1WithRange(UserId, keyword, ProfileId, count);
            //    return new JavaScriptSerializer().Serialize(lstFacebookUserFeed);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return "Something Went Wrong";
            //}

            MongoRepository boardrepo = new MongoRepository("FacebookMessage");
            try
            {

                var result = boardrepo.Find<Domain.Socioboard.MongoDomain.FacebookMessage>(t => t.UserId.Equals(UserId) && t.ProfileId.Equals(ProfileId) && t.ProfileId != t.FromId && t.Type.Equals("fb_home") && t.Message.Contains(keyword)).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<Domain.Socioboard.MongoDomain.FacebookMessage> objfbfeeds = task.Result;

                return new JavaScriptSerializer().Serialize(objfbfeeds.OrderByDescending(x => x.MessageDate).Take(20).ToList());

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
        public string getAllFacebookMessagesOfUserByProfileIdWithRange(string ProfileId, string noOfDataToSkip, string UseId)
        {
            //try
            //{
            //    List<Domain.Socioboard.Domain.FacebookMessage> objFacebookMessage = objFacebookMessageRepository.getAllMessageOfProfileWithRange(ProfileId, noOfDataToSkip, Guid.Parse(UseId));
            //    return new JavaScriptSerializer().Serialize(objFacebookMessage);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return "Something Went Wrong";
            //}


            MongoRepository boardrepo = new MongoRepository("FacebookMessage");
            try
            {

                var result = boardrepo.Find<Domain.Socioboard.MongoDomain.FacebookMessage>(t => t.UserId.Equals(UseId) && t.ProfileId.Equals(ProfileId) && t.ProfileId != t.FromId && t.IsArchived.Equals("1")).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<Domain.Socioboard.MongoDomain.FacebookMessage> objfbfeeds = task.Result;

                return new JavaScriptSerializer().Serialize(objfbfeeds.OrderByDescending(x => x.MessageDate).Skip(Convert.ToInt32(noOfDataToSkip)).Take(15).ToList());

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
        public string GetAllMessageDetailWithRange(string profileid, string noOfDataToSkip, string UserId)
        {
            //List<Domain.Socioboard.Domain.FacebookMessage> lstFacebookMessage = objFacebookMessageRepository.getAllMessageDetail(profileid, noOfDataToSkip, Guid.Parse(UserId));
            //return new JavaScriptSerializer().Serialize(lstFacebookMessage);


            MongoRepository boardrepo = new MongoRepository("FacebookMessage");
            try
            {
                string[] arrsrt = profileid.Split(',');
                var result = boardrepo.Find<Domain.Socioboard.MongoDomain.FacebookMessage>(t => t.ProfileId.Equals(profileid) && arrsrt.Contains(t.ProfileId) && !t.IsArchived.Equals("1")).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<Domain.Socioboard.MongoDomain.FacebookMessage> objfbfeeds = task.Result;

                return new JavaScriptSerializer().Serialize(objfbfeeds.OrderByDescending(x => x.MessageDate).Skip(Convert.ToInt32(noOfDataToSkip)).Take(15).ToList());

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
Exemplo n.º 45
0
        public string getAllFacebookFeedsByUserIdAndProfileId1WithRange(string UserId, string keyword, string ProfileId, string count)
        {
            //try
            //{
            //    List<Domain.Socioboard.Domain.FacebookFeed> lstFacebookFeed = objFacebookFeedRepository.getAllFacebookFeedsOfSBUserWithProfileIdAndRange(UserId, ProfileId, keyword, count);
            //    return new JavaScriptSerializer().Serialize(lstFacebookFeed);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return "Something Went Wrong";
            //}




            MongoRepository boardrepo = new MongoRepository("MongoFacebookFeed");
            try
            {

                var result = boardrepo.Find<MongoFacebookFeed>(x =>  x.UserId.Equals(UserId) && x.ProfileId.Equals(ProfileId)&&x.FeedDescription.Contains(keyword)).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<MongoFacebookFeed> objfbfeeds = task.Result;
                return new JavaScriptSerializer().Serialize(objfbfeeds.OrderByDescending(x => x.FeedDate).Take(20));

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
Exemplo n.º 46
0
        public string getFacebookFeedByProfileId(string ProfileId, string FeedId)
        {
            ObjectId fid = ObjectId.Parse(FeedId);
            MongoRepository boardrepo = new MongoRepository("MongoFacebookFeed");
            try
            {

                var result = boardrepo.Find<MongoFacebookFeed>(x => x.Id.Equals(fid) && x.ProfileId.Equals(ProfileId)).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<MongoFacebookFeed> objfbfeeds = task.Result;
                MongoFacebookFeed fbfeeds = objfbfeeds.FirstOrDefault();
                return new JavaScriptSerializer().Serialize(fbfeeds);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }

            //try
            //{
            //    Domain.Socioboard.Domain.FacebookFeed facebookfeed = objFacebookFeedRepository.getFacebookFeedByProfileId(ProfileId, FeedId);
            //    return new JavaScriptSerializer().Serialize(facebookfeed);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return null;
            //}
        }
        public string GetFacebookMessageWithSentiments(string profileId, string noOfDataToSkip, string count)
        {
            MongoRepository boardrepo = new MongoRepository("FacebookMessage");
            List<Domain.Socioboard.MongoDomain.FacebookMessage> lstFacebookMessage;
            try
            {
                string[] arrId = profileId.Split(',');

                var ret = boardrepo.Find<Domain.Socioboard.MongoDomain.FacebookMessage>(t => arrId.Contains(t.ProfileId));
                var task = Task.Run(async () =>
                {
                    return await ret;
                });
                IList<Domain.Socioboard.MongoDomain.FacebookMessage> _lstFacebookMessage = task.Result;
                lstFacebookMessage = _lstFacebookMessage.Where(t => t.Positive != 0).OrderByDescending(t => t.MessageDate).Skip(Int32.Parse(noOfDataToSkip)).Take(Int32.Parse(count)).ToList();
            }
            catch (Exception ex)
            {
                lstFacebookMessage = new List<Domain.Socioboard.MongoDomain.FacebookMessage>();
            }
            return new JavaScriptSerializer().Serialize(lstFacebookMessage);
        }
Exemplo n.º 48
0
        public string getAllFacebookFeedsByUserIdAndProfileIdUsingLimit(string UserId, string ProfileId, string noOfDataToSkip, string noOfResultsFromTop)
        {
            //List<Domain.Socioboard.Domain.FacebookFeed> lstFacebookFeed = new List<Domain.Socioboard.Domain.FacebookFeed>();
            //try
            //{
            //    if (objFacebookFeedRepository.checkFacebookUserExists(ProfileId, Guid.Parse(UserId)))
            //    {
            //        lstFacebookFeed = objFacebookFeedRepository.getAllFacebookFeedsOfSBUserWithRangeAndProfileId(UserId, ProfileId, noOfDataToSkip, noOfResultsFromTop);
            //    }
            //    else
            //    {
            //        lstFacebookFeed = objFacebookFeedRepository.getAllFacebookFeedsOfSBUserWithRangeByProfileId(ProfileId, noOfDataToSkip, noOfResultsFromTop);
            //    }
            //    return new JavaScriptSerializer().Serialize(lstFacebookFeed);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return "Something Went Wrong";
            //}

            MongoRepository boardrepo = new MongoRepository("MongoFacebookFeed");
            try
            {

                var result = boardrepo.Find<MongoFacebookFeed>(x => x.ProfileId.Equals(ProfileId)&&x.UserId.Equals(UserId)).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<MongoFacebookFeed> objfbfeeds = task.Result;
                if (objfbfeeds.Count() == 0) 
                {

                     result = boardrepo.Find<MongoFacebookFeed>(x => x.ProfileId.Equals(ProfileId)).ConfigureAwait(false);

                     task = Task.Run(async () =>
                    {
                        return await result;
                    });
                }
                List<MongoFacebookFeed> fbfeeds = objfbfeeds.OrderByDescending(x => x.FeedDate).Skip(Convert.ToInt32(noOfDataToSkip)).Take(Convert.ToInt32(noOfResultsFromTop)).ToList();
                return new JavaScriptSerializer().Serialize(fbfeeds);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
        public string getAllFacebookUserFeedOfUsers(string UserId, string ProfileId)
        {
            //try
            //{
            //    List<Domain.Socioboard.Domain.FacebookMessage> lstFacebookUserFeed = objFacebookMessageRepository.getAllFacebookUserFeedOfUsers(Guid.Parse(UserId), ProfileId);
            //    return new JavaScriptSerializer().Serialize(lstFacebookUserFeed);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return "Something Went Wrong";
            //}



            MongoRepository boardrepo = new MongoRepository("FacebookMessage");
            try
            {

                var result = boardrepo.Find<Domain.Socioboard.MongoDomain.FacebookMessage>(t => t.ProfileId.Equals(ProfileId) && t.Type.Equals("fb_home") && t.UserId.Equals(UserId)).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<Domain.Socioboard.MongoDomain.FacebookMessage> objfbfeeds = task.Result;
                return new JavaScriptSerializer().Serialize(objfbfeeds);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
Exemplo n.º 50
0
        public void getUserFeed(oAuthTwitter OAuth, string TwitterScreenName, string TwitterUserId, Guid userId)
        {
            MongoRepository twitterfeedrepo = new MongoRepository("TwitterFeed");
            try
            {
                //User user = (User)Session["LoggedUser"];
                TwitterUser twtuser = new TwitterUser();
                JArray data = twtuser.GetStatuses_Home_Timeline(OAuth);
                Domain.Socioboard.MongoDomain.TwitterFeed objTwitterFeed;
                //TwitterFeedRepository twtmsgrepo = new TwitterFeedRepository();
                //TwitterFeed twtmsg = new TwitterFeed();

                foreach (var item in data)
                {
                    objTwitterFeed = new Domain.Socioboard.MongoDomain.TwitterFeed();
                    //objTwitterFeed.UserId = userId;
                    objTwitterFeed.Type = "twt_feeds";
                    try
                    {
                        objTwitterFeed.Feed = item["text"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.ScreenName = TwitterScreenName;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.ProfileId = TwitterUserId;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FeedDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"')).ToString("yyyy/MM/dd HH:mm:ss");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.Id = ObjectId.GenerateNewId();
                        objTwitterFeed.strId = ObjectId.GenerateNewId().ToString();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    //objTwitterFeed.EntryDate = DateTime.Now;
                    try
                    {
                        objTwitterFeed.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                    var ret = twitterfeedrepo.Find<Domain.Socioboard.MongoDomain.TwitterFeed>(t => t.MessageId.Equals(objTwitterFeed.MessageId));
                    var task = Task.Run(async () =>
                    {
                        return await ret;
                    });
                    int count = task.Result.Count;

                    if (count < 1)
                    {
                        twitterfeedrepo.Add(objTwitterFeed);
                    }


                    // Edited by Antima[20/12/2014]

                    //SentimentalAnalysis _SentimentalAnalysis = new SentimentalAnalysis();
                    //FeedSentimentalAnalysisRepository _FeedSentimentalAnalysisRepository = new FeedSentimentalAnalysisRepository();
                    //try
                    //{
                    //    if (_FeedSentimentalAnalysisRepository.checkFeedExists(objTwitterFeed.ProfileId.ToString(), userId, objTwitterFeed.Id.ToString()))
                    //    {
                    //        if (!string.IsNullOrEmpty(objTwitterFeed.Feed))
                    //        {
                    //            string Network = "twitter";
                    //            _SentimentalAnalysis.GetPostSentimentsFromUclassify(userId, objTwitterFeed.ProfileId, objTwitterFeed.MessageId, objTwitterFeed.Feed, Network);
                    //        }
                    //    }
                    //}
                    //catch (Exception)
                    //{

                    //}

                    //if (!twtmsgrepo.checkTwitterFeedExists(objTwitterFeed.ProfileId, objTwitterFeed.UserId, objTwitterFeed.MessageId))
                    //{
                    //    twtmsgrepo.addTwitterFeed(objTwitterFeed);
                    //}

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


        }
        public string getAllFacebookMessagesOfUserByProfileId(string ProfileId)
        {
            //try
            //{
            //    List<Domain.Socioboard.Domain.FacebookMessage> objFacebookMessage = objFacebookMessageRepository.getAllMessageOfProfile(ProfileId);
            //    return new JavaScriptSerializer().Serialize(objFacebookMessage);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return "Something Went Wrong";
            //}

            MongoRepository boardrepo = new MongoRepository("FacebookMessage");
            try
            {

                var result = boardrepo.Find<Domain.Socioboard.MongoDomain.FacebookMessage>(t => t.ProfileId.Equals(ProfileId)).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<Domain.Socioboard.MongoDomain.FacebookMessage> objfbfeeds = task.Result;
                List<Domain.Socioboard.MongoDomain.FacebookMessage> fbfeeds = objfbfeeds.OrderByDescending(t => t.MessageDate).ToList();
                return new JavaScriptSerializer().Serialize(fbfeeds);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
        public string getAllFacebookMessagesByUserIdWithRange(string UserId, string noOfDataToSkip)
        {
            //List<Domain.Socioboard.Domain.FacebookMessage> lstFacebookMessage = new List<Domain.Socioboard.Domain.FacebookMessage>();
            //try
            //{
            //    //if (objFacebookFeedRepository.checkFacebookUserExists(ProfileId, Guid.Parse(UserId)))
            //    {
            //        lstFacebookMessage = objFacebookMessageRepository.getAllFacebookMessagesOfSBUserWithRange(UserId, noOfDataToSkip);
            //    }
            //    //else
            //    //{
            //    //    lstFacebookFeed = objFacebookFeedRepository.getAllFacebookUserFeeds(ProfileId);
            //    //}
            //    return new JavaScriptSerializer().Serialize(lstFacebookMessage);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return "Something Went Wrong";
            //}


            MongoRepository boardrepo = new MongoRepository("FacebookMessage");
            try
            {

                var result = boardrepo.Find<Domain.Socioboard.MongoDomain.FacebookMessage>(t => t.UserId.Equals(UserId)).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<Domain.Socioboard.MongoDomain.FacebookMessage> objfbfeeds = task.Result;

                return new JavaScriptSerializer().Serialize(objfbfeeds.Skip(Convert.ToInt32(noOfDataToSkip)).Take(20).ToList());

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
Exemplo n.º 53
0
        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)
            {
            }
        }
Exemplo n.º 54
0
        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);
            }
        }
Exemplo n.º 55
0
        public void getTwitterFeeds(string UserId, oAuthTwitter OAuth)
        {
            //int J = 0;

            MongoRepository twitterfeedrepo = new MongoRepository("TwitterFeed");

            TwitterUser twtuser;
            #region Add Twitter User Feed

            twtuser = new TwitterUser();
            try
            {
                JArray Home_Timeline = twtuser.GetStatuses_Home_Timeline(OAuth);
                objTwitterFeed = new Domain.Socioboard.MongoDomain.TwitterFeed();
                foreach (var item in Home_Timeline)
                {
                    //objTwitterFeed.UserId = Guid.Parse(UserId);
                    objTwitterFeed.Type = "twt_feeds";
                    try
                    {
                        objTwitterFeed.Feed = item["text"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.ScreenName = objTwitterAccount.TwitterScreenName;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.ProfileId = objTwitterAccount.TwitterUserId;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FeedDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"')).ToString("yyyy/MM/dd HH:mm:ss");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.Id = ObjectId.GenerateNewId();
                        objTwitterFeed.strId = ObjectId.GenerateNewId().ToString();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                   
                    try
                    {
                        objTwitterFeed.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                    try
                    {
                        objTwitterFeed.MediaUrl = item["extended_entities"]["media"][0]["media_url"].ToString();
                    }
                    catch (Exception ex)
                    {
                    }

                    var ret = twitterfeedrepo.Find<Domain.Socioboard.MongoDomain.TwitterFeed>(t => t.MessageId.Equals(objTwitterFeed.MessageId) && t.ProfileId.Equals(objTwitterFeed.ProfileId));
                    var task = Task.Run(async () =>
                            {
                                return await ret;
                            });
                            int count = task.Result.Count;

                            if (count < 1)
                            {
                                twitterfeedrepo.Add(objTwitterFeed);
                            }
                            
                    //if (!objTwitterFeedRepository.checkTwitterFeedExists(objTwitterFeed.MessageId))
                    //{
                    //    try
                    //    {
                    //        J++;
                    //        objTwitterFeedRepository.addTwitterFeed(objTwitterFeed);
                    //        logger.Error("getTwitterFeedsCount>>>"+J);
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        Console.WriteLine(ex.Message);
                    //        Console.WriteLine(ex.StackTrace);
                    //    }
                    //}
                    // Edited by Antima[20/12/2014]

                    //SentimentalAnalysis _SentimentalAnalysis = new SentimentalAnalysis();
                    //FeedSentimentalAnalysisRepository _FeedSentimentalAnalysisRepository = new FeedSentimentalAnalysisRepository();
                    //try
                    //{
                    //    //if (_FeedSentimentalAnalysisRepository.checkFeedExists(objTwitterFeed.ProfileId.ToString(), Guid.Parse(UserId), objTwitterFeed.Id.ToString()))
                    //    //{
                    //    //    if (!string.IsNullOrEmpty(objTwitterFeed.Feed))
                    //    //    {
                    //    //        string Network = "twitter";
                    //    //        _SentimentalAnalysis.GetPostSentimentsFromUclassify(Guid.Parse(UserId), objTwitterFeed.ProfileId, objTwitterFeed.MessageId, objTwitterFeed.Feed, Network);
                    //    //    }
                    //    //}
                    //}
                    //catch (Exception)
                    //{

                    //}
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                logger.Error("twtuser.GetStatuses_Home_Timeline ex.StackTrace >> " + ex.StackTrace);
                logger.Error("twtuser.GetStatuses_Home_Timeline ex.Message >> " + ex.Message);
            }
            #endregion
        }
Exemplo n.º 56
0
        public string getUnreadMessages(string ProfileId)
        {
            //try
            //{
            //    List<Domain.Socioboard.Domain.FacebookFeed> lstFacebookFeed = FacebookFeedRepository.getUnreadMessages(ProfileId);
            //    return new JavaScriptSerializer().Serialize(lstFacebookFeed);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.StackTrace);
            //    return "Something Went Wrong";
            //}
            MongoRepository boardrepo = new MongoRepository("MongoFacebookFeed");
            try
            {

                var result = boardrepo.Find<MongoFacebookFeed>(x => x.ProfileId.Equals(ProfileId)&& x.ReadStatus.Equals("0") ).ConfigureAwait(false);

                var task = Task.Run(async () =>
                {
                    return await result;
                });
                IList<MongoFacebookFeed> objfbfeeds = task.Result;
                List<MongoFacebookFeed> fbfeeds = objfbfeeds.OrderByDescending(x => x.FeedDate).ToList();
                return new JavaScriptSerializer().Serialize(fbfeeds);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }