Пример #1
0
        void UpdateSearchIndex(long pid)
        {
            var entity = _Repository.EnabledProduct.FirstOrDefault(d => d.pid == pid);

            if (entity != null)
            {
                _SearchManager.UpdateSearchIndex(entity);
            }
        }
Пример #2
0
 public void AddViewCount()
 {
     _LazyEntity.Value.viewCount = (_LazyEntity.Value.viewCount ?? 0) + 1;
     _Repository.SaveChanges();
     try
     {
         //搜索引擎
         var entityFromSearch = _SearchManager.SearchProductByPids(new[] { _LazyEntity.Value.pid }).FirstOrDefault();
         if (entityFromSearch != null)
         {
             //每隔十次更新一下索引
             if ((_LazyEntity.Value.viewCount ?? 0) - (entityFromSearch.viewCount ?? 0) >= 10)
             {
                 _SearchManager.UpdateSearchIndex(_LazyEntity.Value);
             }
         }
     }
     catch (Exception ex)
     {
         Log.LoggerResolver.Current.Error(ex);
     }
 }