private GridResult GetReportDataPage(int from, int to, string sortField, bool isDesc, bool useUserFilter) { DataTable table = GetReportTablePage(from, to, sortField, isDesc, useUserFilter, true); GridResult result = new GridResult(); result.From = from; result.To = to; int page = to - from + 1; if (table.Rows.Count < 1) { //0 rows or exact match result.Total = from > 0 ? from : 0; } else if (table.Rows.Count == page) { //page is full, add some padding result.Total = to + 100; } else { //page is not full, so set the proper total result.Total = from + table.Rows.Count; } result.Data = table; return(result); }
public void ProcessRequest(HttpContext context) { // Variables Nullable <int> pageindex = null; Nullable <int> pagesize = null; GridResult result = new GridResult(); foreach (string key in HttpContext.Current.Request.Form.AllKeys) { if (key == KEY_PAGEINDEX) { pageindex = Convert.ToInt32(HttpContext.Current.Request.Form[key]); } else if (key == KEY_PAGESIZE) { pagesize = Convert.ToInt32(HttpContext.Current.Request.Form[key]); } } int totalRecord = 0; List <PDSchedule> list = getListData(); if (list.Any()) { result.rows = list; } result.total = totalRecord; JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); string sresult = javaScriptSerializer.Serialize(result); context.Response.Clear(); context.Response.ContentType = "application/json; charset=utf-8"; context.Response.Write(sresult); }
public virtual IHttpActionResult Get([FromUri] GridArgs args) { var entities = GetEntities(args.Filtering); if (entities == null) { var empty = new GridResult<WorkHoursModel, int> { total = 0, data = new List<WorkHoursModel>() }; return Ok(empty); } var total = entities.Count(); entities = Page(entities, args.Paging); var result = new GridResult<WorkHoursModel, int> { total = total, data = entities.ToList() }; return Ok(result); }
public void dataLoad() { try { using (SqlConnection con = new SqlConnection(strConString)) { SqlCommand cmd = new SqlCommand("select a.IdBarang, a.[Nama Barang], a.Qty, a.Harga From tblBarang a", con); con.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { GridResult.DataSource = dt; GridResult.DataBind(); } con.Close(); } } catch (Exception ex) { message = ex.Message; ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Oops!! following error occured : " + message.ToString() + "');", true); } }
public object GetGroupInfoList(string fields, string key, string order, string ascOrdesc, int page, int rows) { try { if (string.IsNullOrEmpty(fields)) { fields = "*"; } PageInfo pageInfo = new PageInfo() { PageIndex = (page - 1) * rows, PageSize = rows, RecCount = 0 }; string where = string.Empty; if (!string.IsNullOrEmpty(key)) { where = string.Format("where name like '%{0}%' or description like '%{0}%' ", key); } string orderby = string.Format("order by {0} {1}", order, ascOrdesc); string limit = string.Format("limit {0},{1}", pageInfo.PageIndex, pageInfo.PageSize); List <GroupInfo> list = GroupOperation.GetGroupInfoListAll(fields, where); pageInfo.RecCount = list.Count; List <GroupInfo> target = GroupOperation.GetGroupInfoPageList(fields, where, orderby, limit); GridResult <GroupInfo> result = new GridResult <GroupInfo>(target, pageInfo.RecCount); return(new JsonResult(result)); } catch (Exception ex) { return(ex.Message); } }
public JsonResult SearchPageTemplate(int templateType, string templateName, string fileName, int?templateId, int?page, int rows) { PageTemplatePageModel model = new PageTemplatePageModel(); PageTemplateSerachInfo info = new PageTemplateSerachInfo(); PagedResult pagedResult = pageTemplateBLL.GetPageTemplatePageList(templateType, page, rows, templateName, fileName); model.DataTable = pagedResult.Result; info.ID = templateId.HasValue ? templateId.Value : 0; info.PageIndex = page.HasValue ? page.Value - 1 : 0; info.PageSize = rows; info.TotalRecords = pagedResult.Total; if (info.ID == 0) { if (model.DataTable.Rows.Count <= 0) { info.ID = 0; } else { info.ID = int.Parse(model.DataTable.Rows[0]["TemplateId"].ToString()); } } model.PageTemplateInfo = new PageTemplateInfoModel( model.DataTable, new PageTemplate(info.ID, info.SearchWordTemplateName, info.SearchWordFileName) ); model.PagingInfo = info; model.templeteType = templateType; var result = new GridResult <PageTemplate>(pagedResult.Result.ToList <PageTemplate>(), pagedResult.Total); return(new JsonResult(result)); }
//public GridResult<UserViewModel> ListRoleUsers([ModelBinder(typeof(ExtraFiltersBinder))] GridRequest request) public GridResult <UserViewModel> ListRoleUsers(GridRequest request) { try { if (request.ExtraFilters["RoleId"] == null) { return new GridResult <UserViewModel> { Status = "error", Message = "Greška: parameter is null!" } } ; int roleId = Convert.ToInt32(request.ExtraFilters["RoleId"]); RepositoryAspNetRoles repo = new RepositoryAspNetRoles(); GridResult <UserViewModel> result = repo.GridQueryRoleUsers(roleId, request); return(result); } catch (Exception ex) { return(new GridResult <UserViewModel> { Status = "error", Message = ex.Message }); } }
public void dataLoad_Grid() { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conString"].ToString()); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "spLoadGridView"; cmd.Parameters.Add("@InvoiceNo", SqlDbType.VarChar).Value = textNoInvoice.Text.Trim(); cmd.Connection = con; try { con.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { GridResult.DataSource = dt; GridResult.DataBind(); } con.Close(); } catch (Exception ex) { message = ex.Message; ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Oops!! following error occured : " + message.ToString() + "');", true); } }
public object GetInferfaceConfigPageListByServer(string fields, string server, int page, int rows) { try { SystemSettingBase settings = SystemSettingBase.CreateInstance(); if (settings.SysMySqlDB != null) { ConnString.MySqldb = settings.SysMySqlDB.ConnectionString; } PageInfo pageInfo = new PageInfo() { PageIndex = rows * (page - 1), PageSize = rows, RecCount = 0 }; if (string.IsNullOrEmpty(fields)) { fields = "*"; } StringBuilder sb = new StringBuilder(); if (!string.IsNullOrEmpty(server)) { sb.AppendFormat(" where ServerAddress like '%{0}%' ", server); } List <InterfaceConfigInfo> list = InterfaceConfigInfoOperation.GetInterfaceConfigInfoList(fields, sb.ToString()); pageInfo.RecCount = list.Count; List <InterfaceConfigInfo> target = InterfaceConfigInfoOperation.GetInterfaceConfigInfoPageList(fields, sb.ToString(), pageInfo.PageIndex, pageInfo.PageSize); GridResult <InterfaceConfigInfo> result = new GridResult <InterfaceConfigInfo>(target, pageInfo.RecCount); return(new JsonResult(result)); } catch (Exception ex) { throw ex; } }
public object GetInterfaceConfigInfoPageList(string fields, int page, int rows) { try { SystemSettingBase settings = SystemSettingBase.CreateInstance(); if (settings.SysMySqlDB != null) { ConnString.MySqldb = settings.SysMySqlDB.ConnectionString; } PageInfo pageInfo = new PageInfo() { PageIndex = page, PageSize = rows, RecCount = 0 }; if (string.IsNullOrEmpty(fields)) { fields = "*"; } List <InterfaceConfigInfo> target = InterfaceConfigInfoOperation.GetInterfaceConfigInfoPageList(fields, string.Empty, pageInfo.PageIndex, pageInfo.PageSize); pageInfo.RecCount = target.Count; GridResult <InterfaceConfigInfo> result = new GridResult <InterfaceConfigInfo>(target, pageInfo.RecCount); return(new JsonResult(result)); } catch (Exception ex) { throw ex; } }
public JsonResult SearchFragment(int typeId, string channelId, string keywords, int?fragmentId, int?page, int rows) { FragmentPageModel model = new FragmentPageModel(); FragmentSerachInfo info = new FragmentSerachInfo(); keywords = string.Format("%{0}%", keywords); PagedResult pagedResult = fragmentBLL.GetPageList(typeId, channelId, keywords, rows, page); model.DataTable = pagedResult.Result; info.FragmentId = fragmentId.HasValue ? fragmentId.Value : 0; info.PageIndex = page.HasValue ? page.Value - 1 : 0; info.PageSize = rows; info.TotalRecords = pagedResult.Total; if (info.FragmentId == 0) { if (model.DataTable.Rows.Count > 0) { info.FragmentId = int.Parse(model.DataTable.Rows[0]["FragmentId"].ToString()); } } model.FragmentInfo = new FragmentInfoModel( model.DataTable, new Fragment(info.FragmentId, info.SearchWord) ); model.PagingInfo = info; model.TypeId = typeId; var result = new GridResult <Fragment>(pagedResult.Result.ToList <Fragment>(), pagedResult.Total); return(new JsonResult(result)); }
public IActionResult Profile([FromQuery] GridModel <Profile> profileGrid) { GridResult <Profile> result = _profileService.GetFiltered(profileGrid); AddPageLinks(ref result, profileGrid); return(View(result)); }
public ActionResult SqlReport(Guid id, string report) { var content = DbUtil.Db.ContentOfTypeSql(report); if (content == null) { return(Message("no content")); } if (!CanRunScript(content.Body)) { return(Message("Not Authorized to run this script")); } if (!content.Body.Contains("@qtagid")) { return(Message("missing @qtagid")); } var tag = DbUtil.Db.PopulateSpecialTag(id, DbUtil.TagTypeId_Query); var cs = User.IsInRole("Finance") ? Util.ConnectionStringReadOnlyFinance : Util.ConnectionStringReadOnly; using (var cn = new SqlConnection(cs)) { cn.Open(); var p = new DynamicParameters(); p.Add("@qtagid", tag.Id); ViewBag.name = report; using (var rd = cn.ExecuteReader(content.Body, p)) ViewBag.report = GridResult.Table(rd); return(View()); } }
public virtual IHttpActionResult Get([FromUri] GridArgs args) { var entities = GetEntities(args.Filtering); if (entities == null) { var empty = new GridResult <ReportMaterialModel, int> { total = 0, data = new List <ReportMaterialModel>() }; return(Ok(empty)); } var total = entities.Count(); entities = Page(entities, args.Paging); var result = new GridResult <ReportMaterialModel, int> { total = total, data = entities.ToList() }; return(Ok(result)); }
public static GridEntity <T> GetGridData_No_Paging(string comname, string ProcName, string CallType, string parm1 = "", string parm2 = "", string parm3 = "", string parm4 = "", string parm5 = "", string parm6 = "", string parm7 = "", string parm8 = "", string parm9 = "", string parm10 = "") { try { dbConn = new SqlConnection(ConnectionString); dbConn.Open(); cmd = new SqlCommand(ProcName, dbConn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@ComC1", comname)); cmd.Parameters.Add(new SqlParameter("@CallType", CallType)); cmd.Parameters.Add(new SqlParameter("@Desc1", parm1)); cmd.Parameters.Add(new SqlParameter("@Desc2", parm2)); cmd.Parameters.Add(new SqlParameter("@Desc3", parm3)); cmd.Parameters.Add(new SqlParameter("@Desc4", parm4)); cmd.Parameters.Add(new SqlParameter("@Desc5", parm5)); cmd.Parameters.Add(new SqlParameter("@Desc6", parm6)); cmd.Parameters.Add(new SqlParameter("@Desc7", parm7)); cmd.Parameters.Add(new SqlParameter("@Desc8", parm8)); cmd.Parameters.Add(new SqlParameter("@Desc9", parm9)); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds); dbConn.Close(); dt = ds.Tables[0]; totalCount = Convert.ToInt32(ds.Tables[0].Rows.Count); var dataList = (List <T>)ListConversion.ConvertTo <T>(dt).ToList(); var result = new GridResult <T>().Data(dataList, totalCount); return(result); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult TotalsByFundCustomReport(string id, TotalsByFundModel model) { var content = CurrentDatabase.ContentOfTypeSql(id); if (content == null) { return(SimpleContent("no content")); } var p = model.GetDynamicParameters(); ViewBag.Name = id.SpaceCamelCase(); var linkUrl = CurrentDatabase.ServerLink($"/TotalsByFundCustomExport/{id}"); var linkHtml = $"<a href='{linkUrl}' class='CustomExport btn btn-default' target='_blank'><i class='fa fa-file-excel-o'></i> Download as Excel</a>"; using (var connection = CurrentDatabase.ReadonlyConnection()) { connection.Open(); var reader = connection.ExecuteReader(content, p, commandTimeout: 1200); var contentTable = GridResult.Table(reader, id.SpaceCamelCase(), excellink: linkHtml); return(SimpleContent(contentTable)); } }
public ActionResult All([FromQuery] GridModel <Profile> gridModel) { GridResult <Profile> result = _profileService.GetFiltered(gridModel); AddPageLinks(ref result, gridModel); return(View("Profiles", result)); }
private void SFormSearch_Load(object sender, EventArgs e) { sMenuSearch1.Tag = this; GridResult.SComponent.DoubleClick += SComponentOnDoubleClick; GridResult.Refresh(); //InicializarComponetesPesquisa(); }
public void ProcessRequest(HttpContext context) { // Variables Nullable<int> pageindex = null; Nullable<int> pagesize = null; GridResult result = new GridResult(); foreach (string key in HttpContext.Current.Request.Form.AllKeys) { if (key == KEY_PAGEINDEX) { pageindex = Convert.ToInt32(HttpContext.Current.Request.Form[key]); } else if (key == KEY_PAGESIZE) { pagesize = Convert.ToInt32(HttpContext.Current.Request.Form[key]); } } int totalRecord = 0; Toacts.KanbanPost.Services.Service1 svc = new Service1(); List<CustomerMaster> list = svc.getCustomerMaster(ref totalRecord, pageindex, pagesize); if (list.Any()) { result.rows = list; } result.total = totalRecord; JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); string sresult = javaScriptSerializer.Serialize(result); context.Response.Clear(); context.Response.ContentType = "application/json; charset=utf-8"; context.Response.Write(sresult); }
public object List() { List <Category> List = BllFactory.GetCategoryBLL().GetList(); var result = new GridResult <Category>(List); return(new JsonResult(result)); }
public virtual GridResult <TModel> GridList(GridRequest request, string defaultSort) { try { IQueryable <TEntity> query = GetQuery(); GridSortFilter.SortFilter sortFilter = GridSortFilter.FromRequest <TModel>(request, defaultSort); if (!string.IsNullOrEmpty(sortFilter.Sort)) { query = query.OrderBy(sortFilter.Sort); } string filter = sortFilter.Filter; List <TModel> pageViewModel = GetListModel(new ListParams(request, defaultSort, filter), ref query); GridResult <TModel> result = new GridResult <TModel> { Status = "success", TotalCount = query.Count(), Records = pageViewModel }; return(result); } catch (Exception ex) { Log.Error(ex); return(new GridResult <TModel> { Status = "error", Message = ex.Message }); } }
public ActionResult TotalsByFundCustomReport(string id, TotalsByFundModel m) { var content = DbUtil.Db.ContentOfTypeSql(id); if (content == null) { return(Content("no content")); } var cs = Util.ConnectionStringReadOnlyFinance; var cn = new SqlConnection(cs); cn.Open(); var p = new DynamicParameters(); p.Add("@StartDate", m.Dt1); p.Add("@EndDate", m.Dt2); p.Add("@CampusId", m.CampusId); p.Add("@Online", m.Online); p.Add("@TaxNonTax", m.TaxDedNonTax); p.Add("@IncludeUnclosedBundles", m.IncUnclosedBundles); if (m.FilterByActiveTag) { var tagid = DbUtil.Db.TagCurrent().Id; p.Add("@ActiveTagFilter", tagid); } else { p.Add("@ActiveTagFilter"); } ViewBag.Name = id.SpaceCamelCase(); var rd = cn.ExecuteReader(content, p, commandTimeout: 1200); return(Content(GridResult.Table(rd, id.SpaceCamelCase()))); }
public void SaveGrid(string NameOrIdentity = "") { GridResult Result = new GridResult(true); //Gets grids player is looking at if (!Result.GetGrids(Chat, AdminUserCharacter, NameOrIdentity)) { return; } GridStamp stamp = Result.GenerateGridStamp(); PlayerHangar PlayersHanger = new PlayerHangar(Result.OwnerSteamID, Chat, true); GridUtilities.FormatGridName(PlayersHanger, stamp); if (PlayersHanger.SaveGridsToFile(Result, stamp.GridName)) { PlayersHanger.SaveGridStamp(stamp, true); Chat?.Respond("Save Complete!"); } else { Chat?.Respond("Saved Failed!"); return; } }
public object List(CustomerSearchInfo pagingInfo) { pagingInfo.CheckPagingInfoState(); List<Customer> List = BllFactory.GetCustomerBLL().GetList(pagingInfo); var result = new GridResult<Customer>(List, pagingInfo.RecCount); return new JsonResult(result); }
public object List(ProductSearchInfo pagingInfo) { pagingInfo.CheckPagingInfoState(); List <Product> List = BllFactory.GetProductBLL().SearchProduct(pagingInfo); var result = new GridResult <Product>(List, pagingInfo.TotalRecords); return(new JsonResult(result)); }
public GridResult <UserViewModel> GridQueryRoleUsers(int roleId, GridRequest request) { try { DateTime minLockoutDate = DateTime.Parse("2100-01-01"); IQueryable <UserViewModel> query = from u in Context.Set <AspNetUser>() from rl in u.AspNetRoles.Where(x => x.Id == roleId && x.Code > 1) join p in Context.Set <UserProfile>() on u.Id equals p.UserId into joinedP from p in joinedP.DefaultIfEmpty() select new UserViewModel { UserId = u.Id, UserName = u.UserName, Email = u.Email, FirstName = p.FirstName, LastName = p.LastName, Locked = ((DateTime?)u.LockoutEndDateUtc ?? DateTime.Now) >= minLockoutDate.Date }; GridSortFilter.SortFilter sortFilter = GridSortFilter.FromRequest <UserViewModel>(request, "UserName"); if (!string.IsNullOrEmpty(sortFilter.Sort)) { query = query.OrderBy(sortFilter.Sort); } string filter = sortFilter.Filter; // custom filters if (!string.IsNullOrEmpty(filter)) { query = query.Where(filter); } var page = query .Skip(request.Skip) .Take(request.Take); GridResult <UserViewModel> result = new GridResult <UserViewModel> { Status = "success", TotalCount = query.Count(), Records = page.ToList() }; return(result); } catch (Exception ex) { Log.Error(ex); return(new GridResult <UserViewModel> { Status = "error", Message = ex.Message }); } }
public object List(CustomerSearchInfo pagingInfo) { pagingInfo.CheckPagingInfoState(); List <Customer> List = BllFactory.GetCustomerBLL().GetList(pagingInfo); var result = new GridResult <Customer>(List, pagingInfo.TotalRecords); return(new JsonResult(result)); }
/// <summary> /// 获取Gird的数据(Mapper) /// </summary> /// <param name="inDto">表格接收参数</param> /// <returns>grid</returns> public async Task <string> GetGridMapperList(GetGridListInDto inDto) { string viewName = inDto.ViewName.ToCamel(); if (!string.IsNullOrEmpty(inDto.Sort)) { inDto.Order = inDto.Sort + " " + inDto.Order; } if (!string.IsNullOrEmpty(inDto.Select)) { inDto.Select = $"new({inDto.Select})"; } PagedInputDto pagedInputDto = new PagedInputDto() { PageSize = inDto.limit.ToString().ToDefault(99999), PageIndex = inDto.page.ToString().ToDefault(1), Order = inDto.Order, Select = inDto.Select, configurationProvider = inDto.configurationProvider }; if (!string.IsNullOrEmpty(inDto.Filter)) { pagedInputDto.Filter = JsonConvert.DeserializeObject <PageFilterDto>(inDto.Filter); } MyDbContext db = this._dbContextProvider.GetDbContext(); PropertyInfo prop = db.GetType().GetProperty(viewName); object propVaule = prop.GetValue(db, null); Assembly autoAssembly = Assembly.Load("GridData.Core"); string viewFullName = $"My.D3.Entity.Demo.View.{viewName}"; string viewModel = $"My.D3.Entity.Demo.Dto.{viewName}Dto"; Assembly assembly = Assembly.Load("My.D3.Entity"); Type curType = assembly.GetType(viewFullName); Type resultModel = assembly.GetType(viewModel); MethodInfo pageMethodinfo = autoAssembly.GetExtensionMethods("GetPageAsync").FirstOrDefault(); dynamic result = await pageMethodinfo.MakeGenericMethod(curType, resultModel) .InvokeAsync(null, new object[] { propVaule, pagedInputDto }); GridResult gridResult = new GridResult { data = result.DataList, count = result.RowCount }; JsonSerializerSettings settings = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Error, //忽略循环引用,如果设置为Error,则遇到循环引用的时候报错(建议设置为Error,这样更规范) DateFormatString = "yyyy-MM-dd HH:mm:ss", //日期格式化,默认的格式也不好看 ContractResolver = new CamelCasePropertyNamesContractResolver() //json中属性开头字母小写的驼峰命名 }; return(JsonConvert.SerializeObject(gridResult, settings)); }
private void fillResult(string sid, SqlConnection con) { SqlDataAdapter ad = new SqlDataAdapter("select SID,ExamSeason,Course,Part,SubID,Status from SExamMarks where SID='" + sid + "' order by Part,ExamSeason desc", con); DataTable dt = new DataTable(); ad.Fill(dt); GridResult.DataSource = dt; GridResult.DataBind(); }
public bool SaveGrids(GridResult Grids, GridStamp Stamp) { List <MyObjectBuilder_CubeGrid> objectBuilders = new List <MyObjectBuilder_CubeGrid>(); foreach (MyCubeGrid grid in Grids.Grids) { /* Remove characters from cockpits */ Action P = delegate { foreach (var blck in grid.GetFatBlocks().OfType <MyCockpit>()) { if (blck.Pilot != null) { blck.RemovePilot(); } } }; Task KickPlayers = GameEvents.InvokeActionAsync(P); KickPlayers.Wait(5000); /* What else should it be? LOL? */ if (!(grid.GetObjectBuilder() is MyObjectBuilder_CubeGrid objectBuilder)) { throw new ArgumentException(grid + " has a ObjectBuilder thats not for a CubeGrid"); } objectBuilders.Add(objectBuilder); } try { //Need To check grid name string GridSavePath = Path.Combine(FolderPath, Stamp.GridName + ".sbc"); //Log.Info("SavedDir: " + pathForPlayer); bool saved = SaveGridToFile(GridSavePath, Stamp.GridName, objectBuilders); if (saved) { DisposeGrids(Grids.Grids); } return(saved); } catch (Exception e) { //Hangar.Debug("Saving Grid Failed!", e, Hangar.ErrorType.Fatal); return(false); } }
protected async Task <GridResult <ApiModelT> > ApplyGridAsync(GridModel <ApiModelT> entityGridModel, IQueryable <DbEntityT> entities) { var type = typeof(DbEntityT); if (entityGridModel.IsFiltering) { // entities = entities.Where(post => entityGridModel.FilterValues.Contains(filterProperty.GetValue(post).ToString())); PropertyInfo filterProperty = type.GetProperty(entityGridModel.FilterField); var parameter = Expression.Parameter(type, filterProperty.Name); var propertyAccess = Expression.MakeMemberAccess(parameter, filterProperty); MethodInfo toString = filterProperty.PropertyType.GetMethod("ToString", new Type[] {}); var toStringExp = Expression.Call(propertyAccess, toString); MethodInfo containsMethod = typeof(List <string>).GetMethod("Contains", new Type[] { typeof(string) }); var values = Expression.Constant(entityGridModel.FilterValues); var containsExp = Expression.Call(values, containsMethod, toStringExp); var whereExp = Expression.Lambda <Func <DbEntityT, bool> >(containsExp, parameter); entities = entities.Where(whereExp); } if (entityGridModel.IsSorting) { //Expression<Func<ApiModelT, object>> orderExpression = p => sortProperty.GetValue(p); //posts = postGridModel.IsSortingASC ? posts.OrderBy(orderExpression) : posts.OrderByDescending(orderExpression); PropertyInfo sortProperty = type.GetProperty(entityGridModel.SortField); var parameter = Expression.Parameter(type, sortProperty.Name); var propertyAccess = Expression.MakeMemberAccess(parameter, sortProperty); var orderByExp = Expression.Lambda(propertyAccess, parameter); var typeArguments = new Type[] { type, sortProperty.PropertyType }; var methodName = entityGridModel.IsSortingASC ? "OrderBy" : "OrderByDescending"; var resultExp = Expression.Call(typeof(Queryable), methodName, typeArguments, entities.Expression, Expression.Quote(orderByExp)); entities = entities.Provider.CreateQuery <DbEntityT>(resultExp); } IQueryable <DbEntityT> page = entities .Skip(entityGridModel.PageIndex * entityGridModel.PageSize) .Take(entityGridModel.PageSize); var result = new GridResult <ApiModelT>() { Values = (await page.ToListAsync()).Select(e => TranslateToApiModel(e)).ToList(), PageIndex = entityGridModel.PageIndex, PageSize = entityGridModel.PageSize, Next = entities.Skip((entityGridModel.PageIndex + 1) * entityGridModel.PageSize).Take(entityGridModel.PageSize).Any(), Previous = entityGridModel.PageIndex > 0 }; return(result); }
private string getPlanData() { // Variables Nullable <int> pageindex = null; Nullable <int> pagesize = null; GridResult result = new GridResult(); foreach (string key in HttpContext.Current.Request.Form.AllKeys) { if (key == KEY_PAGEINDEX) { pageindex = Convert.ToInt32(HttpContext.Current.Request.Form[key]); } else if (key == KEY_PAGESIZE) { pagesize = Convert.ToInt32(HttpContext.Current.Request.Form[key]); } } int totalRecord = 0; List <PlanManagementsData> list = new List <PlanManagementsData>(); for (int i = 0; i < 10; i++) { list.Add(new PlanManagementsData() { Part_No = "AB39 21201A38 A" + i.ToString(), Customer_Name = "AAT", Model_Name = "P375", Line_Speed = 25, Packing = 30, Forecast_Qty = 2940, day1 = 0, day2 = 0, day3 = 0, day4 = 0, day5 = 0, day6 = 0, day7 = 0, day8 = 0, day9 = 0, day10 = 0, day11 = 0, day12 = 0, day13 = 0, day14 = 0, Total = 0 }); } if (list.Any()) { result.rows = list; } result.total = 20; return(new JavaScriptSerializer().Serialize(result)); }
public virtual GridResult <TEntity> GetGridPresentation(FilterModel <TEntity> filter) { var result = new GridResult <TEntity>(); result.ItemsNumber = GetCount(filter); result.Items = GetList(filter); result.CurrentFilter = filter; return(result); }
public object Search2(OrderSearchInfo info) { info.CheckPagingInfoState(); List<Order> list = BllFactory.GetOrderBLL().Search(info); var result = new GridResult<Order>(list, info.RecCount); return new JsonResult(result); }
private string getPlanData() { // Variables Nullable<int> pageindex = null; Nullable<int> pagesize = null; GridResult result = new GridResult(); foreach (string key in HttpContext.Current.Request.Form.AllKeys) { if (key == KEY_PAGEINDEX) { pageindex = Convert.ToInt32(HttpContext.Current.Request.Form[key]); } else if (key == KEY_PAGESIZE) { pagesize = Convert.ToInt32(HttpContext.Current.Request.Form[key]); } } int totalRecord = 0; List<PlanManagementsData> list = new List<PlanManagementsData>(); for (int i = 0; i < 10; i++) { list.Add(new PlanManagementsData() { Part_No = "AB39 21201A38 A" + i.ToString(), Customer_Name = "AAT", Model_Name = "P375", Line_Speed = 25, Packing = 30, Forecast_Qty = 2940, day1 = 0, day2 = 0, day3 = 0, day4 = 0, day5 = 0, day6 = 0, day7 = 0, day8 = 0, day9 = 0, day10 = 0, day11 = 0, day12 = 0, day13 = 0, day14 = 0, Total = 0 }); } if (list.Any()) { result.rows = list; } result.total = 20; return new JavaScriptSerializer().Serialize(result); }
/// <summary> /// Execute method for GetCustomerByPage which gets collection of customer entities /// </summary> /// <param name="page">Current page</param> /// <param name="pageSize">Size of page</param> /// <returns>IEnumerable of Customers</returns> public GridResult<IEnumerable<Customer>> Execute(int page, int pageSize) { Guard.Against<ArgumentOutOfRangeException>(page < 0, "Parameter 'page' is out of range"); Guard.Against<ArgumentOutOfRangeException>(pageSize < 0, "Parameter 'pageSize' is out of range"); // Get page of customer entities IEnumerable<Customer> customers = _customerQueryableRepository.GetAll().Skip(page - 1 *pageSize).Take(pageSize).ToList(); // Get total customers int totalRecords = _customerQueryableRepository.GetAll().Count(); // Assume that we should have at least one customer Guard.Against<NullReferenceException>(customers == null, "Customers cannot be null"); GridResult<IEnumerable<Customer>> result = new GridResult<IEnumerable<Customer>>(){Entity = customers, ErrorMessage = null, Success = true}; result.TotalRecords = totalRecords; return result; }
public object List(ProductSearchInfo pagingInfo) { pagingInfo.CheckPagingInfoState(); List<Product> List = BllFactory.GetProductBLL().SearchProduct(pagingInfo); var result = new GridResult<Product>(List, pagingInfo.TotalRecords); return new JsonResult(result); }
public object List() { List<Category> List = BllFactory.GetCategoryBLL().GetList(); var result = new GridResult<Category>(List); return new JsonResult(result); }
public void ProcessRequest(HttpContext context) { // Variables Nullable<int> pageindex = null; Nullable<int> pagesize = null; GridResult result = new GridResult(); foreach (string key in HttpContext.Current.Request.Form.AllKeys) { if (key == KEY_PAGEINDEX) { pageindex = Convert.ToInt32(HttpContext.Current.Request.Form[key]); } else if (key == KEY_PAGESIZE) { pagesize = Convert.ToInt32(HttpContext.Current.Request.Form[key]); } } int totalRecord = 0; List<ForecastOrderData> list = getTestData(); if (list.Any()) { result.rows = list; } result.total = totalRecord; JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); string sresult = javaScriptSerializer.Serialize(result); context.Response.Clear(); context.Response.ContentType = "application/json; charset=utf-8"; context.Response.Write(sresult); }