示例#1
0
        public static List <Domain.Socioboard.Models.Mongo.FacaebookPageDailyReports> GetFbpageDetails(string[] lstfbpageid, Model.DatabaseRepository dbr, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
        {
            List <Domain.Socioboard.Models.Mongo.FacaebookPageDailyReports> inMemFacaebookPageDailyReports = _redisCache.Get <List <Domain.Socioboard.Models.Mongo.FacaebookPageDailyReports> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheInstagramDailyReport + lstfbpageid);

            if (inMemFacaebookPageDailyReports != null)
            {
                return(inMemFacaebookPageDailyReports);
            }
            else
            {
                List <Domain.Socioboard.Models.Mongo.FacaebookPageDailyReports> fbpdailyrep     = new List <FacaebookPageDailyReports>();
                Domain.Socioboard.Models.Mongo.FacaebookPageDailyReports        fbdailyrepodata = new FacaebookPageDailyReports();
                MongoRepository mongorepo = new MongoRepository("FacaebookPageDailyReports", _appSettings);

                DateTime dayStart = new DateTime(DateTime.UtcNow.AddDays(-90).Year, DateTime.UtcNow.AddDays(-90).Month, DateTime.UtcNow.AddDays(-90).Day, 0, 0, 0, DateTimeKind.Utc);
                DateTime dayEnd   = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 23, 59, 59, DateTimeKind.Utc);

                var ret  = mongorepo.Find <Domain.Socioboard.Models.Mongo.FacaebookPageDailyReports>(t => lstfbpageid.Contains(t.pageId) && t.date <= Helper.DateExtension.ConvertToUnixTimestamp(dayEnd) && t.date >= Helper.DateExtension.ConvertToUnixTimestamp(dayStart));
                var task = Task.Run(async() =>
                {
                    return(await ret);
                });
                if (task.Result != null)
                {
                    List <Domain.Socioboard.Models.Mongo.FacaebookPageDailyReports> lstfbpagedet = task.Result.ToList();
                    if (lstfbpagedet.Count > 0)
                    {
                        _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheInstagramDailyReport + lstfbpageid, lstfbpagedet.ToList());
                    }
                    return(lstfbpagedet.OrderBy(t => t.date).ToList());
                }
                return(new List <Domain.Socioboard.Models.Mongo.FacaebookPageDailyReports>());
            }
        }
        public static string ValidateEmail(string Token, Helper.AppSettings settings, ILogger _logger, Model.DatabaseRepository dbr)
        {
            Domain.Socioboard.Models.YoutubeGroupInvite _lstMembers = dbr.Single <Domain.Socioboard.Models.YoutubeGroupInvite>(t => t.EmailValidationToken == Token);

            if (_lstMembers.SBUserName == "New User")
            {
                Domain.Socioboard.Models.User tempUser = dbr.Single <Domain.Socioboard.Models.User>(t => t.EmailId == _lstMembers.SBEmailId);
                if (tempUser != null)
                {
                    _lstMembers.SBEmailId = tempUser.EmailId;
                    if (tempUser.ProfilePicUrl == "" || tempUser.ProfilePicUrl == null)
                    {
                    }
                    else
                    {
                        _lstMembers.SBProfilePic = tempUser.ProfilePicUrl;
                    }
                    _lstMembers.SBUserName = tempUser.FirstName + " " + tempUser.LastName;
                    _lstMembers.UserId     = tempUser.Id;
                    _lstMembers.SBEmailId  = tempUser.EmailId;
                    _lstMembers.Active     = true;
                    dbr.Update(_lstMembers);
                }
            }
            else
            {
                _lstMembers.Active = true;
                dbr.Update(_lstMembers);
            }

            return("200");
        }
        public static IList <Domain.Socioboard.Models.YoutubeGroupInvite> GetGroupMembers(Int64 userId, Helper.AppSettings settings, ILogger _logger, Model.DatabaseRepository dbr)
        {
            IList <Domain.Socioboard.Models.YoutubeGroupInvite> _lstMembers = dbr.Find <Domain.Socioboard.Models.YoutubeGroupInvite>(t => t.AccessSBUserId == userId);

            return(_lstMembers);
        }
        public static string AddRssFeed(string TextUrl, long Userid, Domain.Socioboard.Models.RssFeedUrl _RssFeedUrl, string profileId, Domain.Socioboard.Enum.SocialProfileType ProfileType, string profileimageurl, string profilename, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings)
        {
            int             UrlAdded       = 0;
            string          RetMsg         = string.Empty;
            MongoRepository _RssRepository = new MongoRepository("Rss", _appSettings);

            string rt   = ParseFeedUrl(TextUrl, ProfileType, profileId, Userid, profilename, profileimageurl, _appSettings);
            var    ret  = _RssRepository.Find <Domain.Socioboard.Models.Mongo.Rss>(t => t.RssFeedUrl.Equals(TextUrl) && t.ProfileId.Contains(profileId) && t.ProfileType == ProfileType && t.UserId.Equals(Userid));
            var    task = Task.Run(async() =>
            {
                return(await ret);
            });
            int count = task.Result.Count;

            if (count < 1)
            {
                if (rt == "ok")
                {
                    Domain.Socioboard.Models.Mongo.Rss _Rss = new Domain.Socioboard.Models.Mongo.Rss();
                    _Rss.Id              = ObjectId.GenerateNewId();
                    _Rss.strId           = ObjectId.GenerateNewId().ToString();
                    _Rss.RssFeedUrl      = TextUrl;
                    _Rss.ProfileType     = ProfileType;
                    _Rss.ProfileId       = profileId;
                    _Rss.UserId          = Userid;
                    _Rss.ProfileImageUrl = profileimageurl;
                    _Rss.ProfileName     = profilename;
                    _Rss.rssFeedUrl      = _RssFeedUrl;
                    _Rss.CreatedOn       = DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm:ss");
                    _RssRepository.Add(_Rss);
                    UrlAdded++;
                }
                else
                {
                    return("Please Fill Correct Url For Feeds");
                }
            }
            else
            {
            }
            if (UrlAdded == 1)
            {
                RetMsg = "Url for " + UrlAdded.ToString() + " account is added";
            }
            else if (UrlAdded > 1)
            {
                RetMsg = "Url for " + UrlAdded.ToString() + " accounts is added";
            }
            else
            {
                RetMsg = "Url has already added";
            }
            return(RetMsg);
        }
        private static void TwitterSchedulemessage(object o)
        {
            try
            {
                MongoRepository          mongorepo = new Helper.MongoRepository("ContentFeedsShareathon");
                int                      pageapiHitsCount;
                object[]                 arr                   = o as object[];
                FacebookPageFeedShare    shareathon            = (FacebookPageFeedShare)arr[0];
                Model.DatabaseRepository dbr                   = (Model.DatabaseRepository)arr[1];
                MongoRepository          _ShareathonRepository = (MongoRepository)arr[2];
                string[]                 ids                   = shareathon.socialProfiles.Split(',');
                foreach (string id in ids)
                {
                    Domain.Socioboard.Models.TwitterAccount  _TwitterAccount = dbr.Single <Domain.Socioboard.Models.TwitterAccount>(t => t.twitterUserId == id && t.isActive);
                    Domain.Socioboard.Models.LinkedInAccount _LinkedinAcc    = dbr.Single <Domain.Socioboard.Models.LinkedInAccount>(t => t.LinkedinUserId == id && t.IsActive);

                    Domain.Socioboard.Models.User _user = dbr.Single <Domain.Socioboard.Models.User>(t => t.Id == _TwitterAccount.userId);

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



                    if (_TwitterAccount != null || _LinkedinAcc != null)
                    {
                        var resultshare = _ShareathonRepository.Find <FacebookPageFeedShare>(t => t.pageId == shareathon.pageId && t.status != Domain.Socioboard.Enum.RealTimeShareFeedStatus.deleted);
                        var task        = Task.Run(async() =>
                        {
                            return(await resultshare);
                        });
                        int count     = task.Result.Count;
                        var feedsData = task.Result.ToList();
                        if (count != 0)
                        {
                            foreach (var item in feedsData)
                            {
                                if (item.socialmedia.StartsWith("tw"))
                                {
                                    try
                                    {
                                        Console.WriteLine(item.socialProfiles + "Scheduling Started");
                                        PostTwitterMessage(item, _TwitterAccount, null, _user);
                                        Console.WriteLine(item.socialProfiles + "Scheduling");
                                    }
                                    catch (Exception)
                                    {
                                        Thread.Sleep(60000);
                                    }
                                }
                                if (item.socialmedia.StartsWith("lin"))
                                {
                                    try
                                    {
                                        Console.WriteLine(item.socialProfiles + "Scheduling Started");
                                        PostTwitterMessage(item, null, _LinkedinAcc, _user);
                                        Console.WriteLine(item.socialProfiles + "Scheduling");
                                    }
                                    catch (Exception)
                                    {
                                        Thread.Sleep(60000);
                                    }
                                }
                            }
                            //fbAcc.contenetShareathonUpdate = DateTime.UtcNow;
                            //facebookPage.contenetShareathonUpdate = DateTime.UtcNow;
                            //dbr.Update<Domain.Socioboard.Models.Facebookaccounts>(fbAcc);
                            //dbr.Update<Domain.Socioboard.Models.Facebookaccounts>(facebookPage);
                        }
                        //_TwitterAccount.SchedulerUpdate = DateTime.UtcNow;

                        //  dbr.Update<Domain.Socioboard.Models.TwitterAccount>(_TwitterAccount);
                    }
                }
            }
            catch (Exception ex)
            {
                Thread.Sleep(60000);
            }
            finally
            {
                noOfthreadRunning--;
                objSemaphore.Release();
                Console.WriteLine(Thread.CurrentThread.Name + " Is Released");
            }
        }
