示例#1
0
        public IActionResult GettwitterSingle(string profileId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);

            Domain.Socioboard.Models.TwitterAccount AccDetails = dbr.Single <Domain.Socioboard.Models.TwitterAccount>(t => t.twitterUserId == profileId);
            return(Ok(AccDetails));
        }
示例#2
0
 public IActionResult PluginScheduleMessage(string profile, string twitterText, string tweetId, string tweetUrl, string facebookText, string url, string imgUrl, long userId, string scheduleTime)
 {
     string[] profiles = profile.Split(',');
     foreach (var item in profiles)
     {
         string[] ids = item.Split('~');
         if (ids[1] == "facebook")
         {
             DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
             Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(ids[0], _redisCache, dbr);
             Helper.ScheduleMessageHelper.ScheduleMessage(ids[0], objFacebookAccount.FbUserName, facebookText.ToString(), Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage, userId, imgUrl, "https://graph.facebook.com/" + ids[0] + "/picture?type=small", scheduleTime, _appSettings, _redisCache, dbr, _logger);
         }
         else
         {
             DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
             if (!string.IsNullOrEmpty(twitterText) || !string.IsNullOrEmpty(imgUrl))
             {
                 twitterText = twitterText + " " + tweetUrl;
                 Domain.Socioboard.Models.TwitterAccount objTwitterAccount = Api.Socioboard.Repositories.TwitterRepository.getTwitterAccount(ids[0], _redisCache, dbr);
                 Helper.ScheduleMessageHelper.ScheduleMessage(ids[0], objTwitterAccount.twitterScreenName, twitterText, Domain.Socioboard.Enum.SocialProfileType.Twitter, userId, imgUrl, objTwitterAccount.profileImageUrl, scheduleTime, _appSettings, _redisCache, dbr, _logger);
             }
             else
             {
                 string data = TwitterRepository.TwitterRetweet_post(ids[0], tweetId, userId, 0, dbr, _logger, _redisCache, _appSettings);
             }
         }
     }
     return(Ok());
 }
示例#3
0
        public static string ComposeTwitterMessage(string message, string profileid, long userid, string picurl, bool isScheduled, DatabaseRepository dbr, Domain.Socioboard.Models.TwitterAccount TwitterAccount, Domain.Socioboard.Models.ScheduledMessage schmessage)
        {
            bool   rt  = false;
            string ret = "";
            string str = "Message posted";

            if (message.Length > 140)
            {
                message = message.Substring(0, 135);
            }
            Domain.Socioboard.Models.TwitterAccount objTwitterAccount = TwitterAccount;
            // oAuthTwitter OAuthTwt = new oAuthTwitter("MbOQl85ZcvRGvp3kkOOJBlbFS", "GF0UIXnTAX28hFhN1ISNf3tURHARZdKWlZrsY4PlHm9A4llYjZ", "http://serv1.socioboard.com/TwitterManager/Twitter");
            oAuthTwitter OAuthTwt = new oAuthTwitter("h4FT0oJ46KBBMwbcifqZMw", "yfowGI2g21E2mQHjtHjUvGqkfbI7x26WDCvjiSZOjas", "https://www.socioboard.com/TwitterManager/Twitter");

            OAuthTwt.AccessToken       = objTwitterAccount.oAuthToken;
            OAuthTwt.AccessTokenSecret = objTwitterAccount.oAuthSecret;
            OAuthTwt.TwitterScreenName = objTwitterAccount.twitterScreenName;
            OAuthTwt.TwitterUserId     = objTwitterAccount.twitterUserId;

            Tweet twt = new Tweet();

            if (!string.IsNullOrEmpty(picurl))
            {
                try
                {
                    PhotoUpload ph  = new PhotoUpload();
                    string      res = string.Empty;
                    rt = ph.NewTweet(picurl, message, OAuthTwt, ref res);
                }
                catch (Exception ex)
                {
                    apiHitsCount = MaxapiHitsCount;
                }
            }
            else
            {
                try
                {
                    JArray post = twt.Post_Statuses_Update(OAuthTwt, message);
                    ret = post[0]["id_str"].ToString();
                }
                catch (Exception ex)
                {
                    apiHitsCount = MaxapiHitsCount;
                }
            }

            if (!string.IsNullOrEmpty(ret) || rt == true)
            {
                schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                schmessage.url    = ret;
                dbr.Update <ScheduledMessage>(schmessage);
            }
            else
            {
                str = "Message not posted";
            }

            return(str);
        }
        public static string ComposeTwitterMessage(string message, string profileid, long userid, string picurl, bool isScheduled, DatabaseRepository dbr, Domain.Socioboard.Models.TwitterAccount TwitterAccount, Domain.Socioboard.Models.ScheduledMessage schmessage)
        {
            bool   rt  = false;
            string ret = "";
            string str = "Message posted";

            if (message.Length > 140)
            {
                message = message.Substring(0, 135);
            }
            Domain.Socioboard.Models.TwitterAccount objTwitterAccount = TwitterAccount;
            oAuthTwitter OAuthTwt = new oAuthTwitter(Helper.AppSettings.twitterConsumerKey, Helper.AppSettings.twitterConsumerScreatKey, Helper.AppSettings.twitterRedirectionUrl);

            OAuthTwt.AccessToken       = objTwitterAccount.oAuthToken;
            OAuthTwt.AccessTokenSecret = objTwitterAccount.oAuthSecret;
            OAuthTwt.TwitterScreenName = objTwitterAccount.twitterScreenName;
            OAuthTwt.TwitterUserId     = objTwitterAccount.twitterUserId;

            Tweet twt = new Tweet();

            if (!string.IsNullOrEmpty(picurl))
            {
                try
                {
                    PhotoUpload ph  = new PhotoUpload();
                    string      res = string.Empty;
                    rt = ph.NewTweet(picurl, message, OAuthTwt, ref res);
                }
                catch (Exception ex)
                {
                    apiHitsCount = MaxapiHitsCount;
                }
            }
            else
            {
                try
                {
                    JArray post = twt.Post_Statuses_Update(OAuthTwt, message);
                    ret = post[0]["id_str"].ToString();
                }
                catch (Exception ex)
                {
                    apiHitsCount = MaxapiHitsCount;
                }
            }

            if (!string.IsNullOrEmpty(ret) || rt == true)
            {
                schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                schmessage.url    = ret;
                dbr.Update <ScheduledMessage>(schmessage);
            }
            else
            {
                str = "Message not posted";
            }

            return(str);
        }
