Exemple #1
0
        private void DoIndex(TextIndexAction action)
        {
            if (action == TextIndexAction.None)
            {
                return;
            }
            foreach (var t in tenantsProvider.GetTenants())
            {
                foreach (var m in configuration.Modules)
                {
                    if (stop.WaitOne(TimeSpan.Zero))
                    {
                        return;
                    }

                    var indexPath = configuration.GetIndexPath(t.TenantId, m.Name);
                    var indexer   = new TextIndexer(indexPath, t, m);
                    try
                    {
                        Thread.Sleep(configuration.Delay);
                        if (TextIndexAction.Index == (action & TextIndexAction.Index))
                        {
                            var affected = indexer.FindChangedAndIndex();
                            log.DebugFormat("Indexed {0} objects at tenant {1} in module {2}", affected, t, m);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.ErrorFormat("Error FindChangedAndIndex in tenant {0}: {1}", t, ex);
                    }

                    try
                    {
                        Thread.Sleep(configuration.Delay);
                        if (TextIndexAction.Remove == (action & TextIndexAction.Remove))
                        {
                            var affected = indexer.FindRemovedAndIndex();
                            log.DebugFormat("Removed {0} objects at tenant {1} in module {2}", affected, t, m);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.ErrorFormat("Error FindRemovedAndIndex in tenant {0}: {1}", t, ex);
                    }
                }
            }
        }
        private void DoIndex(TextIndexerParams parameters)
        {
            var indexed = DbProvider.GetIndexedModules().ToList();

            foreach (var module in TextIndexCfg.Modules)
            {
                if (stop.WaitOne(TimeSpan.Zero))
                {
                    return;
                }

                var indexer = new TextIndexer(module);

                try
                {
                    if (TextIndexAction.None == parameters.Action && !indexed.Contains(module.Main) ||
                        TextIndexAction.Remove == (parameters.Action & TextIndexAction.Remove))
                    {
                        indexer.FirstTimeIndex();
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Error first time index {0}, module {1}", ex, module.Name);
                }

                try
                {
                    if (TextIndexAction.Index == (parameters.Action & TextIndexAction.Index))
                    {
                        indexer.Rotate();
                    }
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Error rotate {0}, module {1}", ex, module.Name);
                }
            }
        }
        private void DoIndex(TextIndexAction action)
        {
            if (action == TextIndexAction.None) return;
            foreach (var t in tenantsProvider.GetTenants())
            {
                foreach (var m in configuration.Modules)
                {
                    if (stop.WaitOne(TimeSpan.Zero))
                    {
                        return;
                    }

                    var indexPath = configuration.GetIndexPath(t.TenantId, m.Name);
                    var indexer = new TextIndexer(indexPath, t, m);
                    try
                    {
                        if (TextIndexAction.Index == (action & TextIndexAction.Index))
                        {
                            var affected = indexer.FindChangedAndIndex();
                            log.DebugFormat("Indexed {0} objects at tenant {1} in module {2}", affected, t, m);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.ErrorFormat("Error FindChangedAndIndex in tenant {0}: {1}", t, ex);
                    }

                    try
                    {
                        if (TextIndexAction.Remove == (action & TextIndexAction.Remove))
                        {
                            var affected = indexer.FindRemovedAndIndex();
                            log.DebugFormat("Removed {0} objects at tenant {1} in module {2}", affected, t, m);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.ErrorFormat("Error FindRemovedAndIndex in tenant {0}: {1}", t, ex);
                    }
                }
            }
        }
        private void DoIndex(TextIndexerParams parameters)
        {
            var indexed = DbProvider.GetIndexedModules().ToList();

            foreach (var module in TextIndexCfg.Modules)
            {
                if (stop.WaitOne(TimeSpan.Zero))
                {
                    return;
                }
                
                var indexer = new TextIndexer(module);

                try
                {
                    if (TextIndexAction.None == parameters.Action  && !indexed.Contains(module.Main) ||
                        TextIndexAction.Remove == (parameters.Action & TextIndexAction.Remove))
                    {
                        indexer.FirstTimeIndex();
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Error first time index {0}, module {1}", ex, module.Name);
                }

                try
                {
                    if (TextIndexAction.Index == (parameters.Action & TextIndexAction.Index))
                    {
                        indexer.Rotate();
                    }
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Error rotate {0}, module {1}", ex, module.Name);
                }
            }
        }