private static IEnumerable <FacebookPagePromotionDetails> ParseTagAndPromoteDetails(Facebookaccounts facebookAccount, string taggedDetails, FacebookPagePromotion facebookPagePromotion = FacebookPagePromotion.Tagged)
        {
            var data = JObject.Parse(taggedDetails);

            var taggedDetailCollections = new List <FacebookPagePromotionDetails>();

            foreach (var item in data["data"])
            {
                var inboxMessages = new FacebookPagePromotionDetails
                {
                    ProfileId = facebookAccount.FbUserId,
                    type      = facebookPagePromotion,
                    EntryDate = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow)
                };
                try
                {
                    inboxMessages.message         = item.SelectToken("message")?.ToString();
                    inboxMessages.FeedId          = item.SelectToken("id")?.ToString();
                    inboxMessages.FromId          = item.SelectToken("from.id")?.ToString();
                    inboxMessages.FromName        = item.SelectToken("from.name")?.ToString();
                    inboxMessages.FromProfileUrl  = "http://graph.facebook.com/" + inboxMessages.FromId + "/picture?type=small";
                    inboxMessages.FeedDate        = SBHelper.ConvertToUnixTimestamp(Convert.ToDateTime(item.SelectToken("created_time")?.ToString()));
                    inboxMessages.Picture         = item.SelectToken("picture")?.ToString();
                    inboxMessages.FeedDescription = item.SelectToken("description")?.ToString();
                    taggedDetailCollections.Add(inboxMessages);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return(taggedDetailCollections);
        }
Ejemplo n.º 2
0
        public IActionResult Login(UserLoginViewModel user)
        {
            try
            {
                User inMemUser = _redisCache.Get <User>(user.UserName);
                // User inMemUser = (User)_memoryCache.Get(user.UserName);
                if (inMemUser != null)
                {
                    if (inMemUser.Password.Equals(SBHelper.MD5Hash(user.Password)))
                    {
                        return(Ok(inMemUser));
                    }
                    else
                    {
                        return(Ok("Wrong Password"));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation(ex.Message);
                _logger.LogError(ex.StackTrace);
            }



            DatabaseRepository dbr     = new DatabaseRepository(_logger, _appEnv);
            IList <User>       lstUser = dbr.Find <User>(t => t.EmailId.Equals(user.UserName));

            if (lstUser != null && lstUser.Count() > 0)
            {
                if (lstUser.First().Password != null && lstUser.First().Password.Equals(SBHelper.MD5Hash(user.Password)))
                {
                    DateTime d1 = DateTime.UtcNow;
                    //User userTable = dbr.Single < User>(t => t.EmailId == user.UserName);
                    lstUser.First().LastLoginTime = d1;
                    //userTable.LastLoginTime = d1;
                    dbr.Update <User>(lstUser.First());

                    // _memoryCache.Set(lstUser.First().EmailId, lstUser.First());
                    _redisCache.Set <User>(lstUser.First().EmailId, lstUser.First());
                    if (lstUser.First().ActivationStatus == Domain.Socioboard.Enum.SBUserActivationStatus.Active)
                    {
                        return(Ok(lstUser.First()));
                    }
                    else
                    {
                        return(Ok("Account not activated."));
                    }
                }
                else
                {
                    return(Ok("Wrong Password"));
                }
            }
            else
            {
                return(Ok("EmailId Not Exist"));
            }
        }
        public string ShareFeed(string fbAccesstoken, string FeedId, string pageId, string message, string fbUserId, string FbPageName)
        {
            string ret = "";

            try
            {
                MongoRepository mongorepo = new Helper.MongoRepository("SharethonPagePost");
                Domain.Socioboard.Models.Mongo.SharethonPagePost objshrpost = new Domain.Socioboard.Models.Mongo.SharethonPagePost();
                string link = "https://www.facebook.com/" + pageId + "/posts/" + FeedId;

                FacebookClient fb = new FacebookClient();
                fb.AccessToken = fbAccesstoken;
                var args = new Dictionary <string, object>();

                args["link"] = link;

                var ret1 = mongorepo.Find <Domain.Socioboard.Models.Mongo.SharethonPagePost>(t => t.Facebookaccountid == fbUserId && t.Facebookpageid == pageId && t.PostId == FeedId);
                var task = Task.Run(async() =>
                {
                    return(await ret1);
                });
                int count = task.Result.Count;

                try
                {
                    //if (pageapiHitsCount < pageMaxapiHitsCount)
                    //{
                    dynamic output  = fb.Post("v2.1/" + fbUserId + "/feed", args);
                    string  feed_id = output["id"].ToString();
                    if (!string.IsNullOrEmpty(feed_id))
                    {
                        pageapiHitsCount++;
                    }
                    if (count < 1)
                    {
                        objshrpost.Id = ObjectId.GenerateNewId();
                        objshrpost.Facebookaccountid = fbUserId;
                        objshrpost.Facebookpageid    = pageId;
                        objshrpost.PostId            = FeedId;
                        objshrpost.PostedTime        = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                        objshrpost.Facebookpagename  = FbPageName;
                        mongorepo.Add <Domain.Socioboard.Models.Mongo.SharethonPagePost>(objshrpost);
                        ret = "success";
                    }
                    // }
                }
                catch (Exception ex)
                {
                    Console.Write(ex.StackTrace);
                    pageapiHitsCount = pageMaxapiHitsCount;
                    return("");
                }

                // }
            }
            catch (Exception ex)
            {
            }
            return(ret);
        }
        private void CodeTest_Click(object sender, RoutedEventArgs e)
        {
            var csharpSetting = new CSharpSetting()
            {
                RootPath = Environment.CurrentDirectory,
            };

            var typeScope  = new RelativeScope <CSharpSetting>(csharpSetting, "TypeScope");
            var groupScope = new RelativeScope <CSharpSetting>(csharpSetting, "GroupScope", typeScope);

            var projectScope      = new RootScope("ProjectScope");
            var otherScope        = new RelativeScope <CSharpSetting>(csharpSetting, "OtherScope", typeScope);
            var otherProjectScope = new CombineScope <CSharpSetting>(csharpSetting, projectScope, otherScope);

            var basePath   = new RootPath(csharpSetting.RootPath);
            var secondPath = new RelativePath <CSharpSetting>(csharpSetting, "ProjectPath", basePath);

            var mappingPath = new ScopeMappingPath <CSharpSetting>(csharpSetting, secondPath, groupScope, projectScope);

            var testType = new CSharpGenerateType(csharpSetting, mappingPath, mappingPath, "TestType");

            testType.Usings.Scopes.Add(otherProjectScope);
            testType.TypeDocumentation.Summary = "テストサマリー\r\nサマリー2行目";

            OutputBlock.Text = SBHelper.ToString(sb => {
                sb.AppendLine(testType.GenerateFileName());
                testType.ApppendStrings(sb);
                sb.AppendLine(testType.GenerateFullTypeName());
            });
        }
Ejemplo n.º 5
0
        public string ShareFeed(string fbAccesstoken, string feedId, string pageId, string message, string fbUserId,
                                string fbPageName)
        {
            try
            {
                var mongoRepository = new MongoRepository("SharethonPagePost");

                var link = "https://www.facebook.com/" + pageId + "/posts/" + feedId;

                var sharethonPagePostCollections = mongoRepository.Find <SharethonPagePost>(t =>
                                                                                            t.Facebookaccountid.Equals(fbUserId) && t.Facebookpageid.Equals(pageId) && t.PostId.Equals(feedId));

                var task = Task.Run(async() => await sharethonPagePostCollections);

                var count = task.Result.Count;

                try
                {
                    if (count < 1)
                    {
                        var pageAccessToken = FacebookApiHelper.GetPageAccessToken(pageId, fbAccesstoken, string.Empty);
                        var response        = FacebookApiHelper.PublishPostOnPage(pageAccessToken, pageId, string.Empty,
                                                                                  string.Empty, link);

                        var isPublished = response.Contains("id");

                        if (isPublished)
                        {
                            PageapiHitsCount++;
                        }

                        var objSharethonPagePost = new SharethonPagePost
                        {
                            Id = ObjectId.GenerateNewId(),
                            Facebookaccountid = fbUserId,
                            Facebookpageid    = pageId,
                            PostId            = feedId,
                            PostedTime        = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow),
                            Facebookpagename  = fbPageName
                        };

                        mongoRepository.Add(objSharethonPagePost);
                        return("success");
                    }
                }
                catch (Exception ex)
                {
                    Console.Write(ex.StackTrace);
                    PageapiHitsCount = PageMaxapiHitsCount;
                    return(string.Empty);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(string.Empty);
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> connectedprofilestothisgroup(string selectedgroupid)
        {
            Session["selectedgroupid"] = selectedgroupid;
            Dictionary <GroupProfile, object> dict_ProfileConnected = new Dictionary <GroupProfile, object>();

            dict_ProfileConnected = await SBHelper.GetGroupProfilesByGroupId(selectedgroupid);

            return(PartialView("_ProfilesConnectedToGroupPartial", dict_ProfileConnected));
        }
Ejemplo n.º 7
0
 public virtual string GenerateFullTypeName()
 {
     return(SBHelper.ToString(sb =>
     {
         Scope.AppendScope(sb);
         sb.Append(IncludeSetting.ScopeDelimiter);
         sb.Append(Name);
     }));
 }
Ejemplo n.º 8
0
        public IActionResult ForgotPasswordSendMail(string emailId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            User user = null;

            try
            {
                user = dbr.Single <User>(t => t.EmailId.Equals(emailId));
            }
            catch (Exception ex)
            {
            }
            if (user != null)
            {
                if (user.EmailValidateToken.Equals("Facebook"))
                {
                    return(Ok("you can login wiht facebook."));
                }
                else if (user.EmailValidateToken.Equals("Google"))
                {
                    return(Ok("you can login wiht Google."));
                }
                user.forgotPasswordKeyToken   = SBHelper.RandomString(20);
                user.forgotPasswordExpireDate = DateTime.UtcNow.AddDays(1);
                user.EmailId = emailId;
                user.Id      = user.Id;

                int result = dbr.Update <Domain.Socioboard.Models.User>(user);

                if (result == 1)
                {
                    try
                    {
                        string path = _appEnv.WebRootPath + "\\views\\mailtemplates\\forogtPassword.html";
                        string html = System.IO.File.ReadAllText(path);
                        html = html.Replace("[FirstName]", user.FirstName);
                        html = html.Replace("[AccountType]", user.AccountType.ToString());
                        html = html.Replace("[ActivationLink]", _appSettings.Domain + "/Home/ForgotPassword?Token=" + user.forgotPasswordKeyToken + "&emailId=" + user.EmailId);

                        _emailSender.SendMailSendGrid(_appSettings.frommail, "", user.EmailId, "", "", "You requested for reset password of your account", html, _appSettings.SendgridUserName, _appSettings.SendGridPassword);
                    }
                    catch (Exception ex)
                    {
                    }
                    return(Ok("Mail Sent Successfully."));
                }
                else
                {
                    return(Ok("Failed to send mail."));
                }
            }
            else
            {
                return(Ok("EmailId does not exist"));
            }
        }
Ejemplo n.º 9
0
        private void CreateReports(string instagramId, bool is90DayDataUpdated)
        {
            try
            {
                var day = 1;
                if (!is90DayDataUpdated)
                {
                    day = 90;
                }

                var lstGetVideoPosts            = GetVideoPosts(instagramId, day);
                var lstGetImagePosts            = GetImagePosts(instagramId, day);
                var _InstagramUserDetails       = GetInstagramUserDeatils(instagramId);
                var lstGetInstagramPostComments = GetInstagramPostComments(instagramId, day);
                var lstGetInstagramPostLikes    = GetInstagramPostLikes(instagramId, day);
                var lstMongoTwitterMessage      = GetInstagramFollwerFollowing(instagramId, day);

                for (int dayCount = 1; dayCount < day; dayCount++)
                {
                    var instaDailyRepostObj = new InstagramDailyReport();
                    var since = SBHelper.ConvertToUnixTimestamp(new DateTime(DateTime.UtcNow.AddDays(-(dayCount)).Year, DateTime.UtcNow.AddDays(-(dayCount)).Month, DateTime.UtcNow.AddDays(-(dayCount)).Day, 0, 0, 0, DateTimeKind.Utc));
                    var until = SBHelper.ConvertToUnixTimestamp(new DateTime(DateTime.UtcNow.AddDays(-dayCount).Year, DateTime.UtcNow.AddDays(-dayCount).Month, DateTime.UtcNow.AddDays(-dayCount).Day, 23, 59, 59, DateTimeKind.Utc));


                    instaDailyRepostObj.id             = ObjectId.GenerateNewId();
                    instaDailyRepostObj.date           = since;
                    instaDailyRepostObj.followcount    = Convert.ToInt64(lstMongoTwitterMessage.Count(t => t.messageTimeStamp <= until && t.messageTimeStamp >= since && t.type == Domain.Socioboard.Enum.MessageType.InstagramFollower));
                    instaDailyRepostObj.followingcount = Convert.ToInt64(lstMongoTwitterMessage.Count(t => t.messageTimeStamp <= until && t.messageTimeStamp >= since && t.type == Domain.Socioboard.Enum.MessageType.InstagramFollowing));
                    instaDailyRepostObj.fullName       = _InstagramUserDetails.InsUserName;
                    instaDailyRepostObj.imagepost      = Convert.ToInt64(lstGetImagePosts.Count(t => t.FeedDate <= until && t.FeedDate >= since));
                    instaDailyRepostObj.instaName      = _InstagramUserDetails.InsUserName;
                    instaDailyRepostObj.mediaCount     = Convert.ToInt64(lstGetVideoPosts.Count(t => t.FeedDate <= until && t.FeedDate >= since) + lstGetImagePosts.Count(t => t.FeedDate <= until && t.FeedDate >= since));
                    instaDailyRepostObj.postcomment    = Convert.ToInt64(lstGetInstagramPostComments.Count(t => t.CommentDate <= until && t.CommentDate >= since));
                    instaDailyRepostObj.postlike       = Convert.ToInt64(lstGetInstagramPostLikes.Count(t => t.Created_Date <= until && t.Created_Date >= since));
                    instaDailyRepostObj.profileId      = _InstagramUserDetails.InstagramId;
                    instaDailyRepostObj.videopost      = Convert.ToInt64(lstGetVideoPosts.Count(t => t.FeedDate <= until && t.FeedDate >= since));
                    instaDailyRepostObj.profilePicUrl  = _InstagramUserDetails.ProfileUrl;

                    var mongoRepo = new MongoRepository("InstagramDailyReport");
                    var ret       = mongoRepo.Find <InstagramDailyReport>(t => t.date == instaDailyRepostObj.date && t.profileId == instagramId);
                    var task      = Task.Run(async() =>
                    {
                        return(await ret);
                    });

                    if (task.Result.Count < 1)
                    {
                        mongoRepo.Add(instaDailyRepostObj);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 10
0
        public async Task <ActionResult> Calendar()
        {
            User objUser = (User)Session["User"];
            Dictionary <GroupProfile, object> dict_TeamMember = new Dictionary <GroupProfile, object>();

            if (Session["group"] != null)
            {
                dict_TeamMember = await SBHelper.GetGroupProfiles();
            }
            return(View(dict_TeamMember));
        }
Ejemplo n.º 11
0
        public async Task <ActionResult> ComposeScheduledMessage()
        {
            User objUser = (User)Session["User"];
            Dictionary <GroupProfile, object> dict_TeamMember = new Dictionary <GroupProfile, object>();

            if (Session["group"] != null)
            {
                dict_TeamMember = await SBHelper.GetGroupProfiles();
            }
            return(PartialView("_ComposeMessageSchedulerPartial", dict_TeamMember));
        }
Ejemplo n.º 12
0
        public static void giphysearch()
        {
            string  Imagedata = getHtmlfromUrl();
            JObject shareData = JObject.Parse(Imagedata);

            foreach (var item in shareData["data"])
            {
                MongoRepository mongoreppo = new MongoRepository("AdvanceSerachData");
                Domain.Socioboard.Models.Mongo.AdvanceSerachData _AdvanceSerachData = new Domain.Socioboard.Models.Mongo.AdvanceSerachData();
                _AdvanceSerachData.Id          = ObjectId.GenerateNewId();
                _AdvanceSerachData.strId       = ObjectId.GenerateNewId().ToString();
                _AdvanceSerachData.domainType  = item["source_tld"].ToString();
                _AdvanceSerachData.postType    = Domain.Socioboard.Enum.AdvanceSearchpostType.trending;
                _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.giphy;
                try
                {
                    _AdvanceSerachData.ImageUrl = item["images"]["preview_gif"]["url"].ToString();
                    _AdvanceSerachData.postUrl  = item["source_post_url"].ToString();
                }
                catch { }
                try
                {
                    _AdvanceSerachData.title = item["slug"].ToString();
                }
                catch { }
                try
                {
                    _AdvanceSerachData.postId = item["id"].ToString();
                }
                catch { }
                try
                {
                    _AdvanceSerachData.userName = item["username"].ToString();
                }
                catch { }
                try
                {
                    _AdvanceSerachData.postedTime = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(Convert.ToDateTime(item["trending_datetime"].ToString()));
                }
                catch
                {
                    _AdvanceSerachData.postedTime = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                }
                int count = mongoreppo.Counts <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(t => t.postUrl == _AdvanceSerachData.postUrl);
                if (count == 0)
                {
                    mongoreppo.Add <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(_AdvanceSerachData);
                }
                else
                {
                }
            }
        }
        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);
                }
            }
        }
Ejemplo n.º 14
0
 public string GenerateFileName()
 {
     return(SBHelper.ToString(sb =>
     {
         Path.AppendPath(sb);
         sb.Append(IncludeSetting.PathDelimiter);
         sb.Append(Name);
         if (!string.IsNullOrWhiteSpace(Extention))
         {
             sb.Append(IncludeSetting.ExtentionString);
             sb.Append(Extention);
         }
     }));
 }
Ejemplo n.º 15
0
        public override void ApppendStrings(StringBuilder sb, int indent)
        {
            var scopeArray = Scopes.Select(s => SBHelper.ToString(enumSb => s.AppendScope(enumSb))).ToArray();

            foreach (var scope in scopeArray.OrderBy(s => s))
            {
                AppendIndent(sb, indent);
                sb.Append(BeforeString);
                sb.Append(scope);
                sb.Append(AfterString);
                AppendNewLine(sb);
            }

            base.ApppendStrings(sb, indent);
        }
Ejemplo n.º 16
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);
            }
        }
Ejemplo n.º 17
0
        public static void ImgurSearch()
        {
            var imagedata = GetImgurHtmlContent();
            var shareData = JObject.Parse(imagedata);

            foreach (var item in shareData["data"])
            {
                var type = item.SelectToken("type")?.ToString();

                if (string.IsNullOrEmpty(type))
                {
                    continue;
                }

                var mongoreppo = new MongoRepository("AdvanceSerachData");

                try
                {
                    var advanceSearchData = new Domain.Socioboard.Models.Mongo.AdvanceSerachData
                    {
                        Id              = ObjectId.GenerateNewId(),
                        strId           = ObjectId.GenerateNewId().ToString(),
                        domainType      = "http://imgur.com/",
                        postType        = Domain.Socioboard.Enum.AdvanceSearchpostType.trending,
                        networkType     = Domain.Socioboard.Enum.NetworkType.imgur,
                        ImageUrl        = item.SelectToken("link")?.ToString(),
                        title           = item.SelectToken("title")?.ToString(),
                        postdescription = item.SelectToken("description")?.ToString(),
                        postId          = item.SelectToken("id")?.ToString(),
                        postedTime      = double.Parse(item.SelectToken("datetime")?.ToString() ??
                                                       SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow)
                                                       .ToString(CultureInfo.InvariantCulture)),
                        totalShareCount = Convert.ToInt32(item.SelectToken("comment_count")?.ToString())
                    };
                    var count = mongoreppo.Counts <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(t => t.postId == advanceSearchData.postId);

                    if (count == 0)
                    {
                        mongoreppo.Add(advanceSearchData);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
        public IEnumerable <MongoMessageModel> UpdatePageNotifications(Facebookaccounts facebookAccount)
        {
            var notificationDetails = new List <MongoMessageModel>();

            try
            {
                var notificationsDetails = FacebookApiHelper.GetPageNotifications(facebookAccount.AccessToken);

                var notifications = JObject.Parse(notificationsDetails);

                foreach (var item in notifications["data"])
                {
                    var inboxMessages = new MongoMessageModel
                    {
                        profileId        = facebookAccount.FbUserId,
                        type             = MessageType.FacebookPageNotification,
                        messageTimeStamp = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow)
                    };

                    try
                    {
                        inboxMessages.Message        = item.SelectToken("title")?.ToString();
                        inboxMessages.messageId      = item.SelectToken("id").ToString();
                        inboxMessages.fromId         = item.SelectToken("from.id").ToString();
                        inboxMessages.fromName       = item.SelectToken("from.name").ToString();
                        inboxMessages.fromScreenName = item.SelectToken("from.name").ToString();
                        inboxMessages.fromProfileUrl = "http://graph.facebook.com/" + inboxMessages.fromId + "/picture?type=small";
                        inboxMessages.RecipientId    = item.SelectToken("to.id").ToString();
                        inboxMessages.RecipientName  = item.SelectToken("to.name").ToString();
                        inboxMessages.messageDate    = Convert.ToDateTime(item["created_time"].ToString()).ToString(CultureInfo.InvariantCulture);

                        notificationDetails.Add(inboxMessages);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                AddNotificationsToDb(notificationDetails);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(notificationDetails);
        }
Ejemplo n.º 19
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);
            }
        }
Ejemplo n.º 20
0
        public IActionResult ChangePassword(long userId, string currentPassword, string newPassword, string conformPassword)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            User user = dbr.Single <User>(t => t.Id == userId);

            if (user != null && user.Password != null)
            {
                if (user.Password.Equals(SBHelper.MD5Hash(currentPassword)))
                {
                    if (user.Password.Equals(SBHelper.MD5Hash(newPassword)))
                    {
                        return(Ok("Current Password and New Password are same.Try with New Password"));
                    }
                    if (newPassword.Equals(conformPassword))
                    {
                        user.Password = SBHelper.MD5Hash(newPassword);
                        int res = dbr.Update <User>(user);
                        if (res == 1)
                        {
                            return(Ok("Password Updated"));
                        }
                        else
                        {
                            return(BadRequest("error while updating password, pls try after some time."));
                        }
                    }
                    else
                    {
                        return(BadRequest("new password and conform password are not matching."));
                    }
                }
                else
                {
                    return(BadRequest("Wrong password"));
                }
            }
            else
            {
                //return Unauthorized();
                return(BadRequest("Please Follow The Password Policy One Capital letter, One Small letter, One number, One special character and min lenght must be 8"));
            }
        }
Ejemplo n.º 21
0
        public static void CreateReport(string ProfileId, bool is90daysupdated)
        {
            int day = 1;

            if (!is90daysupdated)
            {
                day = 90;
            }
            for (int i = 0; i < day; i++)
            {
                DateTime date = DateTime.UtcNow.AddDays(-1 * i);
                Domain.Socioboard.Models.Mongo.Fbpublicpagedailyreports _Fbpublicpagedailyreports = new Domain.Socioboard.Models.Mongo.Fbpublicpagedailyreports();
                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 mongoreppo     = new MongoRepository("FbPublicPagePost");
                MongoRepository mongoreppopage = new MongoRepository("Fbpublicpagedailyreports");
                var             ret            = mongoreppo.Find <Domain.Socioboard.Models.Mongo.FbPublicPagePost>(t => t.PageId == ProfileId && t.PostDate <= SBHelper.ConvertToUnixTimestamp(dayEnd) && t.PostDate >= SBHelper.ConvertToUnixTimestamp(dayStart));
                var             task           = Task.Run(async() =>
                {
                    return(await ret);
                });
                IList <Domain.Socioboard.Models.Mongo.FbPublicPagePost> lstFbPublicPagePost = task.Result.ToList();
                _Fbpublicpagedailyreports.id            = ObjectId.GenerateNewId();
                _Fbpublicpagedailyreports.date          = SBHelper.ConvertToUnixTimestamp(date);
                _Fbpublicpagedailyreports.likescount    = lstFbPublicPagePost.ToList().Sum(t => t.Likes);
                _Fbpublicpagedailyreports.pageid        = ProfileId;
                _Fbpublicpagedailyreports.pommentscount = lstFbPublicPagePost.ToList().Sum(t => t.Comments);
                _Fbpublicpagedailyreports.postscount    = lstFbPublicPagePost.ToList().Count();
                _Fbpublicpagedailyreports.sharescount   = lstFbPublicPagePost.ToList().Sum(t => t.Shares);

                var retfb  = mongoreppopage.Find <Domain.Socioboard.Models.Mongo.Fbpublicpagedailyreports>(t => t.date >= _Fbpublicpagedailyreports.date && t.pageid == _Fbpublicpagedailyreports.pageid);
                var taskfb = Task.Run(async() => {
                    return(await retfb);
                });
                IList <Domain.Socioboard.Models.Mongo.Fbpublicpagedailyreports> lstfbpublicreport = taskfb.Result.ToList();
                if (lstfbpublicreport.ToList().Count < 1)
                {
                    mongoreppopage.Add <Domain.Socioboard.Models.Mongo.Fbpublicpagedailyreports>(_Fbpublicpagedailyreports);
                }
            }
        }
 public IEnumerable <MongoFacebookFeed> FetchAccountsFeedDetails(Facebookaccounts facebookAccount,
                                                                 JObject feedDetails)
 {
     return((from feed in feedDetails.SelectTokens("data")?.SelectMany(feed => feed)
             select JObject.Parse(feed.ToString())
             into feedDetail
             let fromName = feedDetail.SelectToken("from.name")?.ToString()
                            let fromId = feedDetail.SelectToken("from.id")?.ToString()
                                         let feedId = feedDetail.SelectToken("id")?.ToString()
                                                      let createdDateTime = DateTime.Parse(feedDetail.SelectToken("created_time")?.ToString() ?? DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))
                                                                            .ToString("yyyy/MM/dd HH:mm:ss")
                                                                            let likeCount = feedDetail.SelectToken("likes.summary.total_count")?.ToString()
                                                                                            let commentCount = feedDetail.SelectToken("comments.summary.total_count")?.ToString()
                                                                                                               let postType = feedDetail.SelectToken("type")?.ToString() ?? "status"
                                                                                                                              let postingFrom = feedDetail.SelectToken("application.name")?.ToString() ?? "Facebook"
                                                                                                                                                let picture = feedDetail.SelectToken("picture")?.ToString()
                                                                                                                                                              let message = feedDetail.SelectToken("message")?.ToString() ?? feedDetail.SelectToken("description")?.ToString() ?? feedDetail.SelectToken("story")?.ToString() ?? string.Empty
                                                                                                                                                                            let postDate = SBHelper.ConvertToUnixTimestamp(Convert.ToDateTime(createdDateTime))
                                                                                                                                                                                           select new MongoFacebookFeed
     {
         Type = "fb_feed",
         ProfileId = facebookAccount.FbUserId,
         Id = ObjectId.GenerateNewId(),
         FromProfileUrl = $"http://graph.facebook.com/{facebookAccount.FbUserId}/picture?type=small",
         FromName = fromName,
         FromId = fromId,
         FeedId = feedId,
         FeedDate = postDate.ToString(CultureInfo.InvariantCulture),
         FeedDateToshow = SBHelper.ConvertFromUnixTimestamp(Convert.ToDouble(postDate)).ToString("yyyy/MM/dd HH:mm:ss"),
         FbComment = $"http://graph.facebook.com/{feedId}/comments",
         FbLike = $"http://graph.facebook.com/{feedId}/likes",
         Likecount = likeCount,
         Commentcount = commentCount,
         postType = postType,
         postingFrom = postingFrom,
         Picture = picture,
         FeedDescription = message,
         EntryDate = DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm:ss")
     }).ToList());
 }
        public static void GiphySearch()
        {
            var imagedata = GetGiphyHtmlContent();
            var shareData = JObject.Parse(imagedata);

            foreach (var item in shareData["data"])
            {
                try
                {
                    var mongoreppo        = new MongoRepository("AdvanceSerachData");
                    var advanceSearchData =
                        new Domain.Socioboard.Models.Mongo.AdvanceSerachData
                    {
                        Id          = ObjectId.GenerateNewId(),
                        strId       = ObjectId.GenerateNewId().ToString(),
                        domainType  = item.SelectToken("source_tld")?.ToString(),
                        postType    = Domain.Socioboard.Enum.AdvanceSearchpostType.trending,
                        networkType = Domain.Socioboard.Enum.NetworkType.giphy,
                        ImageUrl    = item["images"]["preview_gif"]["url"].ToString(),
                        postUrl     = item.SelectToken("source_post_url")?.ToString(),
                        title       = item.SelectToken("slug")?.ToString(),
                        postId      = item.SelectToken("id")?.ToString(),
                        userName    = item.SelectToken("username")?.ToString(),
                        postedTime  = double.Parse(item.SelectToken("datetime")?.ToString() ??
                                                   SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow)
                                                   .ToString(CultureInfo.InvariantCulture))
                    };

                    var count = mongoreppo.Counts <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(t => t.postUrl == advanceSearchData.postUrl);
                    if (count == 0)
                    {
                        mongoreppo.Add(advanceSearchData);
                    }
                }
                catch (Exception e) {
                    Console.WriteLine(e.Message);
                }
            }
        }
Ejemplo n.º 24
0
        public IActionResult ResendMail(string Email)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            User user = null;

            try
            {
                user = dbr.Single <User>(t => t.EmailId.Equals(Email));
            }
            catch { }
            if (user != null)
            {
                user.EmailValidateToken      = SBHelper.RandomString(20);
                user.ValidateTokenExpireDate = DateTime.UtcNow.AddDays(1);
                int result = dbr.Update <User>(user);
                if (result == 1)
                {
                    string path = _appEnv.WebRootPath + "\\views\\mailtemplates\\registrationmail.html";
                    string html = System.IO.File.ReadAllText(path);
                    html = html.Replace("[FirstName]", user.FirstName);
                    html = html.Replace("[AccountType]", user.AccountType.ToString());
                    html = html.Replace("[ActivationLink]", "http://localhost:9821/Home/Active?Token=" + user.EmailValidateToken + "&id=" + user.Id);


                    _emailSender.SendMailSendGrid(_appSettings.frommail, "", user.EmailId, "", "", "Socioboard Email conformation Link", html, _appSettings.SendgridUserName, _appSettings.SendGridPassword);

                    return(Ok("Mail Sent Successfully."));
                }
                else
                {
                    return(Ok("Failed to send mail."));
                }
            }
            else
            {
                return(Ok("Wrong Email"));
            }
        }
