Example #1
0
        private async void CheckCompileFilters(string source)
        {
            try
            {
                var newFilter = await Task.Run(() => QueryCompiler.CompileFilters(source));

                newFilter.GetEvaluator(); // validate types
                newFilter.GetSqlQuery();  // validate types (phase 2)
                _lastCommit = newFilter;
                FoundError  = false;
            }
            catch (Exception ex)
            {
                FoundError       = true;
                ExceptionMessage = ex.Message;
            }
            _isDirtyState = false;
        }
Example #2
0
        public void Close()
        {
            if (!IsConfigurationActive)
            {
                return;
            }
            this.IsConfigurationActive = false;

            // refresh mute filter
            if (_isDirtyState)
            {
                try
                {
                    var newFilter = QueryCompiler.CompileFilters(_currentQueryString);
                    newFilter.GetEvaluator(); // validate types
                    _lastCommit = newFilter;
                }
                catch { }
            }
            if (_lastCommit != null)
            {
                Setting.Muteds.Value = _lastCommit;
            }

            // update connection property
            _accounts.ForEach(a => a.CommitChanges());

            // dispose fswatcher
            this._fsWatcher.Dispose();

            // update theme
            ApplyTheme();

            // callback completion handler
            if (_completeCallback != null)
            {
                _completeCallback.OnNext(Unit.Default);
                _completeCallback.OnCompleted();
                _completeCallback = null;
            }
        }
Example #3
0
        public string CreateFilterQuery()
        {
            switch (_option)
            {
            case SearchOption.Local:
            case SearchOption.CurrentTab:
                var pan   = SplitPositiveNegativeQuery(_query);
                var query = pan.Item1.Select(s => "text contains " + s.EscapeForQuery().Quote())
                            .Concat(
                    pan.Item2.Select(s => "!(text contains " + s.EscapeForQuery().Quote() + ")"))
                            .JoinString("&&");
                var ctab = TabManager.CurrentFocusTab;
                var ctf  = ctab?.FilterQuery;
                if (_option != SearchOption.CurrentTab || ctf == null)
                {
                    return("where " + query);
                }
                var cqf     = QueryCompiler.CompileFilters(query);
                var filters = ctf.PredicateTreeRoot.Operator;
                var nfq     = new FilterQuery
                {
                    Sources           = ctf.Sources.ToArray(),
                    PredicateTreeRoot = new FilterExpressionRoot
                    {
                        Operator = filters.And(cqf.Operator)
                    }
                };
                return(nfq.ToQuery());

            case SearchOption.Query:
                return(_filterQuery == null ? "!()" : _query);

            case SearchOption.Web:
                return("from search:" + _query.EscapeForQuery().Quote() + " where ()");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #4
0
 public void AddPredicate(string query)
 {
     Value = QueryCompiler.CompileFilters(Value.ToQuery() + " | " + query);
 }