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");
        }
예제 #2
0
        public static void PostTwitterDirectmessage(string toId, string message, string profileId, long UserId, 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);
            Domain.Socioboard.Models.TwitterAccount objTwitterAccount = new TwitterAccount();
            objTwitterAccount = dbr.Single <TwitterAccount>(t => t.userId == UserId && t.twitterUserId.Contains(profileId));
            if (objTwitterAccount == null)
            {
                objTwitterAccount = dbr.Single <TwitterAccount>(t => t.userId == UserId && t.twitterUserId.Contains(toId));
                toId = profileId;
            }
            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)
            {
            }
        }
예제 #3
0
        private static void TwitterSchedulemessage(object o)
        {
            try
            {
                Console.WriteLine(Thread.CurrentThread.Name + " Is Entered in Method");
                object[] arr = o as object[];
                Model.DatabaseRepository dbr = (Model.DatabaseRepository)arr[0];
                IGrouping <string, Domain.Socioboard.Models.ScheduledMessage> items = (IGrouping <string, Domain.Socioboard.Models.ScheduledMessage>)arr[1];

                Domain.Socioboard.Models.TwitterAccount _TwitterAccount = dbr.Single <Domain.Socioboard.Models.TwitterAccount>(t => t.twitterUserId == items.Key && t.isActive);

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

                if (_TwitterAccount != null)
                {
                    foreach (var item in items)
                    {
                        try
                        {
                            Console.WriteLine(item.socialprofileName + "Scheduling Started");
                            TwitterScheduler.PostTwitterMessage(item, _TwitterAccount, _user);
                            Console.WriteLine(item.socialprofileName + "Scheduling");
                        }
                        catch (Exception)
                        {
                            Thread.Sleep(60000);
                        }
                    }
                    _TwitterAccount.SchedulerUpdate = DateTime.UtcNow;
                    dbr.Update <Domain.Socioboard.Models.TwitterAccount>(_TwitterAccount);
                }
            }
            catch (Exception)
            {
                Thread.Sleep(60000);
            }
            finally
            {
                noOfthreadRunning--;
                objSemaphore.Release();
                Console.WriteLine(Thread.CurrentThread.Name + " Is Released");
            }
        }
 public static Domain.Socioboard.Models.Package GetPackage(string packagename, Model.DatabaseRepository dbr)
 {
     try
     {
         Domain.Socioboard.Models.Package _package = dbr.Single <Domain.Socioboard.Models.Package>(t => t.packagename.Equals(packagename));
         return(_package);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
예제 #5
0
 //Delete youtube group member
 public static void DeleteMember(Int64 id, Helper.AppSettings settings, ILogger _logger, Model.DatabaseRepository dbr)
 {
     Domain.Socioboard.Models.YoutubeGroupInvite memberObj = dbr.Single <Domain.Socioboard.Models.YoutubeGroupInvite>(t => t.Id == id);
     new Thread(delegate()
     {
         deleteTnRParentComment(memberObj.AccessSBUserId, memberObj.UserId, settings);
     }).Start();
     new Thread(delegate()
     {
         deleteTnRChildComment(memberObj.AccessSBUserId, memberObj.UserId, settings);
     }).Start();
     dbr.Delete(memberObj);
 }
예제 #6
0
        public IActionResult GetUserData(string emailId)
        {
            DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv);
            User user = dbr.Single <User>(t => t.EmailId == emailId);

            if (user != null)
            {
                return(Ok(user));
            }
            else
            {
                return(NotFound());
            }
        }
예제 #7
0
        public IActionResult UpdateFreeUser(string userId)
        {
            Model.DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv);
            User _user = dbr.Single <User>(t => t.Id == Convert.ToInt64(userId));

            if (_user != null)
            {
                _user.PaymentStatus = Domain.Socioboard.Enum.SBPaymentStatus.Paid;
                _user.ExpiryDate    = DateTime.UtcNow.AddDays(30);
                _user.Id            = Convert.ToInt64(userId);
                dbr.Update <User>(_user);
            }
            return(Ok(_user));
        }
