public async Task <IReadOnlyCollection <IPartialRssItem> > SearchAsync(string searchText, RssItemState[] includes, string feedId, CancellationToken token) { if (searchText is null) { throw new ArgumentNullException(nameof(searchText)); } if (includes is null) { throw new ArgumentNullException(nameof(includes)); } var searchExpr = SearchExpression.Parse(searchText); var items = await this.ListCoreAsync(includes, feedId, searchExpr, token).ConfigureAwait(false); token.ThrowIfCancellationRequested(); if (searchExpr.Parts.OfType <IAppSearchPart>().Any()) { items = await Task.Run(() => { IEnumerable <PartialRssItem> r = items; foreach (var part in searchExpr.Parts.OfType <IAppSearchPart>()) { r = part.Where(r); } return(r.ToArray()); }).ConfigureAwait(false); } return(items); }
/// <summary> /// Creates the command to get the number of rows in the given section. /// </summary> /// <returns> /// The command to get the number of rows in the given section. /// </returns> /// <param name='section'> /// The section to get the number of rows for. /// </param> protected virtual SQLiteCommand CreateRowCountCommand(int section) { string query = "select count (*) from \"" + TableName + "\""; object[] args; if (SectionExpression != null) { SQLiteWhereExpression where = new SQLiteWhereExpression(); SQLiteAndExpression and = new SQLiteAndExpression(); and.Add(new SQLiteEqualToExpression(SectionExpression, SectionTitles[section])); if (SearchExpression != null && SearchExpression.Expression != null) { and.AddRange(SearchExpression.Expression); } where.Expression = and; query += " " + where.ToString(out args); } else if (SearchExpression != null) { query += " " + SearchExpression.ToString(out args); } else { args = new object [0]; } return(Connection.CreateCommand(query, args)); }
public void TestSearchMultipleColumns() { var actual = new SearchExpression() { Columns = new List <ColumnReference>() { new ColumnReference() { Identifiers = new List <string>() { "c1" } }, new ColumnReference() { Identifiers = new List <string>() { "c2" } } }, Value = new StringLiteral() { Value = "test" } }.Print(); var expected = "CONTAINS((c1, c2), 'test')"; actual.Should().Be(expected); }
private ISearchExpression RemoveParentSelectAsExpression(ISearchExpression exp) { if (m_parentSm.SelectAsColumns == null) /* || m_innerSearchManager.Count == 0) */ // 不知道为什么有这句话 { return(exp); } Feng.Search.LogicalExpression le = exp as Feng.Search.LogicalExpression; if (le != null) { ISearchExpression sel = RemoveParentSelectAsExpression(le.LeftHandSide); ISearchExpression ser = RemoveParentSelectAsExpression(le.RightHandSide); return(new Feng.Search.LogicalExpression(sel, ser, le.LogicOperator)); } else { Feng.Search.SimpleExpression se = exp as Feng.Search.SimpleExpression; if (se != null) { if (m_parentSm.SelectAsColumns.ContainsKey(se.FullPropertyName)) { return(SearchExpression.True()); } else { return(se); } } } return(null); }
static internal FixedList <Faq> SearchFaq(string keywords = "") { string filter = SearchExpression.ParseAndLikeKeywords("Keywords", keywords); return(BaseObject.GetList <Faq>(filter) .ToFixedList()); }
public static SearchItem CreateSearchExpressionItem(SearchExpression expr) { return(new SearchItem("") { data = expr }); }
FilterDefinition <T> GetSearchQuery(SearchExpression searchExpression) { try { if (searchExpression == null) { return(FilterDefinition <T> .Empty); } if (searchExpression is PropertySearchExpression) { var builder = Builders <T> .Filter; // This is necessary to match properties of the format ProcessITTOs.ITTOId. //ProcessITTOs is the main property but MongoDB filter allows projection into properties of objects or arrays. String property = (searchExpression as PropertySearchExpression).Property.Split('.')[0].Trim(); PropertyInfo info = typeof(T).GetProperties().FirstOrDefault(p => p.Name.Trim() == property); if (info != null) { return(GenerateFilterConditionByType(info.PropertyType, searchExpression as PropertySearchExpression)); } return(FilterDefinition <T> .Empty); } else { return(ToDocumentBinary(GetSearchQuery((searchExpression as BinarySearchExpression <T>).LeftSearch), (searchExpression as BinarySearchExpression <T>).BinaryOperator, GetSearchQuery((searchExpression as BinarySearchExpression <T>).RightSearch))); } } catch (Exception ex) { return(FilterDefinition <T> .Empty); } }
private string GetVariableText(TaskInfo info) { string text = info.Text; MatchCollection mc = s_regexOwnData.Matches(text); foreach (Match m in mc) { string s = string.Empty; switch (m.Groups[1].Value.ToUpper()) { case "COUNT": if (!string.IsNullOrEmpty(info.SearchManagerClassName)) { ISearchManager searchManager = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(info.SearchManagerClassName, info.SearchManagerClassParams); s = searchManager.GetCount(SearchExpression.Parse(EntityHelper.ReplaceExpression(info.SearchExpression))).ToString(); m_sms[info.Name] = searchManager; } break; case "EXP": string exp = m.Groups[3].Value.Trim(); object ret = PythonHelper.ExecutePythonExpression(exp, null); s = ret == null ? string.Empty : ret.ToString(); break; default: throw new NotSupportedException("Invalid text of " + text); } text = text.Replace(m.Groups[0].Value, s); } return(text); }
public void RefreshData() { m_新任务集合Grid.DisplayManager.SearchManager.LoadData( SearchExpression.Parse("车辆作业 ISNULL"), null); m_作业未结束Grid.DisplayManager.SearchManager.LoadData(); LoadLabelData(); }
/// <summary> /// 以entities为数据打印(例如滞箱费减免联系单) /// </summary> /// <param name="entities"></param> public void FillDataSet(object[] entities) { ISearchExpression se = null; foreach (object entity in entities) { if (se == null) { se = SearchExpression.Parse(EntityHelper.ReplaceEntity(m_reportInfo.SearchExpression, entity)); } else { se = SearchExpression.Or(se, SearchExpression.Parse(EntityHelper.ReplaceEntity(m_reportInfo.SearchExpression, entity))); } } for (int i = 0; i < m_reportDataInfos.Count; ++i) { object data = m_sms[i].GetData(se, null); System.Collections.IEnumerable dataList = data as System.Collections.IEnumerable; if (dataList == null) { dataList = (data as System.Data.DataTable).DefaultView; } FillDataSet(i, dataList); } }
static private string BuildTransactionEntriesFilter(SearchVouchersCommand command, string nestedFilter) { if (command.AccountKeywords.Length == 0 && command.SubledgerAccountKeywords.Length == 0) { return(string.Empty); } string filter = string.Empty; if (command.AccountKeywords.Length != 0) { filter = SearchExpression.ParseAndLikeKeywords("CUENTA_ESTANDAR_KEYWORDS", command.AccountKeywords); } if (command.SubledgerAccountKeywords.Length != 0) { if (filter.Length != 0) { filter += " AND "; } filter += SearchExpression.ParseAndLikeKeywords("CUENTA_AUXILIAR_KEYWORDS", command.SubledgerAccountKeywords); } if (nestedFilter.Length != 0) { return($"ID_TRANSACCION IN (SELECT ID_TRANSACCION FROM VW_COF_MOVIMIENTO_SEARCH WHERE ({nestedFilter} AND {filter}))"); } else { return($"ID_TRANSACCION IN (SELECT ID_TRANSACCION FROM VW_COF_MOVIMIENTO_SEARCH WHERE {filter})"); } }
public void TestCloneSearchExpression() { SearchExpression searchExpression = new SearchExpression() { AllColumns = false, Columns = new List <ColumnReference>() { new ColumnReference() { Identifiers = new List <string>() { "c1" } } }, Value = new StringLiteral() { Value = "test" } }; var clone = searchExpression.Clone() as SearchExpression; Assert.AreEqual(searchExpression, clone); Assert.IsFalse(ReferenceEquals(searchExpression, clone)); Assert.IsFalse(ReferenceEquals(searchExpression.Value, clone.Value)); for (int i = 0; i < searchExpression.Columns.Count; i++) { Assert.IsFalse(ReferenceEquals(searchExpression.Columns[i], clone.Columns[i])); } }
/// <summary> /// Creates the command used to get the list of section titles. /// </summary> /// <returns> /// The command to get the list of section titles or null if /// the model does not have any sections or titles. /// </returns> protected virtual SQLiteCommand CreateSectionTitlesCommand() { if (SectionExpression == null) { return(null); } string query = "select distinct " + SectionExpression + " from \"" + TableName + "\" as Title"; object[] args; if (SearchExpression != null) { query += " " + SearchExpression.ToString(out args); } else { args = new object [0]; } if (OrderBy.Count > 0) { query += " " + OrderBy.ToString(); } return(Connection.CreateCommand(query, args)); }
public static SearchExpression CreateStreamExpression(SearchExpression currentStream, string name = "<streamexpr>") { var exp = new SearchExpression(SearchExpressionType.Function, name.GetStringView(), new SearchExpressionEvaluator("StreamEvaluator", context => currentStream.Execute(context), SearchExpressionEvaluationHints.Default)); return(exp); }
public void ParseComplexStatement() { SearchExpression expr = QueryParser.Parse("('anwaltliche Vertretung' oder Scheidung) und Ehe*"); Assert.That(expr, Is.Not.Null); Assert.That(expr, Is.InstanceOf <AndSearchExpression>()); Assert.That(((AndSearchExpression)expr).Expressions.Length, Is.EqualTo(2)); }
void AdInfoSearchForm_DoubleClick(object sender, EventArgs e) { Xceed.Grid.DataCell cell = sender as Xceed.Grid.DataCell; var row = cell.ParentRow; var dmc = ServiceProvider.GetService <IApplication>().ExecuteAction(row.Cells["Table"].Value.ToString()) as IDisplayManagerContainer; dmc.DisplayManager.SearchManager.LoadData(SearchExpression.Eq(row.Cells["Column"].Value.ToString(), row.Cells["Value"].Value.ToString()), null); }
public void ParseSimplePhrase() { SearchExpression expr = QueryParser.Parse("'Ehe Recht'"); Assert.That(expr, Is.Not.Null); Assert.That(expr, Is.InstanceOf <PhraseSearchExpression>()); Assert.That(((PhraseSearchExpression)expr).Value, Is.EqualTo("Ehe Recht")); }
void CustomSearchItem_Click(object sender, SmartItemClickEventArgs e) { Xceed.SmartUI.SmartItem item = sender as Xceed.SmartUI.SmartItem; CustomSearchInfo info = item.Tag as CustomSearchInfo; m_sm.FirstResult = 0; m_sm.LoadData(SearchExpression.Parse(info.SearchExpression), null); }
void HistoryPaneItem_Click(object sender, SmartItemClickEventArgs e) { Xceed.SmartUI.SmartItem item = sender as Xceed.SmartUI.SmartItem; SearchHistoryInfo his = item.Tag as SearchHistoryInfo; m_sm.FirstResult = 0; m_sm.LoadData(SearchExpression.Parse(his.Expression), SearchOrder.Parse(his.Order)); }
public void ParseAndOrWithParens() { SearchExpression expr = QueryParser.Parse("(Scheidung oder Tod) und Ehe"); Assert.That(expr, Is.Not.Null); Assert.That(expr, Is.InstanceOf <AndSearchExpression>()); Assert.That(((AndSearchExpression)expr).Expressions.Length, Is.EqualTo(2)); }
public void ParseOder() { SearchExpression expr = QueryParser.Parse("Ehe oDeR Recht"); Assert.That(expr, Is.Not.Null); Assert.That(expr, Is.InstanceOf <OrSearchExpression>()); Assert.That(((OrSearchExpression)expr).Expressions.Length, Is.EqualTo(2)); }
public void ParseExplicitUnd() { SearchExpression expr = QueryParser.Parse("Ehe UnD Recht"); Assert.That(expr, Is.Not.Null); Assert.That(expr, Is.InstanceOf <AndSearchExpression>()); Assert.That(((AndSearchExpression)expr).Expressions.Length, Is.EqualTo(2)); }
public void TestSearchExpression2() { SearchExpression searchExpression = "[Name Like 'xiaoli']"; Assert.Equal("Name", searchExpression.Left); Assert.Equal(SearchOperator.Like, searchExpression.Op); Assert.Equal("'xiaoli'", searchExpression.Right); }
public void ParseSimpleTerm() { SearchExpression expr = QueryParser.Parse("Ehe"); Assert.That(expr, Is.Not.Null); Assert.That(expr, Is.InstanceOf <TermSearchExpression>()); Assert.That(((TermSearchExpression)expr).Value, Is.EqualTo("Ehe")); }
public void TestSearchExpression1() { var searchExpression = new SearchExpression("[Name Like 'xiaoli']"); Assert.Equal("Name", searchExpression.Left); Assert.Equal(SearchOperator.Like, searchExpression.Op); Assert.Equal("'xiaoli'", searchExpression.Right); }
public void TestSearchExpressionAccept() { Mock <KoraliumSqlVisitor> mock = new Mock <KoraliumSqlVisitor>(); SearchExpression searchExpression = new SearchExpression(); searchExpression.Accept(mock.Object); mock.Verify(x => x.VisitSearchExpression(searchExpression)); }
/// <summary> /// /// </summary> /// <param name="searchConditions"></param> /// <param name="searchOrders"></param> public void FillSearchConditions(IList <ISearchExpression> searchConditions, IList <ISearchOrder> searchOrders) { if (myComboBox1.SelectedValue != null && dict.ContainsKey(myComboBox1.SelectedValue.ToString())) { searchConditions.Add(SearchExpression.Parse(dict[myComboBox1.SelectedValue.ToString()])); } }
public void On_PropertyPath_Succeeds() { var expression = new SearchExpression <Request, Entity, Result>(x => x.SubEntityValue); expression.On("SubEntity.Value"); expression.ItemPropertyPaths[0].Should().Be("SubEntity.Value"); }
public string GetKeywordsFilter() { if (this.Keywords.Length != 0) { return(SearchExpression.ParseAndLike("Name", this.Keywords)); } return(String.Empty); }
static internal FixedList <BpmnDiagram> SearchBpmnDiagrams(string keywords, string sort = "") { string filter = SearchExpression.ParseAndLikeKeywords("ObjectKeywords", keywords); sort = sort ?? "ObjectName"; return(BaseObject.GetList <BpmnDiagram>(filter, sort) .ToFixedList()); }
public string FindClassificationByPath(string path) { string result; var searchExpr = new SearchExpression("NamePath=" + path); var classificationCollection = new ClassificationCollection(application); classificationCollection.Load(searchExpr); if (classificationCollection.Count > 0) result = classificationCollection[0].Name; else result = "Not found"; return result; }
public List<string> FindClassificationByPathAndDate(string path, DateTime date) { //TO DO here subclassification, not root var result = new List<string>(); string id; var searchExpr = new SearchExpression("NamePath=" + path); var classificationCollection = new ClassificationCollection(application); classificationCollection.Load(searchExpr); if (classificationCollection.Count > 0) id = classificationCollection[0].Id.ToString(); else throw new Exception("Not found"); searchExpr = new SearchExpression("Root=" + id + " AND CreatedOn > " + date.Month + '/' + date.Day + '/' + date.Year); classificationCollection = new ClassificationCollection(application); classificationCollection.Load(searchExpr); foreach (Classification classification in classificationCollection) { result.Add(classification.Name); } return result; }
public List<string> FindRecordWithFieldCreator() { var result = new List<string>(); var searchExpression = new SearchExpression("FieldName(\"Creator\") <> \"\""); var recordCollection = new RecordCollection(application); recordCollection.Load(searchExpression); foreach (Record record in recordCollection) { result.Add(record.Id.ToString()); } return result; }
public List<string> FindRecordWithFileSize(string size) { var result = new List<string>(); var searchExpression = new SearchExpression("File.Version.Filesize > " + size); var recordCollection = new RecordCollection(application); recordCollection.Load(searchExpression); foreach (Record record in recordCollection) { result.Add(record.Id.ToString()); } return result; }
public List<string> FindRecordWithSpecialTypes(string[] types) { var result = new List<string>(); var searchExpr = new SearchExpression("Extension = eps OR Extension = pdf"); var recordCollection = new RecordCollection(application); recordCollection.Load(searchExpr); foreach (Record record in recordCollection) { result.Add(record.Id.ToString()); } return result; }
public List<string> FindUserGroup(string group) { List<string> result = new List<string>(); SearchExpression searchExpr = new SearchExpression("Group.Name="+group); UserCollection userCollection = new UserCollection(application); userCollection.Load(searchExpr); foreach (User user in userCollection) { result.Add(user.Name); } return result; }
public List<string> FindUserLoggedIn(DateTime date) { var result = new List<string>(); SearchExpression searchExpr = new SearchExpression("LastSuccessfulLogOn > " + date.Month + '/' + date.Day + '/'+ date.Year); UserCollection userCollection = new UserCollection(application); userCollection.Load(searchExpr); foreach (User user in userCollection) { result.Add(user.Name); } return result; }
public List<string> FindUserStartsWith(string begin) { List<string> result = new List<string>(); SearchExpression searchExpr = new SearchExpression("Name=" + begin + "*"); UserCollection userCollection = new UserCollection(application); userCollection.Load(searchExpr); foreach (User user in userCollection) { result.Add(user.Name); } return result; }
public List<string> FindRecordFromClassifications(string classification) { var result = new List<string>(); var searchExpression = new SearchExpression("Classification.NamePath ="+classification); var recordCollection = new RecordCollection(application); recordCollection.Load(searchExpression); foreach (Record record in recordCollection) { result.Add(record.Id.ToString()); } return result; }