public List<PostWrapped> Wrap(List<Guid> postIds, User currentUser = null) { var posts = new List<PostWrapped>(); foreach (var postId in postIds) { var post = _postDao.GetPostById(postId); if (post != null) posts.Add(new PostWrapped(post)); } var authors = _membershipService.GetUsersByIds(posts.Select(x => x.Post.UserId).Distinct().ToList()).ToDictionary(x => x.Id, x => x); var subs = _subDao.GetSubsByIds(posts.Select(x => x.Post.SubId).Distinct().ToList()).ToDictionary(x => x.Id, x => x); var likes = currentUser != null ? _voteDao.GetVotesOnPostsByUser(currentUser.Id, postIds) : new Dictionary<Guid, VoteType>(); var canManagePosts = currentUser != null ? subs.Values.Where(x => _permissionDao.CanUserManageSubPosts(currentUser, x.Id)) .Select(x => x.Id) .ToList() : new List<Guid>(); foreach (var item in posts) { item.Author = authors.ContainsKey(item.Post.UserId) ? authors[item.Post.UserId] : null; item.Sub = subs.ContainsKey(item.Post.SubId) ? subs[item.Post.SubId] : null; if (currentUser != null) item.CurrentUserVote = likes.ContainsKey(item.Post.Id) ? likes[item.Post.Id] : (VoteType?)null; if (canManagePosts.Contains(item.Post.SubId)) { // this user can approve/disapprove of a post, mark it NSFW, etc item.CanManage = true; item.Verdict = item.Post.PostVerdict; if (item.Post.NumberOfReports > 0) { var reports = _reportDao.GetReportsForPost(item.Post.Id); item.Reports = new List<ReportSummary>(); foreach (var report in reports) { var summary = new ReportSummary(); if (!authors.ContainsKey(report.ReportedBy)) authors.Add(report.ReportedBy, _membershipService.GetUserById(report.ReportedBy)); var user = authors[report.ReportedBy]; if (user != null) summary.UserName = user.UserName; summary.Reason = report.Reason; item.Reports.Add(summary); } } } if (currentUser != null) item.CanReport = true; // authors can only edit text posts if (item.Post.PostType == PostType.Text && currentUser != null && currentUser.Id == item.Post.UserId) item.CanEdit = true; } return posts; }
private static List<ReportSummary> GetAllReportsSummary(IEnumerable<string> reports) { var summaryCollection = new List<ReportSummary>(reports.Count()); foreach (var r in reports) { var lines = System.IO.File.ReadAllLines(r).Skip(1);// skip the header line; var reportSummary = new ReportSummary(r, lines.Count()); reportSummary.AvgOfMinValues = GetAvgOfColumn(lines, reportSummary.NumberOfLines, 10); reportSummary.AvgOfMaxValues = GetAvgOfColumn(lines, reportSummary.NumberOfLines, 12); reportSummary.AvgOfMeanValues = GetAvgOfColumn(lines, reportSummary.NumberOfLines, 14); reportSummary.AvgOfMedianValues = GetAvgOfColumn(lines, reportSummary.NumberOfLines, 16); summaryCollection.Add(reportSummary); } return summaryCollection; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LoadTitle(); LoadProvisionGroup(); LoadTransactionType(); ReportList.DataSource = string.Empty; ReportList.DataBind(); ReportSummary.DataSource = string.Empty; ReportSummary.DataBind(); DateTime sd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); dtpfordate.SelectedDate = sd; dtpuntildate.SelectedDate = DateTime.Now; } }
private async void RunTests_OnClick(object sender, RoutedEventArgs e) { if (UrlGeneratorPlugins.SelectedItem == null) { return; } if (!(UrlGeneratorPlugins.SelectedItem is IThreadedPerformanceSessionTestUrlGenerator)) { return; } _testUrls = (UrlGeneratorPlugins.SelectedItem as IThreadedPerformanceSessionTestUrlGenerator).GenerateTests(); var wrapper = new WebClientPerfWrapper(); var results = new List <Tuple <TimeSpan, string, string> >(); var numTries = Int32.Parse(TrialsTextBox.Text); ReportSummary.StatSummary.ViewModel = new StatSummaryViewModel(); foreach (var testCase in _testUrls) { var request = testCase; if (string.IsNullOrEmpty(request)) { continue; } var tasks = Enumerable.Range(0, numTries).Select(x => wrapper.RunPerformanceRequestTask(request)); var taskResults = await Task.WhenAll(tasks); var newResults = taskResults.Where(x => x != null).ToList(); results.AddRange(newResults); ReportSummary.AddDataToChart(request, newResults.Select(x => x.Item1).ToList(), results.Select(x => x.Item1).ToList()); ReportSummary.StatSummary.ViewModel.Requests.Add(request); foreach (var result in results) { ReportSummary.StatSummary.ViewModel.Runtimes.Add(result.Item1); } ReportSummary.IndividualRuntime.ViewModel = new IndividualRuntimeViewModel(results.Select(x => x.Item1).ToList()); } }
public void ReportProperty() { ReactivePropertyScheduler.SetDefault(CurrentThreadScheduler.Instance); var navigationService = new Mock <INavigationService>(); var referReport = new Mock <IReferReport>(); var reportSummaries = new ObservableCollection <ReportSummary>(); var readOnlyReportSummaries = new ReadOnlyObservableCollection <ReportSummary>(reportSummaries); referReport .Setup(m => m.ReportSummaries) .Returns(readOnlyReportSummaries); var actual = new ReportListPageViewModel(navigationService.Object, referReport.Object); Assert.Equal(0, actual.ReportSummaries.Count); var reportSummary = new ReportSummary(); reportSummaries.Add(reportSummary); Assert.Equal(1, actual.ReportSummaries.Count); Assert.Equal(reportSummary, actual.ReportSummaries[0]); }
public List <PostWrapped> Wrap(List <Guid> postIds, User currentUser = null) { var posts = new List <PostWrapped>(); foreach (var postId in postIds) { var post = _postDao.GetPostById(postId); if (post != null) { posts.Add(new PostWrapped(post)); } } var authors = _membershipService.GetUsersByIds(posts.Select(x => x.Post.UserId).Distinct().ToList()).ToDictionary(x => x.Id, x => x); var subs = _subDao.GetSubsByIds(posts.Select(x => x.Post.SubId).Distinct().ToList()).ToDictionary(x => x.Id, x => x); var likes = currentUser != null?_voteDao.GetVotesOnPostsByUser(currentUser.Id, postIds) : new Dictionary <Guid, VoteType>(); var canManagePosts = currentUser != null ? subs.Values.Where(x => _permissionDao.CanUserManageSubPosts(currentUser, x.Id)) .Select(x => x.Id) .ToList() : new List <Guid>(); foreach (var item in posts) { item.Author = authors.ContainsKey(item.Post.UserId) ? authors[item.Post.UserId] : null; item.Sub = subs.ContainsKey(item.Post.SubId) ? subs[item.Post.SubId] : null; if (currentUser != null) { item.CurrentUserVote = likes.ContainsKey(item.Post.Id) ? likes[item.Post.Id] : (VoteType?)null; } if (canManagePosts.Contains(item.Post.SubId)) { // this user can approve/disapprove of a post, mark it NSFW, etc item.CanManage = true; item.Verdict = item.Post.PostVerdict; if (item.Post.NumberOfReports > 0) { var reports = _reportDao.GetReportsForPost(item.Post.Id); item.Reports = new List <ReportSummary>(); foreach (var report in reports) { var summary = new ReportSummary(); if (!authors.ContainsKey(report.ReportedBy)) { authors.Add(report.ReportedBy, _membershipService.GetUserById(report.ReportedBy)); } var user = authors[report.ReportedBy]; if (user != null) { summary.UserName = user.UserName; } summary.Reason = report.Reason; item.Reports.Add(summary); } } item.CanSticky = true; } if (currentUser != null) { item.CanReport = true; } // authors can only edit text posts if (item.Post.PostType == PostType.Text && currentUser != null && currentUser.Id == item.Post.UserId) { item.CanEdit = true; } item.CanDelete = currentUser != null && (currentUser.IsAdmin || item.Post.UserId == currentUser.Id); } return(posts); }
public List<CommentWrapped> Wrap(List<Guid> commentIds, User currentUser = null) { var result = new List<CommentWrapped>(); foreach (var commentId in commentIds) { var comment = _commentDao.GetCommentById(commentId); if (comment != null) result.Add(new CommentWrapped(comment)); } var authors = _membershipService.GetUsersByIds(result.Select(x => x.Comment.AuthorUserId).Distinct().ToList()).ToDictionary(x => x.Id, x => x); var subs = _subDao.GetSubsByIds(result.Select(x => x.Comment.SubId).Distinct().ToList()).ToDictionary(x => x.Id, x => x); var posts = result.Select(x => x.Comment.PostId).Distinct().Select(x => _postDao.GetPostById(x)).Where(x => x != null).ToDictionary(x => x.Id, x => x); var userCanModInSubs = new List<Guid>(); if (currentUser != null) foreach (var sub in subs.Values) if (_permissionDao.CanUserManageSubPosts(currentUser, sub.Id)) userCanModInSubs.Add(sub.Id); var likes = currentUser != null ? _voteDao.GetVotesOnCommentsByUser(currentUser.Id, commentIds) : new Dictionary<Guid, VoteType>(); foreach (var item in result) { item.Author = authors.ContainsKey(item.Comment.AuthorUserId) ? authors[item.Comment.AuthorUserId] : null; item.CurrentUserVote = likes.ContainsKey(item.Comment.Id) ? likes[item.Comment.Id] : (VoteType?)null; item.Sub = subs.ContainsKey(item.Comment.SubId) ? subs[item.Comment.SubId] : null; item.Score = item.Comment.VoteUpCount - item.Comment.VoteDownCount; item.Post = posts.ContainsKey(item.Comment.PostId) ? posts[item.Comment.PostId] : null; var userCanMod = item.Sub != null && userCanModInSubs.Contains(item.Sub.Id); item.CanManage = userCanMod; if ((item.Author != null && currentUser != null) && currentUser.Id == item.Author.Id) item.CurrentUserIsAuthor = true; item.CanDelete = item.CanManage || item.CurrentUserIsAuthor; item.CanEdit = item.CurrentUserIsAuthor; if (currentUser != null) item.CanReport = true; if (item.CanManage && item.Comment.NumberOfReports > 0) { var reports = _reportDao.GetReportsForComment(item.Comment.Id); item.Reports = new List<ReportSummary>(); foreach (var report in reports) { var summary = new ReportSummary(); if (!authors.ContainsKey(report.ReportedBy)) authors.Add(report.ReportedBy, _membershipService.GetUserById(report.ReportedBy)); var user = authors[report.ReportedBy]; if (user != null) summary.UserName = user.UserName; summary.Reason = report.Reason; item.Reports.Add(summary); } } } return result; }
public List <CommentWrapped> Wrap(List <Guid> commentIds, User currentUser = null) { var result = new List <CommentWrapped>(); foreach (var commentId in commentIds) { var comment = _commentDao.GetCommentById(commentId); if (comment != null) { result.Add(new CommentWrapped(comment)); } } var authors = _membershipService.GetUsersByIds(result.Select(x => x.Comment.AuthorUserId).Distinct().ToList()).ToDictionary(x => x.Id, x => x); var subs = _subDao.GetSubsByIds(result.Select(x => x.Comment.SubId).Distinct().ToList()).ToDictionary(x => x.Id, x => x); var posts = result.Select(x => x.Comment.PostId).Distinct().Select(x => _postDao.GetPostById(x)).Where(x => x != null).ToDictionary(x => x.Id, x => x); var userCanModInSubs = new List <Guid>(); if (currentUser != null) { foreach (var sub in subs.Values) { if (_permissionDao.CanUserManageSubPosts(currentUser, sub.Id)) { userCanModInSubs.Add(sub.Id); } } } var likes = currentUser != null?_voteDao.GetVotesOnCommentsByUser(currentUser.Id, commentIds) : new Dictionary <Guid, VoteType>(); foreach (var item in result) { item.Author = authors.ContainsKey(item.Comment.AuthorUserId) ? authors[item.Comment.AuthorUserId] : null; item.CurrentUserVote = likes.ContainsKey(item.Comment.Id) ? likes[item.Comment.Id] : (VoteType?)null; item.Sub = subs.ContainsKey(item.Comment.SubId) ? subs[item.Comment.SubId] : null; item.Score = item.Comment.VoteUpCount - item.Comment.VoteDownCount; item.Post = posts.ContainsKey(item.Comment.PostId) ? posts[item.Comment.PostId] : null; var userCanMod = item.Sub != null && userCanModInSubs.Contains(item.Sub.Id); item.CanManage = userCanMod; if ((item.Author != null && currentUser != null) && currentUser.Id == item.Author.Id) { item.CurrentUserIsAuthor = true; } item.CanDelete = item.CanManage || item.CurrentUserIsAuthor; item.CanEdit = item.CurrentUserIsAuthor; if (currentUser != null) { item.CanReport = true; } if (item.CanManage && item.Comment.Reports > 0) { var reports = _reportDao.GetReportsForComment(item.Comment.Id); item.Reports = new List <ReportSummary>(); foreach (var report in reports) { var summary = new ReportSummary(); if (!authors.ContainsKey(report.ReportedBy)) { authors.Add(report.ReportedBy, _membershipService.GetUserById(report.ReportedBy)); } var user = authors[report.ReportedBy]; if (user != null) { summary.Username = user.UserName; } summary.Reason = report.Reason; item.Reports.Add(summary); } } } return(result); }
public TreeViewHelper(ReportSummary view, DurationCalculator calc) { _view = view; _durationCalculator = calc; }
internal void Summary(bool passed, int actions, string suiteName, string testName, string data, string errorScript, int errorLine, string errorMessage) { summary = new ReportSummary(passed, actions, suiteName, testName, data, errorScript, errorLine, errorMessage); }
internal void Summary(bool passed, int actions, string suiteName, string testName, string data) { summary = new ReportSummary(passed, actions, suiteName, testName, data); }