public static string Get(string name) { lock (_locker) { if (_settingsList.ContainsKey(name)) { return(_settingsList[name]); } var filters = new CHXFilters(); filters.Add(new CHXFilter() { Field = "parameter", Operator = CHXQueryOperator.AND, Value = name }); var olddata = IndexManager.Search(filters); if (olddata == null) { return(null); } if (olddata.Rows[0]["parameter"]?.ToString() != name) { return(null); } return(olddata.Rows[0]["value"]?.ToString()); } }
public void Delete(CHXFilters filters) { var query = FilterToQuery(filters); if (query == null) { return; } Writer.DeleteDocuments(query); Writer.Optimize(); Writer.Commit(); }
public DataTable Search(CHXFilters filters, int recordCount = 1000000) { var query = FilterToQuery(filters); if (query == null) { return(null); } var result = Search(query, recordCount); return(result); }
public static void Set(string name, string value) { lock (_locker) { if (string.IsNullOrEmpty(name)) { throw new NullReferenceException("parametre name değeri boş olamaz"); } if (string.IsNullOrEmpty(value)) { throw new NullReferenceException("parametre value değeri boş olamaz"); } var indexdata = new Dictionary <string, string>(); indexdata.Add("parameter", name); indexdata.Add("value", value); var filters = new CHXFilters(); filters.Add(new CHXFilter() { Field = "parameter", Operator = CHXQueryOperator.AND, Value = name }); var olddata = IndexManager.Search(filters); if (olddata != null) { IndexManager.Delete(filters); } IndexManager.Index(indexdata); if (_settingsList.ContainsKey(name)) { _settingsList[name] = value; } else { _settingsList.Add(name, value); } } }
internal Query FilterToQuery(CHXFilters filters) { if (filters == null) { return(null); } if (filters.Count < 1) { return(null); } var booleanQuery = new BooleanQuery(); foreach (var filter in filters) { var _QueryParser = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, filter.Field, Analyzer); var _Query = _QueryParser.Parse(filter.Value); booleanQuery.Add(_Query, filter.LuceneOperator); } return(booleanQuery); }