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");
        }
Exemplo n.º 2
0
        public static List <Domain.Socioboard.Models.ScheduledMessage> DeleteSocialMessages(long socioqueueId, long userId, long GroupId, Helper.Cache _redisCache, Helper.AppSettings _appSeetings, Model.DatabaseRepository dbr)
        {
            string[] profileids = null;
            Domain.Socioboard.Models.ScheduledMessage ScheduledMessage = dbr.Find <Domain.Socioboard.Models.ScheduledMessage>(t => t.id == socioqueueId).FirstOrDefault();
            ScheduledMessage.status = Domain.Socioboard.Enum.ScheduleStatus.Deleted;
            dbr.Update <Domain.Socioboard.Models.ScheduledMessage>(ScheduledMessage);
            List <Domain.Socioboard.Models.Groupprofiles> iMmemGroupprofiles = _redisCache.Get <List <Domain.Socioboard.Models.Groupprofiles> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + GroupId);
            List <Domain.Socioboard.Models.Groupprofiles> lstGroupprofiles   = new List <Groupprofiles>();

            if (iMmemGroupprofiles != null && iMmemGroupprofiles.Count > 0)
            {
                lstGroupprofiles = iMmemGroupprofiles;
            }
            else
            {
                lstGroupprofiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == GroupId).ToList();
                _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + GroupId, lstGroupprofiles);
            }
            profileids = lstGroupprofiles.Select(t => t.profileId).ToArray();
            List <Domain.Socioboard.Models.ScheduledMessage> lstScheduledMessage = dbr.Find <Domain.Socioboard.Models.ScheduledMessage>(t => profileids.Contains(t.profileId) && t.status == 0).ToList();

            if (lstScheduledMessage != null && lstScheduledMessage.Count > 0)
            {
                _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheScheduleMessage + GroupId, lstScheduledMessage);
                return(lstScheduledMessage);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
 public static void CreateFacebookPublicPageReport()
 {
     Helper.Cache cache = new Helper.Cache(Helper.AppSettings.RedisConfiguration);
     while (true)
     {
         try
         {
             Model.DatabaseRepository dbr = new Model.DatabaseRepository();
             List <Domain.Socioboard.Models.Facebookaccounts> lstFbacc = dbr.Find <Domain.Socioboard.Models.Facebookaccounts>(t => t.FbProfileType == Domain.Socioboard.Enum.FbProfileType.FacebookPublicPage && t.IsActive).ToList();
             foreach (var item in lstFbacc)
             {
                 if (item.lastpagereportgenerated.AddHours(24) <= DateTime.UtcNow)
                 {
                     CreateReport(item.FbUserId, item.Is90DayDataUpdated);
                     item.Is90DayDataUpdated      = true;
                     item.lastpagereportgenerated = DateTime.UtcNow;
                     dbr.Update <Domain.Socioboard.Models.Facebookaccounts>(item);
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine("issue in web api calling" + ex.StackTrace);
             Thread.Sleep(600000);
         }
     }
 }
 public IActionResult UpdateRecurringUser(string subscr_id, string txn_id)
 {
     try
     {
         Model.DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv);
         Domain.Socioboard.Models.PaymentTransaction _PaymentTransaction = dbr.FindSingle <Domain.Socioboard.Models.PaymentTransaction>(t => t.paymentId.Contains(subscr_id));
         Domain.Socioboard.Models.User _user = dbr.FindSingle <Domain.Socioboard.Models.User>(x => x.Id == _PaymentTransaction.userid);
         _user.ExpiryDate  = _user.ExpiryDate.AddDays(30);
         _user.TrailStatus = Domain.Socioboard.Enum.UserTrailStatus.active;
         dbr.Update <Domain.Socioboard.Models.User>(_user);
         _PaymentTransaction.trasactionId = txn_id;
         dbr.Update <Domain.Socioboard.Models.PaymentTransaction>(_PaymentTransaction);
     }
     catch (Exception ex)
     {
         _logger.LogError("UpdateRecurringUser======" + ex.StackTrace);
         _logger.LogError("UpdateRecurringUser=========" + ex.Message);
     }
     return(Ok());
 }
        public IActionResult UpdateRecurringUser(string subscr_id, string txn_id, DateTime subscr_date, string payer_email, string Payername, string payment_status, string item_name, string amount, string media)
        {
            try
            {
                string path = _appEnv.WebRootPath + "\\views\\mailtemplates\\invoice.html";
                string html = System.IO.File.ReadAllText(path);
                html = html.Replace("[paymentId]", txn_id);
                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);

                Model.DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv);
                Domain.Socioboard.Models.PaymentTransaction _PaymentTransaction = dbr.FindSingle <Domain.Socioboard.Models.PaymentTransaction>(t => t.paymentId.Contains(subscr_id));
                Domain.Socioboard.Models.User _user = dbr.FindSingle <Domain.Socioboard.Models.User>(x => x.Id == _PaymentTransaction.userid);
                _user.ExpiryDate  = _user.ExpiryDate.AddDays(30);
                _user.TrailStatus = Domain.Socioboard.Enum.UserTrailStatus.active;
                dbr.Update <Domain.Socioboard.Models.User>(_user);
                _PaymentTransaction.trasactionId  = txn_id;
                _PaymentTransaction.paymentdate   = DateTime.UtcNow;
                _PaymentTransaction.payeremail    = payer_email;
                _PaymentTransaction.Payername     = Payername;
                _PaymentTransaction.paymentstatus = payment_status;
                _PaymentTransaction.itemname      = item_name;
                _PaymentTransaction.media         = media;
                _PaymentTransaction.subscrdate    = subscr_date;
                _PaymentTransaction.amount        = amount;
                dbr.Update(_PaymentTransaction);
            }
            catch (Exception ex)
            {
                _logger.LogError("UpdateRecurringUser======" + ex.StackTrace);
                _logger.LogError("UpdateRecurringUser=========" + ex.Message);
            }
            return(Ok());
        }
