Ejemplo n.º 1
0
		private void HandleTextLoadCompletedDetail(BackgroundTextLoadTaskCompletedEventArgs e, ContentPageRequestState reqStateDetail) {
			if(!e.Success){
				this.wbDescription.Document.Body.InnerHtml = "取得失敗";
				this.tabpReview.Text = "レビュー(取得失敗)";
				this.lvReview.Items.Clear();
				this.txtReview.Clear();
				this.StatusMessage = string.Format("詳細ビューでの詳細ページ取得エラー: {0}", e.Error.Message);
				return;
			}
			string text = e.Text;

			if (!reqStateDetail.Age.HasValue) {
				int? age = AdultUtility.FindAdultThresholdInContent(text);
				if (age.HasValue) {
					this.bgTextLoader.AddTaskFirst(new BackgroundTextLoadTask(reqStateDetail.Content.ContentDetailUri, AdultUtility.AdultAnswerBody, new ContentPageRequestState(reqStateDetail.Content, age.Value)));
					return;
				}
			}
			
			Match m = DetailView.regexText.Match(text);
			if (m.Success) {
				string desc = m.Groups["Text"].Value;
				this.wbDescription.Document.Body.InnerHtml = string.Format(
					@"{0}<div style=""{1}"">{2}</ul>",
					reqStateDetail.Age.HasValue ?
						string.Format(@"<div id=""gexplorer_warning"">R{0}のコンテンツです</div>", reqStateDetail.Age.Value)
						: string.Empty,
					this.descriptionStyle,
					desc);
			} else {
				this.wbDescription.Document.Body.InnerHtml =
					string.Format(@"<div id=""gexplorer_warning"">正規表現にマッチしませんでした</div><pre><code>{0}</code></pre>",
						HttpUtility.HtmlEncode(text));
			}
			m = DetailView.regexReviewCount.Match(text);
			if (m.Success) {
				int reviewCount = int.Parse(m.Groups["Count"].Value);
				m = DetailView.regexReviewAverageScore.Match(text);
				if (!m.Success) goto reviewFail;
				int aveScore = int.Parse(m.Groups["Score"].Value);
				this.lvReview.BeginUpdate();
				this.lvReview.Items.Clear();
				for (m = DetailView.regexReviewPost.Match(text); m.Success; m = m.NextMatch()) {
					this.lvReview.Items.Add(new ReviewPostListViewItem(
						int.Parse(m.Groups["ReviewId"].Value),
						m.Groups["NetaBare"].Success,
						int.Parse(m.Groups["Score"].Value),
						int.Parse(m.Groups["Denominator"].Value),
						int.Parse(m.Groups["Numerator"].Value),
						HttpUtility.HtmlDecode(m.Groups["Title"].Value),
						HttpUtility.HtmlDecode(m.Groups["Author"].Value),
						m.Groups["Posted"].Value,
						HttpUtility.HtmlDecode(m.Groups["Body"].Value)));
				}
				this.lvReview.EndUpdate();
				this.tabpReview.Text = string.Format("レビュー(数{0} 評価{1})", reviewCount, aveScore);
				this.reviewTotalCount = reviewCount;
				this.ChangeEnabilityOfReadMoreControls(reviewCount > DetailView.ReviewCountOnDetailPage);
				goto reviewEnd;
			} else {
				goto reviewFail;
			}
		reviewFail:
			this.tabpReview.Text = "レビュー(無いか取得失敗)";
			this.lvReview.Items.Clear();
		reviewEnd:
			this.txtReview.Clear();
		}
Ejemplo n.º 2
0
		private void HandleTextLoadCompletedList(BackgroundTextLoadTaskCompletedEventArgs e, ReviewListPageRequestState reqStateList) {
			if (!e.Success) {
				this.bgTextLoader.ClearTasks();
				this.StatusMessage = string.Format("レビューの追加取得失敗エラー: {0}", e.Error.Message);
				return;
			}
			
			List<ReviewPostListViewItem> lvis = new List<ReviewPostListViewItem>();
			for (Match m = DetailView.regexReviewListPost.Match(e.Text); m.Success; m = m.NextMatch()) {
				lvis.Add(new ReviewPostListViewItem(
						int.Parse(m.Groups["ReviewId"].Value),
						m.Groups["NetaBare"].Success,
						int.Parse(m.Groups["Score"].Value),
						int.Parse(m.Groups["Denominator"].Value),
						int.Parse(m.Groups["Numerator"].Value),
						HttpUtility.HtmlDecode(m.Groups["Title"].Value),
						HttpUtility.HtmlDecode(m.Groups["Author"].Value),
						m.Groups["Posted"].Value,
						HttpUtility.HtmlDecode(m.Groups["Body"].Value)));
			}
			
			if (lvis.Count <= 0) {
				this.bgTextLoader.ClearTasks();
				this.StatusMessage = "レビューの追加取得でレビューが一件も拾えなかった.";
				return;
			} else {
				this.lvReview.Items.AddRange(lvis.ToArray());
			}
		}
Ejemplo n.º 3
0
		private void bgTextLoader_TaskCompleted(object sender, BackgroundTextLoadTaskCompletedEventArgs e) {
			PageRequestState state = e.UserState as PageRequestState;
			if (!object.ReferenceEquals(state.Content, this.cont)) return;
			if (this.InvokeRequired) {
				this.Invoke(new EventHandler<BackgroundTextLoadTaskCompletedEventArgs>(this.bgTextLoader_TaskCompleted), sender, e);
			} else {
				ContentPageRequestState stateDetail = state as ContentPageRequestState;
				ReviewListPageRequestState stateList = state as ReviewListPageRequestState;

				if (stateDetail != null) this.HandleTextLoadCompletedDetail(e, stateDetail);
				else if (stateList != null) this.HandleTextLoadCompletedList(e, stateList);
				else throw new ArgumentException();
			}
		}