Пример #1
0
 public IActionResult PluginComposemessage(string profile, string twitterText, string tweetId, string tweetUrl, string facebookText, string url, string imgUrl, long userId)
 {
     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);
             string ret = Helper.FacebookHelper.ComposeMessage(objFacebookAccount.FbProfileType, objFacebookAccount.AccessToken, objFacebookAccount.FbUserId, facebookText, ids[0], userId, imgUrl, url, dbr, _logger);
         }
         else
         {
             DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
             if (!string.IsNullOrEmpty(twitterText) || !string.IsNullOrEmpty(imgUrl))
             {
                 twitterText = twitterText + " " + tweetUrl;
                 string ret = Helper.TwitterHelper.PostTwitterMessage(_appSettings, _redisCache, twitterText, ids[0], userId, imgUrl, true, dbr, _logger);
             }
             else
             {
                 string data = TwitterRepository.TwitterRetweet_post(ids[0], tweetId, userId, 0, dbr, _logger, _redisCache, _appSettings);
             }
         }
     }
     return(Ok());
 }
        public string UpdateBoard(Domain.Socioboard.Models.MongoBoards boards)
        {
            try
            {
                DatabaseRepository dbr = new DatabaseRepository();
                if (!string.IsNullOrEmpty(boards.twitterHashTag))
                {
                    TwitterRepository twtrepo = new TwitterRepository();
                    boards.twitterHashTag = twtrepo.AddTwitterHashTag(boards.twitterHashTag, boards.id.ToString());
                }
                if (!string.IsNullOrEmpty(boards.instagramHashTag))
                {
                    InstagramRepository instRepo = new InstagramRepository();
                    boards.instagramHashTag = instRepo.AddInstagramHashTag(boards.instagramHashTag, boards.id.ToString());
                }
                if (!string.IsNullOrEmpty(boards.gplusHashTag))
                {
                    GplusRepository gplusRepo = new GplusRepository();
                    boards.gplusHashTag = gplusRepo.AddGplusHashTag(boards.gplusHashTag, boards.id.ToString());
                }

                dbr.Update <Domain.Socioboard.Models.MongoBoards>(boards);
                return("update");
            }
            catch (Exception)
            {
                return("Issue in board updation");
            }
        }
Пример #3
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());
 }
