public List <ProductScan> GetProductScans(IVisitorContext visitorContext, string currentCatalogItemId)
        {
            Assert.ArgumentNotNull(visitorContext, "visitorContext");
            var model             = ModelProvider.GetModel <ProductListJsonResult>();
            var curentCatalogItem = !string.IsNullOrEmpty(currentCatalogItemId) ? Context.Database.GetItem(currentCatalogItemId) : null;

            if (string.IsNullOrEmpty(currentCatalogItemId))
            {
                curentCatalogItem = StorefrontContext.CurrentStorefront.CatalogItem;
            }
            if (curentCatalogItem == null)
            {
                return(null);
            }

            CategorySearchInformation searchInformation     = SearchInformation.GetCategorySearchInformation(curentCatalogItem);
            CommerceSearchOptions     commerceSearchOptions = new CommerceSearchOptions(GetDefaultItemsPerPage(null, searchInformation), 0);

            SearchResults        childProducts     = GetChildProducts(commerceSearchOptions, curentCatalogItem);
            List <ProductEntity> productEntityList = AdjustProductPriceAndStockStatus(visitorContext, childProducts, curentCatalogItem);

            productEntityList.Select(p => p.ProductId);

            return(productEntityList.Select(p => new ProductScan {
                ProductId = p.ProductId, ScanFilePath = GetProductArMapFilePath(p.ProductId, StorefrontContext.CurrentStorefront.Context)
            }).ToList());
        }
示例#2
0
        static void Main(string[] args)
        {
            //DirectoryObject directory = new DirectoryObject("C:\\")
            //    .SubDirectory("Users")
            //    .SubDirectory("Jon")
            //    .SubDirectory("Desktop")
            //    .SubDirectory("DataUtil");
            //directory.AllFiles[0].Content.Lines = new System.Collections.Generic.List<string>() { "A", "B", "C" };
            //directory.AllFiles[0].Content.Value = "a\rb\rc";
            //directory.AllFiles[0].Content.MemoryStream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes("1\r2\r3"));
            //FileObjectList listDesktopDirectories = directory.AllDirectories.AllFiles;

            // Okay, Im Looking For Files With Lots Of Constraints.. So Overload The Hell Out Of It
            SearchInformation searchInfo = new SearchInformation(true, "*.cs", true,
                                                                 FileInformation.FileDatePropertyType.CreationDate, new DateTime(2015, 1, 1), DateTime.Now,
                                                                 FileInformation.FileSizeType.KiloBytes, 0, 10);

            // But Check Back In With Me Every Now And Then
            SearchInformation.SearchCallback callback =
                new SearchInformation.SearchCallback(Callback);

            // Now, Go Get Me Stuff And Lemme Know What's Goin On Every 5 Seconds
            FileObjectList files = new DirectoryObject("C:\\Users\\Jon\\Desktop\\DataUtil")
                                   .GetFilesAsync(searchInfo, callback, 5);
        }
示例#3
0
        /// <summary>
        /// 新しい検索を開始してページを移動
        /// </summary>
        /// <param name="criteria"></param>
        public bool StartNewSearch(ISqlSearch criteria)
        {
            var search = new SearchInformation(new ComplexSearch(false));

            if (criteria != null)
            {
                search.Root.Add(criteria);
            }

            //// 同じ内容の検索は無視
            //if (this.front.FeaturedGroup == null && this.front.SearchInformation != null)
            //{
            //    if (this.SelectedPage.Value == PageType.Catalog
            //        && this.front.SearchInformation.SettingEquals(search))
            //    {
            //        Debug.WriteLine("same search");
            //        return false;
            //    }
            //}

            this.SetNewSearch(search);
            this.ChangePage(PageType.Catalog, null, 0);

            return(true);
        }