示例#6
0
        public static List <TaskCommentsViewModel> GetAllCompletedTasksOfUserAndGroup(Int64 recipientUserId, Int64 groupId, ILogger _logger, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository _dbr)
        {
            try
            {
                List <TaskCommentsViewModel> lstTaskCommentsViewModel = new List <TaskCommentsViewModel>();
                MongoRepository taskmongorepo        = new MongoRepository("Tasks", _appSettings);
                MongoRepository taskcommentmongorepo = new MongoRepository("TaskComments", _appSettings);
                var             ret  = taskmongorepo.Find <Tasks>(t => t.groupId == groupId && t.recipientUserId == recipientUserId && t.taskStatus == Domain.Socioboard.Enum.TaskStatus.Completed);
                var             task = Task.Run(async() =>
                {
                    return(await ret);
                });
                IList <Tasks> lstTask = task.Result.ToList();
                foreach (Tasks item in lstTask)
                {
                    TaskCommentsViewModel taskCommentsViewModel = new TaskCommentsViewModel();
                    var ret1  = taskcommentmongorepo.Find <TaskComments>(t => t.taskId == item.strId);
                    var task1 = Task.Run(async() =>
                    {
                        return(await ret1);
                    });
                    taskCommentsViewModel.tasks = item;
                    taskCommentsViewModel.user  = _dbr.FindSingle <User>(t => t.Id == item.senderUserId);
                    IList <TaskComments>        lstTaskComment      = task1.Result.ToList();
                    List <TaskCommentViewModel> lstCommentViewModel = new List <TaskCommentViewModel>();
                    foreach (TaskComments item1 in lstTaskComment)
                    {
                        TaskCommentViewModel commentViewModel = new TaskCommentViewModel();
                        commentViewModel.taskComments = item1;
                        commentViewModel.user         = _dbr.FindSingle <User>(t => t.Id == item1.userId);
                        lstCommentViewModel.Add(commentViewModel);
                    }

                    taskCommentsViewModel.lstTaskComments = lstCommentViewModel;
                    lstTaskCommentsViewModel.Add(taskCommentsViewModel);
                }
                return(lstTaskCommentsViewModel);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(new List <TaskCommentsViewModel>());
            }
        }
        public static string PostRssfeed(Domain.Socioboard.Enum.SocialProfileType profiletype, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr, Helper.Cache _redisCache)
        {
            string          ret = "";
            MongoRepository _RssFeedRepository = new MongoRepository("RssFeed", _appSettings);
            List <Domain.Socioboard.Models.Mongo.RssFeed> objrssdata = new List <Domain.Socioboard.Models.Mongo.RssFeed>();
            var rt   = _RssFeedRepository.Find <Domain.Socioboard.Models.Mongo.RssFeed>(t => t.Status == false && t.ProfileType.Equals(profiletype));
            var task = Task.Run(async() =>
            {
                return(await rt);
            });
            IList <Domain.Socioboard.Models.Mongo.RssFeed> _objrssdata = task.Result;

            objrssdata = _objrssdata.ToList();
            foreach (var item in objrssdata)
            {
                if (profiletype == Domain.Socioboard.Enum.SocialProfileType.Facebook)
                {
                    try
                    {
                        Domain.Socioboard.Models.Facebookaccounts _Facebookaccounts = Repositories.FacebookRepository.getFacebookAccount(item.ProfileId, _redisCache, dbr);
                        ret = Helper.FacebookHelper.FacebookComposeMessageRss(item.Message, _Facebookaccounts.AccessToken, _Facebookaccounts.FbUserId, item.Title, item.Link, item.strId, _appSettings);
                    }
                    catch (Exception ex)
                    {
                        return("");
                    }
                }
                else if (profiletype == Domain.Socioboard.Enum.SocialProfileType.Twitter)
                {
                    try
                    {
                        string message        = "";
                        string UrlShortendata = GetShortenUrl(item.Link, _appSettings);
                        string shortenUrl     = string.Empty;
                        try
                        {
                            JObject JData = JObject.Parse(UrlShortendata);
                            if (JData["status_txt"].ToString() == "OK")
                            {
                                shortenUrl = JData["data"]["url"].ToString();
                            }
                        }
                        catch (Exception ex)
                        {
                        }

                        if (item.Message.Length > 115)
                        {
                            message = item.Message.Substring(0, 115);
                        }
                        else
                        {
                            message = item.Message;
                        }
                        message += " " + shortenUrl;
                        Domain.Socioboard.Models.TwitterAccount _TwitterAccount = Repositories.TwitterRepository.getTwitterAccount(item.ProfileId, _redisCache, dbr);
                        ret = Helper.TwitterHelper.TwitterComposeMessageRss(message, _TwitterAccount.oAuthToken, _TwitterAccount.oAuthSecret, _TwitterAccount.twitterUserId, _TwitterAccount.twitterScreenName, item.strId, _appSettings);
                    }
                    catch (Exception ex)
                    {
                        return("");
                    }
                }
            }
            return(ret);
        }
        /// <summary>
        /// To add the member to the specified group
        /// </summary>
        /// <param name="groupId">group Id</param>
        /// <param name="user">user details</param>
        /// <param name="redisCache"></param>
        /// <param name="dbr">Database respository object</param>
        /// <returns></returns>
        public static int CreateGroupMember(long groupId, User user, Helper.Cache redisCache, Model.DatabaseRepository dbr)
        {
            var grpMember = new Groupmembers
            {
                groupid      = groupId,
                email        = user.EmailId,
                firstName    = user.FirstName,
                lastName     = user.LastName,
                memberStatus = Domain.Socioboard.Enum.GroupMemberStatus.Accepted,
                profileImg   = user.ProfilePicUrl,
                userId       = user.Id,
                memberCode   = "Admin",
                isAdmin      = true
            };

            return(dbr.Add(grpMember));
        }
        public static List <Domain.Socioboard.Models.Groupmembers> getGroupadmin(long groupId, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            List <Domain.Socioboard.Models.Groupmembers> adminDetails = dbr.Find <Domain.Socioboard.Models.Groupmembers>(t => t.groupid == groupId && t.isAdmin).ToList();
            long userID = adminDetails.First().userId;
            List <Domain.Socioboard.Models.User> user = dbr.Find <Domain.Socioboard.Models.User>(t => t.Id == userID).ToList();
            string Email = null;

            try
            {
                Email = user.First().EmailId;
            }
            catch (Exception ex)
            {
            }

            adminDetails.First().email = Email;
            return(adminDetails);
        }
        public static List <Domain.Socioboard.Models.retaingroup> RetainGrpMber(long userId, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            List <Domain.Socioboard.Models.retaingroup> lstgrpdetal = new List <retaingroup>();
            List <Groupmembers> lstadmingrpmember = dbr.Find <Groupmembers>(t => t.userId == userId && t.memberStatus == Domain.Socioboard.Enum.GroupMemberStatus.Accepted && t.isAdmin == true).ToList();
            List <long>         tempLst           = new List <long>();

            foreach (var itemLst in lstadmingrpmember)
            {
                tempLst.Add(itemLst.groupid);
            }
            List <Groupmembers> membersAdminGrp      = dbr.Find <Domain.Socioboard.Models.Groupmembers>(t => tempLst.Contains(t.groupid) && t.memberStatus == Domain.Socioboard.Enum.GroupMemberStatus.Accepted && t.isAdmin != true).ToList();
            List <Groupmembers> lstnonadmingrpmember = dbr.Find <Groupmembers>(t => t.userId == userId && t.memberStatus == Domain.Socioboard.Enum.GroupMemberStatus.Accepted && t.isAdmin != true).ToList();

            foreach (var item in membersAdminGrp)
            {
                Domain.Socioboard.Models.retaingroup lstretailgrp = new retaingroup();

                Groups grp     = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.id == item.groupid).First();
                string grpname = grp.groupName;
                lstretailgrp.grpname  = grpname;
                lstretailgrp.username = item.firstName;
                lstretailgrp.userId   = item.email;
                lstretailgrp.memberid = item.id;
                lstretailgrp.grpid    = item.groupid;
                lstretailgrp.type     = "You";

                lstgrpdetal.Add(lstretailgrp);
            }
            foreach (var item in lstnonadmingrpmember)
            {
                Domain.Socioboard.Models.retaingroup lstretailgrp = new retaingroup();

                Groups grp     = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.id == item.groupid).First();
                string grpname = grp.groupName;
                lstretailgrp.grpname  = grpname;
                lstretailgrp.username = item.firstName;
                lstretailgrp.userId   = item.email;
                lstretailgrp.memberid = item.id;
                lstretailgrp.grpid    = item.groupid;
                lstretailgrp.type     = "Other";
                lstgrpdetal.Add(lstretailgrp);
            }
            //lstretailgrp.memberofadmin = membersAdminGrp;
            //lstretailgrp.memberofNonadmin = lstnonadmingrpmember;
            return(lstgrpdetal);
        }
        public static List <Domain.Socioboard.Models.Groupmembers> findmember(long SBgroupId, long userId, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            try
            {
                List <Domain.Socioboard.Models.Groupmembers> inMemGroupMembers = _redisCache.Get <List <Domain.Socioboard.Models.Groupmembers> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupMembers + userId);
                if (inMemGroupMembers != null)
                {
                    return(inMemGroupMembers);
                }
            }
            catch { }
            List <Domain.Socioboard.Models.Groupmembers> groupMembers = dbr.Find <Domain.Socioboard.Models.Groupmembers>(t => t.userId == userId && t.groupid != SBgroupId).ToList();

            _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupMembers + userId, groupMembers);
            return(groupMembers);
        }
        public static List <Domain.Socioboard.Models.Groupmembers> LeaveTeam(long groupId, long userId, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            List <Domain.Socioboard.Models.Groupmembers> leave = dbr.Find <Domain.Socioboard.Models.Groupmembers>(t => t.groupid == groupId && t.userId == userId).ToList();

            foreach (Domain.Socioboard.Models.Groupmembers item in leave)
            {
                dbr.Delete <Domain.Socioboard.Models.Groupmembers>(item);
            }

            return(leave);
        }
        public static List <Domain.Socioboard.Models.Groupmembers> adminDelete(long groupId, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            List <Domain.Socioboard.Models.Groupmembers> adminDetails = dbr.Find <Domain.Socioboard.Models.Groupmembers>(t => t.groupid == groupId).ToList();

            foreach (Domain.Socioboard.Models.Groupmembers item in adminDetails)
            {
                Groupmembers user = item;
                dbr.Delete <Domain.Socioboard.Models.Groupmembers>(user);
            }
            List <Domain.Socioboard.Models.Groups> groupName = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.id == groupId).ToList();

            foreach (Domain.Socioboard.Models.Groups item in groupName)
            {
                Groups group = item;
                dbr.Delete <Domain.Socioboard.Models.Groups>(group);
            }
            return(adminDetails);
        }