示例#5
0
        public IActionResult GetPluginProfile(long groupId)
        {
            List <Domain.Socioboard.Helpers.PluginProfile> lstPluginProfile = new List <Domain.Socioboard.Helpers.PluginProfile>();
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            List <Domain.Socioboard.Models.Groupprofiles> lstGroupprofiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId.Equals(groupId) && (t.profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook || t.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage || t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter)).ToList();

            lstGroupprofiles = lstGroupprofiles.GroupBy(t => t.profileId).Select(g => g.First()).ToList();
            foreach (var item in lstGroupprofiles)
            {
                try
                {
                    if (item.profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook || item.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage)
                    {
                        Domain.Socioboard.Models.Facebookaccounts _Facebookaccounts = FacebookRepository.getFacebookAccount(item.profileId, _redisCache, dbr);
                        if (_Facebookaccounts != null)
                        {
                            if (!string.IsNullOrEmpty(_Facebookaccounts.AccessToken))
                            {
                                if (_Facebookaccounts.IsActive)
                                {
                                    Domain.Socioboard.Helpers.PluginProfile _sb = new Domain.Socioboard.Helpers.PluginProfile();
                                    _sb.type            = "facebook";
                                    _sb.facebookprofile = _Facebookaccounts;
                                    _sb.twitterprofile  = new Domain.Socioboard.Models.TwitterAccount();
                                    lstPluginProfile.Add(_sb);
                                }
                            }
                        }
                    }
                    if (item.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter)
                    {
                        Domain.Socioboard.Models.TwitterAccount _TwitterAccount = TwitterRepository.getTwitterAccount(item.profileId, _redisCache, dbr);
                        if (_TwitterAccount != null)
                        {
                            if (_TwitterAccount.isActive)
                            {
                                Domain.Socioboard.Helpers.PluginProfile _sb = new Domain.Socioboard.Helpers.PluginProfile();
                                _sb.type            = "twitter";
                                _sb.twitterprofile  = _TwitterAccount;
                                _sb.facebookprofile = new Domain.Socioboard.Models.Facebookaccounts();
                                lstPluginProfile.Add(_sb);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    return(Ok(lstPluginProfile));
                }
            }
            return(Ok(lstPluginProfile));
        }
示例#6
0
        public IActionResult GetAllTwitterProfiles(long groupId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            List <Domain.Socioboard.Models.Groupprofiles>  lstGrpProfiles = Repositories.GroupProfilesRepository.getAllGroupProfiles(groupId, _redisCache, dbr);
            List <Domain.Socioboard.Models.TwitterAccount> lstTwtAcc      = new List <Domain.Socioboard.Models.TwitterAccount>();

            foreach (var item in lstGrpProfiles.Where(t => t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter))
            {
                Domain.Socioboard.Models.TwitterAccount twtAcc = Repositories.TwitterRepository.getTwitterAccount(item.profileId, _redisCache, dbr);
                if (twtAcc != null)
                {
                    lstTwtAcc.Add(twtAcc);
                }
            }
            return(Ok(lstTwtAcc));
        }
示例#7
0
        public static string TwitterUserFollow(string profileId, string toTwitterUserId, Model.DatabaseRepository dbr, ILogger _logger, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
        {
            Domain.Socioboard.Models.TwitterAccount twtacc   = new Domain.Socioboard.Models.TwitterAccount();
            Domain.Socioboard.Models.TwitterAccount imtwtacc = _redisCache.Get <Domain.Socioboard.Models.TwitterAccount>(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterAccount + profileId);
            if (imtwtacc == null)
            {
                twtacc = dbr.Find <Domain.Socioboard.Models.TwitterAccount>(t => t.twitterUserId.Equals(profileId)).FirstOrDefault();
                if (twtacc != null)
                {
                    _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterAccount + profileId, twtacc);
                }
            }
            else
            {
                twtacc = imtwtacc;
            }
            oAuthTwitter oAuth = new oAuthTwitter(_appSettings.twitterConsumerKey, _appSettings.twitterConsumerScreatKey, _appSettings.twitterRedirectionUrl);

            oAuth.AccessToken       = twtacc.oAuthToken;
            oAuth.AccessTokenSecret = twtacc.oAuthSecret;
            oAuth.TwitterScreenName = twtacc.twitterScreenName;
            oAuth.TwitterUserId     = twtacc.twitterUserId;
            FollowerManage follow_obj = new FollowerManage();

            try
            {
                string followUserResp = follow_obj.FollowUserByUserId(oAuth, toTwitterUserId);
                if (followUserResp != "")
                {
                    return("User followed successfully");
                }
                else
                {
                    return("Issue in user following");
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("user following" + ex.StackTrace);
                _logger.LogError("user following" + ex.Message);
                return("api issue while user following");
            }
        }
示例#8
0
        public static List <Domain.Socioboard.Models.TwitterContactSearch> twitterConstactSearchlist(string profileId, string contact, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings)
        {
            string profileids = profileId;
            List <Domain.Socioboard.Models.TwitterContactSearch> lstContact = new List <Domain.Socioboard.Models.TwitterContactSearch>();

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

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

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

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

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

            try
            {
                ret = twtuser.PostDirect_Messages_New(OAuthTwt, message, toId);
                _TwitterDirectMessages.messageId           = ret[0]["id_str"].ToString();
                _TwitterDirectMessages.message             = ret[0]["text"].ToString();
                _TwitterDirectMessages.profileId           = objTwitterAccount.twitterUserId;
                _TwitterDirectMessages.createdDate         = DateTime.ParseExact(ret[0]["created_at"].ToString().TrimStart('"').TrimEnd('"'), format, System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy/MM/dd HH:mm:ss");
                _TwitterDirectMessages.timeStamp           = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.ParseExact(ret[0]["created_at"].ToString().TrimStart('"').TrimEnd('"'), format, System.Globalization.CultureInfo.InvariantCulture));
                _TwitterDirectMessages.entryDate           = DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm:ss");
                _TwitterDirectMessages.recipientId         = ret[0]["recipient"]["id_str"].ToString();
                _TwitterDirectMessages.recipientProfileUrl = ret[0]["recipient"]["profile_image_url_https"].ToString();
                _TwitterDirectMessages.recipientScreenName = ret[0]["recipient"]["screen_name"].ToString();
                _TwitterDirectMessages.senderId            = ret[0]["sender"]["id_str"].ToString();
                _TwitterDirectMessages.senderProfileUrl    = ret[0]["sender"]["profile_image_url_https"].ToString();
                _TwitterDirectMessages.senderScreenName    = ret[0]["sender"]["screen_name"].ToString();
                _TwitterDirectMessages.type = Domain.Socioboard.Enum.TwitterMessageType.TwitterDirectMessageSent;
                MongoRepository mongorepo = new MongoRepository("MongoTwitterDirectMessages", _appSettings);
                mongorepo.Add <Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages>(_TwitterDirectMessages);
            }
            catch (Exception ex)
            {
            }
        }
示例#10
0
        public static List <Domain.Socioboard.Models.profilesdetail> getTop3GroupProfiles(long groupId, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            //try
            //{
            //    List<Domain.Socioboard.Models.Groupprofiles> inMemGroupProfiles = _redisCache.Get<List<Domain.Socioboard.Models.Groupprofiles>>(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
            //    if (inMemGroupProfiles != null)
            //    {
            //         return inMemGroupProfiles;
            //    }
            //}
            //catch { }
            //Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail();
            List <Domain.Socioboard.Models.profilesdetail> lstprofiledetail = new List <profilesdetail>();
            List <Domain.Socioboard.Models.Groupprofiles>  groupProfiles    = dbr.FindWithRange <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId, 0, 3).ToList();

            // _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId, groupProfiles);
            //  List<Domain.Socioboard.Models.Groupprofiles> groupProfiless = groupProfiles.Take(3).ToList();
            foreach (Domain.Socioboard.Models.Groupprofiles profile in groupProfiles)
            {
                if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook)
                {
                    Domain.Socioboard.Models.Facebookaccounts fbAcc = Repositories.FacebookRepository.getFacebookAccount(profile.profileId, _redisCache, dbr);

                    Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail();
                    profiledetails.Fbaccount = fbAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage)
                {
                    Domain.Socioboard.Models.Facebookaccounts fbpageAcc      = Repositories.FacebookRepository.getFacebookAccount(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail   profiledetails = new profilesdetail();
                    profiledetails.Fbaccount = fbpageAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter)
                {
                    Domain.Socioboard.Models.TwitterAccount twtAcc         = Repositories.TwitterRepository.getTwitterAccount(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail();
                    profiledetails.Twtaccount = twtAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram)
                {
                    Domain.Socioboard.Models.Instagramaccounts insAcc         = Repositories.InstagramRepository.getInstagramAccount(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail    profiledetails = new profilesdetail();
                    profiledetails.Instaaccount = insAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.GPlus)
                {
                    Domain.Socioboard.Models.Googleplusaccounts gPlusAcc       = Repositories.GplusRepository.getGPlusAccount(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail     profiledetails = new profilesdetail();
                    profiledetails.Gplusaccount = gPlusAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn)
                {
                    Domain.Socioboard.Models.LinkedInAccount linkdAcc       = Repositories.LinkedInAccountRepository.getLinkedInAccount(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail  profiledetails = new profilesdetail();
                    profiledetails.LinkdInaccount = linkdAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage)
                {
                    Domain.Socioboard.Models.LinkedinCompanyPage LinkedcompanyAcc = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail      profiledetails   = new profilesdetail();
                    profiledetails.LinkdINcompanyaccount = LinkedcompanyAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.YouTube)
                {
                    Domain.Socioboard.Models.YoutubeChannel YTChnl         = Repositories.GplusRepository.getYTChannel(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail();
                    profiledetails.Ytubeaccount = YTChnl;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics)
                {
                    Domain.Socioboard.Models.GoogleAnalyticsAccount gAAcc          = Repositories.GplusRepository.getGAAccount(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail         profiledetails = new profilesdetail();
                    profiledetails.GAaccount = gAAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.Pinterest)
                {
                    Domain.Socioboard.Models.PinterestAccount PinAcc         = Repositories.PinterestRepository.getPinterestAccountDetail(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail   profiledetails = new profilesdetail();
                    profiledetails.Pintrestaccount = PinAcc;
                    lstprofiledetail.Add(profiledetails);
                }

                //lstprofiledetail.Add(profiledetails);
            }

            return(lstprofiledetail);
        }
示例#11
0
        public IActionResult AddProfileToGroup(string profileId, long groupId, long userId, Domain.Socioboard.Enum.SocialProfileType profileType)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            List <Domain.Socioboard.Models.Groupprofiles> lstGroupProfiles = GroupProfilesRepository.getGroupProfiles(groupId, _redisCache, dbr);

            if (lstGroupProfiles.Where(t => t.profileId.Equals(profileId)).Count() > 0)
            {
                return(BadRequest("profile already added"));
            }
            else
            {
                Domain.Socioboard.Models.Groups grp = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.id == groupId).FirstOrDefault();
                if (grp == null)
                {
                    return(BadRequest("Invalid groupId"));
                }
                else
                {
                    Domain.Socioboard.Models.Groupprofiles grpProfile = new Domain.Socioboard.Models.Groupprofiles();
                    if (profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook || profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage || profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookPublicPage)
                    {
                        Domain.Socioboard.Models.Facebookaccounts fbAcc = Repositories.FacebookRepository.getFacebookAccount(profileId, _redisCache, dbr);
                        if (fbAcc == null)
                        {
                            return(BadRequest("Invalid profileId"));
                        }
                        if (fbAcc.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = fbAcc.FbUserName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = "http://graph.facebook.com/" + fbAcc.FbUserId + "/picture?type=small";
                        grpProfile.profileType    = profileType;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter)
                    {
                        Domain.Socioboard.Models.TwitterAccount twtAcc = Repositories.TwitterRepository.getTwitterAccount(profileId, _redisCache, dbr);
                        if (twtAcc == null)
                        {
                            return(BadRequest("Invalid profileId"));
                        }
                        if (twtAcc.userId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = twtAcc.twitterScreenName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = twtAcc.profileImageUrl;
                        grpProfile.profileType    = Domain.Socioboard.Enum.SocialProfileType.Twitter;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.GPlus)
                    {
                        Domain.Socioboard.Models.Googleplusaccounts gplusAccount = Repositories.GplusRepository.getGPlusAccount(profileId, _redisCache, dbr);
                        if (gplusAccount == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (gplusAccount.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = gplusAccount.GpUserName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = gplusAccount.GpProfileImage;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics)
                    {
                        Domain.Socioboard.Models.GoogleAnalyticsAccount gplusAccount = Repositories.GplusRepository.getGAAccount(profileId, _redisCache, dbr);
                        if (gplusAccount == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (gplusAccount.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = gplusAccount.GaProfileName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = gplusAccount.ProfilePicUrl;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram)
                    {
                        Domain.Socioboard.Models.Instagramaccounts _Instagramaccounts = Repositories.InstagramRepository.getInstagramAccount(profileId, _redisCache, dbr);
                        if (_Instagramaccounts == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (_Instagramaccounts.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = _Instagramaccounts.InsUserName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = _Instagramaccounts.ProfileUrl;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn)
                    {
                        Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(profileId, _redisCache, dbr);
                        if (_LinkedInAccount == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (_LinkedInAccount.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = _LinkedInAccount.LinkedinUserName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = _LinkedInAccount.ProfileImageUrl;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage)
                    {
                        Domain.Socioboard.Models.LinkedinCompanyPage _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(profileId, _redisCache, dbr);
                        if (_LinkedInAccount == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (_LinkedInAccount.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = _LinkedInAccount.LinkedinPageName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = _LinkedInAccount.LogoUrl;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.YouTube)
                    {
                        Domain.Socioboard.Models.YoutubeChannel _YoutubeChannel = Repositories.GplusRepository.getYTChannel(profileId, _redisCache, dbr);
                        if (_YoutubeChannel == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (_YoutubeChannel.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = _YoutubeChannel.YtubeChannelName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = _YoutubeChannel.ChannelpicUrl;
                    }
                    if (profileType == Domain.Socioboard.Enum.SocialProfileType.Pinterest)
                    {
                        Domain.Socioboard.Models.PinterestAccount pinAcc = dbr.Find <Domain.Socioboard.Models.PinterestAccount>(t => t.username.Equals(profileId)).FirstOrDefault();
                        if (pinAcc == null)
                        {
                            return(BadRequest("Invalid profileId"));
                        }
                        if (pinAcc.userid != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = pinAcc.firstname + " " + pinAcc.lastname;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = pinAcc.profileimgaeurl;
                        grpProfile.profileType    = profileType;
                    }
                    grpProfile.entryDate   = DateTime.UtcNow;
                    grpProfile.groupId     = grp.id;
                    grpProfile.profileId   = profileId;
                    grpProfile.profileType = profileType;
                    dbr.Add <Domain.Socioboard.Models.Groupprofiles>(grpProfile);
                    //codes to clear cache
                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                    //end codes to clear cache
                    return(Ok("Added Successfully"));
                }
            }
        }
        public static string ComposeTwitterMessage(string message, string profileid, long userid, string picurl, bool isScheduled, DatabaseRepository dbr, Domain.Socioboard.Models.TwitterAccount TwitterAccount, Domain.Socioboard.Models.ScheduledMessage schmessage, Domain.Socioboard.Models.User _user)
        {
            bool   rt  = false;
            string ret = "";
            string str = "Message posted";

            if (message.Length > 140)
            {
                message = message.Substring(0, 135);
            }
            Domain.Socioboard.Models.TwitterAccount objTwitterAccount = TwitterAccount;
            oAuthTwitter OAuthTwt = new oAuthTwitter(AppSettings.twitterConsumerKey, AppSettings.twitterConsumerScreatKey, AppSettings.twitterRedirectionUrl);

            OAuthTwt.AccessToken       = objTwitterAccount.oAuthToken;
            OAuthTwt.AccessTokenSecret = objTwitterAccount.oAuthSecret;
            OAuthTwt.TwitterScreenName = objTwitterAccount.twitterScreenName;
            OAuthTwt.TwitterUserId     = objTwitterAccount.twitterUserId;

            Tweet twt = new Tweet();

            if (!string.IsNullOrEmpty(picurl))
            {
                try
                {
                    PhotoUpload ph  = new PhotoUpload();
                    string      res = string.Empty;
                    rt = ph.NewTweet(picurl, message, OAuthTwt, ref res);
                }
                catch (Exception ex)
                {
                    apiHitsCount = MaxapiHitsCount;
                }
            }
            else
            {
                try
                {
                    JArray post = twt.Post_Statuses_Update(OAuthTwt, message);
                    ret = post[0]["id_str"].ToString();
                }
                catch (Exception ex)
                {
                    apiHitsCount = MaxapiHitsCount;
                }
            }

            if (!string.IsNullOrEmpty(ret) || rt == true)
            {
                schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                //schmessage.url = ret;
                dbr.Update <ScheduledMessage>(schmessage);
                Domain.Socioboard.Models.Notifications notify = new Notifications();
                Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id);
                if (lstnotifications == null)
                {
                    notify.MsgId            = schmessage.id;
                    notify.MsgStatus        = "Scheduled";
                    notify.notificationtime = schmessage.localscheduletime;
                    notify.NotificationType = "Schedule Successfully";
                    notify.ReadOrUnread     = "Unread";
                    notify.UserId           = userid;
                    dbr.Add <Notifications>(notify);
                    if (_user.scheduleSuccessUpdates)
                    {
                        string sucResponse = SendMailbySendGrid(AppSettings.from_mail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                }
                else
                {
                    //if (_user.scheduleSuccessUpdates)
                    //{
                    //    string sucResponse = SendMailbySendGrid(AppSettings.from_mail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    //}
                }
            }
            else
            {
                str = "Message not posted";
                Domain.Socioboard.Models.Notifications notify = new Notifications();
                Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id);
                if (lstnotifications == null)
                {
                    notify.MsgId            = schmessage.id;
                    notify.MsgStatus        = "Failed";
                    notify.notificationtime = schmessage.localscheduletime;
                    notify.NotificationType = "Schedule Failed";
                    notify.ReadOrUnread     = "Unread";
                    notify.UserId           = userid;
                    dbr.Add <Notifications>(notify);
                    if (_user.scheduleFailureUpdates)
                    {
                        string falResponse = SendMailbySendGrid(AppSettings.from_mail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                }
                else
                {
                    //if (_user.scheduleFailureUpdates)
                    //{
                    //    string falResponse = SendMailbySendGrid(AppSettings.from_mail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    //}
                }
            }

            return(str);
        }
 public static void PostTwitterMessage(Domain.Socioboard.Models.ScheduledMessage schmessage, Domain.Socioboard.Models.TwitterAccount _TwitterAccount, Domain.Socioboard.Models.User _user)
 {
     try
     {
         DatabaseRepository dbr = new DatabaseRepository();
         //if (_TwitterAccount.SchedulerUpdate.AddMinutes(15) <= DateTime.UtcNow)
         //{
         if (_TwitterAccount != null)
         {
             if (_TwitterAccount.isActive)
             {
                 //if (apiHitsCount < MaxapiHitsCount)
                 //{
                 if (schmessage.scheduleTime <= DateTime.UtcNow)
                 {
                     string twitterdata = ComposeTwitterMessage(schmessage.shareMessage, schmessage.profileId, schmessage.userId, schmessage.url, false, dbr, _TwitterAccount, schmessage, _user);
                     if (!string.IsNullOrEmpty(twitterdata) && twitterdata != "Message not posted")
                     {
                         apiHitsCount++;
                     }
                     else if (twitterdata == "Message not posted")
                     {
                         _TwitterAccount.isActive = false;
                         dbr.Update <TwitterAccount>(_TwitterAccount);
                     }
                 }
                 //}
                 //_TwitterAccount.lastUpdate = DateTime.UtcNow;
                 //dbr.Update<Domain.Socioboard.Models.TwitterAccount>(_TwitterAccount);
             }
             else
             {
                 // apiHitsCount = MaxapiHitsCount;
             }
         }
         //}
         //else
         //{
         //    apiHitsCount = 0;
         //}
     }
     catch (Exception ex)
     {
         apiHitsCount = MaxapiHitsCount;
     }
 }
示例#14
0
        public static string PostTwitterMessage(AppSettings _AppSettings, Cache _redisCache, string message, string profileid, long userid, string url, bool isScheduled, DatabaseRepository dbr, ILogger _logger, string sscheduledmsgguid = "")
        {
            bool   rt    = false;
            string ret   = "";
            string str   = "";
            int    Twtsc = 0;

            Domain.Socioboard.Models.TwitterAccount objTwitterAccount = Api.Socioboard.Repositories.TwitterRepository.getTwitterAccount(profileid, _redisCache, dbr);
            oAuthTwitter OAuthTwt = new oAuthTwitter(_AppSettings.twitterConsumerKey, _AppSettings.twitterConsumerScreatKey, _AppSettings.twitterRedirectionUrl);

            OAuthTwt.AccessToken       = objTwitterAccount.oAuthToken;
            OAuthTwt.AccessTokenSecret = objTwitterAccount.oAuthSecret;
            OAuthTwt.TwitterScreenName = objTwitterAccount.twitterScreenName;
            OAuthTwt.TwitterUserId     = objTwitterAccount.twitterUserId;

            Tweet twt = new Tweet();

            if (!string.IsNullOrEmpty(url))
            {
                try
                {
                    PhotoUpload ph  = new PhotoUpload();
                    string      res = string.Empty;
                    rt = ph.NewTweet(url, message, OAuthTwt, ref res);
                }
                catch (Exception ex)
                {
                    _logger.LogError("PostTwitterMessageWithImage" + ex.StackTrace);
                    _logger.LogError("PostTwitterMessageWithImage" + ex.Message);
                }
            }
            else
            {
                try
                {
                    JArray post = twt.Post_Statuses_Update(OAuthTwt, message);
                    ret = post[0]["id_str"].ToString();
                }
                catch (Exception ex)
                {
                    _logger.LogError("PostTwitterMessage" + ex.StackTrace);
                    _logger.LogError("PostTwitterMessage" + ex.Message);
                }
            }

            if (!string.IsNullOrEmpty(ret) || rt == true)
            {
                ScheduledMessage scheduledMessage = new ScheduledMessage();
                scheduledMessage.createTime        = DateTime.UtcNow;
                scheduledMessage.picUrl            = objTwitterAccount.profileImageUrl;
                scheduledMessage.profileId         = profileid;
                scheduledMessage.profileType       = Domain.Socioboard.Enum.SocialProfileType.Twitter;
                scheduledMessage.scheduleTime      = DateTime.UtcNow;
                scheduledMessage.shareMessage      = message;
                scheduledMessage.socialprofileName = objTwitterAccount.twitterScreenName;
                scheduledMessage.userId            = userid;
                scheduledMessage.status            = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                scheduledMessage.url = url;
                dbr.Add <ScheduledMessage>(scheduledMessage);
            }
            else
            {
                str = "Message not posted";
            }

            return(str);
        }
 public static void PostTwitterMessage(Domain.Socioboard.Models.ScheduledMessage schmessage, Domain.Socioboard.Models.TwitterAccount _TwitterAccount)
 {
     try
     {
         DatabaseRepository dbr = new DatabaseRepository();
         if (_TwitterAccount.SchedulerUpdate.AddMinutes(15) <= DateTime.UtcNow)
         {
             if (_TwitterAccount != null)
             {
                 if (_TwitterAccount.isActive)
                 {
                     if (apiHitsCount < MaxapiHitsCount)
                     {
                         if (schmessage.scheduleTime <= DateTime.UtcNow)
                         {
                             string twitterdata = ComposeTwitterMessage(schmessage.shareMessage, schmessage.profileId, schmessage.userId, schmessage.url, false, dbr, _TwitterAccount, schmessage);
                             if (!string.IsNullOrEmpty(twitterdata))
                             {
                                 apiHitsCount++;
                             }
                         }
                     }
                 }
                 else
                 {
                     apiHitsCount = MaxapiHitsCount;
                 }
             }
         }
         else
         {
             apiHitsCount = 0;
         }
     }
     catch (Exception ex)
     {
         apiHitsCount = MaxapiHitsCount;
     }
 }
示例#16
0
        public static Domain.Socioboard.Models.TwitterFriendRelation TwitterFrindsRelation(string profileId, string toTwitterUserId, Model.DatabaseRepository dbr, ILogger _logger, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
        {
            Domain.Socioboard.Models.TwitterAccount twtacc   = new Domain.Socioboard.Models.TwitterAccount();
            Domain.Socioboard.Models.TwitterAccount imtwtacc = _redisCache.Get <Domain.Socioboard.Models.TwitterAccount>(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterAccount + profileId);
            if (imtwtacc == null)
            {
                twtacc = dbr.Find <Domain.Socioboard.Models.TwitterAccount>(t => t.twitterUserId.Equals(profileId)).FirstOrDefault();
                if (twtacc != null)
                {
                    _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterAccount + profileId, twtacc);
                }
            }
            else
            {
                twtacc = imtwtacc;
            }
            oAuthTwitter oAuth = new oAuthTwitter(_appSettings.twitterConsumerKey, _appSettings.twitterConsumerScreatKey, _appSettings.twitterRedirectionUrl);

            oAuth.AccessToken       = twtacc.oAuthToken;
            oAuth.AccessTokenSecret = twtacc.oAuthSecret;
            oAuth.TwitterScreenName = twtacc.twitterScreenName;
            oAuth.TwitterUserId     = twtacc.twitterUserId;
            FollowerManage follow_obj = new FollowerManage();

            try
            {
                Domain.Socioboard.Models.TwitterFriendRelation _objLstData = new Domain.Socioboard.Models.TwitterFriendRelation();
                string  friendRelationResp  = follow_obj.RelatnFriendshipByUserId(oAuth, toTwitterUserId);
                JObject jFriendRelationResp = JObject.Parse(friendRelationResp);
                if (friendRelationResp == "")
                {
                    return(null);
                }
                else
                {
                    _objLstData.myId                    = jFriendRelationResp["relationship"]["source"]["id_str"].ToString();
                    _objLstData.myScreenName            = jFriendRelationResp["relationship"]["source"]["screen_name"].ToString();
                    _objLstData.myFollowing             = jFriendRelationResp["relationship"]["source"]["following"].ToString();
                    _objLstData.myFollowedBy            = jFriendRelationResp["relationship"]["source"]["followed_by"].ToString();
                    _objLstData.myLiveFollowing         = jFriendRelationResp["relationship"]["source"]["live_following"].ToString();
                    _objLstData.myFollowingReceived     = jFriendRelationResp["relationship"]["source"]["following_received"].ToString();
                    _objLstData.myFollowingRequested    = jFriendRelationResp["relationship"]["source"]["following_requested"].ToString();
                    _objLstData.myNotificationsEnabled  = jFriendRelationResp["relationship"]["source"]["notifications_enabled"].ToString();
                    _objLstData.myCanDm                 = jFriendRelationResp["relationship"]["source"]["can_dm"].ToString();
                    _objLstData.myBlocking              = jFriendRelationResp["relationship"]["source"]["blocking"].ToString();
                    _objLstData.myBlockedBy             = jFriendRelationResp["relationship"]["source"]["blocked_by"].ToString();
                    _objLstData.myMuting                = jFriendRelationResp["relationship"]["source"]["muting"].ToString();
                    _objLstData.myWantRetweets          = jFriendRelationResp["relationship"]["source"]["want_retweets"].ToString();
                    _objLstData.myAllReplies            = jFriendRelationResp["relationship"]["source"]["all_replies"].ToString();
                    _objLstData.myMarkedSpam            = jFriendRelationResp["relationship"]["source"]["marked_spam"].ToString();
                    _objLstData.targetId                = jFriendRelationResp["relationship"]["target"]["id_str"].ToString();
                    _objLstData.targetScreenName        = jFriendRelationResp["relationship"]["target"]["screen_name"].ToString();
                    _objLstData.targetFollowing         = jFriendRelationResp["relationship"]["target"]["following"].ToString();
                    _objLstData.targetFollowedBy        = jFriendRelationResp["relationship"]["target"]["followed_by"].ToString();
                    _objLstData.targetFollowingReceived = jFriendRelationResp["relationship"]["target"]["following_received"].ToString();
                    _objLstData.targetFollowingRequsted = jFriendRelationResp["relationship"]["target"]["following_requested"].ToString();
                    return(_objLstData);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("error finding friendship relation" + ex.StackTrace);
                _logger.LogError("error finding friendship relation" + ex.Message);
                return(null);
            }
        }
示例#17
0
        public IActionResult AddRssUrl(long userId, long groupId, string rssUrl, string profileId)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument(); // Create an XML document object
                xmlDoc.Load(rssUrl);
                var abc = xmlDoc.DocumentElement.GetElementsByTagName("item");
                if (abc.Count == 0)
                {
                    return(Ok("This Url Does't  Conatin Rss Feed"));
                }
            }
            catch (Exception ex)
            {
                return(Ok("This Url Does't  Conatin Rss Feed"));
            }

            try
            {
                var dbr         = new DatabaseRepository(_logger, _env);
                var _RssFeedUrl = Repositories.RssFeedRepository.AddRssUrl(profileId, rssUrl, dbr);

                if (_RssFeedUrl != "null")
                {
                    string[] lstProfileIds;
                    if (profileId != null)
                    {
                        lstProfileIds = profileId.Split(',');
                        profileId     = lstProfileIds[0];
                    }
                    else
                    {
                        return(Ok("profileId required"));
                    }

                    foreach (var item in lstProfileIds)
                    {
                        if (item.StartsWith("fb"))
                        {
                            string prId = item.Substring(3, item.Length - 3);
                            Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(prId, _redisCache, dbr);
                            string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.Facebook, "http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small", objFacebookAccount.FbUserName, null, dbr, _appSettings);
                        }
                        else if (item.StartsWith("page"))
                        {
                            string prId = item.Substring(5, item.Length - 5);
                            Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(prId, _redisCache, dbr);
                            string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage, "http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small", objFacebookAccount.FbUserName, null, dbr, _appSettings);
                        }
                        else if (item.StartsWith("tw"))
                        {
                            string prId = item.Substring(3, item.Length - 3);
                            Domain.Socioboard.Models.TwitterAccount objTwitterAccount = Api.Socioboard.Repositories.TwitterRepository.getTwitterAccount(prId, _redisCache, dbr);
                            string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.Twitter, objTwitterAccount.profileImageUrl, objTwitterAccount.twitterName, null, dbr, _appSettings);
                        }
                        else if (item.StartsWith("lin"))
                        {
                            string prId = item.Substring(4);
                            Domain.Socioboard.Models.LinkedInAccount objLinkedInAccount = Api.Socioboard.Repositories.LinkedInAccountRepository.getLinkedInAccount(prId, _redisCache, dbr);
                            string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.LinkedIn, objLinkedInAccount.ProfileImageUrl, objLinkedInAccount.LinkedinUserName, null, dbr, _appSettings);
                        }
                        else if (item.StartsWith("Cmpylinpage"))
                        {
                            string prId = item.Substring(12);
                            Domain.Socioboard.Models.LinkedinCompanyPage objLinkedinCompanyPage = Api.Socioboard.Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(prId, _redisCache, dbr);
                            string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage, objLinkedinCompanyPage.LogoUrl, objLinkedinCompanyPage.LinkedinPageName, null, dbr, _appSettings);
                        }
                    }
                    return(Ok("Added Successfully"));
                }
            }
            catch (Exception)
            {
                return(Ok("Can't Add Rss Url"));
            }
            return(Ok("Can't Add Rss Url"));
        }
示例#18
0
        public static List <Domain.Socioboard.Models.profilesdetail> SearchProfileType(long groupId, string Profiletype, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            try
            {
                List <Domain.Socioboard.Models.Groupprofiles> inMemGroupProfiles = _redisCache.Get <List <Domain.Socioboard.Models.Groupprofiles> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                if (inMemGroupProfiles != null)
                {
                    // return inMemGroupProfiles;
                }
            }
            catch { }
            List <Domain.Socioboard.Models.profilesdetail> lstprofiledetail = new List <profilesdetail>();
            {
                if (Profiletype == "Facebook")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> FbProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles profil in FbProfiles)
                    {
                        Domain.Socioboard.Models.Facebookaccounts fbAcc          = Repositories.FacebookRepository.getFacebookAccount(profil.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail   profiledetails = new profilesdetail();
                        profiledetails.Fbaccount = fbAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "FacebookPage")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> Fbpage = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles page in Fbpage)
                    {
                        Domain.Socioboard.Models.Facebookaccounts fbpageAcc      = Repositories.FacebookRepository.getFacebookAccount(page.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail   profiledetails = new profilesdetail();
                        profiledetails.Fbaccount = fbpageAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "twitter")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> TwitterProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles Twitter in TwitterProfiles)
                    {
                        Domain.Socioboard.Models.TwitterAccount twtAcc         = Repositories.TwitterRepository.getTwitterAccount(Twitter.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail();
                        profiledetails.Twtaccount = twtAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "instagram")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> InstagramProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles Instagram in InstagramProfiles)
                    {
                        Domain.Socioboard.Models.Instagramaccounts insAcc         = Repositories.InstagramRepository.getInstagramAccount(Instagram.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail    profiledetails = new profilesdetail();
                        profiledetails.Instaaccount = insAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "googlepluse")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> GPlusProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.GPlus).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles GPlus in GPlusProfiles)
                    {
                        Domain.Socioboard.Models.Googleplusaccounts gPlusAcc       = Repositories.GplusRepository.getGPlusAccount(GPlus.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail     profiledetails = new profilesdetail();
                        profiledetails.Gplusaccount = gPlusAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "linkedin")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> LinkedInProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles LinkedIn in LinkedInProfiles)
                    {
                        Domain.Socioboard.Models.LinkedInAccount linkdAcc       = Repositories.LinkedInAccountRepository.getLinkedInAccount(LinkedIn.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail  profiledetails = new profilesdetail();
                        profiledetails.LinkdInaccount = linkdAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "linkedincompanypage")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> LinkedInComapanyPageProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage).ToList();

                    foreach (Domain.Socioboard.Models.Groupprofiles LinkedInComapanyPage in LinkedInComapanyPageProfiles)
                    {
                        Domain.Socioboard.Models.LinkedinCompanyPage LinkedcompanyAcc = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(LinkedInComapanyPage.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail      profiledetails   = new profilesdetail();
                        profiledetails.LinkdINcompanyaccount = LinkedcompanyAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "Youtube")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> YouTubeProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.YouTube).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles YouTube in YouTubeProfiles)
                    {
                        Domain.Socioboard.Models.YoutubeChannel YTChnl         = Repositories.GplusRepository.getYTChannel(YouTube.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail();
                        profiledetails.Ytubeaccount = YTChnl;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "GAnalytics")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> GoogleAnalyticsProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics).ToList();

                    foreach (Domain.Socioboard.Models.Groupprofiles GoogleAnalytics in GoogleAnalyticsProfiles)
                    {
                        Domain.Socioboard.Models.GoogleAnalyticsAccount gAAcc          = Repositories.GplusRepository.getGAAccount(GoogleAnalytics.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail         profiledetails = new profilesdetail();
                        profiledetails.GAaccount = gAAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "Pinterest")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> PinterestProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Pinterest).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles Pinterest in PinterestProfiles)
                    {
                        Domain.Socioboard.Models.PinterestAccount PinAcc         = Repositories.PinterestRepository.getPinterestAccountDetail(Pinterest.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail   profiledetails = new profilesdetail();
                        profiledetails.Pintrestaccount = PinAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }

                return(lstprofiledetail);
            }
        }
示例#19
0
 public IActionResult PluginScheduleMessage(string profile, string twitterText, string tweetId, string tweetUrl, string facebookText, string url, string imgUrl, long userId, string scheduleTime, string localscheduleTime)
 {
     string[] profiles = profile.Split(',');
     foreach (var item in profiles)
     {
         string[] ids = item.Split('~');
         if (ids[1] == "facebook")
         {
             try
             {
                 string updatedtext = "";
                 string postmessage = "";
                 if (!string.IsNullOrEmpty(facebookText))
                 {
                     string[] updatedmessgae = Regex.Split(facebookText, "<br>");
                     foreach (var items in updatedmessgae)
                     {
                         if (!string.IsNullOrEmpty(items))
                         {
                             if (items.Contains("https://") || items.Contains("http://"))
                             {
                                 if (string.IsNullOrEmpty(url))
                                 {
                                     url = items;
                                     if (items.Contains("https://"))
                                     {
                                         string link = getBetween(url + "###", "https", "###");
                                         link = "https" + link;
                                         url  = link;
                                     }
                                     if (items.Contains("http://"))
                                     {
                                         string link = getBetween(url + "###", "http", "###");
                                         link = "http" + link;
                                         url  = link;
                                     }
                                 }
                             }
                             if (items.Contains("hhh") || items.Contains("nnn"))
                             {
                                 if (items.Contains("hhh"))
                                 {
                                     postmessage = postmessage + "\n\r" + items.Replace("hhh", "#");
                                 }
                                 else
                                 {
                                     postmessage = postmessage + "\n\r" + items;
                                 }
                             }
                             else
                             {
                                 postmessage = postmessage + "\n\r" + items;
                             }
                         }
                     }
                 }
                 updatedtext = postmessage;
                 DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
                 Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(ids[0], _redisCache, dbr);
                 Helper.ScheduleMessageHelper.ScheduleMessage(ids[0], objFacebookAccount.FbUserName, updatedtext.ToString(), Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage, userId, url, imgUrl, "https://graph.facebook.com/" + ids[0] + "/picture?type=small", scheduleTime, localscheduleTime, _appSettings, _redisCache, dbr, _logger);
             }
             catch (Exception ex)
             {
             }
         }
         else
         {
             try
             {
                 DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
                 if (!string.IsNullOrEmpty(twitterText) || !string.IsNullOrEmpty(imgUrl))
                 {
                     twitterText = twitterText + " " + tweetUrl;
                     Domain.Socioboard.Models.TwitterAccount objTwitterAccount = Api.Socioboard.Repositories.TwitterRepository.getTwitterAccount(ids[0], _redisCache, dbr);
                     Helper.ScheduleMessageHelper.ScheduleMessage(ids[0], objTwitterAccount.twitterScreenName, twitterText, Domain.Socioboard.Enum.SocialProfileType.Twitter, userId, "", imgUrl, objTwitterAccount.profileImageUrl, scheduleTime, localscheduleTime, _appSettings, _redisCache, dbr, _logger);
                 }
                 else
                 {
                     string data = TwitterRepository.TwitterRetweet_post(ids[0], tweetId, userId, 0, dbr, _logger, _redisCache, _appSettings);
                 }
             }
             catch (Exception ex)
             {
             }
         }
     }
     return(Ok());
 }
示例#20
0
        public async Task <ActionResult> ScheduleMessage(string message, string profileId, long userId, string imagePath, string link, string scheduledatetime, IFormFile files)
        {
            var    filename    = "";
            string postmessage = "";
            var    uploads     = _appEnv.WebRootPath + "\\wwwwroot\\upload\\" + profileId;

            if (files != null)
            {
                if (files.Length > 0)
                {
                    var fileName = Microsoft.Net.Http.Headers.ContentDispositionHeaderValue.Parse(files.ContentDisposition).FileName.Trim('"');
                    // await file.s(Path.Combine(uploads, fileName));
                    filename = Microsoft.Net.Http.Headers.ContentDispositionHeaderValue
                               .Parse(files.ContentDisposition)
                               .FileName
                               .Trim('"');
                    //apiimgPath = _appSettings.ApiDomain + "/api/Media/get?id=" + $@"{Domain.Socioboard.Helpers.SBHelper.RandomString(10) + '.' + fileName.Split('.')[1]}";
                    var tempName = Domain.Socioboard.Helpers.SBHelper.RandomString(10) + '.' + fileName.Split('.')[1];
                    filename = _appEnv.WebRootPath + "\\upload" + $@"\{tempName}";

                    uploads = _appSettings.ApiDomain + "/api/Media/get?id=" + $@"{tempName}";

                    // size += file.Length;
                    using (FileStream fs = System.IO.File.Create(filename))
                    {
                        files.CopyTo(fs);
                        fs.Flush();
                    }
                    filename = uploads;
                }
            }
            else if (!string.IsNullOrEmpty(imagePath))
            {
                filename = imagePath;
            }


            string[] updatedmessgae = Regex.Split(message, "<br>");
            foreach (var item in updatedmessgae)
            {
                if (!string.IsNullOrEmpty(item))
                {
                    if (item.Contains("https://") || item.Contains("http://"))
                    {
                        link = item;
                    }
                    if (item.Contains("hhh") || item.Contains("nnn"))
                    {
                        if (item.Contains("hhh"))
                        {
                            postmessage = postmessage + "\n\r" + item.Replace("hhh", "#");
                        }
                    }
                    else
                    {
                        postmessage = postmessage + "\n\r" + item;
                    }
                }
            }
            message = postmessage;

            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);

            string[] lstProfileIds = null;
            if (profileId != null)
            {
                lstProfileIds = profileId.Split(',');
                profileId     = lstProfileIds[0];
            }
            else
            {
                return(Ok("profileId required"));
            }

            string retunMsg = string.Empty;

            foreach (var item in lstProfileIds)
            {
                if (item.StartsWith("fb"))
                {
                    try
                    {
                        string prId = item.Substring(3, item.Length - 3);
                        Domain.Socioboard.Models.Facebookaccounts objFacebookaccounts = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(prId, _redisCache, dbr);
                        Helper.ScheduleMessageHelper.ScheduleMessage(prId, objFacebookaccounts.FbUserName, message, Domain.Socioboard.Enum.SocialProfileType.Facebook, userId, filename, "https://graph.facebook.com/" + prId + "/picture?type=small", scheduledatetime, _appSettings, _redisCache, dbr, _logger);
                    }
                    catch (System.Exception ex)
                    {
                        _logger.LogError(ex.StackTrace);
                        //return Ok("Issue With Facebook schedulers");
                    }
                }
                if (item.StartsWith("page"))
                {
                    try
                    {
                        string prId = item.Substring(5, item.Length - 5);
                        Domain.Socioboard.Models.Facebookaccounts objFacebookaccounts = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(prId, _redisCache, dbr);
                        Helper.ScheduleMessageHelper.ScheduleMessage(prId, objFacebookaccounts.FbUserName, message, Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage, userId, filename, "https://graph.facebook.com/" + prId + "/picture?type=small", scheduledatetime, _appSettings, _redisCache, dbr, _logger);
                    }
                    catch (System.Exception ex)
                    {
                        _logger.LogError(ex.StackTrace);
                        // return Ok("Issue With Facebook Page schedulers");
                    }
                }
                if (item.StartsWith("tw"))
                {
                    try
                    {
                        string prId = item.Substring(3, item.Length - 3);
                        Domain.Socioboard.Models.TwitterAccount objTwitterAccount = Api.Socioboard.Repositories.TwitterRepository.getTwitterAccount(prId, _redisCache, dbr);
                        Helper.ScheduleMessageHelper.ScheduleMessage(prId, objTwitterAccount.twitterScreenName, message, Domain.Socioboard.Enum.SocialProfileType.Twitter, userId, filename, objTwitterAccount.profileImageUrl, scheduledatetime, _appSettings, _redisCache, dbr, _logger);
                    }
                    catch (System.Exception ex)
                    {
                        _logger.LogError(ex.StackTrace);

                        // return Ok("Issue With Twitter schedulers");
                    }
                }
                if (item.StartsWith("lin"))
                {
                    try
                    {
                        string prId = item.Substring(4, item.Length - 4);
                        Domain.Socioboard.Models.LinkedInAccount objLinkedInAccount = Api.Socioboard.Repositories.LinkedInAccountRepository.getLinkedInAccount(prId, _redisCache, dbr);
                        Helper.ScheduleMessageHelper.ScheduleMessage(prId, objLinkedInAccount.LinkedinUserName, message, Domain.Socioboard.Enum.SocialProfileType.LinkedIn, userId, filename, objLinkedInAccount.ProfileImageUrl, scheduledatetime, _appSettings, _redisCache, dbr, _logger);
                    }
                    catch (System.Exception ex)
                    {
                        _logger.LogError(ex.StackTrace);

                        // return Ok("Issue With Linkedin schedulers");
                    }
                }
                if (item.StartsWith("Cmpylinpage"))
                {
                    try
                    {
                        string prId = item.Substring(12, item.Length - 12);
                        Domain.Socioboard.Models.LinkedinCompanyPage objLinkedinCompanyPage = Api.Socioboard.Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(prId, _redisCache, dbr);
                        Helper.ScheduleMessageHelper.ScheduleMessage(prId, objLinkedinCompanyPage.LinkedinPageName, message, Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage, userId, filename, objLinkedinCompanyPage.LogoUrl, scheduledatetime, _appSettings, _redisCache, dbr, _logger);
                    }
                    catch (System.Exception ex)
                    {
                        _logger.LogError(ex.StackTrace);

                        // return Ok("Issue With Linkedin Page schedulers");
                    }
                }
            }
            return(Ok("scheduled"));
        }