Exemplo n.º 1
0
		/// <summary>Creates a navigation using unordered list elements.</summary>
		public static N2.Web.Tree Tree(this HtmlHelper html,
			ContentItem startsFrom = null,
			ContentItem current = null,
			int takeLevels = 2,
			bool parallelRoot = true,
			bool appendCreatorNode = false,
			ItemFilter filter = null,
			object htmlAttributes = null)
		{
			if (startsFrom == null) startsFrom = html.StartPage();
			if (current == null) current = html.CurrentPage();
			if (filter == null) filter = new NavigationFilter(html.ViewContext.HttpContext.User, html.ContentEngine().SecurityManager);

			var builder = parallelRoot
				? (HierarchyBuilder)new ParallelRootHierarchyBuilder(startsFrom, takeLevels)
				: (HierarchyBuilder)new TreeHierarchyBuilder(startsFrom, takeLevels);

			if (builder == null)
				throw new ArgumentException("builder == null");

			if (appendCreatorNode && ControlPanelExtensions.GetControlPanelState(html).IsFlagSet(ControlPanelState.DragDrop))
				builder.GetChildren = (i) => i == null ? null : i.Children.FindNavigatablePages().Where(filter).AppendCreatorNode(html.ContentEngine(), i);
			else
				builder.GetChildren = (i) => i == null ? null : i.Children.FindNavigatablePages().Where(filter);

			var tree = N2.Web.Tree.Using(builder);
			if (htmlAttributes != null)
				tree.Tag(ApplyToRootUl(htmlAttributes));

			ClassifyAnchors(startsFrom, current, parallelRoot, tree);

			return tree;
		}
Exemplo n.º 2
0
		internal static void Write(HierarchyNode<ContentItem> hierarchy, ContentItem selectedItem, IContentAdapterProvider adapters, ItemFilter filter, string selectableTypes, string selectableExtensions, bool excludeRoot, string target, TextWriter writer)
		{
			N2.Web.Tree.Using(hierarchy)
				.OpenTo(selectedItem)
				.Filters(filter)
				.IdProvider(n => "u" + n.Current.ID, n => "l" + n.Current.ID)
				.LinkWriter((n, w) =>
				{
					BuildLink(adapters.ResolveAdapter<NodeAdapter>(n.Current), n.Current, n.Current.Path == selectedItem.Path, target, IsSelectable(n.Current, selectableTypes, selectableExtensions)).WriteTo(w);
					if (n.Children.Count == 0 && adapters.ResolveAdapter<NodeAdapter>(n.Current).HasChildren(n.Current, filter))
					{
						var ul = new TagBuilder("ul");
						ul.AddCssClass("ajax");
						w.Write(ul.ToString(TagRenderMode.StartTag));

						var li = new TagBuilder("li");
						li.InnerHtml = "{url:" + Url.ParseTokenized("{ManagementUrl}/Content/Navigation/LoadTree.ashx")
							.AppendQuery("target", target)
							.AppendQuery(SelectionUtility.SelectedQueryKey, HttpUtility.UrlEncode(n.Current.Path))
							.AppendQuery("selectableTypes", selectableTypes)
							.AppendQuery("selectableExtensions", selectableExtensions)
							+ "}";
						w.Write(li.ToString());

						w.Write(ul.ToString(TagRenderMode.EndTag));
					}
				})
				.ExcludeRoot(excludeRoot)
				.WriteTo(writer);
		}
Exemplo n.º 3
0
        public AllChannelMediaQuery()
        {
            ChannelIds = new string[] { };

            ContentTypes = new ChannelMediaContentType[] { };

            Filters = new ItemFilter[] { };
            Fields = new List<ItemFields>();
        }
Exemplo n.º 4
0
        /// <summary>Builds the hierachy using the specified child factory method.</summary>
        /// <param name="filters">The filters.</param>
        /// <returns></returns>
        public HierarchyBuilder Children(params ItemFilter[] filters)
        {
            Filter = (filters.Length == 1)
                ? filters[0]
                : new AllFilter(filters);

            GetChildren = (item) => item.Children.Filter(filters);
            return this;
        }
		private ItemFilter[] GetFilters()
		{
			ItemFilter[] filters;
			if (FeedRoot != null)
				filters = new ItemFilter[] {new TypeFilter(typeof (ISyndicatable)), new AccessFilter(), new ParentFilter(FeedRoot)};
			else
				filters = new ItemFilter[] {new TypeFilter(typeof (ISyndicatable)), new AccessFilter()};
			return filters;
		}
Exemplo n.º 6
0
 internal static HierarchyNode<ContentItem> BuildBranchStructure(ItemFilter filter, IContentAdapterProvider adapters, ContentItem selectedItem, ContentItem root)
 {
     var structure = new BranchHierarchyBuilder(selectedItem, root, true) { UseMasterVersion = false }
         .Children((item) =>
         {
             var q = new N2.Persistence.Sources.Query { Parent = item, OnlyPages = true, Interface = Interfaces.Managing, Filter = filter };
             return adapters.ResolveAdapter<NodeAdapter>(item).GetChildren(q);
         })
         .Build();
     return structure;
 }
Exemplo n.º 7
0
 internal static HierarchyNode<ContentItem> BuildTreeStructure(ItemFilter filter, IContentAdapterProvider adapters, ContentItem selectedItem, int maxDepth)
 {
     var structure = new TreeHierarchyBuilder(selectedItem, maxDepth)
         .Children((item) =>
         {
             var q = new N2.Persistence.Sources.Query { Parent = item, OnlyPages = true, Interface = Interfaces.Managing, Filter = filter };
             return adapters.ResolveAdapter<NodeAdapter>(item).GetChildren(q);
         })
         .Build();
     return structure;
 }
Exemplo n.º 8
0
        public Tree TreeFrom(ContentItem item, int takeLevels = 3, bool rootless = false, Func<ContentItem, string> cssGetter = null, ItemFilter filter = null)
        {
            if (item == null)
                return CreateTree(new NoHierarchyBuilder());

            if (cssGetter == null)
                cssGetter = GetNavigationClass;

            return CreateTree(new TreeHierarchyBuilder(item, takeLevels))
                .ExcludeRoot(rootless)
                .LinkProvider((i) => LinkTo(i).Class(cssGetter(i)))
                .Filters(filter ?? N2.Content.Is.Navigatable());
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            portalDc = new DALPortalDataContext();

              this.itemFilter = (ItemFilter)Session["itemFilter"];

              if (!IsPostBack)
              {
            this.selectedItemId = Convert.ToInt32(Session["selectedItemId"]);
            this.selectedCompanyCode = Session["selectedCompanyCode"].ToString();

            IQueryable<vw_item> data = EsmHelper.GetData(portalDc, this.itemFilter);

            int index = data.ToList().FindIndex(c => c.itemId.Equals(selectedItemId) && c.companyCode.Equals(selectedCompanyCode));

            RadDataPager radDataPager = RadListViewItem.FindControl("RadDataPagerItem") as RadDataPager;
            radDataPager.FireCommand("Page", (index).ToString());
              }
        }
Exemplo n.º 10
0
 private static ContentItem First(IEnumerable<ContentItem> children, ItemFilter filter)
 {
     foreach (var child in filter.Pipe(children))
     {
         return child;
     }
     return null;
 }