示例#14
0
        public static List <Domain.Socioboard.ViewModels.FacebookPublicReportViewModal> GetFacebookPublicPageReport(Model.DatabaseRepository dbr, Helper.AppSettings _appSettings, int day)
        {
            List <Domain.Socioboard.ViewModels.FacebookPublicReportViewModal> lstFacebookPublicReportViewModal = new List <Domain.Socioboard.ViewModels.FacebookPublicReportViewModal>();
            List <Domain.Socioboard.Models.Facebookaccounts> lstfbacc = dbr.Find <Domain.Socioboard.Models.Facebookaccounts>(t => t.FbProfileType == Domain.Socioboard.Enum.FbProfileType.FacebookPublicPage).ToList();

            foreach (var item in lstfbacc)
            {
                Domain.Socioboard.ViewModels.FacebookPublicReportViewModal objreportdata = new Domain.Socioboard.ViewModels.FacebookPublicReportViewModal();
                MongoRepository mongoreppopage = new MongoRepository("Fbpublicpagedailyreports", _appSettings);

                DateTime dayStart = new DateTime(DateTime.UtcNow.AddDays(-90).Year, DateTime.UtcNow.AddDays(-90).Month, DateTime.UtcNow.AddDays(-90).Day, 0, 0, 0, DateTimeKind.Utc);
                DateTime dayEnd   = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 23, 59, 59, DateTimeKind.Utc);
                var      ret      = mongoreppopage.Find <Domain.Socioboard.Models.Mongo.Fbpublicpagedailyreports>(t => t.pageid == item.FbUserId && t.date <= Helper.DateExtension.ToUnixTimestamp(dayEnd) && t.date >= Helper.DateExtension.ToUnixTimestamp(dayStart));
                var      task     = Task.Run(async() =>
                {
                    return(await ret);
                });
                IList <Domain.Socioboard.Models.Mongo.Fbpublicpagedailyreports> lstfacebookpagepost = task.Result.ToList();
                objreportdata.FacebookAccount          = item;
                objreportdata.Fbpublicpagedailyreports = lstfacebookpagepost.ToList();
                lstFacebookPublicReportViewModal.Add(objreportdata);
            }
            return(lstFacebookPublicReportViewModal);
        }
        public void pageshreathon(object o)
        {
            try
            {
                object[]                 arr                   = o as object[];
                PageShareathon           shareathon            = (PageShareathon)arr[0];
                Model.DatabaseRepository dbr                   = (Model.DatabaseRepository)arr[1];
                MongoRepository          _ShareathonRepository = (MongoRepository)arr[2];
                string[]                 ids                   = shareathon.Facebookpageid.Split(',');
                GlobalVariable.pageShareathonIdsRunning.Add(shareathon.strId);
                foreach (string id in ids)
                {
                    try
                    {
                        pageapiHitsCount = 0;
                        Domain.Socioboard.Models.Facebookaccounts fbAcc        = dbr.Single <Domain.Socioboard.Models.Facebookaccounts>(t => t.FbUserId == shareathon.Facebookaccountid);
                        Domain.Socioboard.Models.Facebookaccounts facebookPage = null;
                        Domain.Socioboard.Models.Facebookaccounts lstFbAcc     = dbr.Single <Domain.Socioboard.Models.Facebookaccounts>(t => t.FbUserId == id);
                        if (lstFbAcc != null)
                        {
                            facebookPage = lstFbAcc;
                        }
                        if (facebookPage != null)
                        {
                            if (pageapiHitsCount < pageMaxapiHitsCount)
                            {
                                string feeds = string.Empty;
                                if (facebookPage.PageShareathonUpdate.AddHours(1) <= DateTime.UtcNow)
                                {
                                    feeds = Socioboard.Facebook.Data.Fbpages.getFacebookRecentPost(fbAcc.AccessToken, facebookPage.FbUserId);
                                    string feedId = string.Empty;
                                    if (!string.IsNullOrEmpty(feeds) && !feeds.Equals("[]"))
                                    {
                                        pageapiHitsCount++;
                                        JObject fbpageNotes = JObject.Parse(feeds);
                                        foreach (JObject obj in JArray.Parse(fbpageNotes["data"].ToString()))
                                        {
                                            try
                                            {
                                                feedId = obj["id"].ToString();
                                                feedId = feedId.Split('_')[1];
                                                DateTime dt = SBHelper.ConvertFromUnixTimestamp(shareathon.Lastsharetimestamp);
                                                dt = dt.AddMinutes(shareathon.Timeintervalminutes);
                                                if ((!shareathon.Lastpostid.Equals(feedId) && SBHelper.ConvertToUnixTimestamp(dt) <= SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow)))
                                                {
                                                    //if (pageapiHitsCount < pageMaxapiHitsCount)
                                                    //{
                                                    string ret = ShareFeed(fbAcc.AccessToken, feedId, facebookPage.FbUserId, "", fbAcc.FbUserId, facebookPage.FbUserName);
                                                    if (!string.IsNullOrEmpty(ret))
                                                    {
                                                        Thread.Sleep(1000 * 60 * shareathon.Timeintervalminutes);
                                                    }
                                                    // }
                                                }
                                            }
                                            catch
                                            {
                                                pageapiHitsCount = pageMaxapiHitsCount;
                                            }
                                        }
                                        fbAcc.PageShareathonUpdate        = DateTime.UtcNow;
                                        facebookPage.PageShareathonUpdate = 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("FacebookStatus", 0);

                                        _ShareathonRepository.Update <Domain.Socioboard.Models.Mongo.PageShareathon>(update, filter);
                                    }
                                }
                                else
                                {
                                    pageapiHitsCount = 0;
                                }
                            }
                        }
                    }

                    catch
                    {
                        pageapiHitsCount = pageMaxapiHitsCount;
                    }
                }
                try
                {
                    if (!string.IsNullOrEmpty(shareathon.FacebookPageUrlId))
                    {
                        string[] urlsIds = shareathon.FacebookPageUrlId.Split(',');
                        foreach (string id_url in urlsIds)
                        {
                            try
                            {
                                pageapiHitsCount = 0;
                                Domain.Socioboard.Models.Facebookaccounts fbAcc = dbr.Single <Domain.Socioboard.Models.Facebookaccounts>(t => t.FbUserId == shareathon.Facebookaccountid);
                                string pagename = Socioboard.Facebook.Data.Fbpages.getFbPageData(fbAcc.AccessToken, id_url);
                                if (pageapiHitsCount < pageMaxapiHitsCount)
                                {
                                    string feeds = string.Empty;
                                    feeds = Socioboard.Facebook.Data.Fbpages.getFacebookRecentPost(fbAcc.AccessToken, id_url);
                                    string feedId = string.Empty;
                                    if (!string.IsNullOrEmpty(feeds) && !feeds.Equals("[]"))
                                    {
                                        pageapiHitsCount++;
                                        JObject fbpageNotes = JObject.Parse(feeds);
                                        foreach (JObject obj in JArray.Parse(fbpageNotes["data"].ToString()))
                                        {
                                            try
                                            {
                                                feedId = obj["id"].ToString();
                                                feedId = feedId.Split('_')[1];
                                                DateTime dt = SBHelper.ConvertFromUnixTimestamp(shareathon.Lastsharetimestamp);
                                                dt = dt.AddMinutes(shareathon.Timeintervalminutes);
                                                if ((!shareathon.Lastpostid.Equals(feedId) && SBHelper.ConvertToUnixTimestamp(dt) <= SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow)))
                                                {
                                                    string ret = ShareFeed(fbAcc.AccessToken, feedId, id_url, "", fbAcc.FbUserId, pagename);
                                                    if (!string.IsNullOrEmpty(ret))
                                                    {
                                                        Thread.Sleep(1000 * 60 * shareathon.Timeintervalminutes);
                                                    }
                                                }
                                            }
                                            catch
                                            {
                                                pageapiHitsCount = pageMaxapiHitsCount;
                                            }
                                        }
                                        fbAcc.PageShareathonUpdate = DateTime.UtcNow;
                                        dbr.Update <Domain.Socioboard.Models.Facebookaccounts>(fbAcc);
                                    }
                                    else
                                    {
                                        FilterDefinition <BsonDocument> filter = new BsonDocument("strId", shareathon.strId);
                                        var update = Builders <BsonDocument> .Update.Set("FacebookStatus", 1);

                                        _ShareathonRepository.Update <Domain.Socioboard.Models.Mongo.PageShareathon>(update, filter);
                                    }
                                }
                            }
                            catch
                            {
                                pageapiHitsCount = pageMaxapiHitsCount;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
                GlobalVariable.pageShareathonIdsRunning.Remove(shareathon.strId);
            }
            catch (Exception e)
            {
                pageapiHitsCount = pageMaxapiHitsCount;
            }
            finally
            {
                noOfthread_pageshreathonRunning--;
            }
        }
        public static List <Domain.Socioboard.Models.EwalletWithdrawRequest> GetEwalletWithdraw(long userId, Model.DatabaseRepository dbr)
        {
            List <Domain.Socioboard.Models.EwalletWithdrawRequest> lstEwalletWithdrawRequest = dbr.Find <Domain.Socioboard.Models.EwalletWithdrawRequest>(t => t.UserID == userId).ToList();

            if (lstEwalletWithdrawRequest != null)
            {
                return(lstEwalletWithdrawRequest);
            }
            else
            {
                return(null);
            }
        }
        public void groupshreathon(object o)
        {
            try
            {
                object[]                 arr                   = o as object[];
                GroupShareathon          shareathon            = (GroupShareathon)arr[0];
                Model.DatabaseRepository dbr                   = (Model.DatabaseRepository)arr[1];
                MongoRepository          _ShareathonRepository = (MongoRepository)arr[2];
                string[]                 ids                   = shareathon.Facebookpageid.Split(',');
                foreach (string id in ids)
                {
                    try
                    {
                        int groupapiHitsCountNew = 0;
                        Domain.Socioboard.Models.Facebookaccounts fbAcc        = dbr.Single <Domain.Socioboard.Models.Facebookaccounts>(t => t.FbUserId == shareathon.Facebookaccountid);
                        Domain.Socioboard.Models.Facebookaccounts facebookPage = null;
                        Domain.Socioboard.Models.Facebookaccounts lstFbAcc     = dbr.Single <Domain.Socioboard.Models.Facebookaccounts>(t => t.FbUserId == id);

                        if (fbAcc != null)
                        {
                            if (groupapiHitsCountNew < groupMaxapiHitsCount)
                            {
                                string feeds = string.Empty;
                                if (fbAcc.GroupShareathonUpdate.AddHours(1) <= DateTime.UtcNow)
                                {
                                    feeds = Socioboard.Facebook.Data.Fbpages.getFacebookRecentPost(fbAcc.AccessToken, id);
                                    string feedId = string.Empty;
                                    if (!string.IsNullOrEmpty(feeds) && !feeds.Equals("[]"))
                                    {
                                        groupapiHitsCountNew++;
                                        JObject fbpageNotes = JObject.Parse(feeds);
                                        foreach (JObject obj in JArray.Parse(fbpageNotes["data"].ToString()))
                                        {
                                            try
                                            {
                                                string feedid = obj["id"].ToString();
                                                feedid = feedid.Split('_')[1];
                                                feedId = feedid + "," + feedId;
                                            }
                                            catch { }
                                        }
                                        try
                                        {
                                            DateTime dt = SBHelper.ConvertFromUnixTimestamp(shareathon.Lastsharetimestamp);
                                            dt = dt.AddMinutes(shareathon.Timeintervalminutes);
                                            if (shareathon.Lastpostid == null || (!shareathon.Lastpostid.Equals(feedId) && SBHelper.ConvertToUnixTimestamp(dt) <= SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow)))
                                            {
                                                //if (groupapiHitsCountNew < groupMaxapiHitsCount)
                                                //{
                                                ShareFeedonGroup(fbAcc.AccessToken, feedId, id, "", shareathon.Facebookgroupid, shareathon.Timeintervalminutes, shareathon.Facebookaccountid, shareathon.Lastsharetimestamp, shareathon.Facebooknameid);
                                                //}
                                            }
                                            fbAcc.GroupShareathonUpdate = DateTime.UtcNow;
                                            dbr.Update <Domain.Socioboard.Models.Facebookaccounts>(fbAcc);
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }
                                    else
                                    {
                                        FilterDefinition <BsonDocument> filter = new BsonDocument("strId", shareathon.strId);
                                        var update = Builders <BsonDocument> .Update.Set("FacebookStatus", 0);

                                        _ShareathonRepository.Update <Domain.Socioboard.Models.Mongo.GroupShareathon>(update, filter);
                                        groupapiHitsCount = groupMaxapiHitsCount;
                                    }
                                }
                                else
                                {
                                    groupapiHitsCount = 0;
                                }
                            }
                        }

                        //fbAcc.SchedulerUpdate = DateTime.UtcNow;
                        //dbr.Update<Domain.Socioboard.Models.Facebookaccounts>(fbAcc);
                    }

                    catch
                    {
                        groupapiHitsCount = groupMaxapiHitsCount;
                    }
                }
            }
            catch (Exception e)
            {
                groupapiHitsCount = groupMaxapiHitsCount;
            }
            finally
            {
                noOfthread_groupshreathonRunning--;
            }
        }
        public static List <Domain.Socioboard.Models.EwalletWithdrawRequest> GetEwalletWithdraw(Model.DatabaseRepository dbr)
        {
            List <Domain.Socioboard.Models.EwalletWithdrawRequest> lstEwalletWithdrawRequest = dbr.FindAll <Domain.Socioboard.Models.EwalletWithdrawRequest>().ToList();

            if (lstEwalletWithdrawRequest != null)
            {
                return(lstEwalletWithdrawRequest);
            }
            else
            {
                return(null);
            }
        }
        public static List <Domain.Socioboard.Models.Mongo.RssFeed> GetPostedRssDataByUser(long userId, long groupId, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr)
        {
            string[]        profileids     = null;
            MongoRepository _RssRepository = new MongoRepository("RssFeed", _appSettings);
            List <Domain.Socioboard.Models.Mongo.RssFeed> lstRss           = new List <Domain.Socioboard.Models.Mongo.RssFeed>();
            List <Domain.Socioboard.Models.Groupprofiles> lstGroupprofiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId).ToList();

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

            return(lstRss = task.Result.ToList());
        }
 public static void UpdatePaymentStatus(long EwalletWithdrawid, Model.DatabaseRepository dbr)
 {
     Domain.Socioboard.Models.EwalletWithdrawRequest _EwalletWithdrawRequest = dbr.Find <Domain.Socioboard.Models.EwalletWithdrawRequest>(t => t.Id == EwalletWithdrawid).First();
     _EwalletWithdrawRequest.Status = Domain.Socioboard.Enum.EwalletStatus.compleate;
     dbr.Update(_EwalletWithdrawRequest);
 }
        public static string EditFeedUrl(string NewFeedUrl, string OldFeedUrl, string RssId, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr)
        {
            Domain.Socioboard.Models.RssFeedUrl _RssFeedUrl = new Domain.Socioboard.Models.RssFeedUrl();
            _RssFeedUrl        = dbr.Find <Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Contains(OldFeedUrl)).FirstOrDefault();
            _RssFeedUrl.rssurl = NewFeedUrl;
            dbr.Update <Domain.Socioboard.Models.RssFeedUrl>(_RssFeedUrl);
            _RssFeedUrl = dbr.FindSingle <Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Contains(NewFeedUrl));
            try
            {
                MongoRepository _RssRepository         = new MongoRepository("Rss", _appSettings);
                var             builders               = Builders <BsonDocument> .Filter;
                FilterDefinition <BsonDocument> filter = builders.Eq("strId", RssId);
                var update = Builders <BsonDocument> .Update.Set("RssFeedUrl", NewFeedUrl).Set("rssFeedUrl", _RssFeedUrl);

                _RssRepository.Update <Domain.Socioboard.Models.Mongo.Rss>(update, filter);
                return("Success");
            }
            catch (Exception ex)
            {
                return("Error");
            }
        }
 public static void AddRequestToWithdraw(string WithdrawAmount, string PaymentMethod, string PaypalEmail, string IbanCode, string SwiftCode, string Other, long UserID, Model.DatabaseRepository dbr)
 {
     Domain.Socioboard.Models.User _User = dbr.Find <Domain.Socioboard.Models.User>(t => t.Id == UserID).First();
     Domain.Socioboard.Models.EwalletWithdrawRequest _EwalletWithdrawRequest = new Domain.Socioboard.Models.EwalletWithdrawRequest();
     _EwalletWithdrawRequest.UserID         = _User.Id;
     _EwalletWithdrawRequest.Other          = Other;
     _EwalletWithdrawRequest.PaymentMethod  = PaymentMethod;
     _EwalletWithdrawRequest.PaypalEmail    = PaypalEmail;
     _EwalletWithdrawRequest.RequestDate    = DateTime.UtcNow;
     _EwalletWithdrawRequest.Status         = Domain.Socioboard.Enum.EwalletStatus.pending;
     _EwalletWithdrawRequest.SwiftCode      = SwiftCode;
     _EwalletWithdrawRequest.UserEmail      = _User.EmailId;
     _EwalletWithdrawRequest.UserName       = _User.FirstName + " " + _User.LastName;
     _EwalletWithdrawRequest.WithdrawAmount = WithdrawAmount;
     dbr.Add(_EwalletWithdrawRequest);
     _User.Ewallet = (Double.Parse(_User.Ewallet) - Double.Parse(WithdrawAmount)).ToString();
     dbr.Update(_User);
 }
        public static string ComposeLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Models.LinkedInAccount _objLinkedInAccount, Model.DatabaseRepository dbr, Domain.Socioboard.Models.User _user)
        {
            string json = "";
            var    img  = "";

            Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = _objLinkedInAccount;
            oAuthLinkedIn _oauth = new oAuthLinkedIn();

            _oauth.ConsumerKey    = AppSettings.LinkedinConsumerKey;
            _oauth.ConsumerSecret = AppSettings.LinkedinConsumerSecret;
            _oauth.Token          = _LinkedInAccount.OAuthToken;
            string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json";



            if (string.IsNullOrEmpty(ImageUrl))
            {
                json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment);
            }
            else
            {
                json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, ImageUrl);
            }
            if (!string.IsNullOrEmpty(json))
            {
                string msg = "feed shared successfully";
                return(msg);
            }
            else
            {
                string msg = "feed has not posted";
                return(msg);
            }
        }