Пример #4
0
        public void TestTextToShowReTweet()
        {
            TwitterRepository tw = new TwitterRepository();
            var firstTweet       = tw.GetTweets().Where(o => o.retweeted_status != null).ToList().FirstOrDefault();

            Assert.AreNotEqual("RT ", firstTweet.textToShow().Substring(0, 3));
        }
        public async Task <IActionResult> getTwitterFeeds(long boardId, int skip, int count)
        {
            try
            {
                DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
                Domain.Socioboard.Models.MongoBoards board = BoardMeRepository.getBoard(boardId, _redisCache, _appSettings, _logger, dbr);
                MongoRepository          mongorepo         = new MongoRepository("MongoBoardTwitterHashTag", _appSettings);
                MongoBoardTwitterHashTag twitterhashtag    = await mongorepo.FindFirstOrDefault <MongoBoardTwitterHashTag>(x => x.Boardid.Equals(board.boardId)).ConfigureAwait(false);

                List <MongoBoardTwtFeeds> twtFeedsList = TwitterRepository.AddBoardTwitterHashTagFeeds(twitterhashtag.Screenname, board.twitterHashTag, null, _appSettings, _logger);
                if (twtFeedsList.Count == 0)
                {
                    MongoRepository            boardrepo          = new MongoRepository("MongoBoardTwtFeeds", _appSettings);
                    var                        builder            = Builders <MongoBoardTwtFeeds> .Sort;
                    var                        sort               = builder.Descending(t => t.Publishedtime);
                    IList <MongoBoardTwtFeeds> objTwitterPagelist = await boardrepo.FindWithRange <MongoBoardTwtFeeds>(t => t.Twitterprofileid.Equals(board.twitterHashTag) && t.Feedurl != null, sort, skip, count);

                    return(Ok(objTwitterPagelist));
                }
                return(Ok(twtFeedsList));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return(Ok("Something Went Wrong"));
        }
Пример #6
0
        public void Should_have_same_length()
        {
            ITwitterRepository repository = new TwitterRepository();
            var actual = repository.AggregateTimeLine(TestVectors.TestTweetCollection());

            Assert.Equal(actual.Count(), TestVectors.TestTweets().Count());
        }
Пример #7
0
        public void Should_return_tweet_data_contract()
        {
            ITwitterRepository repository = new TwitterRepository();
            var actual       = repository.AggregateTimeLine(TestVectors.TestTweetCollection());
            var filteredData = repository.FilterByCriteria(actual);

            Assert.Equal(filteredData.GetType(), typeof(TweetDataContract));
        }
Пример #8
0
        public ApplicationServiceTest()
        {
            IApiService        apiService = new ApiService();
            IUrlBuilder        urlBuilder = new UrlBuilder();
            ITwitterRepository repository = new TwitterRepository();

            this._service = new ApplicationService(repository, apiService, urlBuilder);
        }
Пример #9
0
        public void TestShowDateTimeOfTweet()
        {
            TwitterRepository tw = new TwitterRepository();
            var firstTweet       = tw.GetTweets().ToList().FirstOrDefault();

            firstTweet.created_at = "Thu Mar 01 08:01:58 +0000 2018";

            Assert.AreEqual("03/01/2018 08:01 AM", firstTweet.showDateTime());
        }
Пример #10
0
        public void Should_have_same_members()
        {
            ITwitterRepository repository = new TwitterRepository();
            var actual = repository.AggregateTimeLine(TestVectors.TestTweetCollection());

            var fromTest = TestVectors.TestTweets().Where(a => a.Text == "Bad Cat").Select(a => a.User).First();
            var fromRepo = actual.Where(a => a.Text == "Bad Cat").Select(a => a.User).First();

            Assert.Equal(fromTest.Name, fromRepo.Name);
        }
Пример #11
0
        public void TweetDataContract_should_match()
        {
            ITwitterRepository repository = new TwitterRepository();
            var actual       = repository.AggregateTimeLine(TestVectors.TestTweetCollection());
            var filteredData = repository.FilterByCriteria(actual);

            var fromRepo = filteredData.TimeLine.First();
            var fromTest = TestVectors.TestTweets().First(a => a.User.Id == fromRepo.User.Id);

            fromRepo.User.Name.Should().BeEquivalentTo(fromTest.User.Name);
        }
Пример #12
0
        public TwitterService()
        {
            twitterRepository = new TwitterRepository();
            Auth.SetUserCredentials(AppConfiguration.TwitterConsumerKey,
                                    AppConfiguration.TwitterConsumerSecret,
                                    AppConfiguration.TwitterUserAccessToken,
                                    AppConfiguration.TwitterUserAccessSecret);
            LogManager.Configuration = new XmlLoggingConfiguration(AppConfiguration.NLogPath);

            logger = LogManager.GetCurrentClassLogger();
        }
Пример #13
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));
        }
Пример #14
0
        static void Main(string[] args)
        {
            QueryBuilder      queryBuilder      = new QueryBuilder();
            TwitterRepository twitterRepository = new TwitterRepository();
            ArchiveRepository archiveRepository = new ArchiveRepository();

            var isUsername = isUsernameNotHashtag();
            var searchText = GetSearchText(isUsername);

            var builtQuery = queryBuilder.GenerateQuery(searchText, isUsername);
            var result     = twitterRepository.GetTweetsByUri(builtQuery, 10).ConfigureAwait(false);

            Console.WriteLine("Archiving results");
        }
