public List<PropertySummary> FullSearchV1(List<SearchParameter> searchParameters, Ordering order, Filtering filter) { Check.If(searchParameters).IsNotNull(); return _searchRepository.Search(searchParameters, order, filter).Select(SearchResultFactory.BuildPropertySummary).ToList(); }
public List<SearchResult> Search(List<SearchParameter> searchParameters, Ordering order, Filtering filter) { Check.If(searchParameters).IsNotNull(); return _searchRepository.Search(searchParameters, order, filter).Select(SearchResultFactory.BuildSearchResult).ToList(); }
private void ResolveFieldPaths(Ordering[] orderings) { for (var fieldPathIndex = 0; fieldPathIndex < orderings.Length; ++fieldPathIndex) { var fieldPath = orderings[fieldPathIndex]; fieldPath._resolvedPath = ResolveFieldPath(fieldPath.FieldPath()); } }
public SodaQueryComparator(LocalObjectContainer container, ClassMetadata extent, Ordering[] orderings) { _container = container; _transaction = ((LocalTransaction) _container.Transaction); _extentType = extent; _orderings = orderings; ResolveFieldPaths(orderings); }
public MockTransport(string name, Dictionary<string, string> cap, Reliability reliability, Ordering ordering, uint maxPacketSize) { State = RunningState.Started; Name = name; Capabilities = cap; Reliability = reliability; Ordering = ordering; MaximumPacketSize = maxPacketSize; }
public List<SearchResult> Search(List<SearchParameter> searchParameters, Ordering order, Filtering filter) { Check.If(searchParameters).IsNotNull(); var applications = _searchRepository.Search(searchParameters, order, filter); return applications.GenerateStatuses(_statusGeneratorFactory, _pipelinePositionGenerator) .Select(SearchResultFactory.BuildSearchResult) .ToList(); }
public List<Property> Search(List<SearchParameter> searchParameters, Ordering order, Filtering filter) { var properties = from property in _propertiesContext.Properties.Active() .Include(x => x.Landlord) .Include(x => x.PropertyDetails) .Include(x => x.PropertyPhotos) select property; properties = _searchQueryFactory.GetQueries() .Aggregate(properties, (current, query) => query.BuildSearchQuery(searchParameters, current)); return properties.OrderProperties(order).Filter(filter).ToList().FilterByArea(searchParameters.AreaOrDefault()).ToList(); }
public Guid AddOrdering(AddOrderingCommand command) { string orderCode = _keyGenerationReportService.GetCode(KeyTypeObjects.Order).CodeNew; var ordering = new Ordering() { OrderingId = Guid.NewGuid(), Address = command.Address, Phone = command.Phone, ExchangeRateId = command.ExchangeRateId, Note = command.Note, TotalDiscuss = command.TotalDiscuss, PersonId = command.PersonId, CreatedDate = DateTime.Now, Status = (int)StatusOrderingEnum.New, OrderingCode = orderCode, IsDelivered = false, IsDeposit = false, IsPaid = false, IsDownPayment = false, IsPayAtHome = false, NoteApproved = "", NoteCustomer = "", CreatedByName = "", CreatedBy = command.PersonId, Type = 0, TotalAmount = 0, TotalCount = 0, TotalCustomFees = 0, TotalDomesticCharges = 0, TotalDownPayment = 0, TotalQuantity = 0, TotalPrice = 0, TotalShipAbroad = 0, TotalShipInternal = 0, TotalVat = 0, TotalWage = 0, TransportFee = 0, WeightFee = 0 }; _orderingService.Insert(ordering); _unitOfWork.SaveChanges(); return ordering.OrderingId; }
public List<Application> Search(List<SearchParameter> searchParameters, Ordering order, Filtering filter) { var applications = from application in _applicationsContext.Applications.Filter(filter).Active() .Include(x => x.Customers) .Include(x => x.Customers.Select(c => c.Addresses)) .Include(x => x.Customers.Select(c => c.Emails)) .Include(x => x.Customers.Select(c => c.Names)) .Include(x => x.Customers.Select(c => c.TelephoneNumbers)) .Include(x => x.Properties) .Include(x => x.Requirements) select application; applications = _searchQueryFactory.GetQueries() .Aggregate(applications, (current, query) => query.BuildSearchQuery(searchParameters, current)); return applications.OrderApplications(order).ToList(); }
/// <summary> /// Create a new instance for handling UDP connections providing /// specified ordering requirements. /// </summary> /// <param name="ordering"></param> public UdpConnector(Ordering ordering) { log = LogManager.GetLogger(GetType()); switch (ordering) { case Ordering.Unordered: factory = new TransportFactory<UdpClient>( BaseUdpTransport.UnorderedProtocolDescriptor, h => new UdpClientTransport(h), t => t is UdpClientTransport); return; case Ordering.Sequenced: factory = new TransportFactory<UdpClient>( BaseUdpTransport.SequencedProtocolDescriptor, h => new UdpSequencedClientTransport(h), t => t is UdpSequencedClientTransport); return; default: throw new InvalidOperationException("Unsupported ordering type: " + ordering); } }
private IEnumerable<Property> GetPropertyForAreaAndStatus(List<string> areas, PipelinePosition pipelinePosition, Ordering order, Page page) { Check.If(areas).IsNotNull(); Check.If(areas).IsNotEmpty(); var properties = _propertyRepository.GetPropertiesByAreas(areas, Ordering.Newest).ToList(); if (properties.IsNull() || properties.IsEmpty()) return new List<Property>(); foreach (var property in properties) { property.PipelinePosition = property.PropertyStatus == Status.Let ? PipelinePosition.Let : PipelinePosition.Available; } return properties .Where(p => p.PipelinePosition == pipelinePosition) .Skip(page.StartingIndex()) .Take(page.PageSize); }
public List<CaselistEntry> GetApplicationsForAreaAndStatus(List<string> areas, PipelinePosition pipelinePosition, Ordering order, Page page) { Check.If(areas).IsNotNull(); Check.If(areas).IsNotEmpty(); var applications = _applicationRepository.GetApplicationsForAreas(areas, order); if (applications.IsNull() || applications.IsEmpty()) return new List<CaselistEntry>(); foreach (var application in applications) { application.GeneratePipelinePosition(_pipelinePositionGenerator); } return applications.FilterUnknownApplications() .FilterByPipelinePosition(pipelinePosition) .InWindow(_caselistWindowSettings) .Skip(page.StartingIndex()) .Take(page.PageSize) .Select(CaselistEntryFactory.BuildCaselistEntry) .ToList(); }
public void SetGraphProperties( RankDir value = RankDir.TopToBottom, Style style = Style.Default, string label = null, Ordering ordering = Ordering.None) { string text = null; switch (value) { case RankDir.BottomToTop: text = "BT"; break; case RankDir.TopToBottom: text = "TB"; break; case RankDir.RightToLeft: text = "RL"; break; case RankDir.LeftToRight: text = "LR"; break; } if (text != null) { writer.WriteLine("graph [rankdir={0}]", text); } if (label != null) { writer.WriteLine("graph [label=\"{0}\"]", Escape(label)); } if (style != Style.Default) { writer.WriteLine("graph [style={0}]", StyleToText(style)); } if (ordering != Ordering.None) { writer.WriteLine("graph [ordering={0}]", OrderingToText(ordering)); } }
public void GetPagedResultsByQuery_FirstPage() { var provider = TestObjects.GetScopeProvider(Logger); using (var scope = provider.CreateScope()) { var repository = CreateRepository((IScopeAccessor)provider, out _); var query = scope.SqlContext.Query <IContent>().Where(x => x.Level == 2); try { scope.Database.AsUmbracoDatabase().EnableSqlTrace = true; scope.Database.AsUmbracoDatabase().EnableSqlCount = true; var result = repository.GetPage(query, 0, 1, out var totalRecords, null, Ordering.By("Name")); Assert.That(totalRecords, Is.GreaterThanOrEqualTo(2)); Assert.That(result.Count(), Is.EqualTo(1)); Assert.That(result.First().Name, Is.EqualTo("Text Page 1")); } finally { scope.Database.AsUmbracoDatabase().EnableSqlTrace = false; scope.Database.AsUmbracoDatabase().EnableSqlCount = false; } } }
public void GetPagedResultsByQuery_With_Variant_Names() { // one invariant content type named "umbInvariantTextPage" // var invariantCt = MockedContentTypes.CreateSimpleContentType("umbInvariantTextpage", "Invariant Textpage"); invariantCt.Variations = ContentVariation.Nothing; foreach (var p in invariantCt.PropertyTypes) { p.Variations = ContentVariation.Nothing; } ServiceContext.FileService.SaveTemplate(invariantCt.DefaultTemplate); // else, FK violation on contentType! ServiceContext.ContentTypeService.Save(invariantCt); // one variant (by culture) content type named "umbVariantTextPage" // with properties, every 2nd one being variant (by culture), the other being invariant // var variantCt = MockedContentTypes.CreateSimpleContentType("umbVariantTextpage", "Variant Textpage"); variantCt.Variations = ContentVariation.Culture; var propTypes = variantCt.PropertyTypes.ToList(); for (var i = 0; i < propTypes.Count; i++) { var p = propTypes[i]; p.Variations = i % 2 == 0 ? ContentVariation.Culture : ContentVariation.Nothing; } ServiceContext.FileService.SaveTemplate(variantCt.DefaultTemplate); // else, FK violation on contentType! ServiceContext.ContentTypeService.Save(variantCt); invariantCt.AllowedContentTypes = new[] { new ContentTypeSort(invariantCt.Id, 0), new ContentTypeSort(variantCt.Id, 1) }; ServiceContext.ContentTypeService.Save(invariantCt); //create content var root = MockedContent.CreateSimpleContent(invariantCt); ServiceContext.ContentService.Save(root); var children = new List <IContent>(); for (var i = 0; i < 25; i++) { var isInvariant = i % 2 == 0; var name = (isInvariant ? "INV" : "VAR") + "_" + Guid.NewGuid(); var culture = isInvariant ? null : "en-US"; var child = MockedContent.CreateSimpleContent( isInvariant ? invariantCt : variantCt, name, root, culture, setPropertyValues: isInvariant); if (!isInvariant) { //manually set the property values since we have mixed variant/invariant property types child.SetValue("title", name + " Subpage", culture: culture); child.SetValue("bodyText", "This is a subpage", culture: null); //this one is invariant child.SetValue("author", "John Doe", culture: culture); } ServiceContext.ContentService.Save(child); children.Add(child); } var child1 = children[1]; Assert.IsTrue(child1.ContentType.VariesByCulture()); Assert.IsTrue(child1.Name.StartsWith("VAR")); Assert.IsTrue(child1.GetCultureName("en-US").StartsWith("VAR")); var provider = TestObjects.GetScopeProvider(Logger); using (var scope = provider.CreateScope()) { var repository = CreateRepository((IScopeAccessor)provider, out _); var child = repository.Get(children[1].Id); // 1 is variant Assert.IsTrue(child.ContentType.VariesByCulture()); Assert.IsTrue(child.Name.StartsWith("VAR")); Assert.IsTrue(child.GetCultureName("en-US").StartsWith("VAR")); try { scope.Database.AsUmbracoDatabase().EnableSqlTrace = true; scope.Database.AsUmbracoDatabase().EnableSqlCount = true; var query = scope.SqlContext.Query <IContent>().Where(x => x.ParentId == root.Id); var result = repository.GetPage(query, 0, 20, out var totalRecords, null, Ordering.By("UpdateDate")); Assert.AreEqual(25, totalRecords); foreach (var r in result) { var isInvariant = r.ContentType.Alias == "umbInvariantTextpage"; var name = isInvariant ? r.Name : r.CultureInfos["en-US"].Name; var namePrefix = isInvariant ? "INV" : "VAR"; //ensure the correct name (invariant vs variant) is in the result Assert.IsTrue(name.StartsWith(namePrefix)); foreach (var p in r.Properties) { //ensure there is a value for the correct variant/invariant property var value = p.GetValue(p.PropertyType.Variations.VariesByNothing() ? null : "en-US"); Assert.IsNotNull(value); } } } finally { scope.Database.AsUmbracoDatabase().EnableSqlTrace = false; scope.Database.AsUmbracoDatabase().EnableSqlCount = false; } } }
private Auftrag GetAuftrag(Ordering ordering, OrderItem orderItem) { return(orderItem.VeId.HasValue ? GetAuftragForOrderItemWithVeId(ordering, orderItem) : GetAuftragFormularbestellung(ordering, orderItem)); }
public static extern CurandStatus curandSetGeneratorOrdering(CurandGenerator generator, Ordering order);
/// <summary> /// /// Set the ordering of results of the pseudo or quasirandom number generator. /// <para/> /// Legal values of order for pseudorandom generators are:<para/> /// - <see cref="Ordering.PseudoDefault"/><para/> /// - <see cref="Ordering.PseudoBest"/><para/> /// - <see cref="Ordering.PseudoSeeded"/><para/> /// <para/> /// Legal values of order for quasirandom generators are:<para/> /// - <see cref="Ordering.QuasiDefault"/> /// </summary> /// <param name="order"></param> public void SetGeneratorOrdering(Ordering order) { _status = CudaRandNativeMethods.curandSetGeneratorOrdering(_generator, order); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "curandSetGeneratorOrdering", _status)); if (_status != CurandStatus.Success) throw new CudaRandException(_status); }
public void Reset(string[] args, string optstring, Option[] longopts) { if (args == null || optstring == null) { throw new ArgumentNullException(); } this.args = args; this.optstring = optstring; this.longopts = longopts; done = false; opt = -1; optarg = null; optind = 0; optopt = '?'; longIndex = -1; nextchar = null; firstNonopt = lastNonopt = 0; if (optstring.StartsWith("-")) { ordering = Ordering.ReturnInOrder; optstring = optstring.Substring(1); } else if (optstring.StartsWith("+")) { ordering = Ordering.RequireOrder; optstring = optstring.Substring(1); } else if (posixlyCorrect) { ordering = Ordering.RequireOrder; } else { ordering = Ordering.Permute; } }
public List<Application> GetApplicationsForAreas(List<string> areas, Ordering order) { return _applicationsContext.Applications.Active() .Include(a => a.Requirements) .Include(a => a.Customers) .Include(a => a.Properties) .InWindow(_archiveWindowSettings.CalculateWindowStartDate()) .InArea(areas) .NotArchived() .OrderApplications(order) .ToList(); }
public static IQueryable<Property> OrderProperties(this IQueryable<Property> source, Ordering order) { Check.If(source).IsNotNull(); switch (order) { case Ordering.Newest: return source.OrderByDescending(p => p.StartDate); case Ordering.Oldest: return source.OrderBy(p => p.StartDate); case Ordering.LeastExpensive: return source.OrderBy(p => p.MonthlyPrice); default: return source.OrderByDescending(p => p.MonthlyPrice); } }
/// <summary> /// A constructor for specifying the most common requirements. /// </summary> /// <param name="d">the minimum reliability requirement</param> /// <param name="a">the minimum aggregation requirement</param> /// <param name="o">the minimum ordering requirement</param> public MessageDeliveryRequirements(Reliability d, MessageAggregation a, Ordering o) { Reliability = d; Aggregation = a; Ordering = o; }
/// <summary> /// Constructor to set the 3 most common value /// </summary> /// <param name="d">the required reliability</param> /// <param name="a">the desired aggregation</param> /// <param name="o">the required ordered</param> public ChannelDeliveryRequirements(Reliability d, MessageAggregation a, Ordering o) { Reliability = d; Aggregation = a; Ordering = o; Freshness = Freshness.IncludeAll; }
public ConfigurationData( LoggingLevel logging = LoggingLevel.Light, RoutingPolicy routing = RoutingPolicy.Flooding, Ordering ordering = Ordering.Fifo, string pupIP = "localhost") { this.logging = logging; this.routing = routing; this.ordering = ordering; this.PuppetMasterIP = pupIP; }
/// <summary>Yield all subdirectories of the supplied path as a text outline.</summary> /// <param name="rootPath">Topmost directory.</param> /// <param name="fileFilter">Search pattern or *null* for all.</param> /// <param name="drawWith">Outline characters.</param> /// <param name="order">Output sorting.</param> /// <param name="tab">Number of characters to indent per level.</param> /// <returns>All subdirectories of the supplied path as a text outline.</returns> public static IEnumerable <string> GenerateTextTree(string rootPath, string fileFilter, DrawWith drawWith = DrawWith.Graphic, Ordering order = Ordering.None, int tab = 4) { var sb = new StringBuilder(); for (var dv = new DirNode.Vector(rootPath, null, order, drawWith, tab); dv.Advance(); sb.Length = 0) { sb.AppendIndent(dv, false); sb.Append(dv.Depth == 0 ? dv.Top.Path : dv.Top.Name); yield return(sb.ToString()); if (fileFilter != null) { dv.PregetContents(fileFilter); if (dv.Top.FileInfos.Count > 0) { sb.Length = 0; sb.AppendIndent(dv, true); int indentLength = sb.Length; foreach (var fInfo in dv.Top.FileInfos) { sb.Append(fInfo.Name); yield return(sb.ToString()); sb.Length = indentLength; } yield return(sb.ToString()); } } } }
public OrderingClause(Position p, Expression/*!*/ expression, Ordering ordering) : base(p) { Debug.Assert(expression != null); this.expression = expression; this.ordering = ordering; }
public OrderBy(DirectVarUse keyVar, DirectVarUse valueVar, Expression expression, Ordering ordering, LinqOp next, bool isThenBy) { this.keyVar = keyVar; this.valueVar = valueVar; this.expression = expression; this.ordering = ordering; this.next = next; this.isThenBy = isThenBy; }
public PagedResult <ContentItemBasic <ContentPropertyBasic> > GetChildren(int id, int pageNumber = 0, int pageSize = 0, string orderBy = "SortOrder", Direction orderDirection = Direction.Ascending, bool orderBySystemField = true, string filter = "") { //if a request is made for the root node data but the user's start node is not the default, then // we need to return their start nodes if (id == Constants.System.Root && UserStartNodes.Length > 0 && UserStartNodes.Contains(Constants.System.Root) == false) { if (pageNumber > 0) { return(new PagedResult <ContentItemBasic <ContentPropertyBasic> >(0, 0, 0)); } var nodes = _mediaService.GetByIds(UserStartNodes).ToArray(); if (nodes.Length == 0) { return(new PagedResult <ContentItemBasic <ContentPropertyBasic> >(0, 0, 0)); } if (pageSize < nodes.Length) { pageSize = nodes.Length; // bah } var pr = new PagedResult <ContentItemBasic <ContentPropertyBasic> >(nodes.Length, pageNumber, pageSize) { Items = nodes.Select(_umbracoMapper.Map <IMedia, ContentItemBasic <ContentPropertyBasic> >) }; return(pr); } // else proceed as usual long totalChildren; List <IMedia> children; if (pageNumber > 0 && pageSize > 0) { IQuery <IMedia> queryFilter = null; if (filter.IsNullOrWhiteSpace() == false) { //add the default text filter queryFilter = _sqlContext.Query <IMedia>() .Where(x => x.Name.Contains(filter)); } children = _mediaService .GetPagedChildren( id, (pageNumber - 1), pageSize, out totalChildren, queryFilter, Ordering.By(orderBy, orderDirection, isCustomField: !orderBySystemField)).ToList(); } else { //better to not use this without paging where possible, currently only the sort dialog does children = _mediaService.GetPagedChildren(id, 0, int.MaxValue, out var total).ToList(); totalChildren = children.Count; } if (totalChildren == 0) { return(new PagedResult <ContentItemBasic <ContentPropertyBasic> >(0, 0, 0)); } var pagedResult = new PagedResult <ContentItemBasic <ContentPropertyBasic> >(totalChildren, pageNumber, pageSize); pagedResult.Items = children .Select(_umbracoMapper.Map <IMedia, ContentItemBasic <ContentPropertyBasic> >); return(pagedResult); }
public NullTransport(Reliability reliability, Ordering ordering, int delay, uint maxPacketSize) { Active = true; Reliability = reliability; Ordering = ordering; Delay = delay; MaximumPacketSize = maxPacketSize; }
public static IQueryable<Application> OrderApplications(this IQueryable<Application> source, Ordering order) { Check.If(source).IsNotNull(); switch (order) { case Ordering.DateCreated: return source.OrderByDescending(a => a.DateCreated); default: return source.OrderByDescending(a => a.DateUpdated); } }
public void GetPagedResultsByQuery_FilterMatchingAll() { var provider = TestObjects.GetScopeProvider(Logger); using (var scope = provider.CreateScope()) { var repository = CreateRepository((IScopeAccessor)provider, out _); var query = scope.SqlContext.Query <IContent>().Where(x => x.Level == 2); var filterQuery = scope.SqlContext.Query <IContent>().Where(x => x.Name.Contains("text")); var result = repository.GetPage(query, 0, 1, out var totalRecords, filterQuery, Ordering.By("Name")); Assert.That(totalRecords, Is.EqualTo(2)); Assert.That(result.Count(), Is.EqualTo(1)); Assert.That(result.First().Name, Is.EqualTo("Text Page 1")); } }
public IDataBuilder AddAuftrag(Ordering ordering, OrderItem item) { AddValue("Auftrag", GetAuftrag(ordering, item)); return(this); }
/// <summary> /// Visits the ordering. /// </summary> /// <param name="ordering">The ordering.</param> /// <param name="queryModel">The query model.</param> /// <param name="orderByClause">The order by clause.</param> /// <param name="index">The index.</param> public override void VisitOrdering(Ordering ordering, QueryModel queryModel, OrderByClause orderByClause, int index) { var memberMapPath = MemberMapPathBuilder.BuildFrom(this.mongoSession.MappingStore, ordering.Expression); this.querySpec.OrderBy[memberMapPath.Key] = ordering.OrderingDirection == OrderingDirection.Asc ? 1 : -1; }
public IDataBuilder AddBestellung(Ordering ordering) { expando.Bestellung = new Bestellung(ordering); return(this); }
public IQueryable<SalesOrderHeader> OrdersByValue(Ordering ordering) { return ordering == Ordering.Descending ? Instances<SalesOrderHeader>().OrderByDescending(obj => obj.TotalDue) : Instances<SalesOrderHeader>().OrderBy(obj => obj.TotalDue); }
public void GetPagedResultsByQuery_CustomPropertySort() { var provider = TestObjects.GetScopeProvider(Logger); using (var scope = provider.CreateScope()) { var repository = CreateRepository((IScopeAccessor)provider, out _); var query = scope.SqlContext.Query <IContent>().Where(x => x.Name.Contains("Text")); try { scope.Database.AsUmbracoDatabase().EnableSqlTrace = true; scope.Database.AsUmbracoDatabase().EnableSqlCount = true; var result = repository.GetPage(query, 0, 2, out var totalRecords, null, Ordering.By("title", isCustomField: true)); Assert.AreEqual(3, totalRecords); Assert.AreEqual(2, result.Count()); result = repository.GetPage(query, 1, 2, out totalRecords, null, Ordering.By("title", isCustomField: true)); Assert.AreEqual(1, result.Count()); } finally { scope.Database.AsUmbracoDatabase().EnableSqlTrace = false; scope.Database.AsUmbracoDatabase().EnableSqlCount = false; } } }
/// <summary>Yield all subdirectories of the supplied path.</summary> /// <param name="rootPath">Topmost directory.</param> /// <param name="filter">Search pattern or *null* for all.</param> /// <param name="order">Output sorting.</param> /// <returns>All subdirectories of the supplied path as text.</returns> public static IEnumerable <string> EnumerateDirectories(string rootPath, string filter = null, Ordering order = Ordering.None) { for (var dv = new DirNode.Vector(rootPath, filter, order); dv.Advance();) { yield return(dv.Top.Path); } }
public void GetPagedResultsByQuery_DescendingOrder() { var provider = TestObjects.GetScopeProvider(Logger); using (var scope = provider.CreateScope()) { var repository = CreateRepository((IScopeAccessor)provider, out _); var query = scope.SqlContext.Query <IContent>().Where(x => x.Level == 2); var result = repository.GetPage(query, 0, 1, out var totalRecords, null, Ordering.By("Name", Direction.Descending)); Assert.That(totalRecords, Is.GreaterThanOrEqualTo(2)); Assert.That(result.Count(), Is.EqualTo(1)); Assert.That(result.First().Name, Is.EqualTo("Text Page 2")); } }
public string OrderingToText(Ordering value) { switch (value) { case Ordering.Out: return "out"; case Ordering.In: return "in"; case Ordering.None: default: return null; } }
private static Ordering Compare(IEnumerator <KeyValuePair <Node, long> > i1, IEnumerator <KeyValuePair <Node, long> > i2, Ordering requestedOrder) { //TODO: Tail recursion issues? Func <KeyValuePair <Node, long>, KeyValuePair <Node, long>, Ordering, Ordering> compareNext = null; compareNext = (nt1, nt2, currentOrder) => { if (requestedOrder != Ordering.FullOrder && currentOrder != Ordering.Same && currentOrder != requestedOrder) { return(currentOrder); } if (nt1.Equals(CmpEndMarker) && nt2.Equals(CmpEndMarker)) { return(currentOrder); } // i1 is empty but i2 is not, so i1 can only be Before if (nt1.Equals(CmpEndMarker)) { return(currentOrder == Ordering.After ? Ordering.Concurrent : Ordering.Before); } // i2 is empty but i1 is not, so i1 can only be After if (nt2.Equals(CmpEndMarker)) { return(currentOrder == Ordering.Before ? Ordering.Concurrent : Ordering.After); } // compare the nodes var nc = nt1.Key.CompareTo(nt2.Key); if (nc == 0) { // both nodes exist compare the timestamps // same timestamp so just continue with the next nodes if (nt1.Value == nt2.Value) { return(compareNext(NextOrElse(i1, CmpEndMarker), NextOrElse(i2, CmpEndMarker), currentOrder)); } if (nt1.Value < nt2.Value) { // t1 is less than t2, so i1 can only be Before if (currentOrder == Ordering.After) { return(Ordering.Concurrent); } return(compareNext(NextOrElse(i1, CmpEndMarker), NextOrElse(i2, CmpEndMarker), Ordering.Before)); } if (currentOrder == Ordering.Before) { return(Ordering.Concurrent); } return(compareNext(NextOrElse(i1, CmpEndMarker), NextOrElse(i2, CmpEndMarker), Ordering.After)); } if (nc < 0) { // this node only exists in i1 so i1 can only be After if (currentOrder == Ordering.Before) { return(Ordering.Concurrent); } return(compareNext(NextOrElse(i1, CmpEndMarker), nt2, Ordering.After)); } // this node only exists in i2 so i1 can only be Before if (currentOrder == Ordering.After) { return(Ordering.Concurrent); } return(compareNext(nt1, NextOrElse(i2, CmpEndMarker), Ordering.Before)); }; return(compareNext(NextOrElse(i1, CmpEndMarker), NextOrElse(i2, CmpEndMarker), Ordering.Same)); }
public SodaQueryComparator(LocalObjectContainer container, Type extentType, Ordering [] orderings) : this(container, container.ProduceClassMetadata(container.Reflector ().ForClass(extentType)), orderings) { }
public override void VisitOrdering(Ordering ordering, QueryModel queryModel, OrderByClause orderByClause, int index) { _memberExpressionJoinDetector.Transform(ordering); }
/// <summary> /// Updates indexes based on content changes /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void ContentCacheRefresherUpdated(ContentCacheRefresher sender, CacheRefresherEventArgs args) { if (Suspendable.ExamineEvents.CanIndex == false) { return; } if (args.MessageType != MessageType.RefreshByPayload) { throw new NotSupportedException(); } var contentService = _services.ContentService; foreach (var payload in (ContentCacheRefresher.JsonPayload[])args.MessageObject) { if (payload.ChangeTypes.HasType(TreeChangeTypes.Remove)) { // delete content entirely (with descendants) // false: remove entirely from all indexes DeleteIndexForEntity(payload.Id, false); } else if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll)) { // ExamineEvents does not support RefreshAll // just ignore that payload // so what?! // TODO: Rebuild the index at this point? } else // RefreshNode or RefreshBranch (maybe trashed) { // don't try to be too clever - refresh entirely // there has to be race conditions in there ;-( var content = contentService.GetById(payload.Id); if (content == null) { // gone fishing, remove entirely from all indexes (with descendants) DeleteIndexForEntity(payload.Id, false); continue; } IContent published = null; if (content.Published && contentService.IsPathPublished(content)) { published = content; } if (published == null) { DeleteIndexForEntity(payload.Id, true); } // just that content ReIndexForContent(content, published != null); // branch if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshBranch)) { var masked = published == null ? null : new List <int>(); const int pageSize = 500; var page = 0; var total = long.MaxValue; while (page * pageSize < total) { var descendants = contentService.GetPagedDescendants(content.Id, page++, pageSize, out total, //order by shallowest to deepest, this allows us to check it's published state without checking every item ordering: Ordering.By("Path", Direction.Ascending)); foreach (var descendant in descendants) { published = null; if (masked != null) // else everything is masked { if (masked.Contains(descendant.ParentId) || !descendant.Published) { masked.Add(descendant.Id); } else { published = descendant; } } ReIndexForContent(descendant, published != null); } } } } // NOTE // // DeleteIndexForEntity is handled by UmbracoContentIndexer.DeleteFromIndex() which takes // care of also deleting the descendants // // ReIndexForContent is NOT taking care of descendants so we have to reload everything // again in order to process the branch - we COULD improve that by just reloading the // XML from database instead of reloading content & re-serializing! // // BUT ... pretty sure it is! see test "Index_Delete_Index_Item_Ensure_Heirarchy_Removed" } }
/// <summary>Yield all subdirectories of the supplied path.</summary> /// <param name="rootPath">Topmost directory.</param> /// <param name="fileFilter">Search pattern or *null* for all.</param> /// <param name="order">Output sorting.</param> /// <returns>All subdirectories of the supplied path as text.</returns> public static IEnumerable <string> EnumerateFiles(string rootPath, string fileFilter = null, Ordering order = Ordering.None) { if (fileFilter == null) { fileFilter = "*"; } for (var dv = new DirNode.Vector(rootPath, null, order); dv.Advance();) { dv.PregetContents(fileFilter); foreach (var fInfo in dv.Top.FileInfos) { yield return(fInfo.FullName); } } }
private Ordering Compare(IEnumerator <KeyValuePair <UniqueAddress, long> > i1, IEnumerator <KeyValuePair <UniqueAddress, long> > i2, Ordering requestedOrder) { var nt1 = NextOrElse(i1, EndMarker); var nt2 = NextOrElse(i2, EndMarker); var currentOrder = Ordering.Same; while (true) { if (requestedOrder != Ordering.FullOrder && currentOrder != Ordering.Same && currentOrder != requestedOrder) { return(currentOrder); } else if (Equals(nt1, EndMarker) && Equals(nt2, EndMarker)) { return(currentOrder); } else if (Equals(nt1, EndMarker)) { return(currentOrder == Ordering.After ? Ordering.Concurrent : Ordering.Before); } else if (Equals(nt2, EndMarker)) { return(currentOrder == Ordering.Before ? Ordering.Concurrent : Ordering.After); } else { var nc = nt1.Key.CompareTo(nt2.Key); if (nc == 0) { if (nt1.Value < nt2.Value) { if (currentOrder == Ordering.After) { return(Ordering.Concurrent); } currentOrder = Ordering.Before; } else if (nt1.Value > nt2.Value) { if (currentOrder == Ordering.Before) { return(Ordering.Concurrent); } currentOrder = Ordering.After; } nt1 = NextOrElse(i1, EndMarker); nt2 = NextOrElse(i2, EndMarker); } else if (nc < 0) { if (currentOrder == Ordering.Before) { return(Ordering.Concurrent); } currentOrder = Ordering.After; nt1 = NextOrElse(i1, EndMarker); } else { if (currentOrder == Ordering.After) { return(Ordering.Concurrent); } currentOrder = Ordering.Before; nt2 = NextOrElse(i2, EndMarker); } } } }
/// <summary>Yield all subdirectories of the supplied path.</summary> /// <param name="rootPath">Topmost directory.</param> /// <param name="filter">Search pattern or *null* for all.</param> /// <param name="order">Output sorting.</param> /// <returns>All subdirectories of the supplied path as <see cref="DirectoryInfo"/> instances.</returns> public static IEnumerable <DirectoryInfo> EnumerateDirectoriesForInfo(string rootPath, string filter = null, Ordering order = Ordering.None) { for (var dv = new DirNode.Vector(rootPath, filter, order); dv.Advance();) { yield return(dv.Top.dirInfos[dv.Top.Index]); } }
public override void VisitOrdering(Ordering ordering, QueryModel queryModel, OrderByClause orderByClause, int index) { base.VisitOrdering(ordering, queryModel, orderByClause, index); TransformingVisitor.StringBuilder.Append($" {ordering.OrderingDirection.ToString().ToLower()}"); }
public IEnumerable <Post> GetPostsForUser(Guid userId, bool selfPosts, int pageIndex = 1, int pageSize = 1, Ordering <Post> ordering = null, Guid?interestId = null) { IEnumerable <Post> posts = null; if (interestId != null) { posts = Posts.GetPostsForInterest((Guid)interestId, pageIndex, pageSize); } else { posts = Posts.Get(userId, selfPosts, pageIndex, pageSize, ordering); } return(posts); }
public IEnumerable<Property> GetPropertiesByAreas(List<string> areas, Ordering order) { return _propertiesContext.Properties .Include(x => x.PropertyDetails) .Include(x => x.PropertyPhotos) .ActiveLetAvailable() .MatchesAreas(areas) .OrderProperties(order) .FilterByAreas(areas); }
public virtual void VisitOrdering(Ordering ordering, QueryModel queryModel, OrderByClause orderByClause, int index) { }
public override void VisitOrdering(Ordering ordering, QueryModel queryModel, OrderByClause orderByClause, int index) { _groupJoinAggregateDetectionVisitor.Visit(ordering.Expression); }
internal void Parse(Ordering ordering) { direction = ordering.OrderingDirection; Visit(ordering.Expression); }
// get a page of entities public IEnumerable <IEntitySlim> GetPagedResultsByQuery(IQuery <IUmbracoEntity> query, Guid objectType, long pageIndex, int pageSize, out long totalRecords, IQuery <IUmbracoEntity> filter, Ordering ordering) { var isContent = objectType == Constants.ObjectTypes.Document || objectType == Constants.ObjectTypes.DocumentBlueprint; var isMedia = objectType == Constants.ObjectTypes.Media; var sql = GetBaseWhere(isContent, isMedia, false, x => { if (filter == null) { return; } foreach (var filterClause in filter.GetWhereClauses()) { x.Where(filterClause.Item1, filterClause.Item2); } }, objectType); ordering = ordering ?? Ordering.ByDefault(); var translator = new SqlTranslator <IUmbracoEntity>(sql, query); sql = translator.Translate(); sql = AddGroupBy(isContent, isMedia, sql, ordering.IsEmpty); if (!ordering.IsEmpty) { // apply ordering ApplyOrdering(ref sql, ordering); } // TODO: we should be able to do sql = sql.OrderBy(x => Alias(x.NodeId, "NodeId")); but we can't because the OrderBy extension don't support Alias currently //no matter what we always must have node id ordered at the end sql = ordering.Direction == Direction.Ascending ? sql.OrderBy("NodeId") : sql.OrderByDescending("NodeId"); // for content we must query for ContentEntityDto entities to produce the correct culture variant entity names var pageIndexToFetch = pageIndex + 1; IEnumerable <BaseDto> dtos; if (isContent) { var page = Database.Page <ContentEntityDto>(pageIndexToFetch, pageSize, sql); dtos = page.Items; totalRecords = page.TotalItems; } else if (isMedia) { var page = Database.Page <MediaEntityDto>(pageIndexToFetch, pageSize, sql); dtos = page.Items; totalRecords = page.TotalItems; } else { var page = Database.Page <BaseDto>(pageIndexToFetch, pageSize, sql); dtos = page.Items; totalRecords = page.TotalItems; } var entities = dtos.Select(x => BuildEntity(isContent, isMedia, x)).ToArray(); if (isContent) { BuildVariants(entities.Cast <DocumentEntitySlim>()); } return(entities); }
//protected IMemoryCache _memoryCache //{ // get { } set { } //} public ResultDto <ResultProductForSiteDto> Execute(string SearchKey, int?CatId, int Page, int PageSize, Ordering ordering) { //Memorycache ------- var cacheKey = "allproducts"; //List<Product> List_CachedProducts; //string serializedProducts; //var Redis_encodedProducts = _distributedCache.Get(cacheKey); //if(Redis_encodedProducts!=null) //{ // serializedProducts = Encoding.UTF8.GetString(Redis_encodedProducts); // List_CachedProducts = JsonConvert.DeserializeObject<List<Product>>(serializedProducts); //} //else if (!_memoryCache.TryGetValue(cacheKey, out List <Product> List_CachedProducts)) { // List_CachedProducts = _context.Products .Include(p => p.Category) .Include(p => p.SellerProducts) .Include(p => p.ProductImages).ToList(); // var cacheExpirationOption = new MemoryCacheEntryOptions { AbsoluteExpiration = DateTime.Now.AddHours(5), Priority = CacheItemPriority.Normal, SlidingExpiration = TimeSpan.FromMinutes(4), Size = 1024, }; _memoryCache.Set(cacheKey, List_CachedProducts, cacheExpirationOption); // //serializedProducts = //JsonConvert.SerializeObject(List_CachedProducts, Formatting.None, // new JsonSerializerSettings() // { // ReferenceLoopHandling = ReferenceLoopHandling.Ignore // }); //Redis_encodedProducts = Encoding.UTF8.GetBytes(serializedProducts); //_distributedCache.Set(cacheKey, Redis_encodedProducts, cacheExpirationOption); } //_memoryCache //if (!_memoryCache.TryGetValue(cacheKey,out List<Product> List_CachedProduct)) //{ // List_CachedProduct = _context.Products // .Include(p => p.SellerProducts) // .Include(p => p.ProductImages).ToList(); // var cacheExpirationOption = new MemoryCacheEntryOptions() // { // AbsoluteExpiration = DateTime.Now.AddDays(1), // Priority = CacheItemPriority.Normal, // SlidingExpiration = TimeSpan.FromDays(1), // Size = 10258, // }; // _memoryCache.Set(cacheKey, List_CachedProduct,cacheExpirationOption); //} int TotalRows = 0; var productQuery = List_CachedProducts .AsQueryable(); if (CatId != null) { productQuery = productQuery.Include(p => p.SellerProducts).Where(p => p.CategoryId == CatId || p.Category.ParentCategoryId == CatId).AsQueryable(); } if (!String.IsNullOrWhiteSpace(SearchKey)) { productQuery = productQuery.Include(p => p.SellerProducts).Where(p => p.Name.Contains(SearchKey) || p.Brand.Contains(SearchKey)); } switch (ordering) { case Ordering.NotOrder: productQuery = productQuery.OrderByDescending(p => p.Id).AsQueryable(); break; case Ordering.MostVisited: productQuery = productQuery.OrderByDescending(p => p.ViewCount).AsQueryable(); break; case Ordering.Bestselling: productQuery = productQuery.OrderByDescending(p => p.Id).AsQueryable(); break; case Ordering.MostPopular: break; case Ordering.theNewest: productQuery = productQuery.OrderByDescending(p => p.Id).AsQueryable(); break; case Ordering.Cheapest: productQuery = productQuery.OrderBy(p => p.Price).AsQueryable(); break; case Ordering.theMostExpensive: productQuery = productQuery.OrderByDescending(p => p.Price).AsQueryable(); break; } //if (productQuery.ToList().Count == 0) //{ // productQuery = _context.Products // .Include(p => p.ProductImages).Where(p => p.Name.Contains(SearchKey) || p.Brand.Contains(SearchKey)); //} var products = productQuery.ToPaged(Page, PageSize, out TotalRows); //var products2 = _context.Products.FromSqlRaw("SELECT * FROM PRODUCTS").ToList(); Random rd = new Random(); return(new ResultDto <ResultProductForSiteDto>() { Data = new ResultProductForSiteDto() { Products = products.Select(p => new ProductForSiteDto { Id = p.Id, Star = rd.Next(1, 5), Title = p.Name, Price = p.SellerProducts.Count > 0 && p.SellerProducts.Count(s => s.Inventory > 0) > 0 ? p.SellerProducts.OrderBy(s => s.SellerPrice).FirstOrDefault().SellerPrice : 0, ImageSrc = p.ProductImages.FirstOrDefault().Src, }).ToList(), TotalRows = TotalRows }, IsSuccess = true, Message = "", }); }
public SortItem(object sortKey, Ordering ordering, NullOrdering nullOrdering) : this(null, sortKey, ordering, nullOrdering) { }
public int CompareTo(Member other) { return(Ordering.Compare(this, other)); }
public SortItem(NodeLocation location, object sortKey, Ordering ordering, NullOrdering nullOrdering) : base(location) { this.Ordering = ordering; this.NullOrdering = nullOrdering; this.SortKey = sortKey; }
public void GetPagedResultsByQuery_FirstPage() { // Arrange var provider = TestObjects.GetScopeProvider(Logger); using (var scope = provider.CreateScope()) { var repository = CreateRepository(provider, out MediaTypeRepository mediaTypeRepository); // Act var query = scope.SqlContext.Query <IMedia>().Where(x => x.Level == 2); long totalRecords; var result = repository.GetPage(query, 0, 1, out totalRecords, null, Ordering.By("SortOrder")); // Assert Assert.That(totalRecords, Is.GreaterThanOrEqualTo(2)); Assert.That(result.Count(), Is.EqualTo(1)); Assert.That(result.First().Name, Is.EqualTo("Test Image")); } }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public override void VisitOrdering(Ordering ordering, QueryModel queryModel, OrderByClause orderByClause, int index) => ordering.TransformExpressions(TransformingVisitor.Visit);