示例#4
0
 /// <summary>
 /// 新しい検索を開始
 /// </summary>
 /// <param name="search"></param>
 public void SetNewSearch(SearchInformation search)
 {
     this.History.MoveNew(new ViewState()
     {
         Search       = search,
         GroupKey     = null,
         CatalogIndex = 0,
         ViewerIndex  = 0,
         Type         = PageType.None,
     });
 }
        private void StartSearch(Client client, SearchInformation info)
        {
            client.SetNewSearch(info);
            client.MoveToCatalog();

            this.CurrentSearch.Value = SearchInformation.GenerateEmpty();
            if (!this.HasFavoriteSearch(info))
            {
                this.SelectedTab.Value = TabMode.History;
            }
        }
        public string AddSearch(SearchInformation setting)
        {
            var key = Guid.NewGuid().ToString();

            setting.Key = key;
            var value = setting.Clone();

            this.SearchSettings.Add(key, value);
            return(key);
            //this.SearchSettingsList.Add(new SearchInformation(setting));
            //this.CurrentSearchIndex = this.SearchSettingsList.Count - 1;
        }
示例#7
0
        protected virtual void ReportSearchInformation(int depth)
        {
            if (SearchInformationReport != null)
            {
                SearchInformation searchInformation = new SearchInformation();
                searchInformation.Depth              = depth;
                searchInformation.Score              = _Score;
                searchInformation.NodesEvaluated     = _NodesEvaluated;
                searchInformation.PrincipalVariation = new List <Move>(_PrincipalVariation);

                SearchInformationReport(searchInformation);
            }
        }
示例#8
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SearchHelper.SearchExited += SearchHelper_SearchExited;
     if (savedInstanceState != null)
     {
         var bundledResults = savedInstanceState.GetString(BundledSearchResults);
         if (bundledResults != null)
         {
             SearchResults = JsonConvert.DeserializeObject <List <TSearchResult> >(bundledResults);
             string bundledSearchInfo = savedInstanceState.GetString(BundledSearchInfo);
             bundledSearchInformation = JsonConvert.DeserializeObject <SearchInformation>(bundledSearchInfo);
             SearchHelper.Searching   = true;
         }
     }
 }
示例#9
0
        private async Task <Record[]> SearchAsync
            (FileProperty property, object reference, CompareMode mode)
        {
            var search = new SearchInformation(new ComplexSearch(false));

            search.Root
            .Add(new UnitSearch()
            {
                Property  = property,
                Reference = reference,
                Mode      = mode,
            });

            var library = LibraryOwner.GetCurrent();

            var files = await search.SearchAsync(library, 0, 0);

            return(files);
        }
示例#10
0
        private SearchInformation ConvertSearch(SparkImageViewer.FileSearch.SearchInformation source)
        {
            var result = new SearchInformation(this.ConvertComplexSearch(source.Root))
            {
                DateLastUsed      = source.DateLastUsed,
                Key               = source.Key,
                Name              = source.Name,
                ThumbnailFilePath = source.ThumbnailFilekey,
            };

            //result.SortSettings.Clear();
            //source.SortSettings.ForEach(x =>
            //{
            //    var sort = this.ConvertSort(x);
            //    result.SortSettings.Add(sort);
            //});

            result.SetSort(source.SortSettings.Select(x => this.ConvertSort(x)), true);

            return(result);
        }
示例#11
0
        /// <summary>
        /// 検索条件を設定、グループ検索を無効化
        /// </summary>
        /// <param name="criteria"></param>
        public void SetSearch(SearchInformation criteria, bool refreshList)
        {
            var clearFlag = false;

            if (this.FeaturedGroup != null)
            {
                this.FeaturedGroup = null;
                clearFlag          = true;
            }

            if (criteria != null)
            {
                if (!criteria.CheckSimilarity(this.SearchInformation))
                {
                    clearFlag = true;
                }

                this.SearchInformation = library.Searcher.AddSearchToDictionary(criteria);

                this.SearchInformation.Root.DownEdited();

                //履歴・アルバムのリストを更新
                if (refreshList)
                {
                    this.RefreshSearchList();
                }
            }
            else
            {
                this.SearchInformation = null;
            }

            if (clearFlag)
            {
                this.Clear(CacheClearAction.SearchChanged);
            }
        }