Exemplo n.º 6
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));
        }
 public static string DeleteProfile(Model.DatabaseRepository dbr, string profileId, long userId, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
 {
     Domain.Socioboard.Models.Instagramaccounts fbAcc = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId.Equals(profileId) && t.UserId == userId && t.IsActive).FirstOrDefault();
     if (fbAcc != null)
     {
         fbAcc.IsActive = false;
         dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(fbAcc);
         _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheInstagramAccount + profileId);
         return("Deleted");
     }
     else
     {
         return("Account Not Exist");
     }
 }
Exemplo n.º 8
0
        public static List <Domain.Socioboard.Models.Draft> EditDraftMessage(long draftId, long userId, long GroupId, string message, Helper.Cache _redisCache, Helper.AppSettings _appSeetings, Model.DatabaseRepository dbr)
        {
            Domain.Socioboard.Models.Draft _draft = dbr.Find <Domain.Socioboard.Models.Draft>(t => t.id == draftId).FirstOrDefault();
            _draft.shareMessage = message;
            int isSaved = dbr.Update <Domain.Socioboard.Models.Draft>(_draft);
            List <Domain.Socioboard.Models.Draft> lstDraftMessage = dbr.Find <Domain.Socioboard.Models.Draft>(t => t.userId == userId && t.GroupId == GroupId).ToList();

            if (lstDraftMessage != null && lstDraftMessage.Count > 0)
            {
                _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheDraftMessage + userId, lstDraftMessage);
                return(lstDraftMessage);
            }
            else
            {
                return(null);
            }
        }
 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);
 }
Exemplo n.º 10
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");
            }
        }
Exemplo n.º 11
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");
            }
        }
        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)
        {
            string json = "";

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

            //Linkedin_oauth.ConsumerKey = "81k55eukagnqfa";
            //Linkedin_oauth.ConsumerSecret = "d9rqHEf7ewdSbsF1";
            Linkedin_oauth.ConsumerKey    = "754ysxdp72ulk5";
            Linkedin_oauth.ConsumerSecret = "vbU52SjK7xS6cT8H";
            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
            {
                json = company.SetPostOnPageWithImage(Linkedin_oauth, objlicompanypage.LinkedinPageId, ImageUrl, comment);
            }
            if (!string.IsNullOrEmpty(json))
            {
                apiHitsCount++;
                schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                schmessage.url    = json;
                dbr.Update <ScheduledMessage>(schmessage);

                return("posted");
            }
            else
            {
                apiHitsCount = MaxapiHitsCount;
                json         = "Message not posted";
                return(json);
            }
        }
Exemplo n.º 13
0
        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");
            }
        }
Exemplo n.º 14
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)
        {
            string json = "";

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

            //_oauth.ConsumerKey = "81k55eukagnqfa";
            //_oauth.ConsumerSecret = "d9rqHEf7ewdSbsF1";
            _oauth.ConsumerKey    = "754ysxdp72ulk5";
            _oauth.ConsumerSecret = "vbU52SjK7xS6cT8H";
            _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))
            {
                apiHitsCount++;
                schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                schmessage.url    = json;
                dbr.Update <ScheduledMessage>(schmessage);
                return("posted");
            }
            else
            {
                apiHitsCount = MaxapiHitsCount;
                json         = "Message not posted";
                return(json);
            }
        }