Exemplo n.º 11
0
        private IQueryable <ItemDAO> OrFilter(IQueryable <ItemDAO> query, ItemFilter filter)
        {
            if (filter.OrFilter == null || filter.OrFilter.Count == 0)
            {
                return(query);
            }
            IQueryable <ItemDAO> initQuery = query.Where(q => false);

            foreach (ItemFilter ItemFilter in filter.OrFilter)
            {
                IQueryable <ItemDAO> queryable = query;
                if (ItemFilter.SalePrice != null && ItemFilter.SalePrice.HasValue)
                {
                    queryable = queryable.Where(q => q.SalePrice, ItemFilter.SalePrice);
                }
                if (ItemFilter.ProductTypeId != null && ItemFilter.ProductTypeId.HasValue)
                {
                    queryable = queryable.Where(q => q.Product.ProductTypeId, ItemFilter.ProductTypeId);
                }
                if (ItemFilter.ProductGroupingId != null && ItemFilter.ProductGroupingId.HasValue)
                {
                    if (ItemFilter.ProductGroupingId.Equal != null)
                    {
                        ProductGroupingDAO ProductGroupingDAO = DataContext.ProductGrouping
                                                                .Where(o => o.Id == ItemFilter.ProductGroupingId.Equal.Value).FirstOrDefault();
                        queryable = from q in queryable
                                    join ppg in DataContext.ProductProductGroupingMapping on q.ProductId equals ppg.ProductId
                                    join pg in DataContext.ProductGrouping on ppg.ProductGroupingId equals pg.Id
                                    where pg.Path.StartsWith(ProductGroupingDAO.Path)
                                    select q;
                    }
                    if (ItemFilter.ProductGroupingId.NotEqual != null)
                    {
                        ProductGroupingDAO ProductGroupingDAO = DataContext.ProductGrouping
                                                                .Where(o => o.Id == ItemFilter.ProductGroupingId.NotEqual.Value).FirstOrDefault();
                        queryable = from q in queryable
                                    join ppg in DataContext.ProductProductGroupingMapping on q.ProductId equals ppg.ProductId
                                    join pg in DataContext.ProductGrouping on ppg.ProductGroupingId equals pg.Id
                                    where !pg.Path.StartsWith(ProductGroupingDAO.Path)
                                    select q;
                    }
                    if (ItemFilter.ProductGroupingId.In != null)
                    {
                        List <ProductGroupingDAO> ProductGroupingDAOs = DataContext.ProductGrouping
                                                                        .Where(o => o.DeletedAt == null).ToList();
                        List <ProductGroupingDAO> Parents  = ProductGroupingDAOs.Where(o => ItemFilter.ProductGroupingId.In.Contains(o.Id)).ToList();
                        List <ProductGroupingDAO> Branches = ProductGroupingDAOs.Where(o => Parents.Any(p => o.Path.StartsWith(p.Path))).ToList();
                        List <long> ProductGroupingIds     = Branches.Select(o => o.Id).ToList();
                        queryable = from q in queryable
                                    join ppg in DataContext.ProductProductGroupingMapping on q.ProductId equals ppg.ProductId
                                    join pg in DataContext.ProductGrouping on ppg.ProductGroupingId equals pg.Id
                                    where ProductGroupingIds.Contains(pg.Id)
                                    select q;
                    }
                    if (ItemFilter.ProductGroupingId.NotIn != null)
                    {
                        List <ProductGroupingDAO> ProductGroupingDAOs = DataContext.ProductGrouping
                                                                        .Where(o => o.DeletedAt == null).ToList();
                        List <ProductGroupingDAO> Parents  = ProductGroupingDAOs.Where(o => ItemFilter.ProductGroupingId.NotIn.Contains(o.Id)).ToList();
                        List <ProductGroupingDAO> Branches = ProductGroupingDAOs.Where(o => Parents.Any(p => o.Path.StartsWith(p.Path))).ToList();
                        List <long> ProductGroupingIds     = Branches.Select(o => o.Id).ToList();
                        queryable = from q in queryable
                                    join ppg in DataContext.ProductProductGroupingMapping on q.ProductId equals ppg.ProductId
                                    join pg in DataContext.ProductGrouping on ppg.ProductGroupingId equals pg.Id
                                    where !ProductGroupingIds.Contains(pg.Id)
                                    select q;
                    }
                }
                initQuery = initQuery.Union(queryable);
            }
            return(initQuery);
        }
Exemplo n.º 12
0
        private async Task <List <Item> > DynamicSelect(IQueryable <ItemDAO> query, ItemFilter filter)
        {
            List <Item> Items = await query.Select(q => new Item()
            {
                Id          = filter.Selects.Contains(ItemSelect.Id) ? q.Id : default(long),
                ProductId   = filter.Selects.Contains(ItemSelect.ProductId) ? q.ProductId : default(long),
                Code        = filter.Selects.Contains(ItemSelect.Code) ? q.Code : default(string),
                Name        = filter.Selects.Contains(ItemSelect.Name) ? q.Name : default(string),
                ScanCode    = filter.Selects.Contains(ItemSelect.ScanCode) ? q.ScanCode : default(string),
                SalePrice   = filter.Selects.Contains(ItemSelect.SalePrice) ? q.SalePrice : default(decimal?),
                RetailPrice = filter.Selects.Contains(ItemSelect.RetailPrice) ? q.RetailPrice : default(decimal?),
                StatusId    = filter.Selects.Contains(ItemSelect.Status) ? q.StatusId : default(long),
                Product     = filter.Selects.Contains(ItemSelect.Product) && q.Product != null ? new Product
                {
                    Id                      = q.Product.Id,
                    Code                    = q.Product.Code,
                    Name                    = q.Product.Name,
                    Description             = q.Product.Description,
                    ScanCode                = q.Product.ScanCode,
                    ProductTypeId           = q.Product.ProductTypeId,
                    BrandId                 = q.Product.BrandId,
                    UnitOfMeasureId         = q.Product.UnitOfMeasureId,
                    UnitOfMeasureGroupingId = q.Product.UnitOfMeasureGroupingId,
                    SalePrice               = q.Product.SalePrice,
                    RetailPrice             = q.Product.RetailPrice,
                    TaxTypeId               = q.Product.TaxTypeId,
                    StatusId                = q.Product.StatusId,
                    Category                = new Category
                    {
                        Id       = q.Product.Category.Id,
                        Code     = q.Product.Category.Code,
                        Name     = q.Product.Category.Name,
                        Path     = q.Product.Category.Path,
                        ParentId = q.Product.Category.ParentId,
                        StatusId = q.Product.Category.StatusId,
                        Level    = q.Product.Category.Level
                    },
                    ProductType = new ProductType
                    {
                        Id          = q.Product.ProductType.Id,
                        Code        = q.Product.ProductType.Code,
                        Name        = q.Product.ProductType.Name,
                        Description = q.Product.ProductType.Description,
                        StatusId    = q.Product.ProductType.StatusId,
                        UpdatedAt   = q.Product.ProductType.UpdatedAt,
                    },
                    TaxType = new TaxType
                    {
                        Id         = q.Product.TaxType.Id,
                        Code       = q.Product.TaxType.Code,
                        Name       = q.Product.TaxType.Name,
                        Percentage = q.Product.TaxType.Percentage,
                        StatusId   = q.Product.TaxType.StatusId,
                    },
                    UnitOfMeasure = new UnitOfMeasure
                    {
                        Id   = q.Product.UnitOfMeasure.Id,
                        Code = q.Product.UnitOfMeasure.Code,
                        Name = q.Product.UnitOfMeasure.Name,
                    },
                    UnitOfMeasureGrouping = new UnitOfMeasureGrouping
                    {
                        Id   = q.Product.UnitOfMeasureGrouping.Id,
                        Code = q.Product.UnitOfMeasureGrouping.Code,
                        Name = q.Product.UnitOfMeasureGrouping.Name
                    },
                    ProductProductGroupingMappings = q.Product.ProductProductGroupingMappings != null ?
                                                     q.Product.ProductProductGroupingMappings.Select(p => new ProductProductGroupingMapping
                    {
                        ProductId         = p.ProductId,
                        ProductGroupingId = p.ProductGroupingId,
                        ProductGrouping   = new ProductGrouping
                        {
                            Id          = p.ProductGrouping.Id,
                            Code        = p.ProductGrouping.Code,
                            Name        = p.ProductGrouping.Name,
                            ParentId    = p.ProductGrouping.ParentId,
                            Path        = p.ProductGrouping.Path,
                            Description = p.ProductGrouping.Description,
                        },
                    }).ToList() : null,
                } : null,
                Status = filter.Selects.Contains(ItemSelect.Status) && q.Status == null ? null : new Status
                {
                    Id   = q.Status.Id,
                    Code = q.Status.Code,
                    Name = q.Status.Name,
                },
                Used = q.Used,
            }).ToListAsync();

            var Ids                  = Items.Select(x => x.Id).ToList();
            var ProductIds           = Items.Select(x => x.ProductId).ToList();
            var ProductImageMappings = DataContext.ProductImageMapping.Include(x => x.Image).Where(x => ProductIds.Contains(x.ProductId)).ToList();
            var ItemImageMappings    = DataContext.ItemImageMapping.Include(x => x.Image).Where(x => Ids.Contains(x.ItemId)).ToList();

            foreach (var Item in Items)
            {
                Item.ItemImageMappings = new List <ItemImageMapping>();
                var ItemImageMappingDAO = ItemImageMappings.Where(x => x.ItemId == Item.Id).FirstOrDefault();
                if (ItemImageMappingDAO != null)
                {
                    ItemImageMapping ItemImageMapping = new ItemImageMapping
                    {
                        ImageId = ItemImageMappingDAO.ImageId,
                        ItemId  = ItemImageMappingDAO.ItemId,
                        Image   = ItemImageMappingDAO.Image == null ? null : new Image
                        {
                            Id           = ItemImageMappingDAO.Image.Id,
                            Name         = ItemImageMappingDAO.Image.Name,
                            Url          = ItemImageMappingDAO.Image.Url,
                            ThumbnailUrl = ItemImageMappingDAO.Image.ThumbnailUrl
                        }
                    };
                    Item.ItemImageMappings.Add(ItemImageMapping);
                }
                if (Item.ItemImageMappings.Count == 0)
                {
                    var ProductImageMappingDAO = ProductImageMappings.Where(x => x.ProductId == Item.ProductId).FirstOrDefault();
                    if (ProductImageMappingDAO != null)
                    {
                        ItemImageMapping ItemImageMapping = new ItemImageMapping
                        {
                            ImageId = ProductImageMappingDAO.ImageId,
                            ItemId  = Item.Id,
                            Image   = ProductImageMappingDAO.Image == null ? null : new Image
                            {
                                Id           = ProductImageMappingDAO.Image.Id,
                                Name         = ProductImageMappingDAO.Image.Name,
                                Url          = ProductImageMappingDAO.Image.Url,
                                ThumbnailUrl = ProductImageMappingDAO.Image.ThumbnailUrl
                            }
                        };
                        Item.ItemImageMappings.Add(ItemImageMapping);
                    }
                }
            }
            return(Items);
        }
