private static IQueryable<OrderLine> ApplyOrderLineSort( IQueryable<OrderLine> orderLines, OrderLineSortFields sortField ) { switch( sortField ) { case OrderLineSortFields.OrderIDAsc: orderLines = orderLines.OrderBy( l => l.Order.OrderID ).ThenBy( l=>l.Manufacturer ).ThenBy(l=>l.PartNumber); break; case OrderLineSortFields.OrderIDDesc: orderLines = orderLines.OrderByDescending( l => l.Order.OrderID ).ThenBy( l => l.Manufacturer ).ThenBy( l => l.PartNumber ); break; case OrderLineSortFields.Manufacturer: orderLines = orderLines.OrderBy( l => l.Manufacturer ).ThenBy( l => l.PartNumber ); break; case OrderLineSortFields.PartName: orderLines = orderLines.OrderBy( l => l.PartName ); break; case OrderLineSortFields.PriceAsc: orderLines = orderLines.OrderBy( l => l.UnitPrice ); break; case OrderLineSortFields.PriceDesc: orderLines = orderLines.OrderByDescending( l => l.UnitPrice ); break; case OrderLineSortFields.EstSupplyDateAsc: orderLines = orderLines.OrderBy( l => l.EstSupplyDate ); break; case OrderLineSortFields.EstSupplyDateDesc: orderLines = orderLines.OrderByDescending( l => l.EstSupplyDate ); break; case OrderLineSortFields.Status: orderLines = orderLines.OrderBy( l => l.CurrentStatus ); break; } return orderLines; }
public static OrderLine[] GetOrderLinesForLiteRMM(OrderLineFilter filter, OrderLineSortFields orderLineSortFields, int startIndex, int size) { using (var dc = new DCFactory<StoreDataContext>()) { DataLoadOptions options = new DataLoadOptions(); options.LoadWith<OrderLine>(l => l.OrderLineStatusChanges); options.LoadWith<OrderLine>(l => l.Order); dc.DataContext.LoadOptions = options; // deas 23.05.2011 task4130 Ускорение работы со статусами //var stRejected = OrderLineStatusUtil.StatusByte(dc, "Rejected"); var stRejected = OrderLineStatusUtil.StatusByte("Rejected"); var orderLines = dc.DataContext.OrderLines.Where(x => x.InternalFranchName == SiteContext.Current.InternalFranchName).AsQueryable(); //пока закоментировано .Where(l => l.CurrentStatus != stRejected); /*if( filter != null ) orderLines = ApplyOrderLineFilter( orderLines, filter );*/ if (filter != null) { if (filter is OrderLineFilter) { orderLines = ApplyOrderLineFilter(orderLines, (OrderLineFilter)filter); } else { throw new Exception("Incorrect filter object."); } } orderLines = ApplyOrderLineSort(orderLines, orderLineSortFields); //orderLines = ApplyOrderLineSort(orderLines, sortField); return orderLines.Skip(startIndex).Take(size).ToArray(); } }
public static OrderLine[] GetOrderLinesRequiresReaction( string clientId, OrderLineSortFields sortField ) { using (var dc = new DCFactory<StoreDataContext>()) { DataLoadOptions options = new DataLoadOptions(); options.LoadWith<OrderLine>( l => l.OrderLineStatusChanges ); options.LoadWith<OrderLine>( l => l.Order ); dc.DataContext.LoadOptions = options; var res = dc.DataContext.OrderLines .Where( l => l.Order.ClientID == clientId ).Where( OrderBO.PotentiallyRequiresReactionStatusExpression ) .OrderByDescending( l => l.OrderLineStatusChanges.Max( s => s.StatusChangeTime ) ) .ToArray(); foreach( var l in res ) { var parent = l.ParentOrderLine; } res = ApplyOrderLineSort( res.AsQueryable(), sortField ).ToArray(); return res; } }
/// <summary> /// GetOrderLines /// </summary> /// <param name="clientId">ID клиента</param> /// <param name="filter">фильтр (возможны 2 типа OrderLineFilter и OrderLineAnalysisFilter)</param> /// <param name="sortField">поле сортировки</param> /// <param name="startIndex">номер "страницы данных"</param> /// <param name="size">размер "страницы данных"</param> /// <returns>строки заказов</returns> public static OrderLine[] GetOrderLines( string clientId, /*OrderLineFilter filter*/ object filter, OrderLineSortFields sortField, int startIndex, int size ) { using (var dc = new DCFactory<StoreDataContext>()) { DataLoadOptions options = new DataLoadOptions(); options.LoadWith<OrderLine>( l => l.OrderLineStatusChanges ); options.LoadWith<OrderLine>( l => l.Order ); dc.DataContext.LoadOptions = options; // deas 23.05.2011 task4130 Ускорение работы со статусами //var stRejected = OrderLineStatusUtil.StatusByte(dc, "Rejected"); var stRejected = OrderLineStatusUtil.StatusByte( "Rejected" ); var orderLines = dc.DataContext.OrderLines.Where(l => l.Order.ClientID == clientId && l.CurrentStatus != stRejected); /*if( filter != null ) orderLines = ApplyOrderLineFilter( orderLines, filter );*/ if (filter != null) { if (filter is OrderLineFilter) { orderLines = ApplyOrderLineFilter(orderLines, (OrderLineFilter)filter); } else if (filter is OrderLineAnalysisFilter) { orderLines = ApplyOrderLineAnalysisFilter(orderLines, (OrderLineAnalysisFilter)filter); } else { throw new Exception("Incorrect filter object."); } } orderLines = ApplyOrderLineSort( orderLines, sortField ); var res = orderLines.Skip( startIndex ).Take( size ).ToArray(); foreach( var l in res ) { var parent = l.ParentOrderLine; } return res; } }