Exemplo n.º 15
0
        public static List <Domain.Socioboard.ViewModels.YoutubeProfiles> GetYoutubeAccount(string code, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr)
        {
            Domain.Socioboard.ViewModels.YoutubeProfiles        _YoutubeChannels;
            List <Domain.Socioboard.ViewModels.YoutubeProfiles> lstYoutubeProfiles = new List <Domain.Socioboard.ViewModels.YoutubeProfiles>();
            string   access_token  = string.Empty;
            string   refresh_token = string.Empty;
            Channels _Channels     = new Channels(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri);

            try
            {
                oAuthTokenYoutube objToken = new oAuthTokenYoutube(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri);


                string  accessToken = objToken.GetRefreshToken(code);
                JObject JData       = JObject.Parse(accessToken);


                try
                {
                    refresh_token = JData["refresh_token"].ToString();
                }
                catch (Exception ex)
                {
                    access_token = JData["access_token"].ToString();
                    objToken.RevokeToken(access_token);
                    return(null);
                }

                access_token = JData["access_token"].ToString();

                string  channelsdata = _Channels.Get_Channel_List(access_token, "snippet,contentDetails,statistics", 50, true);
                JObject JChanneldata = JObject.Parse(channelsdata);


                foreach (var item in JChanneldata["items"])
                {
                    try
                    {
                        string channelid    = item["id"].ToString();
                        string channelname  = item["snippet"]["title"].ToString();
                        string channelimage = item["snippet"]["thumbnails"]["default"]["url"].ToString();
                        channelimage = channelimage.Replace(".jpg", "");
                        string publishdate      = item["snippet"]["publishedAt"].ToString();
                        string viewscount       = item["statistics"]["viewCount"].ToString();
                        string commentscount    = item["statistics"]["commentCount"].ToString();
                        string subscriberscount = item["statistics"]["subscriberCount"].ToString();
                        string videoscount      = item["statistics"]["videoCount"].ToString();
                        string channeldescrip   = item["snippet"]["description"].ToString();

                        #region Update Access and refresh token after authentication for every time
                        try
                        {
                            List <Domain.Socioboard.Models.YoutubeChannel> lstYTChannel = dbr.Find <Domain.Socioboard.Models.YoutubeChannel>(t => t.YtubeChannelId.Equals(channelid)).ToList();
                            if (lstYTChannel != null && lstYTChannel.Count() > 0)
                            {
                                lstYTChannel.First().AccessToken  = access_token;
                                lstYTChannel.First().RefreshToken = refresh_token;
                                dbr.Update <Domain.Socioboard.Models.YoutubeChannel>(lstYTChannel.First());
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        #endregion


                        try
                        {
                            _YoutubeChannels                  = new Domain.Socioboard.ViewModels.YoutubeProfiles();
                            _YoutubeChannels.Accesstoken      = access_token;
                            _YoutubeChannels.Refreshtoken     = refresh_token;
                            _YoutubeChannels.YtChannelId      = channelid;
                            _YoutubeChannels.YtChannelName    = channelname;
                            _YoutubeChannels.YtChannelImage   = channelimage;
                            _YoutubeChannels.PublishDate      = publishdate;
                            _YoutubeChannels.viewscount       = viewscount;
                            _YoutubeChannels.commentscount    = commentscount;
                            _YoutubeChannels.subscriberscount = subscriberscount;
                            _YoutubeChannels.videoscount      = videoscount;
                            _YoutubeChannels.YtChannelDescrip = channeldescrip;
                            lstYoutubeProfiles.Add(_YoutubeChannels);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            catch
            {
            }
            return(lstYoutubeProfiles);
        }
        public static string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string code, long userId, long groupId, Model.DatabaseRepository dbr, ILogger _logger, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
        {
            string           ret      = string.Empty;
            oAuthInstagram   objInsta = new oAuthInstagram();
            ConfigurationIns configi  = new ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram   _api     = new oAuthInstagram();

            _api = oAuthInstagram.GetInstance(configi);
            AccessToken access = new AccessToken();

            access = _api.AuthGetAccessToken(code);
            UserController objusercontroller = new UserController();

            if (access != null)
            {
                Domain.Socioboard.Models.Instagramaccounts Instagramaccounts = new Domain.Socioboard.Models.Instagramaccounts();
                Domain.Socioboard.Models.Instagramaccounts objInstagramAccount;
                #region InstagramAccount
                InstagramResponse <User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token);

                objInstagramAccount             = new Domain.Socioboard.Models.Instagramaccounts();
                objInstagramAccount.AccessToken = access.access_token;
                objInstagramAccount.InstagramId = access.user.id;
                try
                {
                    objInstagramAccount.bio = access.user.bio;
                }
                catch {
                    objInstagramAccount.bio = "";
                }
                try
                {
                    objInstagramAccount.ProfileUrl = access.user.profile_picture;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.InsUserName = access.user.username;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.TotalImages = objuser.data.counts.media;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.FollowedBy = objuser.data.counts.followed_by;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.Followers = objuser.data.counts.follows;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                objInstagramAccount.UserId     = userId;
                objInstagramAccount.IsActive   = true;
                objInstagramAccount.lastUpdate = DateTime.UtcNow;
                if (objInstagramAccount.InstagramId != null)
                {
                    Instagramaccounts = Api.Socioboard.Repositories.InstagramRepository.getInstagramAccount(objInstagramAccount.InstagramId, _redisCache, dbr);
                    if (Instagramaccounts != null && Instagramaccounts.IsActive == true)
                    {
                        return("This Account is added by some body else.");
                    }
                }
                else
                {
                    return("Issue while fetching instagram userId");
                }

                if (Instagramaccounts == null)
                {
                    int isSaved = dbr.Add <Domain.Socioboard.Models.Instagramaccounts>(objInstagramAccount);
                    if (isSaved == 1)
                    {
                        List <Domain.Socioboard.Models.Instagramaccounts> lstinsAcc = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId.Equals(objInstagramAccount.InstagramId)).ToList();
                        if (lstinsAcc != null && lstinsAcc.Count() > 0)
                        {
                            isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstinsAcc.First().InstagramId, lstinsAcc.First().InsUserName, userId, lstinsAcc.First().ProfileUrl, Domain.Socioboard.Enum.SocialProfileType.Instagram, dbr);
                            if (isSaved == 1)
                            {
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);

                                GetInstagramSelfFeeds(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings);
                                GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _redisCache, dbr);
                                GetInstagramFollowing(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                GetInstagramFollower(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                new Thread(delegate()
                                {
                                    GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                    GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings);
                                }).Start();

                                return("Added_Successfully");
                            }
                        }
                    }
                }
                else
                {
                    objInstagramAccount.id = Instagramaccounts.id;
                    int isSaved = dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(objInstagramAccount);
                    if (isSaved == 1)
                    {
                        List <Domain.Socioboard.Models.Instagramaccounts> lstinsAcc = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId.Equals(objInstagramAccount.InstagramId)).ToList();
                        if (lstinsAcc != null && lstinsAcc.Count() > 0)
                        {
                            isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstinsAcc.First().InstagramId, lstinsAcc.First().InsUserName, userId, lstinsAcc.First().ProfileUrl, Domain.Socioboard.Enum.SocialProfileType.Instagram, dbr);
                            if (isSaved == 1)
                            {
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);


                                //todo : codes to update feeds
                                GetInstagramSelfFeeds(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings);
                                GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _redisCache, dbr);
                                GetInstagramFollowing(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                GetInstagramFollower(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                new Thread(delegate()
                                {
                                    GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                    GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings);
                                }).Start();



                                return("Added_Successfully");
                            }
                        }
                    }
                }
            }
            return("issue in access token fetching");

            #endregion
        }
        public static string GetInstagramUserDetails(string profile_id, string access_token, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            string code_status = "false";

            Domain.Socioboard.Models.Mongo.InstagramUserDetails insert = new Domain.Socioboard.Models.Mongo.InstagramUserDetails();
            JObject post_data = new JObject();
            string  url       = "https://api.instagram.com/v1/users/" + profile_id + "?access_token=" + access_token;

            try
            {
                post_data = JObject.Parse(ApiInstagramHttp(url));
            }
            catch (Exception)
            {
            }

            try
            {
                dynamic item = post_data["data"];

                try
                {
                    string   insta_name   = item["username"].ToString();
                    string   full_name    = item["full_name"].ToString();
                    string   imageUrl     = item["profile_picture"].ToString();
                    string   media_count  = item["counts"]["media"].ToString();
                    DateTime Created_Time = DateTime.Now;
                    string   follower     = item["counts"]["followed_by"].ToString();
                    string   following    = item["counts"]["follows"].ToString();
                    Domain.Socioboard.Models.Instagramaccounts Instagramaccounts = Api.Socioboard.Repositories.InstagramRepository.getInstagramAccount(profile_id, _redisCache, dbr);

                    if (Instagramaccounts != null && Instagramaccounts.IsActive == true)
                    {
                        Instagramaccounts.TotalImages = Convert.ToInt32(media_count);
                        Instagramaccounts.Followers   = Convert.ToInt32(follower);
                        Instagramaccounts.FollowedBy  = Convert.ToInt32(following);
                        Instagramaccounts.InsUserName = insta_name;
                        Instagramaccounts.ProfileUrl  = imageUrl;
                        Instagramaccounts.InstagramId = profile_id;
                        dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(Instagramaccounts);
                    }

                    DateTime t1 = DateTime.Now.Date;
                    DateTime t2 = DateTime.Now.Date.AddHours(12);
                    DateTime t3 = DateTime.Now.AddDays(1).Date.AddSeconds(-1);
                    if (DateTime.Now.TimeOfDay >= t1.TimeOfDay && DateTime.Now.TimeOfDay < t2.TimeOfDay)
                    {
                        if (Instagramaccounts != null && Instagramaccounts.IsActive == true)
                        {
                            Instagramaccounts.TotalImages = Convert.ToInt32(media_count);
                            Instagramaccounts.Followers   = Convert.ToInt32(follower);
                            Instagramaccounts.FollowedBy  = Convert.ToInt32(following);
                            Instagramaccounts.InsUserName = insta_name;
                            Instagramaccounts.ProfileUrl  = imageUrl;
                            Instagramaccounts.InstagramId = profile_id;
                            dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(Instagramaccounts);
                        }
                    }
                    if (DateTime.Now.TimeOfDay >= t2.TimeOfDay && DateTime.Now.TimeOfDay < t3.TimeOfDay)
                    {
                        if (Instagramaccounts != null && Instagramaccounts.IsActive == true)
                        {
                            Instagramaccounts.TotalImages = Convert.ToInt32(media_count);
                            Instagramaccounts.Followers   = Convert.ToInt32(follower);
                            Instagramaccounts.FollowedBy  = Convert.ToInt32(following);
                            Instagramaccounts.InsUserName = insta_name;
                            Instagramaccounts.ProfileUrl  = imageUrl;
                            Instagramaccounts.InstagramId = profile_id;
                            dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(Instagramaccounts);
                        }
                    }

                    code_status = "true";
                }
                catch (Exception ex)
                {
                }
            }
            catch (Exception ex)
            {
            }
            return(code_status);
        }
        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--;
            }
        }
        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--;
            }
        }
