public static List <int> Search(params ModuleInfo[] modules)
        {
            if (CheckServiceAvailability())
            {
                return(new List <int>());
            }

            try
            {
                using (var service = new TextIndexServiceClient())
                {
                    return(service.Search(modules).SelectMany(r => r.Value).Distinct().ToList());
                }
            }
            catch (Exception e)
            {
                if (e is CommunicationException || e is TimeoutException)
                {
                    lastErrorTime = DateTime.Now;
                }

                log.Error(e);
            }

            return(new List <int>());
        }
示例#2
0
        public static List <int> Search(params ModuleInfo[] modules)
        {
            if (CheckServiceAvailability())
            {
                return(new List <int>());
            }

            try
            {
                var info = modules.Select(m => m.Name + "|" + m.GetSqlQuery()).ToArray();

                using (var service = new TextIndexServiceClient())
                {
                    var result = service.Search(CoreContext.TenantManager.GetCurrentTenant().TenantId, info);
                    return(result.ToList());
                }
            }
            catch (Exception e)
            {
                if (e is CommunicationException || e is TimeoutException)
                {
                    lastErrorTime = DateTime.Now;
                }
                log.Error(e);
            }

            return(new List <int>());
        }
示例#3
0
        public static TextSearchResult Search(string query, string module, int tenantId)
        {
            var result = new TextSearchResult();

            if (IsServiceProbablyNotAvailable() || string.IsNullOrEmpty(query))
            {
                return(result);
            }
            if (TextIndexCfg.MaxQueryLength < query.Length)
            {
                query = query.Substring(0, TextIndexCfg.MaxQueryLength);
            }
            query = query.Replace(":", "\\:");

            using (var service = new TextIndexServiceClient())
            {
                try
                {
                    var ids = service.Search(tenantId, query, module);
                    foreach (var id in ids)
                    {
                        result.AddIdentifier(id);
                    }
                    return(result);
                }
                catch (FaultException fe)
                {
                    LogError(fe);
                }
                catch (CommunicationException ce)
                {
                    LogError(ce);
                    lastErrorTime = DateTime.Now;
                }
                catch (TimeoutException te)
                {
                    LogError(te);
                    lastErrorTime = DateTime.Now;
                }
            }
            return(result);
        }