/// <summary> /// 初始化ModifyCommandCreator,dbAccess不能为空 /// </summary> /// <exception cref="RException(DatabaseErrorCode.ConnectDbServerError - 0x00010001)"> /// 传入的dbAccess为空,引发此异常 /// </exception> /// <param name="dbAccess">数据库访问接口</param> public SelectCommandCreator(IDBAccess dbAccess) { this.DbAccess = dbAccess; FilterProterties = new string[0]; OrderBy = new SortInfo[0]; }
public void SortInfoPropTest() { MyArray <int>[] myArrs = new MyArray <int>[] { new MyArray <int>(new int[] { 2, 5, 3, 2, 6 }), new MyArray <int>(new int[] { 2, 4, 12, 88 }), new MyArray <int>(new int[] { 2, 6, 9, 11, 4, 6 }), new MyArray <int>(new int[] { 1, 2, 3, 1, 7, 88 }) }; SortInfo <int> sort = new SortInfo <int>(myArrs); if (sort.Arrays.Count != 4) { Assert.Fail(); } for (int i = 0; i < myArrs.Length; i++) { for (int j = 0; j < myArrs[i].Length; j++) { if (myArrs[i][j] != sort.Arrays[i][j]) { Assert.Fail(); } } } }
/// <summary> /// Sorts the elements of an array by a given attribute of an element in the array. /// {% assign sorted = pages | sort:"date:desc;name" %} /// </summary> /// <param name="input"></param> /// <param name="sort"></param> /// <returns></returns> public static object Sort(object input, string sort) { var retVal = input; IEnumerable enumerable = retVal as IEnumerable; IMutablePagedList muttablePagedList = input as IMutablePagedList; var sortInfos = SortInfo.Parse(sort).ToList(); if (muttablePagedList != null) { muttablePagedList.Slice(muttablePagedList.PageNumber, muttablePagedList.PageSize, sortInfos); } if (enumerable != null) { //Queryable.Cast<T>(input).OrderBySortInfos(sortInfos) call by reflection var queryable = enumerable.AsQueryable(); var elementType = enumerable.GetType().GetEnumerableType(); MethodInfo castMethodInfo = typeof(Queryable).GetMethods().Where(x => x.Name == "Cast" && x.IsGenericMethod).First(); castMethodInfo = castMethodInfo.MakeGenericMethod(new Type[] { elementType }); var genericQueryable = castMethodInfo.Invoke(null, new object[] { queryable }); var orderBySortInfosMethodInfo = typeof(IQueryableExtensions).GetMethod("OrderBySortInfos"); orderBySortInfosMethodInfo = orderBySortInfosMethodInfo.MakeGenericMethod(new Type[] { elementType }); retVal = orderBySortInfosMethodInfo.Invoke(null, new object[] { genericQueryable, sortInfos.ToArray() }); } return(retVal); }
public async Task <ActionResult> VendorDetails(string vendorId) { var vendor = (await _customerService.GetVendorsByIdsAsync(base.WorkContext.CurrentStore, base.WorkContext.CurrentLanguage, vendorId)).FirstOrDefault(); if (vendor != null) { vendor.Products = new MutablePagedList <Product>((pageNumber, pageSize, sortInfos, @params) => { var criteria = new ProductSearchCriteria { VendorId = vendorId, PageNumber = pageNumber, PageSize = pageSize, SortBy = SortInfo.ToString(sortInfos), ResponseGroup = base.WorkContext.CurrentProductSearchCriteria.ResponseGroup }; if (@params != null) { criteria.CopyFrom(@params); } var searchResult = _catalogService.SearchProducts(criteria); return(searchResult.Products); }, 1, ProductSearchCriteria.DefaultPageSize); WorkContext.CurrentPageSeo = vendor.SeoInfo; WorkContext.CurrentVendor = vendor; return(View("vendor", WorkContext)); } return(NotFound()); }
public object GetAllInfo(int start, int limit, SortInfo[] sort, FilterInfo[] filter) { return new { Root = _tasks.Skip(start).Take(limit).Select(t => new { t.Id, t.Number, t.Title, t.Description, t.State }), Total = _tasks.Count() }; }
public static string getDeviceList(string conditions, int rows, int page, string sort, string sortOrder) { if (rows == 0) { return("{\"total\":0,\"rows\":[]}"); } StatisticsBLL bll = new StatisticsBLL(); PagerInfo pagerInfo = new PagerInfo(); pagerInfo.CurrenetPageIndex = page; pagerInfo.PageSize = rows; SortInfo sortInfo = new SortInfo(sort, sortOrder); QueryConditionModel conditionModel = JsonConvert.DeserializeObject <QueryConditionModel>(conditions.Replace("\"0\"", "\"\"")); //List<QueryList> list = new List<QueryList>(); DataTable dt = bll.StatisticsAllBioDevicesBLL(conditionModel, pagerInfo, sortInfo); pagerInfo.RecordCount = bll.getBioDeviceCount(conditionModel); //Json格式的要求{total:22,rows:{}} //构造成Json的格式传递 var result = new { total = pagerInfo.RecordCount, rows = dt }; return(JsonConvert.SerializeObject(result).Replace("null", "\"\"")); }
private void TrySetSortInfo(DataGridView grid, SortInfo sortInfo) { if (sortInfo != null && sortInfo.Column != null && sortInfo.Order != SortOrder.None) { grid.Sort(dgvTexts.Columns[sortInfo.Column.Index], (sortInfo.Order == SortOrder.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending); } }
private ODataRequest() { InlineCount = InlineCount.None; Sort = new SortInfo[0]; Select = new List <string>(); Expand = new List <string>(); AutofiltersEnabled = FilterStatus.Default; }
public SortInfo GetSortInfo() { SortInfo si = new SortInfo(); si.Type = this.Type; si.Width = this.Width; return(si); }
/// <summary> /// Order /// </summary> /// <typeparam name="T"></typeparam> /// <param name="source"></param> /// <param name="propertyName"></param> /// <param name="descending"></param> /// <param name="anotherLevel"></param> /// <returns></returns> public static IOrderedQueryable <T> Order <T>(this IQueryable <T> source, SortInfo sortInfo, bool anotherLevel = false) { if (sortInfo.Sort.IsNullOrWhiteSpace()) { throw new ArgumentException(nameof(sortInfo.Sort)); } return(Order(source, sortInfo.Sort !, sortInfo.SortDir == SortDirection.DESC, anotherLevel)); }
void Bind() { try { list = new List <SortInfo>(); list = SortClass.GetSortInfo(); if (list.Count > 0) { SortInfo lishi = list.Where(item => item.Ctype == 2).GroupBy(item => item.Ctype).Select(item => new SortInfo { Ctype = 0, CigaretteCode = "立式烟仓", CigaretteName = "立式烟仓分拣进度", MachineSeq = 0, SortedNum = item.Sum(x => x.SortedNum), TotalNum = item.Sum(x => x.TotalNum), UnSortNum = item.Sum(x => x.UnSortNum) }).FirstOrDefault(); SortInfo woshi = list.Where(item => item.Ctype == 3).GroupBy(item => item.Ctype).Select(item => new SortInfo { Ctype = 0, CigaretteCode = "卧式烟仓", CigaretteName = "卧式烟仓分拣进度", MachineSeq = 0, SortedNum = item.Sum(x => x.SortedNum), TotalNum = item.Sum(x => x.TotalNum), UnSortNum = item.Sum(x => x.UnSortNum) }).FirstOrDefault(); SortInfo teyixing = list.Where(item => item.Ctype == 1).GroupBy(item => item.Ctype).Select(item => new SortInfo { Ctype = 0, CigaretteCode = "特异型烟道", CigaretteName = "特异型烟道分拣进度", MachineSeq = 0, SortedNum = item.Sum(x => x.SortedNum), TotalNum = item.Sum(x => x.TotalNum), UnSortNum = item.Sum(x => x.UnSortNum) }).FirstOrDefault(); SortInfo zongshu = new SortInfo() { SortedNum = list.Sum(item => item.SortedNum), UnSortNum = list.Sum(item => item.UnSortNum), TotalNum = list.Sum(item => item.TotalNum), Ctype = 0, MachineSeq = 0, CigaretteCode = "总分拣量", CigaretteName = "总分拣量" }; list.Insert(0, zongshu); if (lishi != null) { list.Insert(1, lishi); } if (woshi != null) { list.Insert(2, woshi); } if (teyixing != null) { list.Insert(3, teyixing); } DgvSort.DataSource = list.OrderBy(item => item.MachineSeq).OrderBy(item => item.Ctype).ToList(); } else { DgvSort.DataSource = list; MessageBox.Show("当前没有分拣数据"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public static string GetOrderMethodName(this SortInfo sortInfo) { if (sortInfo.IsFirst) { return(sortInfo.IsDescending ? nameof(Queryable.OrderByDescending) : nameof(Queryable.OrderBy)); } return(sortInfo.IsDescending ? nameof(Queryable.ThenByDescending) : nameof(Queryable.ThenBy)); }
private ODataRequest() { InlineCount = InlineCount.None; //Format = OutputFormat.VerboseJSON; Sort = new SortInfo[0]; Select = new List <string>(); Expand = new List <string>(); AutofiltersEnabled = FilterStatus.Disabled; }
public async Task <ActionResult> CategoryBrowsing(string categoryId, string view) { var category = (await _searchService.GetCategoriesAsync(new[] { categoryId }, CategoryResponseGroup.Full)).FirstOrDefault(); if (category == null) { return(NotFound($"Category {categoryId} not found.")); } WorkContext.CurrentCategory = category; WorkContext.CurrentPageSeo = category.SeoInfo.JsonClone(); WorkContext.CurrentPageSeo.Slug = category.Url; var criteria = WorkContext.CurrentProductSearchCriteria.Clone() as ProductSearchCriteria; criteria.Outline = category.Outline; // should we simply take it from current category? category.Products = new MutablePagedList <Product>((pageNumber, pageSize, sortInfos, @params) => { criteria.PageNumber = pageNumber; criteria.PageSize = pageSize; if (string.IsNullOrEmpty(criteria.SortBy) && !sortInfos.IsNullOrEmpty()) { criteria.SortBy = SortInfo.ToString(sortInfos); } if (@params != null) { criteria.CopyFrom(@params); } var result = _searchService.SearchProducts(criteria); //Need change ProductSearchResult with preserve reference because Scriban engine keeps this reference and use new operator will create the new //object that doesn't tracked by Scriban WorkContext.ProductSearchResult.Aggregations = result.Aggregations; WorkContext.ProductSearchResult.Products = result.Products; return(result.Products); }, 1, ProductSearchCriteria.DefaultPageSize); WorkContext.ProductSearchResult.Products = category.Products; // make sure title is set if (string.IsNullOrEmpty(WorkContext.CurrentPageSeo.Title)) { WorkContext.CurrentPageSeo.Title = category.Name; } if (string.IsNullOrEmpty(view)) { view = "grid"; } if (view.Equals("list", StringComparison.OrdinalIgnoreCase)) { return(View("collection.list", WorkContext)); } return(View("collection", WorkContext)); }
/// <summary> ///查询用户列表信息 /// </summary> /// <param name="info">UserInfo实体类</param> /// <param name="pageSize">网页列表一次最多显示多少行记录</param> /// <param name="currentPage">用户查询的第几页信息</param> /// <param name="sortInfo">排列的列名实体类,可以指定几个列名,并且可以指定排列是升序还是降序</param> /// <param name="isFirstSearch">代表是否第一点击查询(如果是则需要对totalRecNum赋值,否则不需要,这样可以避免每次都去计算记录总数)</param> /// <param name="totalRecNum">根据查询条件查询的总记录数</param> /// <param name="retValue"返回string(DataSet格式)类型,字段包括用户名称、用户工号、所在用户组等信息</param> /// <returns>返回bool类型,错误返回false,正确返回true</returns> public static bool QueryUserList(UserInfo info, int pageSize, int currentPage, SortInfo sortInfo, bool isFirstSearch, out int totalRecNum, out string retValue) { totalRecNum = 0; retValue = null; #region 处理查询语句和排序语句 string sqlSelect = @"select U.UserID,U.JobNo,U.PassWord,U.RealName,U.JobDuty, U.UserGroupID,U.RoleID,R.RoleName,UG.UserGroupName "; string[] sortColumns = null; if (sortInfo != null && !string.IsNullOrEmpty(sortInfo.SortSql)) { sortColumns = sortInfo.SortSql.Split(','); string sqlSortIn = null; if (sortColumns != null && sortColumns.Length > 0) { foreach (string sortItem in sortColumns) { sqlSortIn += sortItem + ","; } sqlSortIn = sqlSortIn.Substring(0, sqlSortIn.Length - 1); } sqlSelect += ",Row_Number() Over(Order By " + sqlSortIn + ") AS serialNum"; } else { sqlSelect += ",Row_Number() Over(Order By UserID) AS serialNum"; } string sqlFrom = @" from [User] U Left Join UserGroup UG On U.UserGroupID=UG.UserGroupID Left Join [Role] R On U.RoleID=R.RoleID Where 1=1 "; #endregion #region 处理参数 List <System.Data.SqlClient.SqlParameter> listSqlPara = new List <System.Data.SqlClient.SqlParameter>(); if (info != null) { System.Data.SqlClient.SqlParameter sqlPara = null; if (!string.IsNullOrEmpty(info.JobNo)) { sqlFrom += " AND JobNo like '%'+@JobNo+'%'"; sqlPara = new System.Data.SqlClient.SqlParameter(); sqlPara.SqlDbType = SqlDbType.NVarChar; sqlPara.ParameterName = "JobNo"; sqlPara.Value = info.JobNo; listSqlPara.Add(sqlPara); } } #endregion return(ExcutePage.ExcutePageCommand(sqlSelect, sqlFrom, sortColumns, pageSize, currentPage, listSqlPara, isFirstSearch, out totalRecNum, out retValue)); }
/// <summary> /// GoodsInfoHelper 转换为 GoodsInfo /// </summary> /// <param name="goodsInfoHelper"></param> /// <returns></returns> public GoodsInfo GetGoodsInfo(GoodsInfoHelper goodsInfoHelper) { GoodsInfo goodsInfo = new GoodsInfo(); var sort = goodsInfoHelper.SortName; var unit = goodsInfoHelper.UnitName; var wholeSalerName = goodsInfoHelper.WholeSalerName; //将Sort 转换为SortID //在sort表中查询是否有该数据,有则返回ID 无则添加该类型 后返回ID int sortId = sortInfoDal.GetSortIdByName(sort); if (sortId == int.MaxValue) { //添加该类型 SortInfo sortInfo = new SortInfo(); sortInfo.SortName = sort; sortInfo.DelFlag = false; sortId = sortInfoDal.GetIdByAdd(sortInfo); } int unitId = unitInfoDal.GetUnitIdByName(unit); if (unitId == int.MaxValue) { //添加该类型 UnitInfo unitInfo = new UnitInfo(); unitInfo.UnitName = unit; unitInfo.DelFlag = false; sortId = unitInfoDal.GetIdByAdd(unitInfo); } int wholesalerId = wholeSalerInfoDal.GetWholeSaleIdByName(wholeSalerName); if (wholesalerId == int.MaxValue) { WholeSalerInfo wholeSalerInfo = new WholeSalerInfo(); wholeSalerInfo.SupName = wholeSalerName; wholeSalerInfo.Management = "未知"; wholeSalerInfo.AddressInfo = "未知"; wholeSalerInfo.TelePhone = "未知"; wholeSalerInfo.AddressInfo = "未知"; wholeSalerInfo.DelFlag = false; wholesalerId = wholeSalerInfoDal.GetIdByAdd(wholeSalerInfo); } goodsInfo.GoodsName = goodsInfoHelper.GoodsName; goodsInfo.GoodsType = goodsInfoHelper.GoodsType; goodsInfo.CreateTime = DateTime.Now; goodsInfo.LastTime = goodsInfoHelper.LastTime; goodsInfo.PayPrice = goodsInfoHelper.PayPrice; goodsInfo.PurPrice = goodsInfoHelper.PurPrice; goodsInfo.Remark = goodsInfoHelper.Remark; goodsInfo.SalesCount = goodsInfoHelper.SalesCount; goodsInfo.SurplusCount = goodsInfoHelper.SurplusCount; goodsInfo.Total = goodsInfoHelper.Total; goodsInfo.UnitId = unitId; goodsInfo.SortId = sortId; goodsInfo.WholeSalerId = wholesalerId; return(goodsInfo); }
public async Task <ActionResult> CategoryBrowsing(string categoryId, string view) { var category = (await _searchService.GetCategoriesAsync(new[] { categoryId }, CategoryResponseGroup.Full)).FirstOrDefault(); if (category == null) { return(NotFound($"Category {categoryId} not found.")); } WorkContext.CurrentCategory = category; WorkContext.CurrentPageSeo = category.SeoInfo.JsonClone(); WorkContext.CurrentPageSeo.Slug = category.Url; var criteria = WorkContext.CurrentProductSearchCriteria.Clone() as ProductSearchCriteria; criteria.Outline = category.Outline; // should we simply take it from current category? category.Products = new MutablePagedList <Product>((pageNumber, pageSize, sortInfos, @params) => { criteria.PageNumber = pageNumber; criteria.PageSize = pageSize; if (string.IsNullOrEmpty(criteria.SortBy) && !sortInfos.IsNullOrEmpty()) { criteria.SortBy = SortInfo.ToString(sortInfos); } if (@params != null) { criteria.CopyFrom(@params); } var result = _searchService.SearchProducts(criteria); //Prevent double api request for get aggregations //Because catalog search products returns also aggregations we can use it to populate workContext using C# closure //now workContext.Aggregation will be contains preloaded aggregations for current search criteria WorkContext.Aggregations = new MutablePagedList <Aggregation>(result.Aggregations); return(result.Products); }, 1, ProductSearchCriteria.DefaultPageSize); // make sure title is set if (string.IsNullOrEmpty(WorkContext.CurrentPageSeo.Title)) { WorkContext.CurrentPageSeo.Title = category.Name; } if (string.IsNullOrEmpty(view)) { view = "grid"; } if (view.Equals("list", StringComparison.OrdinalIgnoreCase)) { return(View("collection.list", WorkContext)); } return(View("collection", WorkContext)); }
public async Task <IActionResult> SortUser([FromBody] SortInfo usersInfo) { var result = await _repository.SortUser(usersInfo); if (result.IsSuccess) { return(Ok(result.Value)); } return(BadRequest(result.Error)); }
// Token: 0x06000074 RID: 116 RVA: 0x0000BDF8 File Offset: 0x00009FF8 protected int GetSortId(string sortname) { SqlParam sqlParam = DbHelper.MakeAndWhere("name", sortname); SortInfo sortInfo = DbHelper.ExecuteModel <SortInfo>(new SqlParam[] { sqlParam }); return(sortInfo.id); }
/// <summary> ///[SortInfo]表添加的方法 /// </summary> public static int addSortInfo(SortInfo sortinfo) { string sql = "insert into SortInfo([sortname]) values (@sortname)"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@sortname", sortinfo.Sortname) }; return(DBHelper.ExecuteCommand(sql, sp)); }
public SortInfo CreateSortInfo(Expression <Func <TModel, object> > pro, SortDir dir) { SortInfo rv = new SortInfo { Property = PropertyHelper.GetPropertyName(pro), Direction = dir }; return(rv); }
/// <summary> /// Based on sorting, we return the collection of answers to display to the end user (we also set any paging buttons here too). /// </summary> /// <param name="currentPage"></param> /// <returns></returns> public List <PostInfo> BindAnswers(int currentPage) { var objSort = new SortInfo { Column = "votes", Direction = Constants.SortDirection.Descending }; if (Sort != Null.NullString) { switch (Sort.ToLower()) { case "oldest": objSort.Column = "oldest"; objSort.Direction = Constants.SortDirection.Ascending; break; case "active": objSort.Column = "active"; break; //case "votes": // objSort.Column = "votes"; // break; default: objSort.Column = "votes"; break; } } var colAnswers = Controller.GetAnswers(QuestionID, ModuleContext.PortalId); TotalRecords = colAnswers.Count(); var answers = Sorting.GetAnswerCollection(PageSize, currentPage, objSort, colAnswers).ToList(); var totalPages = Convert.ToDouble((double)TotalRecords / PageSize); if ((totalPages > 1) && (totalPages > currentPage + 1)) { View.ShowNextButton(true); } else { View.ShowNextButton(false); } if ((totalPages > 1) && (currentPage > 0)) { View.ShowBackButton(true); } else { View.ShowBackButton(false); } return(answers); }
public virtual AssociationSearchRequestBuilder AddSortInfo(string sortInfoString) { var softInfos = SortInfo.Parse(sortInfoString).ToArray(); if (!softInfos.IsNullOrEmpty()) { _searchRequest.Sorting = softInfos.Select(x => new SortingField(x.SortColumn, x.SortDirection == SortDirection.Descending)).ToList(); } return(this); }
/// <summary> ///[SortInfo]表修改的方法 /// </summary> public static int updateSortInfoById(SortInfo sortinfo) { string sql = "update SortInfo set sortname=@sortname where sortid=@sortid"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@sortid", sortinfo.Sortid), new SqlParameter("@sortname", sortinfo.Sortname) }; return(DBHelper.ExecuteCommand(sql, sp)); }
public IHttpActionResult Sort() { _stopwatch = Stopwatch.StartNew(); ParallelSort.Sort<double>(data); _stopwatch.Stop(); SortInfo<double> info = new SortInfo<double>(); info.Name = "Sort"; info.Count = data.Length; info.Elapsed = _stopwatch.Elapsed; info.Array = data; return Json(info); }
public void WebGridDataSourceUsesDefaultSortWhenCurrentSortCannotBeInferred() { // Arrange var values = GetValues(); var defaultSort = new SortInfo { SortColumn = "FirstName" }; var dataSource = new WebGridDataSource(new WebGrid(GetContext()), values: GetValues(), elementType: typeof(Person), canSort: true, canPage: false) { DefaultSort = defaultSort }; // Act var rows = dataSource.GetRows(new SortInfo { SortColumn = "Does-not-exist" }, 0); // Assert CollectionAssert.AreEqual(values.OrderBy(p => p.FirstName).ToList(), rows.Select(r => r.Value).ToList(), new PersonComparer()); }
// Token: 0x06000274 RID: 628 RVA: 0x000087E4 File Offset: 0x000069E4 public static void UpdateSortPosts(int sortid, int posts) { SortInfo sortInfo = SortBll.GetSortInfo(sortid); if (sortInfo.id != 0) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("UPDATE [{0}WMS_SortInfo] SET [posts]=[posts]+{1} WHERE [id] IN({2})|", DbConfigs.Prefix, posts, sortInfo.parentlist); stringBuilder.AppendFormat("UPDATE [{0}WMS_SortInfo] SET [posts]=0 WHERE [posts]<0", DbConfigs.Prefix); DbHelper.ExecuteSql(stringBuilder.ToString()); } }
protected virtual async Task LoadProductAssociationsAsync(IEnumerable <Product> products) { var allAssociations = products.SelectMany(x => x.Associations).ToList(); var allProductAssociations = allAssociations.OfType <ProductAssociation>().ToList(); var allCategoriesAssociations = allAssociations.OfType <CategoryAssociation>().ToList(); if (allProductAssociations.Any()) { var productsIds = allProductAssociations.Select(x => x.ProductId).ToArray(); var allAssociatedProducts = await GetProductsAsync(allProductAssociations.Select(x => x.ProductId).ToArray(), ItemResponseGroup.ItemInfo | ItemResponseGroup.ItemWithPrices | ItemResponseGroup.Seo | ItemResponseGroup.Outlines); foreach (var productAssociation in allProductAssociations) { productAssociation.Product = allAssociatedProducts.FirstOrDefault(x => x.Id == productAssociation.ProductId); } } if (allCategoriesAssociations.Any()) { var categoriesIds = allCategoriesAssociations.Select(x => x.CategoryId).ToArray(); var allAssociatedCategories = await GetCategoriesAsync(categoriesIds, CategoryResponseGroup.Info | CategoryResponseGroup.WithSeo | CategoryResponseGroup.WithOutlines | CategoryResponseGroup.WithImages); foreach (var categoryAssociation in allCategoriesAssociations) { categoryAssociation.Category = allAssociatedCategories.FirstOrDefault(x => x.Id == categoryAssociation.CategoryId); if (categoryAssociation.Category != null && categoryAssociation.Category.Products == null) { categoryAssociation.Category.Products = new MutablePagedList <Product>((pageNumber, pageSize, sortInfos) => { var criteria = new ProductSearchCriteria { PageNumber = pageNumber, PageSize = pageSize, Outline = categoryAssociation.Category.Outline, ResponseGroup = ItemResponseGroup.ItemInfo | ItemResponseGroup.ItemWithPrices | ItemResponseGroup.Inventory | ItemResponseGroup.ItemWithVendor }; if (!sortInfos.IsNullOrEmpty()) { criteria.SortBy = SortInfo.ToString(sortInfos); } var searchResult = SearchProducts(criteria); return(searchResult.Products); }, 1, ProductSearchCriteria.DefaultPageSize); } } } }
public async Task <ActionResult> ProductDetails(string productId) { var product = (await _catalogSearchService.GetProductsAsync(new[] { productId }, WorkContext.CurrentProductResponseGroup)).FirstOrDefault(); WorkContext.CurrentProduct = product; if (product != null) { WorkContext.CurrentPageSeo = product.SeoInfo.JsonClone(); WorkContext.CurrentPageSeo.Slug = product.Url; // make sure title is set if (string.IsNullOrEmpty(WorkContext.CurrentPageSeo.Title)) { WorkContext.CurrentPageSeo.Title = product.Name; } //Lazy initialize product breadcrumbs WorkContext.Breadcrumbs = new MutablePagedList <Breadcrumb>((pageNumber, pageSize, sortInfos, @params) => { var breadcrumbs = product.GetBreadcrumbs().ToList(); return(new StaticPagedList <Breadcrumb>(breadcrumbs, pageNumber, pageSize, breadcrumbs.Count)); }, 1, int.MaxValue); if (product.CategoryId != null) { var category = (await _catalogSearchService.GetCategoriesAsync(new[] { product.CategoryId }, CategoryResponseGroup.Full)).FirstOrDefault(); WorkContext.CurrentCategory = category; if (category != null) { category.Products = new MutablePagedList <Product>((pageNumber, pageSize, sortInfos, @params) => { var criteria = WorkContext.CurrentProductSearchCriteria.Clone() as ProductSearchCriteria; criteria.Outline = product.GetCategoryOutline(); criteria.PageNumber = pageNumber; criteria.PageSize = pageSize; if (string.IsNullOrEmpty(criteria.SortBy) && !sortInfos.IsNullOrEmpty()) { criteria.SortBy = SortInfo.ToString(sortInfos); } if (@params != null) { criteria.CopyFrom(@params); } return(_catalogSearchService.SearchProducts(criteria).Products); }, 1, ProductSearchCriteria.DefaultPageSize); } } } return(View("product", WorkContext)); }
public void ReadData(UMessage msg) { number = msg.ReadChar(); si.Clear(); for (int index = 0; index < (int)number; index++) { SortInfo tempsi = new SortInfo(); tempsi.ReadData(msg); si.Add(tempsi); } god.ReadData(msg); }
public IHttpActionResult Sort() { _stopwatch = Stopwatch.StartNew(); ParallelSort.Sort <double>(data); _stopwatch.Stop(); SortInfo <double> info = new SortInfo <double>(); info.Name = "Sort"; info.Count = data.Length; info.Elapsed = _stopwatch.Elapsed; info.Array = data; return(Json(info)); }
public TerminationRouteDto[] GetAvailableCarrierLCRTerminationRoutes(int pBaseRouteId, DateTime pDate, short pHour) { //Stopwatch _s = new Stopwatch(); //_s.Start(); var _dateHour = new DateTime(pDate.Year, pDate.Month, pDate.Day, pHour, 0, 0); var _termRoutelist = new ArrayList(); using (var _db = new Rbr_Db()) { var _terminationRouteViewRows = _db.TerminationRouteViewCollection.GetAvailableByCustomerBaseRouteId(pBaseRouteId, true); foreach (var _terminationRouteViewRow in _terminationRouteViewRows) { if (_terminationRouteViewRow.RatingType != RatingType.Disabled) { //if rating enabled //TODO: make sure carr Route has active Term EPs var _activeCarrierRouteEPMapCount = _db.CarrierAcctEPMapCollection.GetActiveCountByCarrierRouteId(_terminationRouteViewRow.Carrier_route_id); //TODO: check for DefaultPrimaryTermEP if (_activeCarrierRouteEPMapCount > 0 /* || pCustomerServiceRoute.Service.DefaultPrimaryTermEP > 0*/) { var _lcrRank = getCarrierLCRRank(_terminationRouteViewRow.Carrier_route_id, _dateHour); var _terminationRoute = new TerminationRouteDto(_terminationRouteViewRow.Carrier_route_id, _terminationRouteViewRow.Route_name, _terminationRouteViewRow.Carrier_acct_id, _terminationRouteViewRow.Calling_plan_id, _terminationRouteViewRow.Carrier_acct_name, _lcrRank, _terminationRouteViewRow.PartialCoverage, _activeCarrierRouteEPMapCount > 0); if (!_termRoutelist.Contains(_terminationRoute)) { _termRoutelist.Add(_terminationRoute); } } } } } //need to sort here by CarrierName and RouteName //var _sortInfo = new SortInfo[3]; //_sortInfo[1] = new SortInfo(TerminationRouteDto.CarrierName_PropName, ListSortDirection.Ascending); //_sortInfo[2] = new SortInfo(TerminationRouteDto.CarrierRouteName_PropName, ListSortDirection.Ascending); var _sortInfo = new SortInfo[2]; _sortInfo[0] = new SortInfo(TerminationRouteDto.CarrierName_PropName, ListSortDirection.Ascending); _sortInfo[1] = new SortInfo(TerminationRouteDto.CarrierRouteName_PropName, ListSortDirection.Ascending); _termRoutelist.Sort(new GenericComparer(_sortInfo)); //Debug.WriteLine("TermChoiceController.GetRoutingTable [" + _s.Elapsed.TotalSeconds.ToString("0.0000000") + " sec]"); return((TerminationRouteDto[])_termRoutelist.ToArray(typeof(TerminationRouteDto))); }
public async Task <ActionResult <Catalog[]> > GetCatalogs(string sort = null, int skip = 0, int take = 20) { //TODO //ApplyRestrictionsForCurrentUser(criteria); var stores = await _catalogService.GetCatalogsListAsync(); var sortInfos = !string.IsNullOrEmpty(sort) ? SortInfo.Parse(sort) : new[] { new SortInfo { SortColumn = "Name" } }; var result = stores.Skip(skip).Take(take).AsQueryable().OrderBySortInfos(sortInfos); return(Ok(result)); }
public static Task WithFulfillmentCentersAsync(this IWorkContextBuilder builder) { var serviceProvider = builder.HttpContext.RequestServices; var inventoryService = serviceProvider.GetRequiredService <IInventoryService>(); Func <int, int, IEnumerable <SortInfo>, IPagedList <FulfillmentCenter> > factory = (pageNumber, pageSize, sortInfos) => { return(inventoryService.SearchFulfillmentCenters(new FulfillmentCenterSearchCriteria { PageNumber = pageNumber, PageSize = pageNumber, Sort = SortInfo.ToString(sortInfos) })); }; return(builder.WithFulfillmentCentersAsync(() => new MutablePagedList <FulfillmentCenter>(factory, 1, FulfillmentCenterSearchCriteria.DefaultPageSize))); }
public Pdb(string filePath) { rawData = File.ReadAllBytes(filePath); using (var stream = new MemoryStream(rawData)) { var buf = new byte[32]; stream.Read(buf, 0, 32); filename = Encoding.ASCII.GetString(buf.TakeWhile(b => b > 0).ToArray()); buf = new byte[2]; stream.Read(buf, 0, 2); if (BitConverter.IsLittleEndian) buf = buf.Reverse(); attributes = (PdbAttributes)BitConverter.ToUInt16(buf, 0); stream.Read(buf, 0, 2); if (BitConverter.IsLittleEndian) buf = buf.Reverse(); fileVersion = BitConverter.ToUInt16(buf, 0); buf = new byte[4]; stream.Read(buf, 0, 4); if (BitConverter.IsLittleEndian) buf = buf.Reverse(); creationDate = BitConverter.ToUInt32(buf, 0); stream.Read(buf, 0, 4); if (BitConverter.IsLittleEndian) buf = buf.Reverse(); modificationDate = BitConverter.ToUInt32(buf, 0); stream.Read(buf, 0, 4); if (BitConverter.IsLittleEndian) buf = buf.Reverse(); lastBackupDate = BitConverter.ToUInt32(buf, 0); stream.Read(buf, 0, 4); if (BitConverter.IsLittleEndian) buf = buf.Reverse(); modificationNumber = BitConverter.ToInt32(buf, 0); stream.Read(buf, 0, 4); if (BitConverter.IsLittleEndian) buf = buf.Reverse(); long appInfoOffset = BitConverter.ToUInt32(buf, 0); stream.Read(buf, 0, 4); if (BitConverter.IsLittleEndian) buf = buf.Reverse(); long sortInfoOffset = BitConverter.ToUInt32(buf, 0); stream.Read(buf, 0, 4); filetype = Encoding.ASCII.GetString(buf); stream.Read(buf, 0, 4); creator = Encoding.ASCII.GetString(buf); stream.Read(buf, 0, 4); if (BitConverter.IsLittleEndian) buf = buf.Reverse(); uniqueIdSeed = BitConverter.ToInt32(buf, 0); stream.Read(buf, 0, 4); //nextRecordListID = always 0x00000000 buf = new byte[2]; stream.Read(buf, 0, 2); if (BitConverter.IsLittleEndian) buf = buf.Reverse(); numberOfRecords = BitConverter.ToUInt16(buf, 0); records = new List<PdbRecordInfo>(numberOfRecords); buf = new byte[8]; for (int i = 0; i < numberOfRecords; i++) { stream.Read(buf, 0, 8); records.Add(new PdbRecordInfo(buf)); } if (appInfoOffset != 0) appInfo = ReadAppInfo(stream, appInfoOffset); if (sortInfoOffset != 0) sortInfo = ReadSortInfo(stream, sortInfoOffset); } }
public void WebGridDataSourceSortsUsingSpecifiedSort() { // Arrange var defaultSort = new SortInfo { SortColumn = "FirstName", SortDirection = SortDirection.Ascending }; IEnumerable<dynamic> values = new[] { new Person { LastName = "Z" }, new Person { LastName = "X" }, new Person { LastName = "Y" } }; var dataSource = new WebGridDataSource(new WebGrid(GetContext()), values: values, elementType: typeof(Person), canSort: true, canPage: false) { DefaultSort = defaultSort }; // Act var rows = dataSource.GetRows(new SortInfo { SortColumn = "LastName" }, 0); // Assert Assert.AreEqual(rows.ElementAt(0).Value.LastName, "X"); Assert.AreEqual(rows.ElementAt(1).Value.LastName, "Y"); Assert.AreEqual(rows.ElementAt(2).Value.LastName, "Z"); }
private static void TryTransformSortingInfoColumnNames(IDictionary<string, string> transformationMap, SortInfo[] sortingInfos) { //Try to replace sorting columns names foreach (var sortInfo in sortingInfos) { string newColumnName; if (transformationMap.TryGetValue(sortInfo.SortColumn.ToLowerInvariant(), out newColumnName)) { sortInfo.SortColumn = newColumnName; } } }
internal void SetProperties() { if (_propertiesSet) return; // first make sure your set to your input's properties foreach (InternalRecordSource source in _inputList) { source.SetProperties(); if (_passThruInputSorting) _sorting = source.Sorting; if (_passThruInputBucketting) _bucketting = source.Bucketting; if (_passThruInputSegmenting) _segmenting = source.Segmenting; if (_passThruInputReduced) _isReduced = source.IsReduced; } _propertiesSet = true; }
public IList<WebGridRow> GetRows(SortInfo sortInfo, int pageIndex) { // Data is already sorted and paged. Ignore parameters. return _rows; }