Exemplo n.º 20
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 PostBlueSnapSubscription(string XMLData, string emailId)
        {
            string responseFromServer = string.Empty;

            try
            {
                // Create a request using a URL that can receive a post.
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://sandbox.bluesnap.com/services/2/recurring/subscriptions");
                // Set the Method property of the request to POST.
                request.Method = "POST";
                request.Headers["Authorization"] = "Basic " + _appSettings.bluesnapBase64;
                request.UserAgent = ".NET Framework Test Client";
                string postData  = XMLData;
                byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                request.ContentType   = "application/xml";
                request.ContentLength = byteArray.Length;

                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

                Stream dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();

                // Get the response.

                HttpWebResponse myHttpWebResponse = (HttpWebResponse)request.GetResponse();
                Console.WriteLine((myHttpWebResponse.StatusDescription));
                dataStream = myHttpWebResponse.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                responseFromServer = reader.ReadToEnd();
                Console.WriteLine(responseFromServer);
                reader.Close();
                dataStream.Close();
                myHttpWebResponse.Close();
            }
            catch (WebException wex)
            {
                var pageContent = new StreamReader(wex.Response.GetResponseStream())
                                  .ReadToEnd();

                Console.WriteLine(wex.Message);
                return(BadRequest());
            }



            DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv);

            try
            {
                //JSON
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(responseFromServer);
                JObject jsonTextResponse = JObject.Parse(JsonConvert.SerializeXmlNode(doc));


                User userObj = dbr.FindSingle <User>(t => t.EmailId == emailId);

                PaymentTransaction objPaymentTransaction = new PaymentTransaction();
                objPaymentTransaction.amount       = jsonTextResponse["recurring-subscription"]["recurring-charge-amount"].ToString();
                objPaymentTransaction.userid       = userObj.Id;
                objPaymentTransaction.email        = userObj.EmailId;
                objPaymentTransaction.paymentdate  = DateTime.UtcNow;
                objPaymentTransaction.trasactionId = jsonTextResponse["recurring-subscription"]["subscription-id"].ToString();
                try
                {
                    objPaymentTransaction.paymentId = jsonTextResponse["recurring-subscription"]["charge"]["charge-id"].ToString();
                }
                catch
                {
                    objPaymentTransaction.paymentId = "NA";
                }
                objPaymentTransaction.PaymentType = Domain.Socioboard.Enum.PaymentType.bluesnap;
                try
                {
                    objPaymentTransaction.paymentstatus = jsonTextResponse["recurring-subscription"]["status"].ToString();
                }
                catch
                {
                    objPaymentTransaction.paymentstatus = "NA";
                }
                objPaymentTransaction.itemname  = "Socioboard" + userObj.AccountType.ToString();
                objPaymentTransaction.Payername = userObj.FirstName + " " + userObj.LastName;
                objPaymentTransaction.email     = userObj.EmailId;
                dbr.Add <PaymentTransaction>(objPaymentTransaction);

                userObj.ExpiryDate          = DateTime.Now.AddYears(1);
                userObj.PaymentStatus       = Domain.Socioboard.Enum.SBPaymentStatus.Paid;
                userObj.TrailStatus         = Domain.Socioboard.Enum.UserTrailStatus.active;
                userObj.PayPalAccountStatus = Domain.Socioboard.Enum.PayPalAccountStatus.added;
                userObj.PaymentType         = Domain.Socioboard.Enum.PaymentType.bluesnap;

                dbr.Update <User>(userObj);

                return(Ok());
            }
            catch
            {
                return(BadRequest());
            }
        }