예제 #8
0
        private static void daywiseSchedulemessages(object o)
        {
            try
            {
                Console.WriteLine(Thread.CurrentThread.Name + " Is Entered in Method");
                object[] arr = o as object[];
                Model.DatabaseRepository dbr = (Model.DatabaseRepository)arr[0];
                IGrouping <string, Domain.Socioboard.Models.DaywiseSchedule> items = (IGrouping <string, Domain.Socioboard.Models.DaywiseSchedule>)arr[1];
                Domain.Socioboard.Models.Facebookaccounts _facebook = dbr.Find <Domain.Socioboard.Models.Facebookaccounts>(t => t.FbUserId == items.Key && t.IsActive).FirstOrDefault();
                Domain.Socioboard.Models.User             _user     = dbr.Single <Domain.Socioboard.Models.User>(t => t.Id == _facebook.UserId);
                if (_facebook != null)
                {
                    foreach (var item in items)
                    {
                        try
                        {
                            Console.WriteLine(item.socialprofileName + "Scheduling Started");
                            FacebookScheduler.PostDaywiseFacebookMessage(item, _facebook, _user);
                            Console.WriteLine(item.socialprofileName + "Scheduling");
                        }
                        catch (Exception)
                        {
                        }

                        item.scheduleTime = DateTime.UtcNow;
                        dbr.Update <Domain.Socioboard.Models.DaywiseSchedule>(item);
                    }
                    //_facebook.SchedulerUpdate = DateTime.UtcNow;

                    //dbr.Update<Domain.Socioboard.Models.Facebookaccounts>(_facebook);
                }
            }
            catch (Exception ex)
            {
                //  Thread.Sleep(60000);
            }
            finally
            {
                noOfthreadRunning--;
                objSemaphore.Release();
                Console.WriteLine(Thread.CurrentThread.Name + " Is Released");
            }
        }
예제 #9
0
        public static List <Domain.Socioboard.Models.TwitterContactSearch> twitterConstactSearchlist(string profileId, string contact, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings)
        {
            string profileids = profileId;
            List <Domain.Socioboard.Models.TwitterContactSearch> lstContact = new List <Domain.Socioboard.Models.TwitterContactSearch>();

            Domain.Socioboard.Models.TwitterAccount itemTwt = dbr.Single <Domain.Socioboard.Models.TwitterAccount>(t => profileids.Contains(t.twitterUserId));
            oAuthTwitter oaut    = null;
            Users        twtUser = new Users();

            oaut                   = new oAuthTwitter();
            oaut.AccessToken       = itemTwt.oAuthToken;
            oaut.AccessTokenSecret = itemTwt.oAuthSecret;
            oaut.TwitterScreenName = itemTwt.twitterScreenName;
            oaut.TwitterUserId     = itemTwt.twitterUserId;
            oaut.ConsumerKey       = _appSettings.twitterConsumerKey;
            oaut.ConsumerKeySecret = _appSettings.twitterConsumerScreatKey;
            JArray jarresponse = twtUser.Get_Users_Search(oaut, contact, "20");
            JArray user_data   = JArray.Parse(jarresponse[0]["ids"].ToString());

            foreach (var items in user_data)
            {
                string userid      = items.ToString();
                JArray userprofile = twtUser.Get_Users_LookUp(oaut, userid);
                foreach (var item in userprofile)
                {
                    Domain.Socioboard.Models.TwitterContactSearch objTwitterContact = new Domain.Socioboard.Models.TwitterContactSearch();
                    objTwitterContact.screen_name       = item["screen_name"].ToString();
                    objTwitterContact.name              = item["name"].ToString();
                    objTwitterContact.description       = item["description"].ToString();
                    objTwitterContact.followers         = item["followers_count"].ToString();
                    objTwitterContact.following         = item["friends_count"].ToString();
                    objTwitterContact.location          = item["location"].ToString();
                    objTwitterContact.profile_image_url = item["profile_image_url"].ToString();
                    lstContact.Add(objTwitterContact);
                }
            }

            return(lstContact);
        }
예제 #10
0
        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");
            }
        }