Exemplo n.º 13
0
        private IQueryable <ItemDAO> DynamicOrder(IQueryable <ItemDAO> query, ItemFilter filter)
        {
            switch (filter.OrderType)
            {
            case OrderType.ASC:
                switch (filter.OrderBy)
                {
                case ItemOrder.Id:
                    query = query.OrderBy(q => q.Id);
                    break;

                case ItemOrder.Product:
                    query = query.OrderBy(q => q.ProductId);
                    break;

                case ItemOrder.Code:
                    query = query.OrderBy(q => q.Code);
                    break;

                case ItemOrder.Name:
                    query = query.OrderBy(q => q.Name);
                    break;

                case ItemOrder.ScanCode:
                    query = query.OrderBy(q => q.ScanCode);
                    break;

                case ItemOrder.SalePrice:
                    query = query.OrderBy(q => q.SalePrice);
                    break;

                case ItemOrder.RetailPrice:
                    query = query.OrderBy(q => q.RetailPrice);
                    break;
                }
                break;

            case OrderType.DESC:
                switch (filter.OrderBy)
                {
                case ItemOrder.Id:
                    query = query.OrderByDescending(q => q.Id);
                    break;

                case ItemOrder.Product:
                    query = query.OrderByDescending(q => q.ProductId);
                    break;

                case ItemOrder.Code:
                    query = query.OrderByDescending(q => q.Code);
                    break;

                case ItemOrder.Name:
                    query = query.OrderByDescending(q => q.Name);
                    break;

                case ItemOrder.ScanCode:
                    query = query.OrderByDescending(q => q.ScanCode);
                    break;

                case ItemOrder.SalePrice:
                    query = query.OrderByDescending(q => q.SalePrice);
                    break;

                case ItemOrder.RetailPrice:
                    query = query.OrderByDescending(q => q.RetailPrice);
                    break;
                }
                break;
            }
            query = query.Skip(filter.Skip).Take(filter.Take);
            return(query);
        }
Exemplo n.º 14
0
		/// <summary>Returns true when an item has children.</summary>
		/// <param name="filter">The filter to apply.</param>
		/// <param name="parent">The item whose childrens existence is to be determined.</param>
		/// <returns>True when there are children.</returns>
		public virtual bool HasChildren(ContentItem parent, ItemFilter filter)
		{
			return HasChildren(new Query { Parent = parent, Filter = filter, Interface = Interfaces.Managing });
		}
Exemplo n.º 15
0
 public IEnumerable <ContentItem> DescendantPages(ContentItem item, ItemFilter filter = null)
 {
     return(N2.Find.EnumerateChildren(item).Where(p => p.IsPage).Where((filter ?? DefaultFilter()).Match));
 }
 public static ItemFilter FilterFor()
 {
     return(ItemFilter.FilterForType(TypeID));
 }
Exemplo n.º 17
0
 /// <summary>Descendants of a given item.</summary>
 /// <param name="ancestor"></param>
 /// <param name="filter"></param>
 /// <returns></returns>
 public IEnumerable<ContentItem> Descendants(ContentItem ancestor, ItemFilter filter = null)
 {
     return N2.Find.EnumerateChildren(ancestor).Where(filter ?? DefaultFilter);
 }