Ejemplo n.º 25
0
        public IActionResult ResetPasswordMail(string emailId, string changePassword, string token)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            User user = null;

            try
            {
                user = dbr.Single <User>(t => t.EmailId == emailId);
            }
            catch
            { }

            if (user != null)
            {
                if (user.forgotPasswordKeyToken.Equals(token))
                {
                    user.Password = SBHelper.MD5Hash(changePassword);
                    int res = dbr.Update <User>(user);
                    if (res == 1)
                    {
                        return(Ok("Password changed successfully"));
                    }
                    else
                    {
                        return(BadRequest("error while updating password, pls try after some time."));
                    }
                }
                else
                {
                    return(Ok("wrong link"));
                }
            }
            else
            {
                return(Ok("EmailId does not exist"));
            }
        }
Ejemplo n.º 26
0
        public static void instgramSearch()
        {
            DatabaseRepository dbr           = new DatabaseRepository();
            List <Discovery>   lst_discovery = dbr.Find <Discovery>(t => t.SearchKeyword != "").ToList();

            foreach (var itemdis in lst_discovery)
            {
                MongoRepository mongoreppo = new MongoRepository("AdvanceSerachData");
                try
                {
                    JObject recentactivities = JObject.Parse(TagSearch.InstagramTagSearch(itemdis.SearchKeyword, AdvanceSerachData.Helper.AppSetting.instagramToken));
                    foreach (JObject obj in JArray.Parse(recentactivities["data"].ToString()))
                    {
                        Domain.Socioboard.Models.Mongo.AdvanceSerachData _AdvanceSerachData = new Domain.Socioboard.Models.Mongo.AdvanceSerachData();
                        _AdvanceSerachData.Id          = ObjectId.GenerateNewId();
                        _AdvanceSerachData.strId       = ObjectId.GenerateNewId().ToString();
                        _AdvanceSerachData.domainType  = "https://www.instagram.com/?";
                        _AdvanceSerachData.postType    = Domain.Socioboard.Enum.AdvanceSearchpostType.image;
                        _AdvanceSerachData.networkType = Domain.Socioboard.Enum.NetworkType.instagram;

                        try
                        {
                            _AdvanceSerachData.ImageUrl = obj["images"]["standard_resolution"]["url"].ToString();
                        }
                        catch { }
                        try
                        {
                            _AdvanceSerachData.postUrl = obj["link"].ToString();
                        }
                        catch { }
                        try
                        {
                            foreach (JValue tag in JArray.Parse(obj["tags"].ToString()))
                            {
                                try
                                {
                                    _AdvanceSerachData.postdescription = tag.ToString() + ",";
                                }
                                catch { }
                            }
                        }
                        catch { }
                        try
                        {
                            _AdvanceSerachData.postedTime = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(Convert.ToDateTime(obj["created_time"].ToString()));
                        }
                        catch
                        {
                            _AdvanceSerachData.postedTime = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                        }
                        try
                        {
                            _AdvanceSerachData.postId = obj["id"].ToString();
                        }
                        catch { }
                        try
                        {
                            _AdvanceSerachData.userName = obj["user"]["username"].ToString();
                        }
                        catch { }
                        try
                        {
                            _AdvanceSerachData.userName = obj["user"]["full_name"].ToString();
                        }
                        catch { }
                        int count = mongoreppo.Counts <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(t => t.postUrl == _AdvanceSerachData.postUrl);
                        if (count == 0)
                        {
                            mongoreppo.Add <Domain.Socioboard.Models.Mongo.AdvanceSerachData>(_AdvanceSerachData);
                        }
                        else
                        {
                        }
                    }
                }
                catch { }
            }
        }