示例#24
0
        public static List <Domain.Socioboard.Models.TwitterRecentFollower> TwitterRecentFollower(long groupId, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings)
        {
            string[] profileids = null;
            List <Domain.Socioboard.Models.TwitterRecentFollower> lstTwitterRecentFollower = new List <Domain.Socioboard.Models.TwitterRecentFollower>();
            List <Domain.Socioboard.Models.Groupprofiles>         lstGroupprofiles         = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter).ToList();

            profileids = lstGroupprofiles.Select(t => t.profileId).ToArray();
            List <Domain.Socioboard.Models.TwitterAccount> lstAccRepo = dbr.Find <Domain.Socioboard.Models.TwitterAccount>(t => profileids.Contains(t.twitterUserId) && t.isActive).ToList();
            oAuthTwitter oauth    = null;
            Users        twtUsers = new Users();

            foreach (Domain.Socioboard.Models.TwitterAccount itemTwt in lstAccRepo)
            {
                oauth                   = new oAuthTwitter();
                oauth.AccessToken       = itemTwt.oAuthToken;
                oauth.AccessTokenSecret = itemTwt.oAuthSecret;
                oauth.TwitterScreenName = itemTwt.twitterScreenName;
                oauth.TwitterUserId     = itemTwt.twitterUserId;
                oauth.ConsumerKey       = _appSettings.twitterConsumerKey;
                oauth.ConsumerKeySecret = _appSettings.twitterConsumerScreatKey;
                JArray jarresponse = twtUsers.Get_Followers_ById(oauth, itemTwt.twitterUserId);
                foreach (var item in jarresponse)
                {
                    int resposecount = 0;
                    if (item["ids"] != null)
                    {
                        foreach (var child in item["ids"])
                        {
                            if (resposecount < 2)
                            {
                                JArray userprofile = twtUsers.Get_Users_LookUp(oauth, child.ToString());
                                foreach (var items in userprofile)
                                {
                                    Domain.Socioboard.Models.TwitterRecentFollower objTwitterRecentFollower = new Domain.Socioboard.Models.TwitterRecentFollower();
                                    resposecount++;
                                    objTwitterRecentFollower.screen_name       = items["screen_name"].ToString();
                                    objTwitterRecentFollower.name              = items["name"].ToString();
                                    objTwitterRecentFollower.profile_image_url = items["profile_image_url"].ToString();
                                    lstTwitterRecentFollower.Add(objTwitterRecentFollower);
                                }
                            }
                        }
                    }
                }
            }
            return(lstTwitterRecentFollower);
        }
        public static IList <Domain.Socioboard.Models.Groupprofiles> GetYtGroupChannel(Int64 userId, Helper.AppSettings settings, ILogger _logger, Model.DatabaseRepository dbr)
        {
            IList <Domain.Socioboard.Models.YoutubeGroupInvite> _lstMembers = dbr.Find <Domain.Socioboard.Models.YoutubeGroupInvite>(t => t.UserId == userId && t.AccessSBUserId != userId && t.Active == true);
            List <Int64> userOwnerIdss = _lstMembers.Select(t => t.AccessSBUserId).ToList();
            IList <Domain.Socioboard.Models.Groupprofiles> _lstchannelsss = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => userOwnerIdss.Contains(t.profileOwnerId) && t.profileType == Domain.Socioboard.Enum.SocialProfileType.YouTube);

            return(_lstchannelsss);
        }
