public bool TrySelectIds(Expression <Func <Selector <T>, Selector <T> > > expression, out List <int> result, out long total) { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t) || !Indexer.CheckExist(t)) { result = new List <int>(); total = 0; return(false); } try { result = Indexer.Select(expression, true, out total).Select(r => r.Id).ToList(); } catch (Exception e) { Logger.Error("Select", e); total = 0; result = new List <int>(); return(false); } return(true); }
public void Refresh() { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t)) { return; } Indexer.Refresh(); }
public Task <bool> DeleteAsync(T data, bool immediately = true) { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t)) { return(Task.FromResult(false)); } return(Queue(() => Indexer.Delete(data, immediately))); }
public Task <bool> UpdateAsync(T data, bool immediately = true, params Expression <Func <T, object> >[] fields) { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t)) { return(Task.FromResult(false)); } return(Queue(() => Indexer.Update(data, immediately, fields))); }
public Task <bool> DeleteAsync(Expression <Func <Selector <T>, Selector <T> > > expression, bool immediately = true) { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t)) { return(Task.FromResult(false)); } var tenant = TenantManager.GetCurrentTenant().TenantId; return(Queue(() => Indexer.Delete(expression, tenant, immediately))); }
public void Delete(T data, bool immediately = true) { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t)) { return; } try { Indexer.Delete(data, immediately); } catch (Exception e) { Logger.Error("Delete", e); } }
public void Update(T data, UpdateAction action, Expression <Func <T, IList> > field, bool immediately = true) { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t)) { return; } try { Indexer.Update(data, action, field, immediately); } catch (Exception e) { Logger.Error("Update", e); } }
public void Update(T data, bool immediately = true, params Expression <Func <T, object> >[] fields) { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t)) { return; } try { Indexer.Update(data, immediately, fields); } catch (Exception e) { Logger.Error("Update", e); } }
public void Update(T data, Expression <Func <Selector <T>, Selector <T> > > expression, UpdateAction action, Expression <Func <T, IList> > fields, bool immediately = true) { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t)) { return; } try { var tenant = TenantManager.GetCurrentTenant().TenantId; Indexer.Update(data, expression, tenant, action, fields, immediately); } catch (Exception e) { Logger.Error("Update", e); } }
public FactoryIndexer( IOptionsMonitor <ILog> options, FactoryIndexerHelper factoryIndexerSupport, TenantManager tenantManager, SearchSettingsHelper searchSettingsHelper, FactoryIndexer factoryIndexer, BaseIndexer <T> baseIndexer, Client client, IServiceProvider serviceProvider) { Logger = options.Get("ASC.Indexer"); FactoryIndexerHelper = factoryIndexerSupport; TenantManager = tenantManager; SearchSettingsHelper = searchSettingsHelper; FactoryIndexerCommon = factoryIndexer; Indexer = baseIndexer; Client = client; ServiceProvider = serviceProvider; }
public void Delete(Expression <Func <Selector <T>, Selector <T> > > expression, bool immediately = true) { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t)) { return; } var tenant = TenantManager.GetCurrentTenant().TenantId; try { Indexer.Delete(expression, tenant, immediately); } catch (Exception e) { Logger.Error("Index", e); } }
public bool Index(T data, bool immediately = true) { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t)) { return(false); } try { Indexer.Index(data, immediately); return(true); } catch (Exception e) { Logger.Error("Index", e); } return(false); }
public bool TrySelect(Expression <Func <Selector <T>, Selector <T> > > expression, out IReadOnlyCollection <T> result) { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t) || !Indexer.CheckExist(t)) { result = new List <T>(); return(false); } try { result = Indexer.Select(expression); } catch (Exception e) { Logger.Error("Select", e); result = new List <T>(); return(false); } return(true); }
public void Index(List <T> data, bool immediately = true) { var t = ServiceProvider.GetService <T>(); if (!FactoryIndexerHelper.Support(t) || !data.Any()) { return; } try { Indexer.Index(data, immediately); } catch (AggregateException e) { if (e.InnerExceptions.Count == 0) { throw; } var inner = e.InnerExceptions.OfType <ElasticsearchClientException>().FirstOrDefault(); Logger.Error(inner); if (inner != null) { Logger.Error("inner", inner.Response.OriginalException); if (inner.Response.HttpStatusCode == 413) { data.ForEach(r => Index(r, immediately)); } } else { throw; } } }