Ejemplo n.º 1
0
        private void IndexAllGetData(long start, long stop, DateTime lastIndexed)
        {
            try
            {
                var convertedData = GetDataFromDb(start, stop, lastIndexed);

                FactoryIndexer <T> .Index(convertedData);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                throw;
            }
        }
Ejemplo n.º 2
0
        private async Task IndexAllGetDataAsync(long start, long stop, DateTime lastIndexed)
        {
            try
            {
                var convertedData = GetDataFromDb(start, stop, lastIndexed);

                await FactoryIndexer <T> .IndexAsync(convertedData).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                throw;
            }
        }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
        private void IndexAllGetData(long start, long step, string idColumn, string tenantIdColumn, string lastModifiedColumn, DateTime lastIndexed)
        {
            List <Wrapper> data;

            var dataQuery = new SqlQuery(Wrapper.Table + " " + Alias)
                            .Select(Wrapper.GetColumnNames(Alias))
                            .Where(Exp.Between(idColumn, start, start + step));

            if (!string.IsNullOrEmpty(tenantIdColumn))
            {
                dataQuery.InnerJoin("tenants_tenants t", Exp.EqColumns(tenantIdColumn, "t.id"))
                .Where("t.status", (int)TenantStatus.Active);
            }

            foreach (var con in Wrapper.GetConditions(Alias))
            {
                dataQuery.Where(con.Key, con.Value);
            }

            AddJoins(Wrapper, dataQuery, Alias);

            if (!DateTime.MinValue.Equals(lastIndexed))
            {
                dataQuery.Where(Exp.Gt(lastModifiedColumn, lastIndexed));
            }

            using (var db = new DbManager("default", 1800000))
            {
                db.ExecuteNonQuery("SET SESSION group_concat_max_len = 4294967295;");
                data = db.ExecuteList(dataQuery).ConvertAll(Wrapper.GetDataConverter());
            }

            try
            {
                FactoryIndexer <T> .Index(data.Cast <T>().ToList());
            }
            catch (Exception e)
            {
                Logger.Error(e);
                throw;
            }
        }
Ejemplo n.º 5
0
        public void Start()
        {
            Searcher = new ServiceHost(typeof(Service.Service));
            Searcher.Open();

            logger = LogManager.GetLogger("ASC.Indexer");

            try
            {
                Notify.Subscribe <AscCacheItem>(async(item, action) =>
                {
                    while (IsStarted)
                    {
                        await Task.Delay(10000);
                    }
                    IndexAll(true);
                });
            }
            catch (Exception e)
            {
                logger.Error("Subscribe on start", e);
            }

            var task = new Task(() =>
            {
                while (!FactoryIndexer.CheckState(false))
                {
                    if (cancellationTokenSource.IsCancellationRequested)
                    {
                        return;
                    }
                    Thread.Sleep(10000);
                }

                CheckIfChange();
            }, cancellationTokenSource.Token, TaskCreationOptions.LongRunning);

            task.ConfigureAwait(false);
            task.Start();
        }
Ejemplo n.º 6
0
 public void Deconstruct(out FactoryIndexer factoryIndexer, out Service.Service service)
 {
     factoryIndexer = FactoryIndexer;
     service        = Service;
 }
Ejemplo n.º 7
0
 public ServiceLauncherScope(FactoryIndexer factoryIndexer, Service.Service service)
 {
     FactoryIndexer = factoryIndexer;
     Service        = service;
 }
Ejemplo n.º 8
0
 public FactoryIndexerHelper(IOptionsMonitor <ILog> options, FactoryIndexer factoryIndexer)
 {
     Cache          = AscCache.Memory;
     Logger         = options.Get("ASC.Indexer");
     FactoryIndexer = factoryIndexer;
 }