public static String getCacheName(String fileName)
        {
            string name = "";

            try
            {
                CacheServerConfig[] configCaches = CacheConfigManager.GetConfiguredCaches(fileName);
                if (configCaches != null && configCaches.Length == 1)
                {
                    name = configCaches[0].Name;
                }
            }
            catch (Exception ex)
            {
                throwError(ex.ToString(), false);
            }
            return(name);
        }
        public static bool isCacheExist(String fileName)
        {
            bool isCacheExist = false;

            try
            {
                CacheServerConfig[] configCaches = CacheConfigManager.GetConfiguredCaches(fileName);
                if (configCaches != null && configCaches.Length == 1)
                {
                    isCacheExist = true;
                }
            }
            catch (Exception ex)
            {
                throwError(ex.ToString(), false);
            }
            return(isCacheExist);
        }
Example #3
0
        private void AutoStartCaches(object StateInfo)
        {
            try
            {
                if (_autoStartDelay > 0)
                {
                    Thread.Sleep(_autoStartDelay * 1000);
                }
                CacheServerConfig[] configCaches = CacheConfigManager.GetConfiguredCaches();

                if (configCaches != null && configCaches.Length > 0)
                {
                    foreach (CacheServerConfig cacheServerConfig in configCaches)
                    {
                        if (cacheServerConfig.AutoStartCacheOnServiceStartup && !cacheServerConfig.IsRunning && cacheServerConfig.InProc == false)
                        {
                            try
                            {
                                _nchost.CacheServer.StartCache(cacheServerConfig.Name.Trim(), EncryptionUtil.Encrypt(ServiceConfiguration.CacheUserName), EncryptionUtil.Encrypt(ServiceConfiguration.CacheUserPassword != null ? Protector.DecryptString(ServiceConfiguration.CacheUserPassword) : null));
                                //CacheServerModerator.StartCache(cacheServerConfig.Name.Trim(), userId, password);
                                // AppUtil.LogEvent(_cacheserver, "The cache  '" + cacheServerConfig.Name.Trim() + "' started successfully.", EventLogEntryType.Information, EventCategories.Information, EventID.CacheStart);

                                if (_cacheStartDelay > 0)
                                {
                                    Thread.Sleep(_cacheStartDelay * 1000);
                                }
                            }
                            catch (Exception ex)
                            {
                                //   AppUtil.LogEvent(_cacheserver, "Exception Message  '" + ex, EventLogEntryType.Information, EventCategories.Information, EventID.CacheStart);
                            }// all exceptions are logged in event logs. and are ignored here.
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //  AppUtil.LogEvent(_cacheserver, "An error occurred while auto-starting caches. " + ex.ToString(), EventLogEntryType.Error, EventCategories.Error, EventID.CacheStartError);
            }
        }