Beispiel #1
0
        public List <Result> Query(Query query)
        {
            _cancellationTokenSource?.Cancel(); // cancel if already exist
            var cts     = _cancellationTokenSource = new CancellationTokenSource();
            var results = new List <Result>();

            if (!string.IsNullOrEmpty(query.Search))
            {
                var keyword = query.Search;

                try
                {
                    var searchList = _api.Search(keyword, cts.Token, maxCount: _settings.MaxSearchCount);
                    if (searchList == null)
                    {
                        return(results);
                    }

                    for (int i = 0; i < searchList.Count; i++)
                    {
                        SearchResult searchResult = searchList[i];
                        var          r            = CreateResult(keyword, searchResult, i);
                        results.Add(r);
                    }
                }
                catch (IPCErrorException)
                {
                    results.Add(new Result
                    {
                        Title   = _context.API.GetTranslation("wox_plugin_everything_is_not_running"),
                        IcoPath = "Images\\warning.png"
                    });
                }
                catch (Exception e)
                {
                    Logger.WoxError("Query Error", e);
                    results.Add(new Result
                    {
                        Title    = _context.API.GetTranslation("wox_plugin_everything_query_error"),
                        SubTitle = e.Message,
                        Action   = _ =>
                        {
                            Clipboard.SetText(e.Message + "\r\n" + e.StackTrace);
                            _context.API.ShowMsg(_context.API.GetTranslation("wox_plugin_everything_copied"), null, string.Empty);
                            return(false);
                        },
                        IcoPath = "Images\\error.png"
                    });
                }
            }

            return(results);
        }
Beispiel #2
0
        public List <Result> Query(Query query)
        {
            _cancellationTokenSource?.Cancel(); // cancel if already exist
            var cts     = _cancellationTokenSource = new CancellationTokenSource();
            var results = new List <Result>();

            if (!string.IsNullOrEmpty(query.Search))
            {
                var keyword = query.Search;

                try
                {
                    var searchList = _api.Search(keyword, cts.Token, _settings.SortOption, maxCount: _settings.MaxSearchCount);
                    if (searchList == null)
                    {
                        return(results);
                    }

                    foreach (var searchResult in searchList)
                    {
                        var r = CreateResult(keyword, searchResult);
                        results.Add(r);
                    }
                }
                catch (IPCErrorException)
                {
                    results.Add(new Result
                    {
                        Title    = _context.API.GetTranslation("flowlauncher_plugin_everything_is_not_running"),
                        SubTitle = _context.API.GetTranslation("flowlauncher_plugin_everything_run_service"),
                        IcoPath  = "Images\\warning.png",
                        Action   = _ =>
                        {
                            if (FilesFolders.FileExists(_settings.EverythingInstalledPath))
                            {
                                FilesFolders.OpenPath(_settings.EverythingInstalledPath);
                            }

                            return(true);
                        }
                    });
                }
                catch (Exception e)
                {
                    _context.API.LogException("EverythingPlugin", "Query Error", e);
                    results.Add(new Result
                    {
                        Title    = _context.API.GetTranslation("flowlauncher_plugin_everything_query_error"),
                        SubTitle = e.Message,
                        Action   = _ =>
                        {
                            Clipboard.SetText(e.Message + "\r\n" + e.StackTrace);
                            _context.API.ShowMsg(_context.API.GetTranslation("flowlauncher_plugin_everything_copied"), null, string.Empty);
                            return(false);
                        },
                        IcoPath = "Images\\error.png"
                    });
                }
            }

            return(results);
        }