示例#12
0
        /// <summary>
        /// アプリ外から渡されたファイルリストを使用して起動
        /// </summary>
        /// <param name="list"></param>
        public void ActivateFiles(IEnumerable <string> list)
        {
            var files = list?.Where(x => x.HasText()).ToArray();

            if (files.IsNullOrEmpty())
            {
                return;
            }

            var records = this.front.ActivateFiles(files);

            var state = new ViewState()
            {
                Search       = null,
                GroupKey     = null,
                CatalogIndex = 0,
                ViewerIndex  = 0,
                Type         = PageType.Catalog,
            };

            this.History.MoveNew(state);

            this.ChangePage(PageType.Viewer, 0, 0);

            var record = records[0];

            //画像ロード
            this.core.ImageBuffer.RequestLoading
                (record, this.GenerateImageLoadOption(ImageQuality.Resized),
                null, true, default(CancellationToken));

            if (records.Length != 1)
            {
                return;
            }

            string directory;
            string tmpDir;

            try
            {
                directory = System.IO.Path.GetDirectoryName(record.FullPath);
                tmpDir    = System.IO.Path.GetDirectoryName(System.IO.Path.GetTempPath());
            }
            catch
            {
                return;
            }

            //一時フォルダ内のファイル
            if (directory.ToLower().StartsWith(tmpDir.ToLower()))
            {
                return;
            }

            //ファイルが一つだけ、かつ一時フォルダでない

            Task.Run(async() =>
            {
                //同じフォルダ内のファイルをライブラリに登録
                await this.front.ActivateFolderAsync(directory).ConfigureAwait(false);

                var search = new SearchInformation(new ComplexSearch(false));
                search.Root.Add(new UnitSearch()
                {
                    Property  = FileProperty.DirectoryPathStartsWith,
                    Reference = record.Directory,
                    Mode      = CompareMode.Equal,
                });

                search.SetSort(new[]
                {
                    new SortSetting()
                    {
                        Property = FileProperty.FileName, IsDescending = false
                    }
                }, false);

                var index = await core.Library.FindIndexAsync(search, record).ConfigureAwait(false);

                this.lastViewerImageIndex = new OldNewPair <long>(index, index);

                this.front.Length
                .Where(x => x > index)
                .Take(1)
                .Subscribe(x =>
                {
                    this.viewerImageChangeGate = false;
                    this.ViewerIndexInner      = index;
                    this.viewerImageChangeGate = true;
                });


                state.Search = search;
                this.History.Current.Search = search;
                await Application.Current.Dispatcher.InvokeAsync(() =>
                {
                    this.front.SetSearch(search, true);
                });
            })
            .FireAndForget();
        }
