示例#1
0
        public static bool SupportModule(string module)
        {
            var result = false;

            if (IsServiceProbablyNotAvailable())
            {
                return(result);
            }

            using (var service = new TextIndexServiceClient())
            {
                try
                {
                    result = service.SupportModule(module);
                }
                catch (FaultException fe)
                {
                    LogError(fe);
                }
                catch (CommunicationException ce)
                {
                    LogError(ce);
                    lastErrorTime = DateTime.Now;
                }
                catch (TimeoutException te)
                {
                    LogError(te);
                    lastErrorTime = DateTime.Now;
                }
            }
            return(result);
        }
        public static bool CheckState()
        {
            if (CheckServiceAvailability())
            {
                return(false);
            }

            try
            {
                using (var service = new TextIndexServiceClient())
                {
                    return(service.CheckState());
                }
            }
            catch (Exception e)
            {
                if (e is CommunicationException || e is TimeoutException)
                {
                    lastErrorTime = DateTime.Now;
                }

                log.Error(e);
            }

            return(false);
        }
        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>());
        }
        public static bool SupportModule(params ModuleInfo[] modules)
        {
            if (modules == null || modules.Length == 0 || CheckServiceAvailability())
            {
                return(false);
            }

            try
            {
                using (var service = new TextIndexServiceClient())
                {
                    return(service.SupportModule(modules.Select(r => r.Name).ToArray()));
                }
            }
            catch (Exception e)
            {
                if (e is CommunicationException || e is TimeoutException)
                {
                    lastErrorTime = DateTime.Now;
                }

                log.Error(e);
            }

            return(false);
        }
示例#5
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>());
        }
示例#6
0
        public static bool SupportModule(params ModuleInfo[] modules)
        {
            if (modules == null || modules.Length == 0 || CheckServiceAvailability())
            {
                return(false);
            }

            var names  = modules.Select(m => m.Name).ToArray();
            var key    = string.Join("", names);
            var result = cache.Get <string>(key);

            if (result != null)
            {
                return(bool.Parse(result));
            }

            try
            {
                using (var service = new TextIndexServiceClient())
                {
                    var support = service.SupportModule(names);
                    cache.Insert(key, support.ToString(), DateTime.Now.AddHours(1));
                    return(support);
                }
            }
            catch (Exception e)
            {
                if (e is CommunicationException || e is TimeoutException)
                {
                    lastErrorTime = DateTime.Now;
                }
                log.Error(e);
            }
            return(false);
        }
示例#7
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);
        }
示例#8
0
        public static bool SupportModule(params string[] modules)
        {
            if (modules == null || modules.Length == 0 || IsServiceProbablyNotAvailable())
            {
                return(false);
            }

            try
            {
                using (var service = new TextIndexServiceClient())
                {
                    try
                    {
                        return(service.SupportModule(modules));
                    }
                    catch (FaultException fe)
                    {
                        LogError(fe);
                    }
                    catch (CommunicationException ce)
                    {
                        LogError(ce);
                        lastErrorTime = DateTime.Now;
                    }
                    catch (TimeoutException te)
                    {
                        LogError(te);
                        lastErrorTime = DateTime.Now;
                    }
                }
            }
            catch (Exception e)
            {
                LogError(e);
                lastErrorTime = DateTime.Now;
            }

            return(false);
        }