示例#26
0
        public static void PostTwitterDirectmessage(string toId, string message, string profileId, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings, Helper.Cache _redisCache)
        {
            Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages _TwitterDirectMessages = new Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages();
            Domain.Socioboard.Models.TwitterAccount objTwitterAccount = Repositories.TwitterRepository.getTwitterAccount(profileId, _redisCache, dbr);
            oAuthTwitter OAuthTwt = new oAuthTwitter(_appSettings.twitterConsumerKey, _appSettings.twitterConsumerScreatKey, _appSettings.twitterRedirectionUrl);

            OAuthTwt.AccessToken       = objTwitterAccount.oAuthToken;
            OAuthTwt.AccessTokenSecret = objTwitterAccount.oAuthSecret;
            OAuthTwt.TwitterScreenName = objTwitterAccount.twitterScreenName;
            OAuthTwt.TwitterUserId     = objTwitterAccount.twitterUserId;
            const string format  = "ddd MMM dd HH:mm:ss zzzz yyyy";
            TwitterUser  twtuser = new TwitterUser();
            JArray       ret     = new JArray();

            try
            {
                ret = twtuser.PostDirect_Messages_New(OAuthTwt, message, toId);
                _TwitterDirectMessages.messageId           = ret[0]["id_str"].ToString();
                _TwitterDirectMessages.message             = ret[0]["text"].ToString();
                _TwitterDirectMessages.profileId           = objTwitterAccount.twitterUserId;
                _TwitterDirectMessages.createdDate         = DateTime.ParseExact(ret[0]["created_at"].ToString().TrimStart('"').TrimEnd('"'), format, System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy/MM/dd HH:mm:ss");
                _TwitterDirectMessages.timeStamp           = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.ParseExact(ret[0]["created_at"].ToString().TrimStart('"').TrimEnd('"'), format, System.Globalization.CultureInfo.InvariantCulture));
                _TwitterDirectMessages.entryDate           = DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm:ss");
                _TwitterDirectMessages.recipientId         = ret[0]["recipient"]["id_str"].ToString();
                _TwitterDirectMessages.recipientProfileUrl = ret[0]["recipient"]["profile_image_url_https"].ToString();
                _TwitterDirectMessages.recipientScreenName = ret[0]["recipient"]["screen_name"].ToString();
                _TwitterDirectMessages.senderId            = ret[0]["sender"]["id_str"].ToString();
                _TwitterDirectMessages.senderProfileUrl    = ret[0]["sender"]["profile_image_url_https"].ToString();
                _TwitterDirectMessages.senderScreenName    = ret[0]["sender"]["screen_name"].ToString();
                _TwitterDirectMessages.type = Domain.Socioboard.Enum.TwitterMessageType.TwitterDirectMessageSent;
                MongoRepository mongorepo = new MongoRepository("MongoTwitterDirectMessages", _appSettings);
                mongorepo.Add <Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages>(_TwitterDirectMessages);
            }
            catch (Exception ex)
            {
            }
        }
        public static Domain.Socioboard.Models.YoutubeGroupInvite InviteGroupMember(Int64 userId, string emailId, Helper.AppSettings settings, ILogger _logger, Model.DatabaseRepository dbr)
        {
            YoutubeGroupInvite _objGrp = new YoutubeGroupInvite();

            IList <Domain.Socioboard.Models.User> lstUser = dbr.Find <Domain.Socioboard.Models.User>(t => t.Id == userId || t.EmailId == emailId);

            Domain.Socioboard.Models.User _SBUser       = lstUser.FirstOrDefault(t => t.Id == userId);
            Domain.Socioboard.Models.User _SBUserInvite = lstUser.FirstOrDefault(t => t.EmailId == emailId);

            IList <Domain.Socioboard.Models.YoutubeGroupInvite> lstGrpUser = dbr.Find <Domain.Socioboard.Models.YoutubeGroupInvite>(t => t.AccessSBUserId == userId);

            Domain.Socioboard.Models.YoutubeGroupInvite _grpOwner  = lstGrpUser.FirstOrDefault(t => t.UserId == userId);
            Domain.Socioboard.Models.YoutubeGroupInvite _grpInvMem = lstGrpUser.FirstOrDefault(t => t.SBEmailId == emailId);

            if (_grpOwner == null)
            {
                _objGrp.UserId       = _SBUser.Id;
                _objGrp.Owner        = true;
                _objGrp.OwnerName    = _SBUser.FirstName + " " + _SBUser.LastName;
                _objGrp.Active       = true;
                _objGrp.SBUserName   = _SBUser.FirstName + " " + _SBUser.LastName;
                _objGrp.SBEmailId    = _SBUser.EmailId;
                _objGrp.OwnerEmailid = _SBUser.EmailId;
                if (_SBUser.ProfilePicUrl == null || _SBUser.ProfilePicUrl == "")
                {
                    _objGrp.SBProfilePic = "https://i.imgur.com/zqN47Qp.png";
                }
                else
                {
                    _objGrp.SBProfilePic = _SBUser.ProfilePicUrl;
                }
                _objGrp.AccessSBUserId = userId;
                dbr.Add(_objGrp);
            }

            if (_SBUserInvite != null && _grpInvMem == null)
            {
                _objGrp.UserId       = _SBUserInvite.Id;
                _objGrp.Owner        = false;
                _objGrp.OwnerName    = _SBUser.FirstName + " " + _SBUser.LastName;
                _objGrp.OwnerEmailid = _SBUser.EmailId;
                _objGrp.Active       = false;
                _objGrp.SBUserName   = _SBUserInvite.FirstName + " " + _SBUserInvite.LastName;
                _objGrp.SBEmailId    = _SBUserInvite.EmailId;
                if (_SBUserInvite.ProfilePicUrl == null || _SBUserInvite.ProfilePicUrl == "")
                {
                    _objGrp.SBProfilePic = "https://i.imgur.com/zqN47Qp.png";
                }
                else
                {
                    _objGrp.SBProfilePic = _SBUserInvite.ProfilePicUrl;
                }
                _objGrp.AccessSBUserId       = userId;
                _objGrp.EmailValidationToken = SBHelper.RandomString(35);
                dbr.Add(_objGrp);
                return(_objGrp);
            }
            else if (_SBUserInvite == null && _grpInvMem == null)
            {
                _objGrp.UserId               = 0;
                _objGrp.Owner                = false;
                _objGrp.OwnerName            = _SBUser.FirstName + " " + _SBUser.LastName;
                _objGrp.OwnerEmailid         = _SBUser.EmailId;
                _objGrp.Active               = false;
                _objGrp.SBUserName           = "******";
                _objGrp.SBEmailId            = emailId;
                _objGrp.SBProfilePic         = "https://i.imgur.com/zqN47Qp.png";
                _objGrp.EmailValidationToken = SBHelper.RandomString(35);
                _objGrp.AccessSBUserId       = userId;
                dbr.Add(_objGrp);
                return(_objGrp);
            }

            else if (_grpInvMem.Active == false)
            {
                return(_grpInvMem);
            }
            else
            {
                return(null);
            }
        }
        public void ShceduleConetentStudioFeeds(object o)
        {
            MongoRepository mongorepo      = new Helper.MongoRepository("ContentFeedsShareathon");
            MongoRepository mongorepoconid = new MongoRepository("ContentStudioShareathonIdData");
            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);
                                        double datetotimestamp = SBHelper.ConvertToUnixTimestamp(dt);

                                        DateTime dateval = obj.latsSharetime;// change on 07/02/2018

                                        // if ((obj.Status == false && SBHelper.ConvertToUnixTimestamp(dt) <= SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow))) // comment on 07/02/2018

                                        if ((obj.Status == false && dateval <= DateTime.UtcNow))
                                        {
                                            string ret = Helper.FBPostContentFeeds.FacebookComposeMessageRss(obj.title, facebookPage.AccessToken, facebookPage.FbUserId, "", obj.postUrl, obj.postId);
                                            if (ret == "Messages Posted Successfully")
                                            {
                                                obj.lastsharestamp = datetotimestamp;
                                                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);

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

                                                FilterDefinition <BsonDocument> filterIds = new BsonDocument("strId", obj.strId);
                                                var updatetime = Builders <BsonDocument> .Update.Set("lastsharestamp", obj.lastsharestamp);

                                                mongorepoconid.Update <Domain.Socioboard.Models.Mongo.ContentStudioShareathonIdData>(updatetime, filterIds);



                                                //var updateshareid = Builders<Domain.Socioboard.Models.Mongo.ContentStudioShareathonIdData>.Update.Set(t => t.Status,true);
                                                //reppoFacebookPagePost.Update<Domain.Socioboard.Models.Mongo.FacebookPagePost>(update, t => t.PostId == _FacebookPagePost.PostId);


                                                Thread.Sleep(60 * 1000);
                                            }

                                            //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 string ComposeLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Models.LinkedInAccount _objLinkedInAccount, Model.DatabaseRepository dbr, Domain.Socioboard.Models.ScheduledMessage schmessage, Domain.Socioboard.Models.User _user)
        {
            string json = "";
            var    img  = "";

            Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = _objLinkedInAccount;
            oAuthLinkedIn _oauth = new oAuthLinkedIn();

            _oauth.ConsumerKey    = AppSettings.LinkedinConsumerKey;
            _oauth.ConsumerSecret = AppSettings.LinkedinConsumerSecret;
            _oauth.Token          = _LinkedInAccount.OAuthToken;
            string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json";

            //try
            //{
            //    var client = new ImgurClient(AppSettings.imgurClientId, AppSettings.imgurClientSecret);
            //    var endpoint = new ImageEndpoint(client);
            //    IImage image;
            //    using (var fs = new FileStream(ImageUrl, FileMode.Open))
            //    {
            //        image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult();
            //    }
            //    img = image.Link;
            //}
            //catch (Exception)
            //{
            //    img = ImageUrl;
            //}

            if (string.IsNullOrEmpty(ImageUrl))
            {
                json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment);
            }
            else
            {
                //var client = new ImgurClient("5f1ad42ec5988b7", "f3294c8632ef8de6bfcbc46b37a23d18479159c5");
                //var endpoint = new ImageEndpoint(client);
                //IImage image;
                //using (var fs = new FileStream(imagepath, FileMode.Open))
                //{
                //    image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult();
                //}

                //var imgs = image.Link;
                json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, ImageUrl);
            }

            if (!string.IsNullOrEmpty(json))
            {
                apiHitsCount++;
                schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                //schmessage.url = json;
                dbr.Update <ScheduledMessage>(schmessage);
                Domain.Socioboard.Models.Notifications notify = new Notifications();
                Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id);
                if (lstnotifications == null)
                {
                    notify.MsgId            = schmessage.id;
                    notify.MsgStatus        = "Scheduled";
                    notify.notificationtime = schmessage.localscheduletime;
                    notify.NotificationType = "Schedule Successfully";
                    notify.ReadOrUnread     = "Unread";
                    notify.UserId           = userid;
                    dbr.Add <Notifications>(notify);
                    if (_user.scheduleSuccessUpdates)
                    {
                        string sucResponse = SendMailbySendGrid(AppSettings.from_mail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                    return("posted");
                }
                else
                {
                    //if (_user.scheduleSuccessUpdates)
                    //{
                    //    string sucResponse = SendMailbySendGrid(AppSettings.from_mail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    //}
                    return("posted");
                }
            }
            else
            {
                apiHitsCount = MaxapiHitsCount;
                json         = "Message not posted";
                Domain.Socioboard.Models.Notifications notify = new Notifications();
                Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id);
                if (lstnotifications == null)
                {
                    notify.MsgId            = schmessage.id;
                    notify.MsgStatus        = "Failed";
                    notify.notificationtime = schmessage.localscheduletime;
                    notify.NotificationType = "Schedule Failed";
                    notify.ReadOrUnread     = "Unread";
                    notify.UserId           = userid;
                    dbr.Add <Notifications>(notify);
                    if (_user.scheduleFailureUpdates)
                    {
                        string falResponse = SendMailbySendGrid(AppSettings.from_mail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                    return(json);
                }
                else
                {
                    //if (_user.scheduleFailureUpdates)
                    //{
                    //    string falResponse = SendMailbySendGrid(AppSettings.from_mail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    //}
                    return(json);
                }
            }
        }
示例#30
0
        public static string saveContentDataIdReposi(List <Domain.Socioboard.Models.Mongo.ContentFeedsShareathon> shareathon, long userId, string fbPageId, int timeInterval, Helper.Cache _redisCache, Helper.AppSettings settings, Model.DatabaseRepository dbr)
        {
            string[] lstProfileIds = null;
            if (fbPageId != null)
            {
                lstProfileIds = fbPageId.Split(',');
                fbPageId      = lstProfileIds[0];
            }

            MongoRepository mongorepo        = new MongoRepository("ContentFeedsShareathon", settings);
            MongoRepository mongoreposhareId = new MongoRepository("ContentStudioShareathonIdData", settings);



            int totalval = 0;

            // DateTime timeval = DateTime.Now;
            foreach (var fbid in lstProfileIds)
            {
                Domain.Socioboard.Models.Facebookaccounts listfb = dbr.FindSingle <Domain.Socioboard.Models.Facebookaccounts>(t => t.FbUserId == fbid);
                int    countval     = 0;
                int    countitem    = 0;
                string timevalue    = null;
                string sectimevalue = null;
                foreach (var item in shareathon)
                {
                    var retval  = mongoreposhareId.Find <Domain.Socioboard.Models.Mongo.ContentStudioShareathonIdData>(t => t.FbPageId.Contains(fbid) && t.postId == item.postId);
                    var taskval = Task.Run(async() =>
                    {
                        return(await retval);
                    });
                    int countvalue = taskval.Result.Count;
                    if (countvalue < 1)
                    {
                        Domain.Socioboard.Models.Mongo.ContentStudioShareathonIdData lstIdforPost = new Domain.Socioboard.Models.Mongo.ContentStudioShareathonIdData();
                        lstIdforPost.Id                  = ObjectId.GenerateNewId();
                        lstIdforPost.strId               = ObjectId.GenerateNewId().ToString();
                        lstIdforPost.FbPageId            = fbid;
                        lstIdforPost.Status              = false;
                        lstIdforPost.UserId              = listfb.UserId;
                        lstIdforPost.Timeintervalminutes = timeInterval;
                        lstIdforPost.postId              = item.postId;
                        lstIdforPost.lastsharestamp      = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                        if (countitem == 0)
                        {
                            lstIdforPost.latsSharetime = DateTime.UtcNow;
                        }
                        else
                        {
                            // a.AddMinutes
                            DateTime secval = Convert.ToDateTime(timevalue);
                            lstIdforPost.latsSharetime = secval.AddMinutes(timeInterval);//timevalue.latsSharetime.AddMinutes(timeInterval);
                            // var result = TimeSpan.FromMinutes(timeInterval);
                            //  lstIdforPost.lastsharestamp = lstIdforPost.lastsharestamp + datetotimestamp;
                        }


                        try
                        {
                            mongoreposhareId.Add(lstIdforPost);
                        }
                        catch (Exception ex)
                        {
                            //return "not added";
                        }
                        DateTime timeval = lstIdforPost.latsSharetime;
                        timevalue = timeval.ToString();
                    }
                    int count = 0;
                    try
                    {
                        var ret  = mongorepo.Find <Domain.Socioboard.Models.Mongo.ContentFeedsShareathon>(t => t.postId.Contains(item.postId) && t.FbPageId.Contains(fbid));
                        var task = Task.Run(async() =>
                        {
                            return(await ret);
                        });
                        count = task.Result.Count;
                    }
                    catch
                    {
                        var ret  = mongorepo.Find <Domain.Socioboard.Models.Mongo.ContentFeedsShareathon>(t => t.strId.Contains(item.strId) && t.FbPageId.Contains(fbid));
                        var task = Task.Run(async() =>
                        {
                            return(await ret);
                        });
                        count = task.Result.Count;
                    }


                    if (count < 1)
                    {
                        Domain.Socioboard.Models.Mongo.ContentFeedsShareathon lstforShareathon = new Domain.Socioboard.Models.Mongo.ContentFeedsShareathon();

                        lstforShareathon.Id                  = ObjectId.GenerateNewId();
                        lstforShareathon.strId               = ObjectId.GenerateNewId().ToString();
                        lstforShareathon.FbPageId            = fbid;
                        lstforShareathon.postId              = item.postId;
                        lstforShareathon.networkType         = item.networkType;
                        lstforShareathon.title               = item.title;
                        lstforShareathon.facebookAccount     = listfb.FbUserName;
                        lstforShareathon.ImageUrl            = item.ImageUrl;
                        lstforShareathon.postUrl             = item.postUrl;
                        lstforShareathon.videourl            = item.videourl;
                        lstforShareathon.UserId              = userId;
                        lstforShareathon.Timeintervalminutes = timeInterval;
                        lstforShareathon.lastsharestamp      = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);

                        lstforShareathon.Status = false;
                        if (countitem == 0)
                        {
                            lstforShareathon.latsSharetime = DateTime.UtcNow;
                        }
                        else
                        {
                            // a.AddMinutes
                            DateTime sectableaddtime = Convert.ToDateTime(sectimevalue);
                            lstforShareathon.latsSharetime = sectableaddtime.AddMinutes(timeInterval);
                        }
                        try
                        {
                            mongorepo.Add(lstforShareathon);
                            countval++;
                        }
                        catch (Exception ex)
                        {
                            //return "not added";
                        }

                        DateTime timevalsec = lstforShareathon.latsSharetime;
                        sectimevalue = timevalsec.ToString();
                    }
                    else
                    {
                        // return "some problem while adding";
                    }
                    countitem++;
                    totalval = countval;
                }
            }


            if (totalval > 0)
            {
                return("added successfully");
            }
            else
            {
                return("feed has already added");
            }
        }