Exemplo n.º 22
0
        public static int AddGplusAccount(JObject profile, Model.DatabaseRepository dbr, Int64 userId, Int64 groupId, string accessToken, string refreshToken, Helper.Cache _redisCache, Helper.AppSettings settings, ILogger _logger)
        {
            int isSaved = 0;

            Domain.Socioboard.Models.Googleplusaccounts gplusAcc = GplusRepository.getGPlusAccount(Convert.ToString(profile["id"]), _redisCache, dbr);
            oAuthTokenGPlus ObjoAuthTokenGPlus = new oAuthTokenGPlus(settings.GoogleConsumerKey, settings.GoogleConsumerSecret, settings.GoogleRedirectUri);

            if (gplusAcc != null && gplusAcc.IsActive == false)
            {
                gplusAcc.IsActive     = true;
                gplusAcc.UserId       = userId;
                gplusAcc.AccessToken  = accessToken;
                gplusAcc.RefreshToken = refreshToken;
                gplusAcc.EntryDate    = DateTime.UtcNow;
                try
                {
                    gplusAcc.GpUserName = profile["displayName"].ToString();
                }
                catch
                {
                    try
                    {
                        gplusAcc.GpUserName = profile["name"].ToString();
                    }
                    catch { }
                }
                try
                {
                    gplusAcc.GpProfileImage = Convert.ToString(profile["image"]["url"]);
                }
                catch
                {
                    try
                    {
                        gplusAcc.GpProfileImage = Convert.ToString(profile["picture"]);
                    }
                    catch { }
                }
                gplusAcc.AccessToken = accessToken;
                try
                {
                    gplusAcc.about = Convert.ToString(profile["tagline"]);
                }
                catch
                {
                    gplusAcc.about = "";
                }
                try
                {
                    gplusAcc.college = Convert.ToString(profile["organizations"][0]["name"]);
                }
                catch
                {
                    gplusAcc.college = "";
                }
                try
                {
                    gplusAcc.coverPic = Convert.ToString(profile["cover"]["coverPhoto"]["url"]);
                }
                catch
                {
                    gplusAcc.coverPic = "";
                }
                try
                {
                    gplusAcc.education = Convert.ToString(profile["organizations"][0]["type"]);
                }
                catch
                {
                    gplusAcc.education = "";
                }
                try
                {
                    gplusAcc.EmailId = Convert.ToString(profile["emails"][0]["value"]);
                }
                catch
                {
                    gplusAcc.EmailId = "";
                }
                try
                {
                    gplusAcc.gender = Convert.ToString(profile["gender"]);
                }
                catch
                {
                    gplusAcc.gender = "";
                }
                try
                {
                    gplusAcc.workPosition = Convert.ToString(profile["occupation"]);
                }
                catch
                {
                    gplusAcc.workPosition = "";
                }
                gplusAcc.LastUpdate = DateTime.UtcNow;
                #region Get_InYourCircles
                try
                {
                    string  _InyourCircles  = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleList.Replace("[userId]", gplusAcc.GpUserId).Replace("[collection]", "visible") + "?key=" + settings.GoogleApiKey, accessToken);
                    JObject J_InyourCircles = JObject.Parse(_InyourCircles);
                    gplusAcc.InYourCircles = Convert.ToInt32(J_InyourCircles["totalItems"].ToString());
                }
                catch (Exception ex)
                {
                    gplusAcc.InYourCircles = 0;
                }
                #endregion

                #region Get_HaveYouInCircles
                try
                {
                    string  _HaveYouInCircles  = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleProfile + gplusAcc.GpUserId + "?key=" + settings.GoogleApiKey, accessToken);
                    JObject J_HaveYouInCircles = JObject.Parse(_HaveYouInCircles);
                    gplusAcc.HaveYouInCircles = Convert.ToInt32(J_HaveYouInCircles["circledByCount"].ToString());
                }
                catch (Exception ex)
                {
                    gplusAcc.HaveYouInCircles = 0;
                }
                #endregion



                dbr.Update <Domain.Socioboard.Models.Googleplusaccounts>(gplusAcc);
            }
            else
            {
                gplusAcc          = new Domain.Socioboard.Models.Googleplusaccounts();
                gplusAcc.UserId   = userId;
                gplusAcc.GpUserId = profile["id"].ToString();
                try {
                    gplusAcc.GpUserName = profile["displayName"].ToString();
                }
                catch {
                    try {
                        gplusAcc.GpUserName = profile["name"].ToString();
                    }
                    catch { }
                }
                gplusAcc.IsActive     = true;
                gplusAcc.AccessToken  = accessToken;
                gplusAcc.RefreshToken = refreshToken;
                gplusAcc.EntryDate    = DateTime.UtcNow;
                try {
                    gplusAcc.GpProfileImage = Convert.ToString(profile["image"]["url"]);
                }
                catch
                {
                    try
                    {
                        gplusAcc.GpProfileImage = Convert.ToString(profile["picture"]);
                    }
                    catch { }
                }
                gplusAcc.AccessToken = accessToken;
                try
                {
                    gplusAcc.about = Convert.ToString(profile["tagline"]);
                }
                catch
                {
                    gplusAcc.about = "";
                }
                try
                {
                    gplusAcc.college = Convert.ToString(profile["organizations"][0]["name"]);
                }
                catch
                {
                    gplusAcc.college = "";
                }
                try
                {
                    gplusAcc.coverPic = Convert.ToString(profile["cover"]["coverPhoto"]["url"]);
                }
                catch
                {
                    gplusAcc.coverPic = "";
                }
                try
                {
                    gplusAcc.education = Convert.ToString(profile["organizations"][0]["type"]);
                }
                catch
                {
                    gplusAcc.education = "";
                }
                try
                {
                    gplusAcc.EmailId = Convert.ToString(profile["emails"][0]["value"]);
                }
                catch
                {
                    try {
                        try
                        {
                            gplusAcc.EmailId = Convert.ToString(profile["email"]);
                        }
                        catch { }
                    } catch { }
                    gplusAcc.EmailId = "";
                }
                try
                {
                    gplusAcc.gender = Convert.ToString(profile["gender"]);
                }
                catch
                {
                    gplusAcc.gender = "";
                }
                try
                {
                    gplusAcc.workPosition = Convert.ToString(profile["occupation"]);
                }
                catch
                {
                    gplusAcc.workPosition = "";
                }
                gplusAcc.LastUpdate = DateTime.UtcNow;


                #region Get_InYourCircles
                try
                {
                    string  _InyourCircles  = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleList.Replace("[userId]", gplusAcc.GpUserId).Replace("[collection]", "visible") + "?key=" + settings.GoogleApiKey, accessToken);
                    JObject J_InyourCircles = JObject.Parse(_InyourCircles);
                    gplusAcc.InYourCircles = Convert.ToInt32(J_InyourCircles["totalItems"].ToString());
                }
                catch (Exception ex)
                {
                    gplusAcc.InYourCircles = 0;
                }
                #endregion

                #region Get_HaveYouInCircles
                try
                {
                    string  _HaveYouInCircles  = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleProfile + gplusAcc.GpUserId + "?key=" + settings.GoogleApiKey, accessToken);
                    JObject J_HaveYouInCircles = JObject.Parse(_HaveYouInCircles);
                    gplusAcc.HaveYouInCircles = Convert.ToInt32(J_HaveYouInCircles["circledByCount"].ToString());
                }
                catch (Exception ex)
                {
                    gplusAcc.HaveYouInCircles = 0;
                }
                #endregion

                isSaved = dbr.Add <Domain.Socioboard.Models.Googleplusaccounts>(gplusAcc);
            }

            if (isSaved == 1)
            {
                List <Domain.Socioboard.Models.Googleplusaccounts> lstgplusAcc = dbr.Find <Domain.Socioboard.Models.Googleplusaccounts>(t => t.GpUserId.Equals(gplusAcc.GpUserId)).ToList();
                if (lstgplusAcc != null && lstgplusAcc.Count() > 0)
                {
                    isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstgplusAcc.First().GpUserId, lstgplusAcc.First().GpUserName, userId, lstgplusAcc.First().GpProfileImage, Domain.Socioboard.Enum.SocialProfileType.GPlus, dbr);
                    //codes to delete cache
                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);


                    if (isSaved == 1)
                    {
                        new Thread(delegate()
                        {
                            GetUserActivities(gplusAcc.GpUserId, gplusAcc.AccessToken, settings, _logger);
                        }).Start();
                    }
                }
            }
            return(isSaved);
        }
        public static int AddLinkedInCompantPage(oAuthLinkedIn _oauth, dynamic profile, Model.DatabaseRepository dbr, Int64 userId, Int64 groupId, string accesstoken, Helper.Cache _redisCache, Helper.AppSettings _appSettings, ILogger _logger)
        {
            int isSaved = 0;

            Domain.Socioboard.Models.LinkedinCompanyPage _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(profile.Pageid.ToString(), _redisCache, dbr);
            if (_LinkedInAccount != null && _LinkedInAccount.IsActive == false)
            {
                _LinkedInAccount.IsActive         = true;
                _LinkedInAccount.UserId           = userId;
                _LinkedInAccount.EmailDomains     = profile.EmailDomains.ToString();
                _LinkedInAccount.OAuthToken       = accesstoken;
                _LinkedInAccount.LinkedinPageName = profile.name.ToString();
                _LinkedInAccount.lastUpdate       = DateTime.UtcNow;
                try
                {
                    string NuberOfFollower = profile.num_followers.ToString();
                    _LinkedInAccount.NumFollowers = Convert.ToInt16(NuberOfFollower);
                }
                catch { }
                try
                {
                    _LinkedInAccount.CompanyType = profile.company_type.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.LogoUrl = profile.logo_url.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.SquareLogoUrl = profile.square_logo_url.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.BlogRssUrl = profile.blog_rss_url.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.UniversalName = profile.universal_name.ToString();
                }
                catch { }
                isSaved = dbr.Update <Domain.Socioboard.Models.LinkedinCompanyPage>(_LinkedInAccount);
            }
            else
            {
                _LinkedInAccount = new Domain.Socioboard.Models.LinkedinCompanyPage();
                _LinkedInAccount.LinkedinPageId = profile.Pageid.ToString();
                _LinkedInAccount.IsActive       = true;
                _LinkedInAccount.UserId         = userId;
                _LinkedInAccount.lastUpdate     = DateTime.UtcNow;
                try
                {
                    _LinkedInAccount.EmailDomains = profile.EmailDomains.ToString();
                }
                catch (Exception ex)
                {
                }
                _LinkedInAccount.LinkedinPageName = profile.name.ToString();
                _LinkedInAccount.OAuthToken       = _oauth.Token;
                _LinkedInAccount.OAuthSecret      = _oauth.TokenSecret;
                _LinkedInAccount.OAuthVerifier    = _oauth.Verifier;
                try
                {
                    _LinkedInAccount.Description = profile.description.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.FoundedYear = profile.founded_year.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.EndYear = profile.end_year.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.Locations = profile.locations.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.Specialties = profile.Specialties.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.WebsiteUrl = profile.website_url.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.Status = profile.status.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.EmployeeCountRange = profile.employee_count_range.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.Industries = profile.industries.ToString();
                }
                catch { }
                try
                {
                    string NuberOfFollower = profile.num_followers.ToString();
                    _LinkedInAccount.NumFollowers = Convert.ToInt16(NuberOfFollower);
                }
                catch { }
                try
                {
                    _LinkedInAccount.CompanyType = profile.company_type.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.LogoUrl = profile.logo_url.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.SquareLogoUrl = profile.square_logo_url.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.BlogRssUrl = profile.blog_rss_url.ToString();
                }
                catch { }
                try
                {
                    _LinkedInAccount.UniversalName = profile.universal_name.ToString();
                }
                catch { }
                isSaved = dbr.Add <Domain.Socioboard.Models.LinkedinCompanyPage>(_LinkedInAccount);
                if (isSaved == 1)
                {
                    List <Domain.Socioboard.Models.LinkedinCompanyPage> lstliAcc = dbr.Find <Domain.Socioboard.Models.LinkedinCompanyPage>(t => t.LinkedinPageId.Equals(_LinkedInAccount.LinkedinPageId)).ToList();
                    if (lstliAcc != null && lstliAcc.Count() > 0)
                    {
                        isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstliAcc.First().LinkedinPageId, lstliAcc.First().LinkedinPageName, userId, lstliAcc.First().LogoUrl, Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage, dbr);
                        if (isSaved == 1)
                        {
                            _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                            _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                            new Thread(delegate()
                            {
                                LinkedInAccountRepository.SaveLinkedInCompanyPageFeed(_oauth, lstliAcc.First().LinkedinPageId, lstliAcc.First().UserId, _appSettings);
                            }).Start();
                        }
                    }
                }
            }
            return(isSaved);
        }
