/// <summary>
        /// Initializes a new instance of the <see cref="SelfMediaDatabase.Console.Bootstrap.BootstrapOperations"/> class.
        /// </summary>
        /// <param name="optionUtils">Utils for command line options.</param>
        public BootstrapOperations(
            IOptionsUtils optionsUtils, 
            IRenameOperation renameOperation, 
            ITagsOperation tagsOperation, 
            IPruneOperation pruneOperation,
			IClassifyOperation classifyOperation,
			ISearchOperation searchOperation)
        {
            if (renameOperation == null)
                throw new ArgumentNullException("renameOperation");
            if (optionsUtils == null)
                throw new ArgumentNullException("optionsUtils");
            if (tagsOperation == null)
                throw new ArgumentNullException("tagsOperation");
            if (pruneOperation == null)
                throw new ArgumentNullException("pruneOperation");
			if (classifyOperation == null)
				throw new ArgumentNullException("classifyOperation");
			if (searchOperation == null)
				throw new ArgumentNullException("searchOperation");

            _optionsUtils = optionsUtils;
            _renameOperation = renameOperation;
            _tagsOperation = tagsOperation;
            _pruneOperation = pruneOperation;
			_classifyOperation = classifyOperation;
			_searchOperation = searchOperation;
        }
        /// <summary>
        /// Starts the search operation with search value.
        /// </summary>
        /// <param name="searchOperation">The search operation.</param>
        /// <param name="searchValue">The search value.</param>
        public void StartSearchOperationWithSearchValue(ISearchOperation searchOperation, string searchValue)
        {
            if ((searchValue?.Length ?? 0) < this.MinSearchTextLength && this.ViewReference.ContextValueForKey("Modus") == "GlobalSearch")
            {
                this.CreateNewSearchPageWithEmptyResult();
                return;
            }

            if (this.PreparedSearches == null)
            {
                this.BuildPreparedSearches(false);
            }

            var operation   = searchOperation as Operation;
            var searchCount = this.PreparedSearches?.Count ?? 0;

            for (var i = 0; i < searchCount; i++)
            {
                var preparedSearch = this.PreparedSearches[i];
                var container      = this.CreateContainerMetaInfoWithValuePreparedSearch(searchValue, preparedSearch);
                searchOperation.AddContainerMetaInfo(container);
            }

            ServerSession.CurrentSession.ExecuteRequest(operation);
            this.CurrentSearchOperation = operation;
        }
        public void ClearPackages()
        {
            listOperation        = null;
            listOperationOffline = null;
            searchOperation      = null;

            ClearPackagesInternal();
            OnPackagesChanged(OrderedPackages());
        }
 private void FetchSearchCache()
 {
     if (searchOperation == null && LastSearchPackages == null)
     {
         var operation = OperationFactory.Instance.CreateSearchOperation();
         searchOperation = operation;
         operation.GetAllPackageAsync(infos => { LastSearchPackages = infos; });
     }
 }
		public void Initialize()
		{
			_optionUtils = Substitute.For<IOptionsUtils>();
			_renameOperation = Substitute.For<IRenameOperation>();
			_tagsOperation = Substitute.For<ITagsOperation>();
			_pruneOperation = Substitute.For<IPruneOperation>();
			_classifyOperation = Substitute.For<IClassifyOperation>();
			_searchOperation = Substitute.For<ISearchOperation>();

			_target = new BootstrapOperations(_optionUtils, _renameOperation, _tagsOperation, _pruneOperation, _classifyOperation, _searchOperation);
		}
        private void Reset()
        {
            LastListOfflinePackages = null;
            LastListPackages        = null;
            LastSearchPackages      = null;

            listOperation        = null;
            listOperationOffline = null;
            searchOperation      = null;

            ClearPackagesInternal();
            FetchAllCaches();
        }
        private void SetSearchPackageInfos(IEnumerable <PackageInfo> searchPackageInfos)
        {
            searchOperation = null;
            var copyPackageInfo = new List <PackageInfo>(packageInfos);

            copyPackageInfo.AddRange(searchPackageInfos.Where(pi => !Packages.ContainsKey(pi.Name) || Packages[pi.Name].Versions.All(v => v.Version != pi.Version)));

            LastSearchPackages = copyPackageInfo;

            // Don't update the current list if the filter changed since the operation started
            if (Filter == PackageFilter.All)
            {
                ClearPackageInfosInternal();
                AddPackageInfos(LastSearchPackages);
            }
        }
        /// <summary>
        /// Searches the specified search page.
        /// </summary>
        /// <param name="_searchPage">The search page.</param>
        public override void Search(object _searchPage)
        {
            var searchPage = (UPMSearchPage)_searchPage;

            searchPage.Invalid   = false;
            this.SectionContexts = new Dictionary <string, UPCoreMappingResultContext>();
            string value = null;

            if (!string.IsNullOrEmpty(searchPage.SearchText))
            {
                value = searchPage.SearchText;
            }

            ISearchOperation operation = searchPage.SearchType == SearchPageSearchType.OfflineSearch
                ? (ISearchOperation) new LocalGlobalSearchOperation(this)
                : new RemoteSearchOperation(this);

            this.StartSearchOperationWithSearchValue(operation, value);
        }
Ejemplo n.º 9
0
 internal void FetchSearchCache(bool forceRefetch = false)
 {
     if (!forceRefetch && (searchOperationOngoing || searchPackages.Any()))
     {
         return;
     }
     if (searchOperation != null)
     {
         searchOperation.Cancel();
     }
     searchOperationOngoing = true;
     searchOperation        = OperationFactory.Instance.CreateSearchOperation();
     searchOperation.OnOperationFinalized += () =>
     {
         searchOperationOngoing = false;
         UpdatePackageCollection(true);
     };
     searchOperation.GetAllPackageAsync(UpdateSearchPackageInfos,
                                        error => { Debug.LogError("Error searching packages online."); });
     SearchSignal.SetOperation(searchOperation);
 }