Exemplo n.º 18
0
    // not used

    public static Texture2D ItemToTexture2DSlow(ushort itemId, ushort count, out Color c, ItemFilter iF)
    {
        if (iF == ItemFilter.Items)
        {
            return(ItemToTexture2D(itemId, count, out c));
        }

        ushort    checkValueId = UI_SearchWindow.FilterToItemId(iF, 0);
        ushort    toFindItem   = iF == ItemFilter.Fossils ? itemId : RecipeList.Recipes[itemId];
        Texture2D itemType     = ItemToTexture2D(checkValueId, count, out c);
        Texture2D itemMain     = ItemToTexture2D(toFindItem, count, out c);

        TextureScale.Bilinear(itemType, itemMain.width / 2, itemMain.height / 2);
        return(AddWatermark(itemMain, itemType, 0, 0));
    }
        internal async Task<(IPackageFeed? mainFeed, IPackageFeed? recommenderFeed)> CreatePackageFeedAsync(
            IReadOnlyCollection<IProjectContextInfo> projectContextInfos,
            IReadOnlyCollection<string> targetFrameworks,
            ItemFilter itemFilter,
            bool isSolution,
            bool recommendPackages,
            IEnumerable<SourceRepository> sourceRepositories,
            CancellationToken cancellationToken)
        {
            var logger = new VisualStudioActivityLogger();
            var uiLogger = await ServiceLocator.GetComponentModelServiceAsync<INuGetUILogger>();
            var packageFeeds = (mainFeed: (IPackageFeed?)null, recommenderFeed: (IPackageFeed?)null);

            if (itemFilter == ItemFilter.All && recommendPackages == false)
            {
                packageFeeds.mainFeed = new MultiSourcePackageFeed(sourceRepositories, uiLogger, TelemetryActivity.NuGetTelemetryService);
                return packageFeeds;
            }

            IInstalledAndTransitivePackages installedAndTransitivePackages = await GetInstalledAndTransitivePackagesAsync(projectContextInfos, cancellationToken);

            PackageCollection installedPackageCollection = PackageCollection.FromPackageReferences(installedAndTransitivePackages.InstalledPackages);
            PackageCollection transitivePackageCollection = PackageCollection.FromPackageReferences(installedAndTransitivePackages.TransitivePackages);

            IEnumerable<SourceRepository> globalPackageFolderRepositories = await GetAllPackageFoldersAsync(projectContextInfos, cancellationToken);
            SourceRepository packagesFolderSourceRepository = await _packagesFolderLocalRepositoryLazy.GetValueAsync(cancellationToken);
            var metadataProvider = new MultiSourcePackageMetadataProvider(
                sourceRepositories,
                packagesFolderSourceRepository,
                globalPackageFolderRepositories,
                logger);

            if (itemFilter == ItemFilter.All)
            {
                // if we get here, recommendPackages == true
                packageFeeds.mainFeed = new MultiSourcePackageFeed(sourceRepositories, uiLogger, TelemetryActivity.NuGetTelemetryService);
                packageFeeds.recommenderFeed = new RecommenderPackageFeed(
                    sourceRepositories,
                    installedPackageCollection,
                    transitivePackageCollection,
                    targetFrameworks,
                    metadataProvider,
                    logger);
                return packageFeeds;
            }

            if (itemFilter == ItemFilter.Installed)
            {
                if (!isSolution && await ExperimentUtility.IsTransitiveOriginExpEnabled.GetValueAsync(cancellationToken))
                {
                    packageFeeds.mainFeed = new InstalledAndTransitivePackageFeed(installedPackageCollection, transitivePackageCollection, metadataProvider);
                }
                else
                {
                    packageFeeds.mainFeed = new InstalledPackageFeed(installedPackageCollection, metadataProvider);
                }

                return packageFeeds;
            }

            if (itemFilter == ItemFilter.Consolidate)
            {
                packageFeeds.mainFeed = new ConsolidatePackageFeed(installedPackageCollection, metadataProvider, logger);
                return packageFeeds;
            }

            // Search all / updates available cannot work without a source repo
            if (sourceRepositories == null)
            {
                return packageFeeds;
            }

            if (itemFilter == ItemFilter.UpdatesAvailable)
            {
                packageFeeds.mainFeed = new UpdatePackageFeed(
                    _serviceBroker,
                    installedPackageCollection,
                    metadataProvider,
                    projectContextInfos.ToArray());

                return packageFeeds;
            }

            throw new InvalidOperationException(
                string.Format(CultureInfo.CurrentCulture, Strings.UnsupportedFeedType, itemFilter));
        }
Exemplo n.º 20
0
    public static Texture2D ItemToTexture2D(ushort itemId, ushort count, out Color c, ItemFilter iF)
    {
        if (iF == ItemFilter.Items)
        {
            return(ItemToTexture2D(itemId, count, out c));
        }

        ushort toFindItem = iF == ItemFilter.Fossils ? itemId : RecipeList.Recipes[itemId];

        return(ItemToTexture2D(toFindItem, count, out c));
    }
        public virtual IEnumerable items()
        {
            ItemFilter filter = Filter.Current;

            if (filter == null)
            {
                yield break;
            }
            bool found = false;

            foreach (ARUpdateDiscounts.SelectedItem item in Items.Cache.Inserted)
            {
                found = true;
                yield return(item);
            }
            if (found)
            {
                yield break;
            }


            List <string> added = new List <string>();
            PXSelect <VendorDiscountSequence,
                      Where <VendorDiscountSequence.startDate, LessEqual <Current <ItemFilter.pendingDiscountDate> >,
                             And <VendorDiscountSequence.vendorID, Equal <Current <ItemFilter.vendorID> >,
                                  And <VendorDiscountSequence.isPromotion, Equal <False> > > > > s1 = new PXSelect <VendorDiscountSequence, Where <VendorDiscountSequence.startDate, LessEqual <Current <ItemFilter.pendingDiscountDate> >, And <VendorDiscountSequence.vendorID, Equal <Current <ItemFilter.vendorID> >, And <VendorDiscountSequence.isPromotion, Equal <False> > > > >(this);

            foreach (VendorDiscountSequence sequence in s1.Select())
            {
                string key = string.Format("{0}.{1}", sequence.DiscountID, sequence.DiscountSequenceID);
                added.Add(key);

                ARUpdateDiscounts.SelectedItem item = new ARUpdateDiscounts.SelectedItem();
                item.DiscountID         = sequence.DiscountID;
                item.DiscountSequenceID = sequence.DiscountSequenceID;
                item.Description        = sequence.Description;
                item.DiscountedFor      = sequence.DiscountedFor;
                item.BreakBy            = sequence.BreakBy;
                item.IsPromotion        = sequence.IsPromotion;
                item.IsActive           = sequence.IsActive;
                item.StartDate          = sequence.StartDate;
                item.EndDate            = sequence.UpdateDate;

                yield return(Items.Insert(item));
            }

            foreach (DiscountDetail detail in PXSelectGroupBy <DiscountDetail, Where <DiscountDetail.startDate, LessEqual <Current <ItemFilter.pendingDiscountDate> > >,
                                                               Aggregate <GroupBy <DiscountDetail.discountID, GroupBy <DiscountDetail.discountSequenceID> > > > .Select(this))
            {
                string key = string.Format("{0}.{1}", detail.DiscountID, detail.DiscountSequenceID);

                if (!added.Contains(key))
                {
                    VendorDiscountSequence sequence = PXSelect <VendorDiscountSequence,
                                                                Where <VendorDiscountSequence.discountID, Equal <Required <VendorDiscountSequence.discountID> >,
                                                                       And <VendorDiscountSequence.discountSequenceID, Equal <Required <VendorDiscountSequence.discountSequenceID> > > > > .Select(this, detail.DiscountID, detail.DiscountSequenceID);

                    if (sequence != null && sequence.IsPromotion == false)
                    {
                        ARUpdateDiscounts.SelectedItem item = new ARUpdateDiscounts.SelectedItem();
                        item.DiscountID         = sequence.DiscountID;
                        item.DiscountSequenceID = sequence.DiscountSequenceID;
                        item.Description        = sequence.Description;
                        item.DiscountedFor      = sequence.DiscountedFor;
                        item.BreakBy            = sequence.BreakBy;
                        item.IsPromotion        = sequence.IsPromotion;
                        item.IsActive           = sequence.IsActive;
                        item.StartDate          = sequence.StartDate;
                        item.EndDate            = sequence.UpdateDate;

                        yield return(Items.Insert(item));
                    }
                }
            }

            Items.Cache.IsDirty = false;
        }
Exemplo n.º 22
0
 public async Task <IEnumerable <Item> > Get(ItemFilter filter)
 {
     return(await this._repository.Get(filter));
 }
Exemplo n.º 23
0
 public IEnumerable <ContentItem> Children(ItemFilter filter = null)
 {
     return(Children(CurrentItem, filter ?? DefaultFilter()));
 }
Exemplo n.º 24
0
 public virtual void OnFilterChanged(ItemFilter?previousFilter, ItemFilter currentFilter)
 {
     _filter = currentFilter;
 }