Exemplo n.º 24
0
        public static int AddGaSites(string profiledata, long userId, long groupId, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr, IHostingEnvironment _appEnv)
        {
            int       isSaved    = 0;
            Analytics _Analytics = new Analytics(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri);

            Domain.Socioboard.Models.GoogleAnalyticsAccount _GoogleAnalyticsAccount;
            string[] GAdata = Regex.Split(profiledata, "<:>");
            _GoogleAnalyticsAccount = Repositories.GplusRepository.getGAAccount(GAdata[5], _redisCache, dbr);

            if (_GoogleAnalyticsAccount != null && _GoogleAnalyticsAccount.IsActive == false)
            {
                try
                {
                    _GoogleAnalyticsAccount.UserId          = userId;
                    _GoogleAnalyticsAccount.IsActive        = true;
                    _GoogleAnalyticsAccount.EntryDate       = DateTime.UtcNow;
                    _GoogleAnalyticsAccount.EmailId         = GAdata[4];
                    _GoogleAnalyticsAccount.GaAccountId     = GAdata[2];
                    _GoogleAnalyticsAccount.GaAccountName   = GAdata[3];
                    _GoogleAnalyticsAccount.GaWebPropertyId = GAdata[7];
                    _GoogleAnalyticsAccount.GaProfileId     = GAdata[5];
                    _GoogleAnalyticsAccount.GaProfileName   = GAdata[6];
                    _GoogleAnalyticsAccount.AccessToken     = GAdata[0];
                    _GoogleAnalyticsAccount.RefreshToken    = GAdata[1];
                    _GoogleAnalyticsAccount.WebsiteUrl      = GAdata[8];
                    string visits    = string.Empty;
                    string pageviews = string.Empty;
                    try
                    {
                        string  analytics = _Analytics.getAnalyticsData(GAdata[5], "ga:visits,ga:pageviews", DateTime.UtcNow.AddDays(-7).ToString("yyyy-MM-dd"), DateTime.UtcNow.ToString("yyyy-MM-dd"), GAdata[0]);
                        JObject JData     = JObject.Parse(analytics);
                        visits    = JData["totalsForAllResults"]["ga:visits"].ToString();
                        pageviews = JData["totalsForAllResults"]["ga:pageviews"].ToString();
                    }
                    catch (Exception ex)
                    {
                        visits    = "0";
                        pageviews = "0";
                    }
                    _GoogleAnalyticsAccount.Views         = Double.Parse(pageviews);
                    _GoogleAnalyticsAccount.Visits        = Double.Parse(visits);
                    _GoogleAnalyticsAccount.ProfilePicUrl = "https://www.socioboard.com/Contents/Socioboard/images/analytics_img.png";
                    _GoogleAnalyticsAccount.EntryDate     = DateTime.UtcNow;
                }
                catch (Exception ex)
                {
                }
                dbr.Update <Domain.Socioboard.Models.GoogleAnalyticsAccount>(_GoogleAnalyticsAccount);
            }
            else
            {
                try
                {
                    _GoogleAnalyticsAccount                 = new Domain.Socioboard.Models.GoogleAnalyticsAccount();
                    _GoogleAnalyticsAccount.UserId          = userId;
                    _GoogleAnalyticsAccount.IsActive        = true;
                    _GoogleAnalyticsAccount.EntryDate       = DateTime.UtcNow;
                    _GoogleAnalyticsAccount.EmailId         = GAdata[4];
                    _GoogleAnalyticsAccount.GaAccountId     = GAdata[2];
                    _GoogleAnalyticsAccount.GaAccountName   = GAdata[3];
                    _GoogleAnalyticsAccount.GaWebPropertyId = GAdata[7];
                    _GoogleAnalyticsAccount.GaProfileId     = GAdata[5];
                    _GoogleAnalyticsAccount.GaProfileName   = GAdata[6];
                    _GoogleAnalyticsAccount.AccessToken     = GAdata[0];
                    _GoogleAnalyticsAccount.RefreshToken    = GAdata[1];
                    _GoogleAnalyticsAccount.WebsiteUrl      = GAdata[8];
                    string visits    = string.Empty;
                    string pageviews = string.Empty;
                    try
                    {
                        string  analytics = _Analytics.getAnalyticsData(GAdata[5], "ga:visits,ga:pageviews", DateTime.UtcNow.AddDays(-7).ToString("yyyy-MM-dd"), DateTime.UtcNow.ToString("yyyy-MM-dd"), GAdata[0]);
                        JObject JData     = JObject.Parse(analytics);
                        visits    = JData["totalsForAllResults"]["ga:visits"].ToString();
                        pageviews = JData["totalsForAllResults"]["ga:pageviews"].ToString();
                    }
                    catch (Exception ex)
                    {
                        visits    = "0";
                        pageviews = "0";
                    }
                    _GoogleAnalyticsAccount.Views         = Double.Parse(pageviews);
                    _GoogleAnalyticsAccount.Visits        = Double.Parse(visits);
                    _GoogleAnalyticsAccount.ProfilePicUrl = "https://www.socioboard.com/Themes/Socioboard/Contents/img/analytics_img.png";
                    _GoogleAnalyticsAccount.EntryDate     = DateTime.UtcNow;
                }
                catch (Exception ex)
                {
                }
                isSaved = dbr.Add <Domain.Socioboard.Models.GoogleAnalyticsAccount>(_GoogleAnalyticsAccount);
            }

            if (isSaved == 1)
            {
                List <Domain.Socioboard.Models.GoogleAnalyticsAccount> lstgaAcc = dbr.Find <Domain.Socioboard.Models.GoogleAnalyticsAccount>(t => t.GaProfileId.Equals(_GoogleAnalyticsAccount.GaProfileId)).ToList();
                if (lstgaAcc != null && lstgaAcc.Count() > 0)
                {
                    isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstgaAcc.First().GaProfileId, lstgaAcc.First().GaProfileName, userId, lstgaAcc.First().ProfilePicUrl, Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics, dbr);
                    //codes to delete cache
                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                }
            }
            return(isSaved);
        }
        public static int AddLinkedInAccount(oAuthLinkedIn _oauth, dynamic profile, Model.DatabaseRepository dbr, Int64 userId, Int64 groupId, string accessToken, Helper.Cache _redisCache, Helper.AppSettings settings, ILogger _logger)
        {
            int isSaved = 0;

            Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(profile.id.ToString(), _redisCache, dbr);
            if (_LinkedInAccount != null && _LinkedInAccount.IsActive == false)
            {
                _LinkedInAccount.IsActive    = true;
                _LinkedInAccount.UserId      = userId;
                _LinkedInAccount.EmailId     = profile.email.ToString();
                _LinkedInAccount.OAuthToken  = accessToken;
                _LinkedInAccount.Connections = Convert.ToInt32(profile.connections.ToString());
                _LinkedInAccount.LastUpdate  = DateTime.UtcNow;
                isSaved = dbr.Update <Domain.Socioboard.Models.LinkedInAccount>(_LinkedInAccount);
            }
            else
            {
                _LinkedInAccount = new Domain.Socioboard.Models.LinkedInAccount();
                _LinkedInAccount.LinkedinUserId = profile.id.ToString();
                _LinkedInAccount.IsActive       = true;
                _LinkedInAccount.UserId         = userId;
                _LinkedInAccount.Connections    = Convert.ToInt32(profile.connections.ToString());
                _LinkedInAccount.LastUpdate     = DateTime.UtcNow;
                try
                {
                    _LinkedInAccount.EmailId = profile.email.ToString();
                }
                catch (Exception ex)
                {
                }
                _LinkedInAccount.LinkedinUserName = profile.first_name.ToString() + profile.last_name.ToString();
                _LinkedInAccount.OAuthToken       = _oauth.Token;
                _LinkedInAccount.OAuthSecret      = _oauth.TokenSecret;
                _LinkedInAccount.OAuthVerifier    = _oauth.Verifier;
                try
                {
                    _LinkedInAccount.ProfileImageUrl = profile.picture_url.ToString();
                }
                catch (Exception ex)
                {
                }
                try
                {
                    _LinkedInAccount.ProfileUrl = profile.profile_url.ToString();
                }
                catch (Exception ex)
                {
                }
                isSaved = dbr.Add <Domain.Socioboard.Models.LinkedInAccount>(_LinkedInAccount);
                if (isSaved == 1)
                {
                    List <Domain.Socioboard.Models.LinkedInAccount> lstliAcc = dbr.Find <Domain.Socioboard.Models.LinkedInAccount>(t => t.LinkedinUserId.Equals(_LinkedInAccount.LinkedinUserId)).ToList();
                    if (lstliAcc != null && lstliAcc.Count() > 0)
                    {
                        isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstliAcc.First().LinkedinUserId, lstliAcc.First().LinkedinUserName, userId, lstliAcc.First().ProfileImageUrl, Domain.Socioboard.Enum.SocialProfileType.LinkedIn, dbr);
                        if (isSaved == 1)
                        {
                            _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                            _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                        }
                    }
                }
            }
            return(isSaved);
        }
Exemplo n.º 26
0
 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 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);
                }
            }
        }
Exemplo n.º 28
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);
                }
            }
        }
Exemplo n.º 29
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 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());
        }