예제 #11
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 string ComposeLinkedInCompanyPagePost(string ImageUrl, long userid, string comment, string LinkedinPageId, Model.DatabaseRepository dbr, Domain.Socioboard.Models.LinkedinCompanyPage objLinkedinCompanyPage, Domain.Socioboard.Models.ScheduledMessage schmessage, Domain.Socioboard.Models.User _user)
        {
            string json = "";

            Domain.Socioboard.Models.LinkedinCompanyPage objlicompanypage = objLinkedinCompanyPage;
            oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();

            Linkedin_oauth.ConsumerKey    = AppSettings.LinkedinApiKey;
            Linkedin_oauth.ConsumerSecret = AppSettings.LinkedinSecretKey;
            Linkedin_oauth.Verifier       = objlicompanypage.OAuthVerifier;
            Linkedin_oauth.TokenSecret    = objlicompanypage.OAuthSecret;
            Linkedin_oauth.Token          = objlicompanypage.OAuthToken;
            Linkedin_oauth.Id             = objlicompanypage.LinkedinPageId;
            Linkedin_oauth.FirstName      = objlicompanypage.LinkedinPageName;
            Company company = new Company();

            if (string.IsNullOrEmpty(ImageUrl))
            {
                json = company.SetPostOnPage(Linkedin_oauth, objlicompanypage.LinkedinPageId, comment);
            }
            else
            {
                var    client   = new ImgurClient(AppSettings.imgurclietId, AppSettings.imgurclietSecret);
                var    endpoint = new ImageEndpoint(client);
                IImage image;
                using (var fs = new FileStream(ImageUrl, FileMode.Open))
                {
                    image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult();
                }

                var imgs = image.Link;
                json = company.SetPostOnPageWithImage(Linkedin_oauth, objlicompanypage.LinkedinPageId, imgs, comment);
            }
            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.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                    return("posted");
                }
                else
                {
                    if (_user.scheduleSuccessUpdates)
                    {
                        string sucResponse = SendMailbySendGrid(AppSettings.frommail, "", _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.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                    return(json);
                }
                else
                {
                    if (_user.scheduleFailureUpdates)
                    {
                        string falResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                    return(json);
                }
            }
        }
        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)))
                                            {
                                                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", 1);

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

                    catch
                    {
                        groupapiHitsCount = groupMaxapiHitsCount;
                    }
                }
            }
            catch (Exception e)
            {
                groupapiHitsCount = groupMaxapiHitsCount;
            }
            finally
            {
                noOfthread_groupshreathonRunning--;
            }
        }
        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(',');
                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)))
                                                {
                                                    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", 1);

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

                    catch
                    {
                        pageapiHitsCount = pageMaxapiHitsCount;
                    }
                }
            }
            catch (Exception e)
            {
                pageapiHitsCount = pageMaxapiHitsCount;
            }
            finally
            {
                noOfthread_pageshreathonRunning--;
            }
        }