示例#13
0
        private async Task <Library> CreateLibraryAsync()
        {
            LibraryOwner.Reset();
            //this.settings?.Folders?.Clear();
            this.FileEnumerator?.Clear();

            var path   = System.IO.Directory.GetCurrentDirectory();
            var config = new LibraryConfigurationDummy(path);

            this.FileEnumerator = new Dictionary <string, FolderContainerDummy>();// = new FolderAccesserDummy();
            //config.FolderAccesser = this.FileEnumerator;

            config.GetChildFoldersFunction = s =>
            {
                var key = s.TrimEnd(System.IO.Path.DirectorySeparatorChar);

                if (!this.FileEnumerator.ContainsKey(key))
                {
                    Debug.WriteLine(key);
                    this.FileEnumerator.ForEach(x => Debug.WriteLine(x.Key + "," + x.Value.Path));
                    return(null);
                }
                return(this.FileEnumerator[key]
                       .Folders?.Select(x => x.Value.Path) ?? new string[0]);
            };

            config.GetFolderFunction = s =>
            {
                var key = s.TrimEnd(System.IO.Path.DirectorySeparatorChar);
                FolderContainerDummy f;
                this.FileEnumerator.TryGetValue(key, out f);
                return(f);
            };

            this.config = config;
            LibraryOwner.SetConfig(config);

            //config.Folders.Add(folder);
            //config.FileExistingChecker = _ => false;

            var library = LibraryOwner.GetCurrent();

            this.settings = new LibrarySettings()
            {
                Version = 10,
            };


            library.InitializeLibrarySettings(settings);

            await library.LoadAsync();


            await library.ClearAsync();

            data.ForEach((x, c) =>
            {
                var f = LoadTestData(x);
                this.AddFolder(f);
                library.Folders.Add(new FolderInformation(f.Path));
            });

            await library.RefreshLibraryAsync(true);

            var search = new SearchInformation(new ComplexSearch(false));

            library.Searcher.AddSearchToDictionary(search);

            return(library);
        }
        public SearchPageViewModel(ClientWindowViewModel parent)
        {
            this.parent = parent;
            var client  = parent.Client;
            var library = parent.Library;
            var core    = parent.Core;

            var searcher = library.Searcher;

            this.HistoryList  = searcher.SearchHistory.ToReadOnlyReactiveCollection().AddTo(this.Disposables);
            this.FavoriteList = searcher.FavoriteSearchList.ToReadOnlyReactiveCollection().AddTo(this.Disposables);

            this.SelectedTab = new ReactiveProperty <TabMode>
                                   ((searcher.FavoriteSearchList.Count > 0 && core.LastSearchedFavorite)
                    ? TabMode.Favorite : TabMode.History)
                               .AddTo(this.Disposables);

            this.SelectedTab
            .Subscribe(x => core.LastSearchedFavorite = (x == TabMode.Favorite))
            .AddTo(this.Disposables);

            this.IsEditing = new ReactiveProperty <bool>(false).AddTo(this.Disposables);


            this.SelectHistoryCommand  = new ReactiveCommand().AddTo(this.Disposables);
            this.SelectFavoriteCommand = new ReactiveCommand().AddTo(this.Disposables);

            var hitoryItem = this.SelectHistoryCommand
                             .OfType <SearchInformation>()
                             .Select(x => x.Clone());

            var favoriteItem = this.SelectFavoriteCommand
                               .OfType <SearchInformation>();

            this.CurrentSearch = Observable
                                 .Merge(hitoryItem, favoriteItem)//, newItem)
                                 .ToReactiveProperty(SearchInformation.GenerateEmpty())
                                 .AddTo(this.Disposables);

            this.CurrentSearch
            .Subscribe(x => this.IsEditing.Value = (x != null && !x.Key.IsNullOrEmpty()))
            .AddTo(this.Disposables);

            this.IsThumbnailVisible = this.CurrentSearch
                                      .Select(x => x.DateLastUsed > default(DateTimeOffset))
                                      .ToReadOnlyReactiveProperty()
                                      .AddTo(this.Disposables);

            searcher.FavoriteSearchList
            .ObserveAddChanged()
            .Subscribe(x =>
            {
                if (this.CurrentSearch.Value == x)
                {
                    this.SelectedTab.Value = TabMode.Favorite;
                }
            })
            .AddTo(this.Disposables);

            searcher.FavoriteSearchList
            .ObserveRemoveChanged()
            .Subscribe(x =>
            {
                if (this.CurrentSearch.Value == x && this.SelectedTab.Value == TabMode.Favorite)
                {
                    this.CurrentSearch.Value = SearchInformation.GenerateEmpty();
                }
            })
            .AddTo(this.Disposables);

            this.CurrentSearchType = this.HistoryList
                                     .CollectionChangedAsObservable()
                                     .Merge(this.FavoriteList.CollectionChangedAsObservable())
                                     .Select(_ => this.CurrentSearch.Value)
                                     .Merge(this.CurrentSearch)
                                     .Select(x => this.HasFavoriteSearch(x) ? 1
                    : this.HasHistorySearch(x) ? 0 : 2)
                                     .ToReadOnlyReactiveProperty()
                                     .AddTo(this.Disposables);

            this.IsFavoriteSearch = this.CurrentSearchType
                                    .Select(x => x == 1)
                                    .ToReadOnlyReactiveProperty()
                                    .AddTo(this.Disposables);


            this.ClickHistoryCommand  = new ReactiveCommand().AddTo(this.Disposables);
            this.ClickFavoriteCommand = new ReactiveCommand().AddTo(this.Disposables);

            this.ClickHistoryCommand
            .Select(x => x as SearchInformation)
            .Where(x => x != null)
            .Subscribe(x =>
            {
                if (!this.IsEditing.Value ||
                    this.CurrentSearch.Value == null ||
                    this.CurrentSearch.Value.Key.IsNullOrEmpty() ||
                    this.CurrentSearch.Value.Key.Equals(x.Key))
                {
                    this.StartSearch(client, x);
                }
                else
                {
                    this.SelectHistoryCommand.Execute(x);
                }
            })
            .AddTo(this.Disposables);

            this.ClickFavoriteCommand
            .Select(x => x as SearchInformation)
            .Where(x => x != null)
            .Subscribe(x =>
            {
                if (!this.IsEditing.Value ||
                    this.CurrentSearch.Value == null ||
                    this.CurrentSearch.Value.Key.IsNullOrEmpty() ||
                    this.CurrentSearch.Value.Key.Equals(x.Key))
                {
                    this.StartSearch(client, x);
                }
                else
                {
                    this.SelectFavoriteCommand.Execute(x);
                }
            })
            .AddTo(this.Disposables);

            this.StartSearchCommand = new ReactiveCommand()
                                      .WithSubscribe(_ => this.StartSearch(client, this.CurrentSearch.Value), this.Disposables);

            this.AddCriteriaCommand = new ReactiveCommand()
                                      .WithSubscribe(_ => this.EditSearch(this.CurrentSearch.Value.Root), this.Disposables);

            this.ItemClickCommand = new ReactiveCommand()
                                    .WithSubscribe(item =>
            {
                var search = item as ISqlSearch;

                if (search != null)
                {
                    this.EditSearch(search);
                }
            }, this.Disposables);

            this.AddToFavoriteCommand = new ReactiveCommand()
                                        .WithSubscribe(_ =>
            {
                var item = this.CurrentSearch.Value;
                if (item == null)
                {
                    return;
                }

                if (this.HasFavoriteSearch(item))
                {
                    searcher.MarkSearchUnfavorite(item);
                }
                else
                {
                    searcher.MarkSearchFavorite(item);
                }
            }, this.Disposables);


            this.SwitchModeCommand = new ReactiveCommand()
                                     .WithSubscribe(_ =>
            {
                var item = this.CurrentSearch.Value;
                if (item == null)
                {
                    return;
                }

                item.Root.IsOr = !item.Root.IsOr;
            }, this.Disposables);

            this.NewSearchCommand = new ReactiveCommand()
                                    .WithSubscribe(_ => this.CurrentSearch.Value = SearchInformation.GenerateEmpty(),
                                                   this.Disposables);

            this.ShowFavoriteCommand = new ReactiveCommand()
                                       .WithSubscribe(_ => this.SelectedTab.Value = TabMode.Favorite, this.Disposables);
            this.ShowHistoryCommand = new ReactiveCommand()
                                      .WithSubscribe(_ => this.SelectedTab.Value = TabMode.History, this.Disposables);
        }
 private bool HasHistorySearch(SearchInformation search)
 => (search != null && search.Key != null && this.HistoryList != null &&
     this.HistoryList.Any(y => search.Key.Equals(y?.Key)));
 private bool HasFavoriteSearch(SearchInformation search)
 => (search != null && search.Key != null && this.FavoriteList != null &&
     this.FavoriteList.Any(y => search.Key.Equals(y?.Key)));