private List <Message> GetUserActivity() { if (SelectedSocialNetworks == null) { return(null); } List <Message> messages = new List <Message>(); if (SelectedSocialNetworks.Contains(SocialNetworks.Twitter)) { TwitterDataProvider twitterProvider = new TwitterDataProvider(TwitterInformation.ApiInfo); foreach (UserAccountInfo accountInfo in TwitterInformation.UserAccounts) { try { messages.AddRange(twitterProvider.GetUserTweets(accountInfo.UserID, accountInfo.ScreenName, MessageCount)); } catch (ResourceNotFoundException) { _ctrlErrorDescription.InnerText += String.Format("{0}: {1}", SocialMediaResource.ErrorUnknownTwitterAccount, accountInfo.ScreenName); _ctrlErrorDescriptionContainer.Style.Add(System.Web.UI.HtmlTextWriterStyle.Display, "block"); this.InvalidTwitterAccountExist = true; } } } return(messages.OrderByDescending(m => m.PostedOn).Take(MessageCount).ToList()); }
private void CheckInputParameters() { if (SelectedSocialNetworks.Contains(SocialNetworks.Twitter)) { if (TwitterInformation == null) { throw new ArgumentException("You must set TwitterInformation object"); } } if (SelectedSocialNetworks.Contains(SocialNetworks.Facebook)) { if (FacebookInformation == null) { throw new ArgumentException("You must set FacebookInformation object"); } } if (SelectedSocialNetworks.Contains(SocialNetworks.LinkedIn)) { if (LinkedInInformation == null) { throw new ArgumentException("You must set LinkedInInformation object"); } } }
private List <Message> GetUserActivity() { if (SelectedSocialNetworks == null || SelectedSocialNetworks.Count == 0) { return(null); } List <Message> messageList = new List <Message>(MessageCount); Func <List <Message> > dlgGetWallTwitter = GetUserWallTwitter; Func <List <Message> > dlgGetWallFacebook = GetUserWallFacebook; Func <Tenant, List <Message> > dlgGetWallLinkedIn = GetUserWallLinkedIn; IAsyncResult arGetWallTwitter = null; IAsyncResult arGetWallFacebook = null; IAsyncResult arGetWallLinkedIn = null; List <WaitHandle> waitHandles = new List <WaitHandle>(); if (SelectedSocialNetworks.Contains(SocialNetworks.Twitter)) { arGetWallTwitter = dlgGetWallTwitter.BeginInvoke(null, null); waitHandles.Add(arGetWallTwitter.AsyncWaitHandle); } if (SelectedSocialNetworks.Contains(SocialNetworks.Facebook)) { arGetWallFacebook = dlgGetWallFacebook.BeginInvoke(null, null); waitHandles.Add(arGetWallFacebook.AsyncWaitHandle); } if (SelectedSocialNetworks.Contains(SocialNetworks.LinkedIn)) { Tenant currentTenant = CoreContext.TenantManager.GetCurrentTenant(); arGetWallLinkedIn = dlgGetWallLinkedIn.BeginInvoke(currentTenant, null, null); waitHandles.Add(arGetWallLinkedIn.AsyncWaitHandle); } WaitHandle.WaitAll(waitHandles.ToArray()); if (SelectedSocialNetworks.Contains(SocialNetworks.Twitter)) { messageList.AddRange(dlgGetWallTwitter.EndInvoke(arGetWallTwitter)); } if (SelectedSocialNetworks.Contains(SocialNetworks.Facebook)) { messageList.AddRange(dlgGetWallFacebook.EndInvoke(arGetWallFacebook)); } if (SelectedSocialNetworks.Contains(SocialNetworks.LinkedIn)) { messageList.AddRange(dlgGetWallLinkedIn.EndInvoke(arGetWallLinkedIn)); } return(messageList.OrderByDescending(m => m.PostedOn).Take(MessageCount).ToList()); }