Example #1
0
        private void DoWork()
        {
            var parameters = new TextIndexerParams(TextIndexAction.None, TimeSpan.FromSeconds(1));

            do
            {
                try
                {
                    if (stop.WaitOne(parameters.Period))
                    {
                        return;
                    }

                    DoIndex(parameters);

                    parameters.InitNext();

                    TextSearcher.Instance.Start();

                    log.DebugFormat("Next action '{0}' over {1}", parameters.Action, parameters.Period);
                }
                catch (ThreadAbortException)
                {
                    break;
                }
                catch (ObjectDisposedException)
                {
                    break;
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Error in DoIndex: {0}", ex);
                }
            }while (true);
        }
Example #2
0
        private void DoIndex(TextIndexerParams parameters)
        {
            var indexed = DbProvider.GetIndexedModules().ToList();

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

                var indexer = TextIndexCfg.Chunks > 1 ? new TextIndexerDistributed(module) : new TextIndexer(module);

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

                try
                {
                    if (TextIndexAction.Merge == parameters.Action)
                    {
                        var exitCode = indexer.Merge();
                        if (exitCode == 0)
                        {
                            DbProvider.UpdateLastIndexDate(module.Delta, parameters.LastIndexDate);
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Error rotate {0}, module {1}", ex, module.Name);
                }

                try
                {
                    indexer.RotateDelta();
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Error rotate delta {0}, module {1}", ex, module.Name);
                }
            }
        }
        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(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 DoWork()
        {
            var parameters = new TextIndexerParams(TextIndexAction.None, TimeSpan.FromSeconds(1));

            do
            {
                try
                {
                    if (stop.WaitOne(parameters.Period))
                    {
                        return;
                    }

                    DoIndex(parameters);

                    parameters.InitNext();

                    TextSearcher.Instance.Start();

                    log.DebugFormat("Next action '{0}' over {1}", parameters.Action, parameters.Period);
                }
                catch (ThreadAbortException)
                {
                    break;
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Error in DoIndex: {0}", ex);
                }
            }
            while (true);
        }