Exemplo n.º 25
0
 /// <summary>Children of the current item.</summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 public IEnumerable<ContentItem> Children(ItemFilter filter)
 {
     return Children(CurrentItem, filter ?? DefaultFilter);
 }
Exemplo n.º 26
0
        /// <summary>
        /// Sets the package to be displayed in the detail control.
        /// </summary>
        /// <param name="searchResultPackage">The package to be displayed.</param>
        /// <param name="filter">The current filter. This will used to select the default action.</param>
        public async virtual Task SetCurrentPackage(
            PackageItemListViewModel searchResultPackage,
            ItemFilter filter,
            Func <PackageItemListViewModel> getPackageItemListViewModel)
        {
            _searchResultPackage = searchResultPackage;
            _filter = filter;
            OnPropertyChanged(nameof(Id));
            OnPropertyChanged(nameof(IconUrl));
            OnPropertyChanged(nameof(PrefixReserved));

            var getVersionsTask = searchResultPackage.GetVersionsAsync();

            var cacheContext = new DependencyGraphCacheContext();

            _projectVersionConstraints = new List <ProjectVersionConstraint>();

            // Filter out projects that are not managed by NuGet.
            var projects = _nugetProjects.Where(project => !(project is ProjectKNuGetProjectBase)).ToArray();

            foreach (var project in projects)
            {
                if (project is MSBuildNuGetProject)
                {
                    // cache allowed version range for each nuget project for current selected package
                    var packageReference = (await project.GetInstalledPackagesAsync(CancellationToken.None))
                                           .FirstOrDefault(r => StringComparer.OrdinalIgnoreCase.Equals(r.PackageIdentity.Id, searchResultPackage.Id));

                    var range = packageReference?.AllowedVersions;

                    if (range != null && !VersionRange.All.Equals(range))
                    {
                        var constraint = new ProjectVersionConstraint()
                        {
                            ProjectName      = project.GetMetadata <string>(NuGetProjectMetadataKeys.Name),
                            VersionRange     = range,
                            IsPackagesConfig = true,
                        };

                        _projectVersionConstraints.Add(constraint);
                    }
                }
                else if (project is BuildIntegratedNuGetProject)
                {
                    var packageReferences = await project.GetInstalledPackagesAsync(CancellationToken.None);

                    // First the lowest auto referenced version of this package.
                    var autoReferenced = packageReferences.Where(e => StringComparer.OrdinalIgnoreCase.Equals(searchResultPackage.Id, e.PackageIdentity.Id) &&
                                                                 e.PackageIdentity.Version != null)
                                         .Select(e => e as BuildIntegratedPackageReference)
                                         .Where(e => e?.Dependency?.AutoReferenced == true)
                                         .OrderBy(e => e.PackageIdentity.Version)
                                         .FirstOrDefault();

                    if (autoReferenced != null)
                    {
                        // Add constraint for auto referenced package.
                        var constraint = new ProjectVersionConstraint()
                        {
                            ProjectName  = project.GetMetadata <string>(NuGetProjectMetadataKeys.Name),
                            VersionRange = new VersionRange(
                                minVersion: autoReferenced.PackageIdentity.Version,
                                includeMinVersion: true,
                                maxVersion: autoReferenced.PackageIdentity.Version,
                                includeMaxVersion: true),

                            IsAutoReferenced = true,
                        };

                        _projectVersionConstraints.Add(constraint);
                    }
                }
            }

            // Add Current package version to package versions list.
            _allPackageVersions = new List <NuGetVersion>()
            {
                searchResultPackage.Version
            };
            CreateVersions();
            OnCurrentPackageChanged();

            var versions = await getVersionsTask;

            // GetVersionAsync can take long time to finish, user might changed selected package.
            // Check selected package.
            if (getPackageItemListViewModel() != searchResultPackage)
            {
                return;
            }

            // Get the list of available versions, ignoring null versions
            _allPackageVersions = versions
                                  .Where(v => v?.Version != null)
                                  .Select(v => v.Version)
                                  .ToList();

            // hook event handler for dependency behavior changed
            Options.SelectedChanged += DependencyBehavior_SelectedChanged;

            CreateVersions();
            OnCurrentPackageChanged();
        }
Exemplo n.º 27
0
        /// <summary>Siblings of a given item.</summary>
        /// <param name="item"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        public IEnumerable<ContentItem> Siblings(ContentItem item, ItemFilter filter)
        {
            if (item == null) item = CurrentItem;
            if (item.Parent == null) return Enumerable.Empty<ContentItem>();
            UseMasterVersion(ref item);

            return item.Parent.GetChildren(filter ?? DefaultFilter);
        }
Exemplo n.º 28
0
 protected void AddFilter(ItemFilter filter)
 {
     filters.Add(filter);
 }
 public ChannelItemQuery()
 {
     Filters = new ItemFilter[] { };
     SortBy  = new string[] { };
     Fields  = new ItemFields[] { };
 }
Exemplo n.º 30
0
 public static void FilterInverse(IList<ContentItem> items, ItemFilter filterToInverse)
 {
     Filter(items, new InverseFilter(filterToInverse));
 }
Exemplo n.º 31
0
 public TypesProcessor(IOutputWriter outputWriter, ItemFilter itemFilter)
 {
     _outputWriter = outputWriter;
     _itemFilter   = itemFilter;
 }
Exemplo n.º 32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ItemQuery" /> class.
        /// </summary>
        public ItemQuery()
        {
            LocationTypes = new LocationType[] { };
            ExcludeLocationTypes = new LocationType[] { };
            
            SortBy = new string[] { };

            Filters = new ItemFilter[] {};

            Fields = new ItemFields[] {};

            MediaTypes = new string[] {};

            VideoTypes = new VideoType[] {};

            Genres = new string[] { };
            Studios = new string[] { };
            IncludeItemTypes = new string[] { };
            ExcludeItemTypes = new string[] { };
            Years = new int[] { };
            PersonTypes = new string[] { };
            Ids = new string[] { };
            Artists = new string[] { };

            ImageTypes = new ImageType[] { };
            AirDays = new DayOfWeek[] { };
            SeriesStatuses = new SeriesStatus[] { };
        }