Пример #15
0
        public IActionResult AddTwitterAccount(long userId, long groupId, string requestToken, string requestSecret, string requestVerifier, bool follow)
        {
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
            var dbr   = new DatabaseRepository(_logger, _appEnv);
            var OAuth = new oAuthTwitter(_appSettings.twitterConsumerKey,
                                         _appSettings.twitterConsumerScreatKey, _appSettings.twitterRedirectionUrl)
            {
                AccessToken       = requestToken,
                AccessTokenSecret = requestVerifier
            };

            OAuth.GetTwitterAccessToken(requestToken, requestVerifier);
            var output = TwitterRepository.AddTwitterAccount(userId, groupId, follow, dbr, OAuth, _logger, _redisCache, _appSettings);

            if (output.Contains("Twitter account already added by you") || output.Contains("This Account is added by other user") || output.Contains("Issue while fetching twitter userId") || output.Contains("Your Twitter profile is not Authorized to add") || output.Contains("Error while Adding Account"))
            {
                return(BadRequest(output));
            }

            return(Ok(output));
        }
Пример #16
0
 private void SavedTwitter(List <TwitterObject> twitter, string param)
 {
     try
     {
         using (var twitterRepository = new TwitterRepository())
         {
             foreach (var item in twitter)
             {
                 if (!twitterRepository.ExistsTwitter(item.id))
                 {
                     item.textoSearch = param;
                     twitterRepository.SaveTwitter(new TweetedSave(item));
                 }
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #17
0
        public void TestLastTenTweets()
        {
            TwitterRepository tw = new TwitterRepository();

            Assert.AreEqual(10, tw.GetTweets().ToList().Count);
        }
Пример #18
0
        public IActionResult PluginComposemessage(string profile, string twitterText, string tweetId, string tweetUrl, string facebookText, string url, string imgUrl, long userId)
        {
            string[] profiles = profile.Split(',');

            int i = 0;

            foreach (var item in profiles)
            {
                string[] ids = item.Split('~');
                if (ids[1] == "facebook")
                {
                    string             updatedtext = "";
                    string             postmessage = "";
                    DatabaseRepository dbr         = new DatabaseRepository(_logger, _appEnv);
                    Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(ids[0], _redisCache, dbr);
                    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.Replace(url, "");
                    int count = dbr.GetCount <ScheduledMessage>(t => t.shareMessage == updatedtext && t.profileId == objFacebookAccount.FbUserId && t.url == imgUrl && t.scheduleTime.Date == DateTime.UtcNow.Date);
                    if (count > 0)
                    {
                        i++;
                    }
                    else
                    {
                        string ret = Helper.FacebookHelper.ComposeMessage(objFacebookAccount.FbProfileType, objFacebookAccount.AccessToken, objFacebookAccount.FbUserId, updatedtext, ids[0], userId, imgUrl, url, dbr, _logger);
                    }
                }
                else
                {
                    DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
                    if (!string.IsNullOrEmpty(twitterText) || !string.IsNullOrEmpty(imgUrl))
                    {
                        twitterText = twitterText + " " + tweetUrl;
                        int count = dbr.GetCount <ScheduledMessage>(t => t.shareMessage == twitterText && t.profileId == ids[0] && t.url == imgUrl && t.scheduleTime.Date == DateTime.UtcNow.Date);
                        if (count > 0)
                        {
                            i++;
                        }
                        else
                        {
                            string ret = Helper.TwitterHelper.PostTwitterMessage(_appSettings, _redisCache, twitterText, ids[0], userId, imgUrl, true, dbr, _logger);
                        }
                    }
                    else
                    {
                        string data = TwitterRepository.TwitterRetweet_post(ids[0], tweetId, userId, 0, dbr, _logger, _redisCache, _appSettings);
                    }
                }
            }
            if (i > 0)
            {
                return(Ok("it seems you already posted this message to few profiles"));
            }
            return(Ok("successfully posted"));
        }
Пример #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 void TestSearchTweetsReturnNothing()
        {
            TwitterRepository tw = new TwitterRepository();

            Assert.AreEqual(0, tw.GetTweets("nowayeverthiswouldbeinatweet").ToList().Count);
        }
Пример #21
0
        public static string DeleteProfile(long userId, long groupId, Helper.Cache _redisCache, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings)
        {
            Domain.Socioboard.Models.Groups grp = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.id == groupId).FirstOrDefault();
            IList <Domain.Socioboard.Models.Groupprofiles> grpProfiles = dbr.Find <Groupprofiles>(t => t.groupId == groupId);

            if (grpProfiles.Count != 0)
            {
                foreach (Domain.Socioboard.Models.Groupprofiles grpProfile in grpProfiles)
                {
                    string res = string.Empty;
                    if (grpProfile != null)
                    {
                        try
                        {
                            switch (grpProfile.profileType)
                            {
                            case Domain.Socioboard.Enum.SocialProfileType.Facebook:
                            {
                                res = FacebookRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage:
                            {
                                res = FacebookRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.FacebookPublicPage:
                            {
                                res = FacebookRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.Twitter:
                            {
                                res = TwitterRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.LinkedIn:
                            {
                                res = LinkedInAccountRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage:
                            {
                                res = LinkedInAccountRepository.DeleteCompanyPageProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.Instagram:
                            {
                                res = InstagramRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics:
                            {
                                res = GplusRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.GPlus:
                            {
                                res = GplusRepository.DeleteGplusProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.YouTube:
                            {
                                res = GplusRepository.DeleteYoutubeChannelProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.Pinterest:
                            {
                                res = PinterestRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        try
                        {
                            if (res.Equals("Deleted"))
                            {
                                dbr.Delete <Domain.Socioboard.Models.Groupprofiles>(grpProfile);
                                // dbr.Delete<Domain.Socioboard.Models.Groups>(t => t.id == groupId);
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                            }
                            else
                            {
                                if (grpProfile != null)
                                {
                                    dbr.Delete <Domain.Socioboard.Models.Groupprofiles>(grpProfile);
                                    //dbr.Delete<Domain.Socioboard.Models.Groups>(t => t.id == groupId);
                                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    else
                    {
                        return("Issue while deleting Profile");
                    }
                }
                dbr.Delete <Domain.Socioboard.Models.Groups>(grp);
                return("Deleted");
            }
            else
            {
                dbr.Delete <Domain.Socioboard.Models.Groups>(grp);
            }


            return("Deleted");
        }
        public static string DeleteProfile(long groupId, long userId, string profileId, Helper.Cache _redisCache, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings)
        {
            Domain.Socioboard.Models.Groupprofiles grpProfile = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileId.Equals(profileId)).FirstOrDefault();
            Domain.Socioboard.Models.Groups        grp        = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.id == groupId).FirstOrDefault();
            string res = string.Empty;

            if (grpProfile != null)
            {
                if (grp.groupName.Equals(Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName))
                {
                    switch (grpProfile.profileType)
                    {
                    case Domain.Socioboard.Enum.SocialProfileType.Facebook:
                    {
                        res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage:
                    {
                        res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.FacebookPublicPage:
                    {
                        res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.Twitter:
                    {
                        res = TwitterRepository.DeleteProfile(dbr, profileId, userId, _redisCache);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.LinkedIn:
                    {
                        res = LinkedInAccountRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage:
                    {
                        res = LinkedInAccountRepository.DeleteCompanyPageProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.Instagram:
                    {
                        res = InstagramRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics:
                    {
                        res = GplusRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.GPlus:
                    {
                        res = GplusRepository.DeleteGplusProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }
                    }
                }
                else
                {
                    Groups defaultGroup = GroupsRepository.getAllGroupsofUser(userId, _redisCache, dbr).Find(t => t.groupName.Equals(Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName));
                    List <Groupprofiles> defalutGroupProfiles = getGroupProfiles(defaultGroup.id, _redisCache, dbr);
                    if (defalutGroupProfiles != null && defalutGroupProfiles.Count(t => t.profileId.Equals(profileId)) <= 0)
                    {
                        switch (grpProfile.profileType)
                        {
                        case Domain.Socioboard.Enum.SocialProfileType.Facebook:
                        {
                            res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage:
                        {
                            res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.FacebookPublicPage:
                        {
                            res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.Twitter:
                        {
                            res = TwitterRepository.DeleteProfile(dbr, profileId, userId, _redisCache);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.LinkedIn:
                        {
                            res = LinkedInAccountRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage:
                        {
                            res = LinkedInAccountRepository.DeleteCompanyPageProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.Instagram:
                        {
                            res = InstagramRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics:
                        {
                            res = GplusRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.GPlus:
                        {
                            res = GplusRepository.DeleteGplusProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }
                        }
                    }
                    else
                    {
                        res = "Deleted";
                    }
                }

                if (res.Equals("Deleted"))
                {
                    dbr.Delete <Domain.Socioboard.Models.Groupprofiles>(grpProfile);
                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                    return("Deleted");
                }
                else
                {
                    if (grpProfile != null)
                    {
                        dbr.Delete <Domain.Socioboard.Models.Groupprofiles>(grpProfile);
                        _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                        _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                        return("Deleted");
                    }
                    return(res);
                }
            }
            else
            {
                return("Issue while deleting Profile");
            }
        }
Пример #23
0
        private static void AddedProfileDetails(Cache redisCache, DatabaseRepository dbr, List <profilesdetail> groupProfiles, Groupprofiles profile)
        {
            switch (profile.profileType)
            {
            case SocialProfileType.Facebook:
            {
                var fbAcc          = FacebookRepository.getFacebookAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    Fbaccount = fbAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.FacebookFanPage:
            {
                var fbPageAcc      = FacebookRepository.getFacebookAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    Fbaccount = fbPageAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.Twitter:
            {
                var twtAcc         = TwitterRepository.getTwitterAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    Twtaccount = twtAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.Instagram:
            {
                var insAcc         = InstagramRepository.getInstagramAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    Instaaccount = insAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.GPlus:
            {
                var gPlusAcc       = GplusRepository.getGPlusAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    Gplusaccount = gPlusAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.LinkedIn:
            {
                var linkedInAcc    = LinkedInAccountRepository.getLinkedInAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    LinkdInaccount = linkedInAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.LinkedInComapanyPage:
            {
                var linkedCompanyAcc = LinkedInAccountRepository.getLinkedinCompanyPage(profile.profileId, redisCache, dbr);
                var profileDetails   = new profilesdetail {
                    LinkdINcompanyaccount = linkedCompanyAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.YouTube:
            {
                var youtubeChannel = GplusRepository.getYTChannel(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    Ytubeaccount = youtubeChannel
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.GoogleAnalytics:
            {
                var gAAcc          = GplusRepository.getGAAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    GAaccount = gAAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.Pinterest:
            {
                var pInterestAccountDetail = PinterestRepository.getPinterestAccountDetail(profile.profileId, redisCache, dbr);
                var profileDetails         = new profilesdetail {
                    Pintrestaccount = pInterestAccountDetail
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.GplusPage:
                break;

            case SocialProfileType.Tumblr:
                break;

            case SocialProfileType.FacebookPublicPage:
                break;

            case SocialProfileType.DropBox:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #24
0
        private static string DeleteGroup(long userId, string profileId, Cache _redisCache, DatabaseRepository dbr, AppSettings _appSettings, Groupprofiles grpProfile, string res)
        {
            switch (grpProfile.profileType)
            {
            case SocialProfileType.Facebook:
            {
                res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.FacebookFanPage:
            {
                res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.FacebookPublicPage:
            {
                res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.Twitter:
            {
                res = TwitterRepository.DeleteProfile(dbr, profileId, userId, _redisCache);
                break;
            }

            case SocialProfileType.LinkedIn:
            {
                res = LinkedInAccountRepository.DeleteProfile(dbr, profileId, userId, _redisCache,
                                                              _appSettings);
                break;
            }

            case SocialProfileType.LinkedInComapanyPage:
            {
                res = LinkedInAccountRepository.DeleteCompanyPageProfile(dbr, profileId, userId,
                                                                         _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.Instagram:
            {
                res = InstagramRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.GoogleAnalytics:
            {
                res = GplusRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.GPlus:
            {
                res = GplusRepository.DeleteGplusProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.YouTube:
            {
                res = GplusRepository.DeleteYoutubeChannelProfile(dbr, profileId, userId, _redisCache,
                                                                  _appSettings);
                break;
            }

            case SocialProfileType.Pinterest:
            {
                res = PinterestRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }
            }

            return(res);
        }