예제 #15
0
        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.LinkedinApiKey;
            _oauth.ConsumerSecret = AppSettings.LinkedinSecretKey;
            _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
            {
                var    client   = new ImgurClient(AppSettings.imgurclietId, AppSettings.imgurclietSecret);
                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, imgs);
            }

            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.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                    return("posted");
                }
                else
                {
                    if (_user.scheduleSuccessUpdates)
                    {
                        string sucResponse = SendMailbySendGrid(AppSettings.frommail, "", _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.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                    return(json);
                }
                else
                {
                    if (_user.scheduleFailureUpdates)
                    {
                        string falResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                    return(json);
                }
            }
        }
예제 #16
0
        public IActionResult UpgradeAccount(string userId, string amount, string UserName, string email, Domain.Socioboard.Enum.PaymentType PaymentType, string trasactionId, string paymentId, Domain.Socioboard.Enum.SBAccountType accType, DateTime subscr_date, string payer_email, string Payername, string payment_status, string item_name, string media)
        {
            Model.DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv);
            try
            {
                string path = _appEnv.WebRootPath + "\\views\\mailtemplates\\invoice.html";
                string html = System.IO.File.ReadAllText(path);
                html = html.Replace("[paymentId]", paymentId);
                html = html.Replace("[subscr_date]", subscr_date.ToString());
                html = html.Replace("[payer_email]", payer_email);
                html = html.Replace("[Payername]", Payername);
                html = html.Replace("[payment_status]", payment_status);
                html = html.Replace("[item_name]", item_name);
                html = html.Replace("[amount]", amount + "$");
                html = html.Replace("[media]", media);
                _emailSender.SendMailSendGrid(_appSettings.frommail, "", payer_email, "", "", "Socioboard Payment Invoice", html, _appSettings.SendgridUserName, _appSettings.SendGridPassword);
            }
            catch (Exception)
            {
            }
            try
            {
                User inMemUser = _redisCache.Get <User>(UserName);

                if (inMemUser != null)
                {
                    inMemUser.PaymentStatus       = Domain.Socioboard.Enum.SBPaymentStatus.Paid;
                    inMemUser.PayPalAccountStatus = Domain.Socioboard.Enum.PayPalAccountStatus.added;
                    inMemUser.ExpiryDate          = DateTime.UtcNow.AddDays(30);
                    inMemUser.Id          = Convert.ToInt64(userId);
                    inMemUser.TrailStatus = Domain.Socioboard.Enum.UserTrailStatus.active;
                    if (accType == Domain.Socioboard.Enum.SBAccountType.Free)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Free;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Deluxe)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Deluxe;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Premium)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Premium;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Topaz)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Topaz;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Platinum)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Platinum;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Gold)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Gold;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Ruby)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Ruby;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Standard)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Standard;
                    }
                    dbr.Update <User>(inMemUser);
                }
                else
                {
                    User _user = dbr.Single <User>(t => t.Id == Convert.ToInt64(userId));
                    if (_user != null)
                    {
                        _user.PaymentStatus       = Domain.Socioboard.Enum.SBPaymentStatus.Paid;
                        _user.PayPalAccountStatus = Domain.Socioboard.Enum.PayPalAccountStatus.added;
                        _user.ExpiryDate          = DateTime.UtcNow.AddDays(30);
                        _user.Id          = Convert.ToInt64(userId);
                        _user.TrailStatus = Domain.Socioboard.Enum.UserTrailStatus.active;
                        if (accType == Domain.Socioboard.Enum.SBAccountType.Free)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Free;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Deluxe)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Deluxe;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Premium)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Premium;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Topaz)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Topaz;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Platinum)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Platinum;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Gold)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Gold;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Ruby)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Ruby;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Standard)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Standard;
                        }
                        dbr.Update <User>(_user);
                    }
                }
                int isaved = Repositories.PaymentTransactionRepository.AddPaymentTransaction(Convert.ToInt64(userId), amount, email, PaymentType, paymentId, trasactionId, subscr_date, payer_email, Payername, payment_status, item_name, media, dbr);
                if (isaved == 1)
                {
                    return(Ok("payment done"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation(ex.Message);
                _logger.LogError(ex.StackTrace);
            }
            return(Ok());
        }
        public IActionResult UpgradeAccount(string userId, string amount, string UserName, string email, Domain.Socioboard.Enum.PaymentType PaymentType, string trasactionId, string paymentId, Domain.Socioboard.Enum.SBAccountType accType)
        {
            Model.DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv);
            try
            {
                User inMemUser = _redisCache.Get <User>(UserName);

                if (inMemUser != null)
                {
                    inMemUser.PaymentStatus       = Domain.Socioboard.Enum.SBPaymentStatus.Paid;
                    inMemUser.PayPalAccountStatus = Domain.Socioboard.Enum.PayPalAccountStatus.added;
                    inMemUser.ExpiryDate          = DateTime.UtcNow.AddDays(30);
                    inMemUser.Id          = Convert.ToInt64(userId);
                    inMemUser.TrailStatus = Domain.Socioboard.Enum.UserTrailStatus.active;
                    if (accType == Domain.Socioboard.Enum.SBAccountType.Free)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Free;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Deluxe)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Deluxe;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Premium)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Premium;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Topaz)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Topaz;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Platinum)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Platinum;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Gold)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Gold;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Ruby)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Ruby;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Standard)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Standard;
                    }
                    dbr.Update <User>(inMemUser);
                }
                else
                {
                    User _user = dbr.Single <User>(t => t.Id == Convert.ToInt64(userId));
                    if (_user != null)
                    {
                        _user.PaymentStatus       = Domain.Socioboard.Enum.SBPaymentStatus.Paid;
                        _user.PayPalAccountStatus = Domain.Socioboard.Enum.PayPalAccountStatus.added;
                        _user.ExpiryDate          = DateTime.UtcNow.AddDays(30);
                        _user.Id          = Convert.ToInt64(userId);
                        _user.TrailStatus = Domain.Socioboard.Enum.UserTrailStatus.active;
                        if (accType == Domain.Socioboard.Enum.SBAccountType.Free)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Free;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Deluxe)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Deluxe;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Premium)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Premium;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Topaz)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Topaz;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Platinum)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Platinum;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Gold)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Gold;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Ruby)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Ruby;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Standard)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Standard;
                        }
                        dbr.Update <User>(_user);
                    }
                }
                int isaved = Repositories.PaymentTransactionRepository.AddPaymentTransaction(Convert.ToInt64(userId), amount, email, PaymentType, paymentId, trasactionId, dbr);
                if (isaved == 1)
                {
                    return(Ok("payment done"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation(ex.Message);
                _logger.LogError(ex.StackTrace);
            }
            return(Ok());
        }