// GET: /<controller>/ public IActionResult Index(int id) { ViewMain model = new ViewMain(); model.User = context.Users.Find(id); var Tweets = context.Tweets.OrderByDescending(x => x.ShareDate).ToList(); model.HashTags = context.HashTags.OrderBy(x => x.TweetHashTag.Count).Take(5).ToList(); model.Users = context.Users.ToList(); foreach (Tweet tweet in Tweets) { var likes = context.Likes.Where(x => x.TweetId == tweet.id).ToList(); var retweets = context.ReTweets.Where(x => x.TweetId == tweet.id).ToList(); TweetDetail detail = new TweetDetail(); detail.Tweet = tweet; detail.Likes = likes; detail.ReTweets = retweets; model.TweetDetails.Add(detail); } return(View(model)); }
public IActionResult Index(string username) { ViewMain model = new ViewMain(); Users user = new Users(); user = context.Users.Where(x => x.UserName == username).FirstOrDefault(); model.User = user; var Tweets = context.Tweets.Where(x => x.UserId == user.Id).OrderByDescending(x => x.ShareDate).ToList(); model.HashTags = context.HashTags.OrderBy(x => x.TweetHashTag.Count).Take(5).ToList(); model.Users = context.Users.ToList(); model.Follows = user.Follows.ToList(); //Takip Edilenler model.Followers = context.Follows.Where(x => x.User == user).ToList(); //Takip edenler var notfriend = model.Followers.Except(model.Follows).Take(2); //Önerilen kişiler foreach (Follow fw in notfriend) { model.Users.Add(fw.User); } foreach (Tweet tweet in Tweets) { var likes = context.Likes.Where(x => x.TweetId == tweet.id).ToList(); var retweets = context.ReTweets.Where(x => x.TweetId == tweet.id).ToList(); TweetDetail detail = new TweetDetail(); detail.Tweet = tweet; detail.Likes = likes; detail.ReTweets = retweets; model.TweetDetails.Add(detail); } return(View(model)); }
/// <summary> /// 下载文章详情 /// </summary> private void DownloadDocument(string uri) { WebClient proxy = Tool.SendWebClient(uri, new Dictionary <string, string>( )); proxy.DownloadStringCompleted += (s, e) => { if (e.Error != null) { System.Diagnostics.Debug.WriteLine("获取 {0} 网络错误: {0}", this.DetailType.ToString( ), e.Error.Message); return; } }; switch (this.DetailType) { case DetailType.News: proxy.DownloadStringCompleted += (s, e) => { NewsDetail n = Tool.GetNewsDetail(e.Result); if (n != null) { this.newsDetail = n; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_News(n))); this.CheckApplicationBarByDetailType( ); this.lblCommentCount.Text = string.Format("评论({0})", this.newsDetail.commentCount); } }; break; case DetailType.Post: proxy.DownloadStringCompleted += (s, e) => { PostDetail p = Tool.GetPostDetail(e.Result); if (p != null) { this.postDetail = p; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_Post(p))); this.CheckApplicationBarByDetailType( ); this.lblCommentCount.Text = string.Format("评论({0})", this.postDetail.answerCount); } }; break; case DetailType.Blog: proxy.DownloadStringCompleted += (s, e) => { BlogDetail b = Tool.GetBlogDetail(e.Result); if (b != null) { this.blogDetail = b; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_Blog(b))); this.CheckApplicationBarByDetailType( ); this.lblCommentCount.Text = string.Format("评论({0})", this.blogDetail.commentCount); //这里特别注意 要获取一下owneruid this.commentListControl.owneruid = this.blogDetail.authorID.ToString( ); } }; break; case DetailType.Software: proxy.DownloadStringCompleted += (s, e) => { SoftwareDetail soft = Tool.GetSoftwareDetail(e.Result); if (soft != null) { this.softwareDetail = soft; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_Software(soft))); this.CheckApplicationBarByDetailType( ); } }; break; case DetailType.Tweet: proxy.DownloadStringCompleted += (s, e) => { TweetDetail t = Tool.GetTweetDetail(e.Result); if (t != null) { this.tweetDetail = t; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_Tweet(t))); this.CheckApplicationBarByDetailType( ); this.lblCommentCount.Text = string.Format("评论({0})", this.tweetDetail.commentCount); } }; break; } GC.Collect( ); }
public NeuroniaViewModel(CoreDispatcher dispatcher, ConsumerData consumerData) : base(Messenger.Default) { SharedDispatcher.Dispatcher = dispatcher; twitterUIComponent = new TwitterUIComponent(); accountList = new ObservableCollection <TwitterAccount>(); TimelineListTab = new ObservableCollection <TimelineTab>(); NowTimelineList = new ObservableCollection <TimelineBase>(); SearchDetail = new SearchDetail(); Setting = new SettingData(); TweetDetail = new TweetDetail(new TimelineRow(Tweet.ZeroTweet, "", Setting, CallRowAction)); DMDetail = new DirectMessageDetail(); UserDetail = new UserDetail(); NotifyMessage = new NotificationMessage(); IsFirstNavigate = true; this.consumerData = consumerData; this.connectionStatusStr = ""; Authorizer = new TwitterAuthorizer(); restTimerCounter = 0; LicenseInfo = CurrentApp.LicenseInformation; RestTimer = new DispatcherTimer(); RestTimer.Interval = TimeSpan.FromMinutes(1); RestTimer.Tick += (s, e) => Task.Run(async() => { await SharedDispatcher.RunAsync(() => { NowTime = DateTime.Now; NowTimeStr = NowTime.ToString("HH:mm"); }); if (restTimerCounter % 2 == 0) { foreach (var tab in TimelineListTab) { foreach (var t in tab.TimelineList) { await t.RestUpdate(); } } } if (restTimerCounter % 10 == 0) { TwitterUIComponent.MentionSuggestSourceList.Clear(); TwitterUIComponent.HashSuggestSourceList.Clear(); foreach (var tab in TimelineListTab) { foreach (var t in tab.TimelineList) { foreach (var ac in (await t.GetTimelineAccountListAsync())) { TwitterUIComponent.MentionSuggestSourceList.Add(ac); } foreach (var ac in (await t.GetTimelineHashTagListAsync())) { TwitterUIComponent.HashSuggestSourceList.Add(ac); } } } } restTimerCounter++; if (restTimerCounter > 100) { restTimerCounter = 0; } }); RestTimer.Start(); CommandInitialize(); timelineWidth = 320; IsFirstLaunch = true; if (LicenseInfo.ProductLicenses["ApplicationTheme"].IsActive) { IsPurchase = true; } else { IsPurchase = false; } }
public NeuroniaModel(CoreDispatcher dispatcher, ConsumerData consumerData) { SharedDispatcher.Dispatcher = dispatcher; twitterUIComponent = new TwitterUIComponent(); accountList = new ObservableCollection<TwitterAccount>(); TimelineListTab = new ObservableCollection<TimelineTab>(); NowTimelineList = new ObservableCollection<TimelineBase>(); SearchDetail = new SearchDetail(); Setting = new SettingData(); TweetDetail = new TweetDetail(new TimelineRow(Tweet.ZeroTweet,"",Setting,CallRowAction)); DMDetail = new DirectMessageDetail(); UserDetail = new UserDetail(); NotifyMessage = new NotificationMessage(); IsFirstNavigate = true; this.consumerData = consumerData; this.connectionStatusStr = ""; Authorizer = new TwitterAuthorizer(); restTimerCounter = 0; LicenseInfo = CurrentApp.LicenseInformation; RestTimer = new DispatcherTimer(); RestTimer.Interval = TimeSpan.FromMinutes(1); RestTimer.Tick += (s, e) => Task.Run(async() => { await SharedDispatcher.RunAsync(() => { NowTime = DateTime.Now; NowTimeStr = NowTime.ToString("HH:mm"); }); if (restTimerCounter%2 == 0) { foreach (var tab in TimelineListTab) { foreach (var t in tab.TimelineList) { await t.RestUpdate(); } } } if (restTimerCounter%10 == 0) { TwitterUIComponent.MentionSuggestSourceList.Clear(); TwitterUIComponent.HashSuggestSourceList.Clear(); foreach (var tab in TimelineListTab) { foreach (var t in tab.TimelineList) { foreach (var ac in (await t.GetTimelineAccountListAsync())) { TwitterUIComponent.MentionSuggestSourceList.Add(ac); } foreach (var ac in (await t.GetTimelineHashTagListAsync())) { TwitterUIComponent.HashSuggestSourceList.Add(ac); } } } } restTimerCounter++; if (restTimerCounter > 100) { restTimerCounter = 0; } }); RestTimer.Start(); timelineWidth = 320; IsFirstLaunch = true; if (LicenseInfo.ProductLicenses["ApplicationTheme"].IsActive) { IsPurchase = true; } else { IsPurchase = false; } }