public JsonResult GetPaged(FormCollection forms, Guid? taskid) { //IList<Crawler.Entity.Article> articles = (taskid == null ? articleService.GetAll() : articleService.GetByMasterId(taskid.Value)) as IList<Crawler.Entity.Article>; //Expression<Func<Employee, bool>> criteria = GetCriteria(forms); int pageIndex = Int32.Parse(forms["page"]) - 1; int pageSize = Int32.Parse(forms["rows"]); int recordCount = articleService.Query.Count(); int pageCount = recordCount / pageSize; if (recordCount % pageSize != 0) pageCount += 1; int maximumRows = pageSize; int startRowIndex = pageIndex * pageSize; IEnumerable<Crawler.Entity.Article> articles = articleService.Query.OrderByDescending(a => a.CreatedDate).Skip(startRowIndex).Take(maximumRows).ToList();// as IList<Crawler.Entity.Article>; IList<ArticleViewModel> models = new List<ArticleViewModel>(); foreach (var a in articles) { models.Add(new ArticleViewModel { ID = a.ID, Name = a.Name.Trim(), Url = a.Url, Tags = a.Tags, CreatedDate = a.CreatedDate, RowStatus = a.RowStatus, TaskItemId = a.TaskItemId }); } EasyUIDataGridModel<ArticleViewModel> tms = new EasyUIDataGridModel<ArticleViewModel>(); tms.rows = models; tms.total = recordCount; JsonResult json = Json(tms, JsonRequestBehavior.AllowGet); return json; }
public JsonResult GetPaged(FormCollection forms) { IEnumerable<Crawler.Entity.ArticleCategory> tasks = categoryService.GetAll();//.Table.ToList(); EasyUIDataGridModel<CategoryViewModel> tms = new EasyUIDataGridModel<CategoryViewModel>(); tms.rows = tasks.Select(t => new CategoryViewModel { ID = t.ID, Name = t.Name, ParentID = t.ParentID, Path = t.Path, CreatedDate = t.CreatedDate, IsLeaf = t.IsLeaf, QueryCode = t.QueryCode, RowStatus = t.RowStatus }); // TaskViewModel tms.total = 100; JsonResult json = Json(tms, JsonRequestBehavior.AllowGet); return json; }
public JsonResult GetPaged(FormCollection forms, string taskid) { int pageIndex = Int32.Parse(forms["page"]) - 1; int pageSize = Int32.Parse(forms["rows"]); int recordCount = taskItemService.Query.Count(); int pageCount = recordCount / pageSize; if (recordCount % pageSize != 0) pageCount += 1; int maximumRows = pageSize; int startRowIndex = pageIndex * pageSize; var query = String.IsNullOrEmpty(taskid) ? taskItemService.Query.OrderByDescending(ti => ti.CreatedDate): taskItemService.Query.Where(i => i.TaskId == new Guid(taskid)).OrderByDescending(ti => ti.CreatedDate); IEnumerable<Crawler.Entity.TaskItem> tasks = query.Skip(startRowIndex).Take(maximumRows); EasyUIDataGridModel<TaskItemViewModel> tms = new EasyUIDataGridModel<TaskItemViewModel>(); tms.rows = tasks.Select(t => new TaskItemViewModel { ID = t.ID, AutoPaging = t.AutoPaging, CreatedDate = t.CreatedDate, IsNavigation = t.IsNavigation, MaxPageCount = t.MaxPageCount, NextPage = t.NextPageText, NextPageUrl = t.NextPageUrlXPath, PageCategory = t.PageCategory, RowStatus = t.RowStatus, TaskId = t.TaskId, Url = t.Url }); // TaskViewModel tms.total = recordCount; JsonResult json = Json(tms, JsonRequestBehavior.AllowGet); return json; }
public JsonResult GetPaged(int pageIndex, FormCollection forms) { IEnumerable<Crawler.Entity.Task> tasks = taskService.Table.ToList(); EasyUIDataGridModel<TaskViewModel> tms = new EasyUIDataGridModel<TaskViewModel>(); tms.rows = tasks.Select(t => new TaskViewModel { ID = t.ID, Name = t.Name, CategoryId = t.CategoryId, Cookie = t.Cookie, CreatedDate = t.CreatedDate, Encoding = t.Encoding, LoginUrl = t.LoginUrl, TaskType = t.TaskType }); // TaskViewModel tms.total = 100; JsonResult json = Json(tms, JsonRequestBehavior.AllowGet); return json; }
public JsonResult GetPaged(int pageIndex, string taskitemid, FormCollection forms) { IEnumerable<Crawler.Entity.CaptureRule> tasks = String.IsNullOrEmpty(taskitemid) ? captureRuleService.GetAll(): captureRuleService.GetMany(c => c.TaskItems.Any(t => t.ID == new Guid(taskitemid))); EasyUIDataGridModel<CaptureRuleViewModel> tms = new EasyUIDataGridModel<CaptureRuleViewModel>(); tms.rows = tasks.Select(t => new CaptureRuleViewModel { ID = t.ID, Name = t.Name, Category = t.Category, ContentType = t.ContentType, CreatedDate = t.CreatedDate, EndString = t.EndString, MatchMethod = t.MatchMethod, MatchRegex = t.MatchRegex, MaxPageCount = t.MaxPageCount, NextPage = t.NextPageText, NextPageUrl = t.NextPageUrlXPath, Prefix = t.Prefix, ProcessMethod = t.ProcessMethod, ReplaceRegex = t.ReplaceRegex, RowStatus = t.RowStatus, SortOrder = t.SortOrder, StartString = t.StartString, Suffix = t.Suffix, XPath = t.XPath }); // TaskViewModel tms.total = 100; JsonResult json = Json(tms, JsonRequestBehavior.AllowGet); return json; }