Exemplo n.º 33
0
        private IQueryable <ItemDAO> DynamicFilter(IQueryable <ItemDAO> query, ItemFilter filter)
        {
            if (filter == null)
            {
                return(query.Where(q => false));
            }
            query = query.Where(q => q.DeletedAt == null && q.Product.DeletedAt == null);
            if (filter.Id != null && filter.Id.HasValue)
            {
                query = query.Where(q => q.Id, filter.Id);
            }
            if (filter.ProductId != null && filter.ProductId.HasValue)
            {
                query = query.Where(q => q.ProductId, filter.ProductId);
            }
            if (filter.Code != null && filter.Code.HasValue)
            {
                query = query.Where(q => q.Code, filter.Code);
            }
            if (filter.Name != null && filter.Name.HasValue)
            {
                query = query.Where(q => q.Name, filter.Name);
            }
            if (filter.ScanCode != null && filter.ScanCode.HasValue)
            {
                query = query.Where(q => q.ScanCode, filter.ScanCode);
            }
            if (filter.SalePrice != null && filter.SalePrice.HasValue)
            {
                query = query.Where(q => q.SalePrice, filter.SalePrice);
            }
            if (filter.RetailPrice != null && filter.RetailPrice.HasValue)
            {
                query = query.Where(q => q.RetailPrice, filter.RetailPrice);
            }
            if (filter.ProductGroupingId != null && filter.ProductGroupingId.HasValue)
            {
                if (filter.ProductGroupingId.Equal != null)
                {
                    ProductGroupingDAO ProductGroupingDAO = DataContext.ProductGrouping
                                                            .Where(o => o.Id == filter.ProductGroupingId.Equal.Value).FirstOrDefault();
                    query = from q in query
                            join ppg in DataContext.ProductProductGroupingMapping on q.ProductId equals ppg.ProductId
                            join pg in DataContext.ProductGrouping on ppg.ProductGroupingId equals pg.Id
                            where pg.Path.StartsWith(ProductGroupingDAO.Path)
                            select q;
                }
                if (filter.ProductGroupingId.NotEqual != null)
                {
                    ProductGroupingDAO ProductGroupingDAO = DataContext.ProductGrouping
                                                            .Where(o => o.Id == filter.ProductGroupingId.NotEqual.Value).FirstOrDefault();
                    query = from q in query
                            join ppg in DataContext.ProductProductGroupingMapping on q.ProductId equals ppg.ProductId
                            join pg in DataContext.ProductGrouping on ppg.ProductGroupingId equals pg.Id
                            where !pg.Path.StartsWith(ProductGroupingDAO.Path)
                            select q;
                }
                if (filter.ProductGroupingId.In != null)
                {
                    List <ProductGroupingDAO> ProductGroupingDAOs = DataContext.ProductGrouping
                                                                    .Where(o => o.DeletedAt == null).ToList();
                    List <ProductGroupingDAO> Parents  = ProductGroupingDAOs.Where(o => filter.ProductGroupingId.In.Contains(o.Id)).ToList();
                    List <ProductGroupingDAO> Branches = ProductGroupingDAOs.Where(o => Parents.Any(p => o.Path.StartsWith(p.Path))).ToList();
                    List <long> ProductGroupingIds     = Branches.Select(x => x.Id).ToList();
                    query = from q in query
                            join ppg in DataContext.ProductProductGroupingMapping on q.ProductId equals ppg.ProductId
                            join pg in DataContext.ProductGrouping on ppg.ProductGroupingId equals pg.Id
                            where ProductGroupingIds.Contains(pg.Id)
                            select q;
                }
                if (filter.ProductGroupingId.NotIn != null)
                {
                    List <ProductGroupingDAO> ProductGroupingDAOs = DataContext.ProductGrouping
                                                                    .Where(o => o.DeletedAt == null).ToList();
                    List <ProductGroupingDAO> Parents  = ProductGroupingDAOs.Where(o => filter.ProductGroupingId.NotIn.Contains(o.Id)).ToList();
                    List <ProductGroupingDAO> Branches = ProductGroupingDAOs.Where(o => Parents.Any(p => o.Path.StartsWith(p.Path))).ToList();
                    List <long> ProductGroupingIds     = Branches.Select(x => x.Id).ToList();
                    query = from q in query
                            join ppg in DataContext.ProductProductGroupingMapping on q.ProductId equals ppg.ProductId
                            join pg in DataContext.ProductGrouping on ppg.ProductGroupingId equals pg.Id
                            where !ProductGroupingIds.Contains(pg.Id)
                            select q;
                }
            }

            if (filter.ProductTypeId != null && filter.ProductTypeId.HasValue)
            {
                query = query.Where(q => q.Product.ProductTypeId, filter.ProductTypeId);
            }

            if (filter.StatusId != null && filter.StatusId.HasValue)
            {
                query = query.Where(q => q.StatusId, filter.StatusId);
            }

            if (filter.OpportunityReportId != null)
            {
                query = from q in query
                        join t1 in DataContext.OpportunityItemMapping on q.Id equals t1.ItemId
                        where t1.OpportunityId == filter.OpportunityReportId.Equal
                        select q;
            }

            if (filter.Search != null)
            {
                List <string> Tokens            = filter.Search.Split(" ").Select(x => x.ToLower()).ToList();
                var           queryForCode      = query;
                var           queryForName      = query;
                var           queryForOtherName = query;
                foreach (string Token in Tokens)
                {
                    if (string.IsNullOrWhiteSpace(Token))
                    {
                        continue;
                    }
                    queryForCode      = queryForCode.Where(x => x.Code.ToLower().Contains(Token));
                    queryForName      = queryForName.Where(x => x.Name.ToLower().Contains(Token));
                    queryForOtherName = queryForOtherName.Where(x => x.Product.OtherName.ToLower().Contains(Token));
                }
                query = queryForCode.Union(queryForName).Union(queryForOtherName);
                query = query.Distinct();
            }

            query = OrFilter(query, filter);
            query = query.Distinct();
            return(query);
        }
Exemplo n.º 34
0
        public IEnumerable<BaseItem> RetrieveChildren(string id, bool? collapseBoxSets = null, ItemFilter[] filters = null, bool? isPlayed = null)
        {
            if (id == Guid.Empty.ToString() || string.IsNullOrEmpty(id)) return new List<BaseItem>();  //some dummy items have blank ids

            var dtos = Kernel.ApiClient.GetItems(new ItemQuery
                                                     {
                                                         UserId = Kernel.CurrentUser.Id.ToString(),
                                                         ParentId = id,
                                                         Filters = filters,
                                                         IsPlayed = isPlayed,
                                                         CollapseBoxSetItems = collapseBoxSets,
                                                         Fields = new[] {ItemFields.Overview, ItemFields.Path, ItemFields.ParentId, ItemFields.DisplayPreferencesId, 
                                                            ItemFields.DateCreated, ItemFields.IndexOptions, ItemFields.DateLastMediaAdded, ItemFields.Metascore,
                                                            ItemFields.MediaStreams, ItemFields.SortName, ItemFields.Taglines, ItemFields.MediaSources,  }
                                                     });

            return dtos == null ? new List<BaseItem>() : dtos.Items.Select(dto => GetItem(dto, dto.Type)).Where(item => item != null);
        }
Exemplo n.º 35
0
        private static ContentItem Last(IList<ContentItem> children, ItemFilter filter)
        {
            for (int i = children.Count - 1; i >= 0; i--)
            {
                if (!filter.Match(children[i]))
                    continue;

                return children[i];
            }
            return null;
        }
Exemplo n.º 36
0
        public void SetCriteria(ItemFilter itemFilter)
        {
            this.Criteria = itemFilter;

            foreach (var ob in this.Environment.GetContents(this.Area).OfType<ItemObject>())
            {
                Debug.Assert(ob.StockpiledBy == null || ob.StockpiledBy == this);

                if (ob.IsInstalled)
                    continue;

                if (Match(ob))
                {
                    if (ob.StockpiledBy == null)
                        ob.StockpiledBy = this;
                }
                else
                {
                    if (ob.StockpiledBy != null)
                        ob.StockpiledBy = null;
                }
            }

            if (this.Criteria != null && m_itemTracker.IsEnabled == false)
                EnableItemObjectView();
            else if (this.Criteria == null && m_itemTracker.IsEnabled)
                DisableItemObjectView();
            else
                m_itemTracker.Refresh();
        }
Exemplo n.º 37
0
        protected void Page_Load(object sender, EventArgs e)
        {
            portalDc = new DALPortalDataContext();

              if (!IsPostBack)
              {
            itemFilter = new ItemFilter();

            Session["itemFilter"] = itemFilter;
              }
              else
            itemFilter = (ItemFilter)Session["itemFilter"];
        }
Exemplo n.º 38
0
 public IEnumerable <ContentItem> Siblings(ItemFilter filter = null)
 {
     return(Siblings(null, filter));
 }
Exemplo n.º 39
0
 public InverseFilter(ItemFilter filterToInverse)
 {
     this.filterToInverse = filterToInverse;
 }
