Ejemplo n.º 1
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);
            }
        }