Ejemplo n.º 27
0
        public void ShceduleConetentStudioFeeds(object o)
        {
            MongoRepository mongorepo = new Helper.MongoRepository("ContentFeedsShareathon");
            int             pageapiHitsCount;

            object[] arr = o as object[];
            ContentStudioShareathonIdData shareathon = (ContentStudioShareathonIdData)arr[0];

            Model.DatabaseRepository dbr = (Model.DatabaseRepository)arr[1];
            MongoRepository          _ShareathonRepository = (MongoRepository)arr[2];

            string[] ids = shareathon.FbPageId.Split(',');
            foreach (string id in ids)
            {
                try
                {
                    pageapiHitsCount = 0;
                    //  List<ContentFeedsShareathon> lstcontent = new List<ContentFeedsShareathon>();



                    Domain.Socioboard.Models.Facebookaccounts lstFbAcc     = dbr.Single <Domain.Socioboard.Models.Facebookaccounts>(t => t.FbUserId == id);
                    Domain.Socioboard.Models.Facebookaccounts fbAcc        = dbr.Single <Domain.Socioboard.Models.Facebookaccounts>(t => t.UserId == lstFbAcc.UserId);
                    Domain.Socioboard.Models.Facebookaccounts facebookPage = null;

                    MongoRepository mongoshare = new Helper.MongoRepository("ContentFeedsShareathon");



                    if (lstFbAcc != null)
                    {
                        facebookPage = lstFbAcc;
                    }
                    if (facebookPage != null)
                    {
                        if (pageapiHitsCount < pageMaxapiHitsCount)
                        {
                            //  var lstcontent = mongorepo.Find<ContentFeedsShareathon>(t => t.FbPageId == id && t.UserId == fbAcc.UserId && t.status == 0);
                            var resultshare = mongorepo.Find <ContentFeedsShareathon>(t => t.FbPageId == shareathon.FbPageId && t.Status == false);
                            var task        = Task.Run(async() =>
                            {
                                return(await resultshare);
                            });
                            int count     = task.Result.Count;
                            var feedsData = task.Result.ToList();

                            if (facebookPage.contenetShareathonUpdate.AddHours(1) <= DateTime.UtcNow)
                            {
                                if (count != 0)
                                {
                                    pageapiHitsCount++;
                                    //!shareathon.FbPageId.Equals(obj.FbPageId) && !shareathon.postId.Equals(obj.postId)
                                    foreach (var obj in feedsData)
                                    {
                                        try
                                        {
                                            DateTime dt = SBHelper.ConvertFromUnixTimestamp(obj.lastsharestamp);
                                            dt = dt.AddMinutes(obj.Timeintervalminutes);
                                            if ((obj.Status == false && SBHelper.ConvertToUnixTimestamp(dt) <= SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow)))
                                            {
                                                string ret = Helper.FBPostContentFeeds.FacebookComposeMessageRss(obj.title, facebookPage.AccessToken, facebookPage.FbUserId, "", obj.postUrl, obj.postId);
                                                if (ret == "Messages Posted Successfully")
                                                {
                                                    obj.Status        = true;
                                                    shareathon.Status = true;


                                                    FilterDefinition <BsonDocument> filter = new BsonDocument("strId", obj.strId);
                                                    var update = Builders <BsonDocument> .Update.Set("Status", true);

                                                    mongorepo.Update <Domain.Socioboard.Models.Mongo.ContentFeedsShareathon>(update, filter);

                                                    FilterDefinition <BsonDocument> filterId = new BsonDocument("strId", shareathon.strId);
                                                    var updateId = Builders <BsonDocument> .Update.Set("Status", true);

                                                    mongorepo.Update <Domain.Socioboard.Models.Mongo.ContentStudioShareathonIdData>(updateId, filterId);
                                                }

                                                if (!string.IsNullOrEmpty(ret))
                                                {
                                                    Thread.Sleep(1000 * 60 * shareathon.Timeintervalminutes);
                                                }
                                            }
                                        }
                                        catch
                                        {
                                            pageapiHitsCount = pageMaxapiHitsCount;
                                        }
                                    }
                                    fbAcc.contenetShareathonUpdate        = DateTime.UtcNow;
                                    facebookPage.contenetShareathonUpdate = DateTime.UtcNow;
                                    dbr.Update <Domain.Socioboard.Models.Facebookaccounts>(fbAcc);
                                    dbr.Update <Domain.Socioboard.Models.Facebookaccounts>(facebookPage);
                                }
                                else
                                {
                                    FilterDefinition <BsonDocument> filter = new BsonDocument("strId", shareathon.strId);
                                    var update = Builders <BsonDocument> .Update.Set("Status", false);

                                    _ShareathonRepository.Update <Domain.Socioboard.Models.Mongo.ContentFeedsShareathon>(update, filter);
                                }
                            }
                            else
                            {
                                pageapiHitsCount = 0;
                            }
                        }
                    }
                }
                catch
                {
                    pageapiHitsCount = pageMaxapiHitsCount;
                }
            }
        }
        public static void CreateReports(string ProfileId, string AccessToken, bool is90daysupdated)
        {
            int day = 1;

            if (!is90daysupdated)
            {
                day = 90;
            }
            double  since         = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow.AddDays(-day));
            double  until         = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
            JObject pageobj       = new JObject();
            JArray  likesobj      = new JArray();
            JArray  unlikesobj    = new JArray();
            JArray  impressionobj = new JArray();
            JArray  uniqueobj     = new JArray();
            JArray  facebookstory_typeUrlobj90 = new JArray();
            JArray  facebookorganicobj90       = new JArray();
            JArray  facebookviralobj90         = new JArray();
            JArray  facebookpaidobj90          = new JArray();
            JArray  facebookimpressionbyageobj = new JArray();
            JArray  facebookstoriesobj         = new JArray();
            JArray  facebooksharing_typeUrlobj = new JArray();
            JArray  facebookagegenderUrlobj    = new JArray();
            JObject jounlikes                    = new JObject();
            JObject joimpressionobj              = new JObject();
            JObject jouniqueobj                  = new JObject();
            JObject jofacebookstory_typeUrlobj   = new JObject();
            JObject jofacebookorganicobj         = new JObject();
            JObject jofacebookviralobj           = new JObject();
            JObject jofacebookpaidobj            = new JObject();
            JObject jofacebookimpressionbyageobj = new JObject();
            JObject jofacebookstoriesobj         = new JObject();
            JObject jofacebooksharing_typeUrlobj = new JObject();
            JObject jofacebookagegenderUrlobj    = new JObject();


            #region likes
            try
            {
                string facebookpageUrl   = "https://graph.facebook.com/v2.7/" + ProfileId + "?fields=fan_count,talking_about_count&access_token=" + AccessToken;
                string outputfacepageUrl = getFacebookResponse(facebookpageUrl);
                pageobj = JObject.Parse(outputfacepageUrl);
            }
            catch (Exception ex)
            {
            }

            try
            {
                string facebooknewfanUrl = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_fan_adds?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken;
                string outputface        = getFacebookResponse(facebooknewfanUrl);
                likesobj = JArray.Parse(JArray.Parse(JObject.Parse(outputface)["data"].ToString())[0]["values"].ToString());
            }
            catch (Exception ex)
            {
            }
            #endregion
            #region unlikes
            try
            {
                string facebookunlikjeUrl = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_fan_removes?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken;
                string outputfaceunlike   = getFacebookResponse(facebookunlikjeUrl);
                unlikesobj = JArray.Parse(JArray.Parse(JObject.Parse(outputfaceunlike)["data"].ToString())[0]["values"].ToString());
            }
            catch (Exception ex)
            {
            }
            #endregion
            #region impression
            try
            {
                string facebookimpressionUrl  = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_impressions?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken;
                string outputfaceunimpression = getFacebookResponse(facebookimpressionUrl);
                impressionobj = JArray.Parse(JArray.Parse(JObject.Parse(outputfaceunimpression)["data"].ToString())[0]["values"].ToString());
            }
            catch (Exception ex)
            {
            }
            #endregion
            #region impression user
            try
            {
                string facebookuniqueUrl  = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_impressions_unique?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken;
                string outputfaceununoque = getFacebookResponse(facebookuniqueUrl);
                uniqueobj = JArray.Parse(JArray.Parse(JObject.Parse(outputfaceununoque)["data"].ToString())[0]["values"].ToString());
            }
            catch (Exception ex)
            {
            }
            #endregion
            #region impression breakdown
            try
            {
                string facebookstory_typeUrl90  = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_impressions_by_story_type?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken;
                string outputfaceunstory_type90 = getFacebookResponse(facebookstory_typeUrl90);
                facebookstory_typeUrlobj90 = JArray.Parse(JArray.Parse(JObject.Parse(outputfaceunstory_type90)["data"].ToString())[0]["values"].ToString());
            }
            catch (Exception ex)
            {
            }
            #endregion
            #region impression breakdown organic
            try
            {
                string facebookorganic90   = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_impressions_organic?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken;
                string outputfaceorganic90 = getFacebookResponse(facebookorganic90);
                facebookorganicobj90 = JArray.Parse(JArray.Parse(JObject.Parse(outputfaceorganic90)["data"].ToString())[0]["values"].ToString());
            }
            catch (Exception ex)
            {
            }
            #endregion
            #region imression breakdowm viral
            try
            {
                string facebookviral90   = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_impressions_viral?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken;
                string outputfaceviral90 = getFacebookResponse(facebookviral90);
                facebookviralobj90 = JArray.Parse(JArray.Parse(JObject.Parse(outputfaceviral90)["data"].ToString())[0]["values"].ToString());
            }
            catch (Exception ex)
            {
            }
            #endregion
            #region impression breakdown paid
            try
            {
                string facebookpaid90   = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_impressions_paid?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken;
                string outputfacepaid90 = getFacebookResponse(facebookpaid90);
                facebookpaidobj90 = JArray.Parse(JArray.Parse(JObject.Parse(outputfacepaid90)["data"].ToString())[0]["values"].ToString());
            }
            catch (Exception ex)
            {
            }
            #endregion
            #region page imression by age and gender
            try
            {
                string facebookimpressionbyage   = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_impressions_by_age_gender_unique?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken;
                string outputfaceimpressionbyage = getFacebookResponse(facebookimpressionbyage);
                facebookimpressionbyageobj = JArray.Parse(JArray.Parse(JObject.Parse(outputfaceimpressionbyage)["data"].ToString())[0]["values"].ToString());
            }
            catch (Exception ex)
            {
            }
            #endregion
            #region story sharing
            try
            {
                string facebookstories   = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_stories?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken;
                string outputfacestories = getFacebookResponse(facebookstories);
                facebookstoriesobj = JArray.Parse(JArray.Parse(JObject.Parse(outputfacestories)["data"].ToString())[0]["values"].ToString());
            }
            catch (Exception ex)
            {
            }
            #endregion
            #region sroty sharing by share type
            try
            {
                string facebooksharing_typeUrl  = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_stories_by_story_type?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken;
                string outputfaceunsharing_type = getFacebookResponse(facebooksharing_typeUrl);
                facebooksharing_typeUrlobj = JArray.Parse(JArray.Parse(JObject.Parse(outputfaceunsharing_type)["data"].ToString())[0]["values"].ToString());
            }
            catch (Exception ex)
            {
            }
            #endregion
            #region story sharing by age and gender
            try
            {
                string facebooksharingagegenderUrl = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_storytellers_by_age_gender?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken;
                string outputfaceunagegender       = getFacebookResponse(facebooksharingagegenderUrl);
                facebookagegenderUrlobj = JArray.Parse(JArray.Parse(JObject.Parse(outputfaceunagegender)["data"].ToString())[0]["values"].ToString());
            }
            catch (Exception ex)
            {
            }
            #endregion
            foreach (JObject obj in likesobj)
            {
                Domain.Socioboard.Models.Mongo.FacaebookPageDailyReports facebookReportViewModal = new Domain.Socioboard.Models.Mongo.FacaebookPageDailyReports();
                string key = obj["end_time"].ToString();
                try
                {
                    jounlikes = unlikesobj.Children <JObject>().FirstOrDefault(o => o["end_time"].ToString() == key);
                }
                catch (Exception ex)
                {
                }
                try
                {
                    joimpressionobj = impressionobj.Children <JObject>().FirstOrDefault(o => o["end_time"].ToString() == key);
                }
                catch (Exception ex)
                {
                }
                try
                {
                    jouniqueobj = uniqueobj.Children <JObject>().FirstOrDefault(o => o["end_time"].ToString() == key);
                }
                catch (Exception ex)
                {
                }
                try
                {
                    jofacebookstory_typeUrlobj = facebookstory_typeUrlobj90.Children <JObject>().FirstOrDefault(o => o["end_time"].ToString() == key);
                }
                catch (Exception ex)
                {
                }
                try
                {
                    jofacebookorganicobj = facebookorganicobj90.Children <JObject>().FirstOrDefault(o => o["end_time"].ToString() == key);
                }
                catch (Exception ex)
                {
                }
                try
                {
                    jofacebookviralobj = facebookviralobj90.Children <JObject>().FirstOrDefault(o => o["end_time"].ToString() == key);
                }
                catch (Exception ex)
                {
                }
                try
                {
                    jofacebookpaidobj = facebookpaidobj90.Children <JObject>().FirstOrDefault(o => o["end_time"].ToString() == key);
                }
                catch (Exception ex)
                {
                }
                try
                {
                    jofacebookimpressionbyageobj = facebookimpressionbyageobj.Children <JObject>().FirstOrDefault(o => o["end_time"].ToString() == key);
                }
                catch (Exception ex)
                {
                }
                try
                {
                    jofacebookstoriesobj = facebookstoriesobj.Children <JObject>().FirstOrDefault(o => o["end_time"].ToString() == key);
                }
                catch (Exception ex)
                {
                }
                try
                {
                    jofacebooksharing_typeUrlobj = facebooksharing_typeUrlobj.Children <JObject>().FirstOrDefault(o => o["end_time"].ToString() == key);
                }
                catch (Exception ex)
                {
                }
                try
                {
                    jofacebookagegenderUrlobj = facebookagegenderUrlobj.Children <JObject>().FirstOrDefault(o => o["end_time"].ToString() == key);
                }
                catch (Exception ex)
                {
                }
                DateTime dt = DateTime.Parse(key).Date;
                facebookReportViewModal.pageId = ProfileId;
                facebookReportViewModal.date   = SBHelper.ConvertToUnixTimestamp(dt);
                try
                {
                    facebookReportViewModal.totalLikes = pageobj["fan_count"].ToString();
                }
                catch
                {
                    facebookReportViewModal.totalLikes = "0";
                }
                try
                {
                    facebookReportViewModal.talkingAbout = pageobj["talking_about_count"].ToString();
                }
                catch
                {
                    facebookReportViewModal.talkingAbout = "0";
                }
                try
                {
                    facebookReportViewModal.perDayLikes = obj["value"].ToString();
                }
                catch
                {
                    facebookReportViewModal.perDayLikes = "0";
                }
                try
                {
                    facebookReportViewModal.likes = Int32.Parse(obj["value"].ToString());
                }
                catch
                {
                    facebookReportViewModal.likes = 0;
                }
                try
                {
                    facebookReportViewModal.unlikes = Int32.Parse(jounlikes["value"].ToString());
                }
                catch
                {
                    facebookReportViewModal.unlikes = 0;
                }
                try
                {
                    facebookReportViewModal.perDayUnlikes = jounlikes["value"].ToString();
                }
                catch
                {
                    facebookReportViewModal.perDayUnlikes = "0";
                }
                try
                {
                    facebookReportViewModal.impression = Int32.Parse(joimpressionobj["value"].ToString());
                }
                catch
                {
                    facebookReportViewModal.impression = 0;
                }
                try
                {
                    facebookReportViewModal.perDayImpression = joimpressionobj["value"].ToString();
                }
                catch
                {
                    facebookReportViewModal.perDayImpression = "0";
                }
                try
                {
                    facebookReportViewModal.uniqueUser = Int32.Parse(jouniqueobj["value"].ToString());
                }
                catch
                {
                    facebookReportViewModal.uniqueUser = 0;
                }
                try
                {
                    facebookReportViewModal.uniqueUser = Int32.Parse(jouniqueobj["value"].ToString());
                }
                catch
                {
                    facebookReportViewModal.uniqueUser = 0;
                }
                try
                {
                    facebookReportViewModal.impressionFans = Int32.Parse(jofacebookstory_typeUrlobj["value"]["fan"].ToString());
                }
                catch
                {
                    facebookReportViewModal.impressionFans = 0;
                }
                try
                {
                    facebookReportViewModal.impressionPagePost = Int32.Parse(jofacebookstory_typeUrlobj["value"]["page post"].ToString());
                }
                catch
                {
                    facebookReportViewModal.impressionPagePost = 0;
                }
                try
                {
                    facebookReportViewModal.impressionuserPost = Int32.Parse(jofacebookstory_typeUrlobj["value"]["user post"].ToString());
                }
                catch
                {
                    facebookReportViewModal.impressionuserPost = 0;
                }
                try
                {
                    facebookReportViewModal.impressionCoupn = Int32.Parse(jofacebookstory_typeUrlobj["value"]["coupon"].ToString());
                }
                catch
                {
                    facebookReportViewModal.impressionCoupn = 0;
                }
                try
                {
                    facebookReportViewModal.impressionOther = Int32.Parse(jofacebookstory_typeUrlobj["value"]["other"].ToString());
                }
                catch
                {
                    facebookReportViewModal.impressionOther = 0;
                }
                try
                {
                    facebookReportViewModal.impressionMention = Int32.Parse(jofacebookstory_typeUrlobj["value"]["mention"].ToString());
                }
                catch
                {
                    facebookReportViewModal.impressionMention = 0;
                }
                try
                {
                    facebookReportViewModal.impressionCheckin = Int32.Parse(jofacebookstory_typeUrlobj["value"]["checkin"].ToString());
                }
                catch
                {
                    facebookReportViewModal.impressionCheckin = 0;
                }
                try
                {
                    facebookReportViewModal.impressionQuestion = Int32.Parse(jofacebookstory_typeUrlobj["value"]["question"].ToString());
                }
                catch
                {
                    facebookReportViewModal.impressionQuestion = 0;
                }
                try
                {
                    facebookReportViewModal.impressionEvent = Int32.Parse(jofacebookstory_typeUrlobj["value"]["event"].ToString());
                }
                catch
                {
                    facebookReportViewModal.impressionEvent = 0;
                }
                try
                {
                    facebookReportViewModal.viral = Int32.Parse(jofacebookviralobj["value"].ToString());
                }
                catch
                {
                    facebookReportViewModal.viral = 0;
                }
                try
                {
                    facebookReportViewModal.organic = Int32.Parse(jofacebookorganicobj["value"].ToString());
                }
                catch
                {
                    facebookReportViewModal.organic = 0;
                }
                try
                {
                    facebookReportViewModal.paid = Int32.Parse(jofacebookpaidobj["value"].ToString());
                }
                catch
                {
                    facebookReportViewModal.paid = 0;
                }
                try
                {
                    facebookReportViewModal.f_13_17 = Int32.Parse(jofacebookimpressionbyageobj["value"]["F.13-17"].ToString());
                }
                catch
                {
                    facebookReportViewModal.f_13_17 = 0;
                }
                try
                {
                    facebookReportViewModal.f_18_24 = Int32.Parse(jofacebookimpressionbyageobj["value"]["F.18-24"].ToString());
                }
                catch
                {
                    facebookReportViewModal.f_18_24 = 0;
                }
                try
                {
                    facebookReportViewModal.f_25_34 = Int32.Parse(jofacebookimpressionbyageobj["value"]["F.25-34"].ToString());
                }
                catch
                {
                    facebookReportViewModal.f_25_34 = 0;
                }
                try
                {
                    facebookReportViewModal.f_35_44 = Int32.Parse(jofacebookimpressionbyageobj["value"]["F.35-44"].ToString());
                }
                catch
                {
                    facebookReportViewModal.f_35_44 = 0;
                }
                try
                {
                    facebookReportViewModal.f_45_54 = Int32.Parse(jofacebookimpressionbyageobj["value"]["F.45-54"].ToString());
                }
                catch
                {
                    facebookReportViewModal.f_45_54 = 0;
                }
                try
                {
                    facebookReportViewModal.f_55_64 = Int32.Parse(jofacebookimpressionbyageobj["value"]["F.55-64"].ToString());
                }
                catch
                {
                    facebookReportViewModal.f_55_64 = 0;
                }
                try
                {
                    facebookReportViewModal.f_65 = Int32.Parse(jofacebookimpressionbyageobj["value"]["F.65+"].ToString());
                }
                catch
                {
                    facebookReportViewModal.f_65 = 0;
                }


                try
                {
                    facebookReportViewModal.m_13_17 = Int32.Parse(jofacebookimpressionbyageobj["value"]["M.13-17"].ToString());
                }
                catch
                {
                    facebookReportViewModal.m_13_17 = 0;
                }
                try
                {
                    facebookReportViewModal.m_18_24 = Int32.Parse(jofacebookimpressionbyageobj["value"]["M.18-24"].ToString());
                }
                catch
                {
                    facebookReportViewModal.m_18_24 = 0;
                }
                try
                {
                    facebookReportViewModal.m_25_34 = Int32.Parse(jofacebookimpressionbyageobj["value"]["M.25-34"].ToString());
                }
                catch
                {
                    facebookReportViewModal.m_25_34 = 0;
                }
                try
                {
                    facebookReportViewModal.m_35_44 = Int32.Parse(jofacebookimpressionbyageobj["value"]["M.35-44"].ToString());
                }
                catch
                {
                    facebookReportViewModal.m_35_44 = 0;
                }
                try
                {
                    facebookReportViewModal.m_45_54 = Int32.Parse(jofacebookimpressionbyageobj["value"]["M.45-54"].ToString());
                }
                catch
                {
                    facebookReportViewModal.m_45_54 = 0;
                }
                try
                {
                    facebookReportViewModal.m_55_64 = Int32.Parse(jofacebookimpressionbyageobj["value"]["M.55-64"].ToString());
                }
                catch
                {
                    facebookReportViewModal.m_55_64 = 0;
                }
                try
                {
                    facebookReportViewModal.m_65 = Int32.Parse(jofacebookimpressionbyageobj["value"]["M.65+"].ToString());
                }
                catch
                {
                    facebookReportViewModal.m_65 = 0;
                }
                try
                {
                    facebookReportViewModal.storyShare = Int32.Parse(jofacebookstoriesobj["value"].ToString());
                }
                catch
                {
                    facebookReportViewModal.storyShare = 0;
                }
                try
                {
                    facebookReportViewModal.perDayStoryShare = jofacebookstoriesobj["value"].ToString();
                }
                catch
                {
                    facebookReportViewModal.perDayStoryShare = "0";
                }
                try
                {
                    facebookReportViewModal.story_Fans = Int32.Parse(jofacebooksharing_typeUrlobj["value"]["fan"].ToString());
                }
                catch
                {
                    facebookReportViewModal.story_Fans = 0;
                }
                try
                {
                    facebookReportViewModal.story_PagePost = Int32.Parse(jofacebooksharing_typeUrlobj["value"]["page post"].ToString());
                }
                catch
                {
                    facebookReportViewModal.story_PagePost = 0;
                }
                try
                {
                    facebookReportViewModal.story_UserPost = Int32.Parse(jofacebooksharing_typeUrlobj["value"]["user post"].ToString());
                }
                catch
                {
                    facebookReportViewModal.story_UserPost = 0;
                }
                try
                {
                    facebookReportViewModal.story_Question = Int32.Parse(jofacebooksharing_typeUrlobj["value"]["question"].ToString());
                }
                catch
                {
                    facebookReportViewModal.story_Question = 0;
                }
                try
                {
                    facebookReportViewModal.story_Mention = Int32.Parse(jofacebooksharing_typeUrlobj["value"]["mention"].ToString());
                }
                catch
                {
                    facebookReportViewModal.story_Mention = 0;
                }
                try
                {
                    facebookReportViewModal.story_Other = Int32.Parse(jofacebooksharing_typeUrlobj["value"]["other"].ToString());
                }
                catch
                {
                    facebookReportViewModal.story_Other = 0;
                }
                try
                {
                    facebookReportViewModal.story_Coupon = Int32.Parse(jofacebooksharing_typeUrlobj["value"]["coupon"].ToString());
                }
                catch
                {
                    facebookReportViewModal.story_Coupon = 0;
                }
                try
                {
                    facebookReportViewModal.story_Event = Int32.Parse(jofacebooksharing_typeUrlobj["value"]["event"].ToString());
                }
                catch
                {
                    facebookReportViewModal.story_Event = 0;
                }
                try
                {
                    facebookReportViewModal.story_Checkin = Int32.Parse(jofacebooksharing_typeUrlobj["value"]["checkin"].ToString());
                }
                catch
                {
                    facebookReportViewModal.story_Checkin = 0;
                }

                try
                {
                    facebookReportViewModal.sharing_F_13_17 = Int32.Parse(jofacebookagegenderUrlobj["value"]["F.13-17"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_F_13_17 = 0;
                }
                try
                {
                    facebookReportViewModal.sharing_F_18_24 = Int32.Parse(jofacebookagegenderUrlobj["value"]["F.18-24"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_F_18_24 = 0;
                }
                try
                {
                    facebookReportViewModal.sharing_F_25_34 = Int32.Parse(jofacebookagegenderUrlobj["value"]["F.25-34"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_F_25_34 = 0;
                }
                try
                {
                    facebookReportViewModal.sharing_F_35_44 = Int32.Parse(jofacebookagegenderUrlobj["value"]["F.35-44"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_F_35_44 = 0;
                }
                try
                {
                    facebookReportViewModal.sharing_F_45_54 = Int32.Parse(jofacebookagegenderUrlobj["value"]["F.45-54"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_F_45_54 = 0;
                }
                try
                {
                    facebookReportViewModal.sharing_F_55_64 = Int32.Parse(jofacebookagegenderUrlobj["value"]["F.55-64"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_F_55_64 = 0;
                }
                try
                {
                    facebookReportViewModal.sharing_F_65 = Int32.Parse(jofacebookagegenderUrlobj["value"]["F.65+"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_F_65 = 0;
                }



                try
                {
                    facebookReportViewModal.sharing_M_13_17 = Int32.Parse(jofacebookagegenderUrlobj["value"]["M.13-17"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_M_13_17 = 0;
                }
                try
                {
                    facebookReportViewModal.sharing_M_18_24 = Int32.Parse(jofacebookagegenderUrlobj["value"]["M.18-24"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_M_18_24 = 0;
                }
                try
                {
                    facebookReportViewModal.sharing_M_25_34 = Int32.Parse(jofacebookagegenderUrlobj["value"]["M.25-34"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_M_25_34 = 0;
                }
                try
                {
                    facebookReportViewModal.sharing_M_35_44 = Int32.Parse(jofacebookagegenderUrlobj["value"]["M.35-44"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_M_35_44 = 0;
                }
                try
                {
                    facebookReportViewModal.sharing_M_45_54 = Int32.Parse(jofacebookagegenderUrlobj["value"]["M.45-54"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_M_45_54 = 0;
                }
                try
                {
                    facebookReportViewModal.sharing_M_55_64 = Int32.Parse(jofacebookagegenderUrlobj["value"]["M.55-64"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_M_55_64 = 0;
                }
                try
                {
                    facebookReportViewModal.sharing_M_65 = Int32.Parse(jofacebookagegenderUrlobj["value"]["F.65+"].ToString());
                }
                catch
                {
                    facebookReportViewModal.sharing_M_65 = 0;
                }
                facebookReportViewModal.id = ObjectId.GenerateNewId();
                try
                {
                    MongoRepository mongorepo = new MongoRepository("FacaebookPageDailyReports");
                    var             ret       = mongorepo.Find <Domain.Socioboard.Models.Mongo.FacaebookPageDailyReports>(t => t.date == facebookReportViewModal.date);
                    var             task      = Task.Run(async() =>
                    {
                        return(await ret);
                    });
                    if (task.Result != null)
                    {
                        if (task.Result.Count() < 1)
                        {
                            mongorepo.Add <Domain.Socioboard.Models.Mongo.FacaebookPageDailyReports>(facebookReportViewModal);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Ejemplo n.º 29
0
        public static List <MongoTwitterDirectMessages> GetTwitterDirectMessages(string profileId, DateTime date)
        {
            MongoRepository mongorepo = new MongoRepository("MongoTwitterDirectMessages");
            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 <MongoTwitterDirectMessages>(t => (t.recipientId.Equals(profileId) || t.senderId.Equals(profileId)) && (t.timeStamp > SBHelper.ConvertToUnixTimestamp(dayStart)) && (t.timeStamp < SBHelper.ConvertToUnixTimestamp(dayEnd)));
            var             task      = Task.Run(async() =>
            {
                return(await result);
            });
            IList <Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages> lstTwtMessages = task.Result;

            return(lstTwtMessages.ToList());
        }
Ejemplo n.º 30
0
        public static void CreateReports(long groupId, DateTime date)
        {
            MongoRepository mongoreppo = new MongoRepository("GroupdailyReports");

            Domain.Socioboard.Models.Mongo.GroupdailyReports _GroupdailyReports = new Domain.Socioboard.Models.Mongo.GroupdailyReports();
            string getsexratiodata = gettwittersexdivision(groupId, date);

            string[] ratiodata = getsexratiodata.Split(',');
            _GroupdailyReports.date = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
            try
            {
                _GroupdailyReports.fbfan = getfbfans(groupId, date);
            }
            catch (Exception)
            {
            }
            _GroupdailyReports.femalecount = Convert.ToInt64(ratiodata[1]);
            _GroupdailyReports.GroupId     = groupId;
            _GroupdailyReports.id          = ObjectId.GenerateNewId();
            try
            {
                _GroupdailyReports.inbox = getinboxcount(groupId, date);
            }
            catch (Exception)
            {
                _GroupdailyReports.inbox = 0;
            }
            try
            {
                _GroupdailyReports.interaction = getinteractions(groupId, date);
            }
            catch (Exception)
            {
                _GroupdailyReports.interaction = 0;
            }
            _GroupdailyReports.malecount = Convert.ToInt64(ratiodata[0]);
            try
            {
                _GroupdailyReports.sent = getsentmessage(groupId, date);
            }
            catch (Exception)
            {
                _GroupdailyReports.sent = 0;
            }
            try
            {
                _GroupdailyReports.twitterfollower = gettwitterfollowers(groupId, date);
            }
            catch {
                _GroupdailyReports.twitterfollower = 0;
            }
            try
            {
                _GroupdailyReports.twitter_account_count = total_twitter_accounts(groupId);
            }
            catch (Exception)
            {
                _GroupdailyReports.twitter_account_count = 0;
            }
            try
            {
                _GroupdailyReports.twtmentions = gettwtmentions(groupId, date);
            }
            catch (Exception)
            {
                _GroupdailyReports.twtmentions = 0;
            }
            try
            {
                _GroupdailyReports.twtretweets = gettwtretweets(groupId, date);
            }
            catch (Exception)
            {
                _GroupdailyReports.twtretweets = 0;
            }
            try
            {
                _GroupdailyReports.uniqueusers = uniquetwitteruser(groupId, date);
            }
            catch (Exception)
            {
                _GroupdailyReports.uniqueusers = 0;
            }
            try
            {
                _GroupdailyReports.plainText = getsentmessagePlainText(groupId, date);
            }
            catch (Exception ex)
            {
                _GroupdailyReports.plainText = 0;
            }
            try
            {
                _GroupdailyReports.photoLinks = getsentmessagephotoLinks(groupId, date);
            }
            catch (Exception)
            {
                _GroupdailyReports.photoLinks = 0;
            }
            try
            {
                _GroupdailyReports.linkstoPages = getsentmessagelinkstoPages(groupId, date);
            }
            catch (Exception)
            {
                _GroupdailyReports.linkstoPages = 0;
            }
            try
            {
                _GroupdailyReports.facebookPageCount = facebookPageCount(groupId);
            }
            catch (Exception)
            {
                _GroupdailyReports.facebookPageCount = 0;
            }
            var ret  = mongoreppo.Find <Domain.Socioboard.Models.Mongo.GroupdailyReports>(t => t.date == SBHelper.ConvertToUnixTimestamp(date) && t.GroupId == groupId);
            var task = Task.Run(async() =>
            {
                return(await ret);
            });
            IList <Domain.Socioboard.Models.Mongo.GroupdailyReports> lstDailyReports = task.Result.ToList();

            if (lstDailyReports.Count() > 0)
            {
                lstDailyReports.First().uniqueusers           = _GroupdailyReports.uniqueusers;
                lstDailyReports.First().twtretweets           = _GroupdailyReports.twtretweets;
                lstDailyReports.First().twtmentions           = _GroupdailyReports.twtmentions;
                lstDailyReports.First().twitter_account_count = _GroupdailyReports.twitter_account_count;
                lstDailyReports.First().date              = SBHelper.ConvertToUnixTimestamp(date);
                lstDailyReports.First().twitterfollower   = _GroupdailyReports.twitterfollower;
                lstDailyReports.First().sent              = _GroupdailyReports.sent;
                lstDailyReports.First().malecount         = _GroupdailyReports.malecount;
                lstDailyReports.First().femalecount       = _GroupdailyReports.femalecount;
                lstDailyReports.First().interaction       = _GroupdailyReports.interaction;
                lstDailyReports.First().inbox             = _GroupdailyReports.inbox;
                lstDailyReports.First().GroupId           = _GroupdailyReports.GroupId;
                lstDailyReports.First().fbfan             = _GroupdailyReports.fbfan;
                lstDailyReports.First().linkstoPages      = _GroupdailyReports.linkstoPages;
                lstDailyReports.First().photoLinks        = _GroupdailyReports.photoLinks;
                lstDailyReports.First().plainText         = _GroupdailyReports.plainText;
                lstDailyReports.First().facebookPageCount = _GroupdailyReports.facebookPageCount;
                mongoreppo.UpdateReplace(lstDailyReports.First(), t => t.id == lstDailyReports.First().id);
            }
            else
            {
                mongoreppo.Add <Domain.Socioboard.Models.Mongo.GroupdailyReports>(_GroupdailyReports);
            }
        }