예제 #1
0
        private void IndexAll(bool reindex = false)
        {
            try
            {
                Timer.Change(Timeout.Infinite, Timeout.Infinite);
                IsStarted = true;

                using (var scope = ServiceProvider.CreateScope())
                {
                    var wrappers = scope.ServiceProvider.GetService <IEnumerable <IFactoryIndexer> >();

                    Parallel.ForEach(wrappers, wrapper =>
                    {
                        using (var scope = ServiceProvider.CreateScope())
                        {
                            var w = (IFactoryIndexer)scope.ServiceProvider.GetService(wrapper.GetType());
                            IndexProduct(w, reindex);
                        }
                    });
                }

                Timer.Change(Period, Period);
                IndexNotify.Publish(new IndexAction()
                {
                    Indexing = "", LastIndexed = DateTime.Now.Ticks
                }, CacheNotifyAction.Any);
                IsStarted = false;
            }
            catch (Exception e)
            {
                Log.Fatal("IndexAll", e);
                throw;
            }
        }
예제 #2
0
        private void IndexAll(bool reindex = false)
        {
            try
            {
                Timer.Change(Timeout.Infinite, Timeout.Infinite);
                IsStarted = true;

                using var scope = Container.BeginLifetimeScope();
                var wrappers = scope.Resolve <IEnumerable <IFactoryIndexer> >();

                foreach (var w in wrappers)
                {
                    IndexProduct(w, reindex);
                }

                Timer.Change(Period, Period);
                IndexNotify.Publish(new IndexAction()
                {
                    Indexing = "", LastIndexed = DateTime.Now.Ticks
                }, CacheNotifyAction.Any);
                IsStarted = false;
            }
            catch (Exception e)
            {
                Log.Fatal("IndexAll", e);
                throw;
            }
        }
예제 #3
0
        private void IndexAll(bool reindex = false)
        {
            Timer.Change(-1, -1);
            IsStarted = true;

            using var scope = Container.BeginLifetimeScope();
            var wrappers = scope.Resolve <IEnumerable <IFactoryIndexer> >();

            foreach (var w in wrappers)
            {
                IndexProduct(w, reindex);
            }

            Timer.Change(Period, Period);
            IndexNotify.Publish(new IndexAction()
            {
                Indexing = "", LastIndexed = DateTime.Now.Ticks
            }, CacheNotifyAction.Any);
            IsStarted = false;
        }
예제 #4
0
        public void IndexProduct(IFactoryIndexer product, bool reindex)
        {
            if (reindex)
            {
                try
                {
                    if (!IsStarted)
                    {
                        return;
                    }

                    Log.DebugFormat("Product reindex {0}", product.IndexName);
                    product.ReIndex();
                }
                catch (Exception e)
                {
                    Log.Error(e);
                    Log.ErrorFormat("Product reindex {0}", product.IndexName);
                }
            }

            try
            {
                if (!IsStarted)
                {
                    return;
                }

                Log.DebugFormat("Product {0}", product.IndexName);
                IndexNotify.Publish(new IndexAction()
                {
                    Indexing = product.IndexName, LastIndexed = 0
                }, CacheNotifyAction.Any);
                product.IndexAll();
            }
            catch (Exception e)
            {
                Log.Error(e);
                Log.ErrorFormat("Product {0}", product.IndexName);
            }
        }