Exemplo n.º 40
0
 public IEnumerable <ContentItem> Ancestors(ContentItem item = null, ItemFilter filter = null)
 {
     return((filter ?? DefaultFilter()).Pipe(N2.Find.EnumerateParents(item ?? CurrentItem, StartPage, true)));
 }
Exemplo n.º 41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ItemsByNameQuery" /> class.
 /// </summary>
 public ItemsByNameQuery()
 {
     ImageTypes = new ImageType[] { };
     Filters = new ItemFilter[] { };
     Fields = new ItemFields[] { };
     Recursive = true;
     MediaTypes = new string[] { };
     SortBy = new string[] { };
     ExcludeItemTypes = new string[] { };
     IncludeItemTypes = new string[] { };
 }
Exemplo n.º 42
0
    public void SelectItem(ItemFilter itemF, int id, UI_SearchItem sItem)
    {
        if (id == Item.NONE)
        {
            return;
        }
        SetController.FCount.text = id.ToString();
        ItemSelectedName.text     = sItem.RawValue;
        switch (itemF)
        {
        case ItemFilter.Recipes:
            CurrentItemID = RECIPEITEM;
            break;

        case ItemFilter.Fossils:
            CurrentItemID = FOSSILITEM;
            break;

        case ItemFilter.MsgBottle:
            CurrentItemID = MESSAGEBOTTLEITEM;
            break;

        default:
            CurrentItemID             = id;
            SetController.FCount.text = 0.ToString();
            break;
        }
        CurrentSelectedIndex = spawnedObjects.IndexOf(sItem);
        if (ItemInfo.GetItemKind(Convert.ToUInt16(CurrentItemID)).IsFlower())
        {
            FlowerButtonRoot.SetActive(true);
        }
        else
        {
            FlowerController.ResetToZero();
            FlowerButtonRoot.SetActive(false);
        }
        short remakeIndex = ItemRemakeUtil.GetRemakeIndex(Convert.ToUInt16(CurrentItemID));

        if (remakeIndex < 0)
        {
            SetController.CreateBody(new string[0]);
            SetController.CreateFabric(new string[0]);
        }
        else
        {
            ItemRemakeInfo itemRemakeInfo = ItemRemakeInfoData.List[remakeIndex];
            string         bodySummary    = itemRemakeInfo.GetBodySummary(GameInfo.Strings, tryGetDescriptor: false);
            if (bodySummary.Length != 0)
            {
                string[] values = bodySummary.Split(new string[3]
                {
                    "\r\n",
                    "\r",
                    "\n"
                }, StringSplitOptions.None);
                SetController.CreateBody(values);
            }
            else
            {
                SetController.CreateBody(new string[0]);
            }
            string fabricSummary = itemRemakeInfo.GetFabricSummary(GameInfo.Strings, tryGetDescriptor: false);
            if (fabricSummary.Length != 0)
            {
                string[] values2 = fabricSummary.Split(new string[3]
                {
                    "\r\n",
                    "\r",
                    "\n"
                }, StringSplitOptions.None);
                SetController.CreateFabric(values2);
            }
            else
            {
                SetController.CreateFabric(new string[0]);
            }
        }
        if (currentAnimationFuction != null)
        {
            StopCoroutine(currentAnimationFuction);
        }
        currentAnimationFuction = StartCoroutine(sendSelectorToSelected());
    }
Exemplo n.º 43
0
 /// <summary>Returns true when an item has children.</summary>
 /// <param name="filter">The filter to apply.</param>
 /// <param name="parent">The item whose childrens existence is to be determined.</param>
 /// <returns>True when there are children.</returns>
 public virtual bool HasChildren(ContentItem parent, ItemFilter filter)
 {
     return parent.GetChildren(filter).Count > 0;
 }
Exemplo n.º 44
0
        /// <summary>Gets children applying filters.</summary>
        /// <param name="filter">The filters to apply on the children.</param>
        /// <returns>A list of filtered child items.</returns>
        public virtual ItemList GetChildren(ItemFilter filter)
        {
            IEnumerable <ContentItem> items = VersionOf == null ? Children : VersionOf.Children;

            return(new ItemList(items, filter));
        }
Exemplo n.º 45
0
 public IEnumerable<BaseItem> RetrieveLatestChannelItems(string channelId = null, ItemFilter[] filters = null)
 {
     var dtos = Kernel.ApiClient.GetLatestChannelItems(Kernel.CurrentUser.ApiId, channelId, filters);
     return dtos == null ? new BaseItem[] { } : dtos.Items.Select(dto => GetItem(dto, dto.Type)).Where(item => item != null);
 }
Exemplo n.º 46
0
        private IEnumerable <BaseItem> ApplyFilter(IEnumerable <BaseItem> items, ItemFilter filter, User user)
        {
            // Avoid implicitly captured closure
            var currentUser = user;

            switch (filter)
            {
            case ItemFilter.IsFavoriteOrLikes:
                return(items.Where(item =>
                {
                    var userdata = _userDataManager.GetUserData(user.Id, item.GetUserDataKey());

                    if (userdata == null)
                    {
                        return false;
                    }

                    var likes = userdata.Likes ?? false;
                    var favorite = userdata.IsFavorite;

                    return likes || favorite;
                }));

            case ItemFilter.Likes:
                return(items.Where(item =>
                {
                    var userdata = _userDataManager.GetUserData(user.Id, item.GetUserDataKey());

                    return userdata != null && userdata.Likes.HasValue && userdata.Likes.Value;
                }));

            case ItemFilter.Dislikes:
                return(items.Where(item =>
                {
                    var userdata = _userDataManager.GetUserData(user.Id, item.GetUserDataKey());

                    return userdata != null && userdata.Likes.HasValue && !userdata.Likes.Value;
                }));

            case ItemFilter.IsFavorite:
                return(items.Where(item =>
                {
                    var userdata = _userDataManager.GetUserData(user.Id, item.GetUserDataKey());

                    return userdata != null && userdata.IsFavorite;
                }));

            case ItemFilter.IsResumable:
                return(items.Where(item =>
                {
                    var userdata = _userDataManager.GetUserData(user.Id, item.GetUserDataKey());

                    return userdata != null && userdata.PlaybackPositionTicks > 0;
                }));

            case ItemFilter.IsPlayed:
                return(items.Where(item => item.IsPlayed(currentUser)));

            case ItemFilter.IsUnplayed:
                return(items.Where(item => item.IsUnplayed(currentUser)));

            case ItemFilter.IsFolder:
                return(items.Where(item => item.IsFolder));

            case ItemFilter.IsNotFolder:
                return(items.Where(item => !item.IsFolder));
            }

            return(items);
        }
Exemplo n.º 47
0
 protected override void TextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     ListItems = new ItemFilter(DriveItem.GetAllItems(), Text);
     Input.ListBox.SelectedIndex = 0;
 }
Exemplo n.º 48
0
Arquivo: Menu.cs Projeto: xychb/n2cms
 public Menu()
 {
     Filters = new ItemFilter[] { new NavigationFilter() };
 }
Exemplo n.º 49
0
 public ChannelItemQuery()
 {
     Filters = new ItemFilter[] { };
     SortBy = new string[] { };
     Fields = new List<ItemFields>();
 }
Exemplo n.º 50
0
 public void UpdateFilter(Dropdown filt)
 {
     CurrentFilter = (ItemFilter)filt.value;
     UpdateSearchString(SearchField.text);
 }
Exemplo n.º 51
0
        /// <summary>Children of a given item.</summary>
        /// <param name="parent"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        public IEnumerable<ContentItem> Children(ContentItem parent, ItemFilter filter = null)
        {
            if (parent == null) return Enumerable.Empty<ContentItem>();
            UseMasterVersion(ref parent);

            return parent.GetChildren(filter ?? DefaultFilter);
        }
Exemplo n.º 52
0
    public void SelectItem(ItemFilter itemF, int id, UI_SearchItem sItem)
    {
        if (id == Item.NONE)
        {
            return;
        }
        if (ItemExtensions.IsInternalItem((ushort)id))
        {
            if (!InternalItemWarning.gameObject.activeInHierarchy)
            {
                InternalItemWarning.gameObject.SetActive(true);
            }
            else
            {
                InternalItemWarning.Start();
            }
        }
        SetController.FCount.text = id.ToString();
        ItemSelectedName.text     = sItem.RawValue;
        switch (itemF)
        {
        case ItemFilter.Recipes:
            CurrentItemID = RECIPEITEM;
            break;

        case ItemFilter.Fossils:
            CurrentItemID = FOSSILITEM;
            break;

        case ItemFilter.MsgBottle:
            CurrentItemID = MESSAGEBOTTLEITEM;
            break;

        default:
            CurrentItemID             = id;
            SetController.FCount.text = 0.ToString();
            break;
        }

        CurrentSelectedIndex = spawnedObjects.IndexOf(sItem);
        if (ItemInfo.GetItemKind(Convert.ToUInt16(CurrentItemID)).IsFlower())
        {
            FlowerButtonRoot.SetActive(true);
        }
        else
        {
            FlowerController.ResetToZero();
            FlowerButtonRoot.SetActive(false);
        }

        /*if (new Item((ushort)id).IsMoneyTree())
         *  TreeButtonRoot.gameObject.SetActive(true);
         * else
         *  TreeButtonRoot.gameObject.SetActive(false);*///uncomment this if you want star tree editor again for whatever reason

        SetController.SpawnVariationsButton.gameObject.SetActive(false);
        short remakeIndex = ItemRemakeUtil.GetRemakeIndex(Convert.ToUInt16(CurrentItemID));

        if (remakeIndex < 0)
        {
            SetController.CreateBody(new string[0]);
            SetController.CreateFabric(new string[0]);
        }
        else
        {
            ItemRemakeInfo itemRemakeInfo = ItemRemakeInfoData.List[remakeIndex];
            string         bodySummary    = itemRemakeInfo.GetBodySummary(GameInfo.Strings, false);
            if (bodySummary.Length != 0)
            {
                string[] values = bodySummary.Split(new string[3]
                {
                    "\r\n",
                    "\r",
                    "\n"
                }, StringSplitOptions.None);
                SetController.CreateBody(values);
            }
            else
            {
                SetController.CreateBody(new string[0]);
            }
            string fabricSummary = itemRemakeInfo.GetFabricSummary(GameInfo.Strings, false, false);
            if (fabricSummary.Length != 0)
            {
                string[] values2 = fabricSummary.Split(new string[3]
                {
                    "\r\n",
                    "\r",
                    "\n"
                }, StringSplitOptions.None);
                SetController.CreateFabric(values2);
            }
            else
            {
                SetController.CreateFabric(new string[0]);
            }
        }
        if (currentAnimationFuction != null)
        {
            StopCoroutine(currentAnimationFuction);
        }
        currentAnimationFuction = StartCoroutine(sendSelectorToSelected());
        SetController.FFlagOne.gameObject.SetActive(CurrentItemID >= 60_000);

        OnNewItemSelected?.Invoke((ushort)id, sItem.RawValue);
        UpdateSprite();
    }
Exemplo n.º 53
0
 /// <summary>Siblings of the current item.</summary>
 /// <param name="item"></param>
 /// <param name="filter"></param>
 /// <returns></returns>
 public IEnumerable<ContentItem> Siblings(ItemFilter filter)
 {
     return Siblings(null, filter);
 }
Exemplo n.º 54
0
    public void LoadItem(Item item)
    {
        if (stopSearch || item.ItemId == Item.NONE)
        {
            return;
        }
        CurrentItemID = item.ItemId;
        if (CurrentItemID == MESSAGEBOTTLEITEM)
        {
            CurrentFilter = ItemFilter.MsgBottle;
        }
        else if (CurrentItemID == RECIPEITEM)
        {
            CurrentFilter = ItemFilter.Recipes;
        }
        else if (CurrentItemID == FOSSILITEM)
        {
            CurrentFilter = ItemFilter.Fossils;
        }
        else
        {
            CurrentFilter = ItemFilter.Items;
        }

        List <ComboItem> list      = FilterToItems(CurrentFilter);
        ComboItem        comboItem = (CurrentFilter == ItemFilter.Items) ? list.Find((ComboItem x) => x.Value == item.ItemId) : list.Find((ComboItem x) => x.Value == item.Count);

        SearchField.text = comboItem.Text;
        CurrentItemID    = item.ItemId;
        ItemKind itemKind = ItemInfo.GetItemKind(Convert.ToUInt16(CurrentItemID));

        if (itemKind.IsFlower())
        {
            loadGenes(item.Genes);
            FlowerController.DaysWatered.text    = item.DaysWatered.ToString();
            FlowerController.GoldCanWatered.isOn = item.IsWateredGold;
            FlowerController.Watered.isOn        = item.IsWatered;
            bool[] array = new bool[10];
            for (int i = 0; i < 10; i++)
            {
                array[i] = item.GetIsWateredByVisitor(i);
            }
            FlowerController.SetVisitorWatered(array);
        }
        else
        {
            SetController.FCount.text = item.Count.ToString();
            SetController.CompileBodyFabricFromCount();
            SetController.FUses.text     = item.UseCount.ToString();
            SetController.FFlagZero.text = item.SystemParam.ToString();
        }

        if (itemKind == ItemKind.Kind_MessageBottle || CurrentItemID >= 60_000)
        {
            SetController.FFlagOne.text = item.AdditionalParam.ToString();
            SetController.FFlagOne.gameObject.SetActive(true);
        }
        else
        {
            WrapController.WrapToggle.isOn     = item.WrappingType != ItemWrapping.Nothing;
            WrapController.WrapType.value      = (int)item.WrappingType;
            WrapController.WrapColor.value     = (int)item.WrappingPaper;
            WrapController.ShowItemToggle.isOn = item.WrappingShowItem;
            WrapController.Flag80 = item.Wrapping80;
        }

        DropdownFilter.SetValueWithoutNotify((int)CurrentFilter);
        DropdownFilter.RefreshShownValue();

        UpdateSprite();
    }
Exemplo n.º 55
0
 /// <summary>Ancestors of a given item.</summary>
 /// <param name="item"></param>
 /// <param name="filter"></param>
 /// <returns></returns>
 public IEnumerable<ContentItem> Ancestors(ContentItem item = null, ItemFilter filter = null)
 {
     return N2.Find.EnumerateParents(item ?? CurrentItem, StartPage, true).Where(filter ?? DefaultFilter);
 }
Exemplo n.º 56
0
 protected virtual Node <TreeNode> CreateStructure(HierarchyNode <ContentItem> structure, ItemFilter filter)
 {
     return(ApiExtensions.CreateNode(structure, engine.Resolve <IContentAdapterProvider>(), filter));
 }
Exemplo n.º 57
0
Arquivo: Menu.cs Projeto: Jobu/n2cms
 public Menu()
 {
     Filters = new ItemFilter[] { new NavigationFilter() };
 }
Exemplo n.º 58
0
 /// <summary>Returns true when an item has children.</summary>
 /// <param name="filter">The filter to apply.</param>
 /// <param name="parent">The item whose childrens existence is to be determined.</param>
 /// <returns>True when there are children.</returns>
 public virtual bool HasChildren(ContentItem parent, ItemFilter filter)
 {
     return(Sources.HasChildren(new Query {
         Parent = parent, Filter = filter, Interface = Interfaces.Managing
     }));
 }