Exemple #1
0
 /// <summary>
 /// Initialize cache
 /// </summary>
 /// <param name="config">Application configuration settings</param>
 private void InitializeCache(ApplicationConfigurationElement config)
 {
     ///Cache is only initialized once
     if (this.Cache == null)
     {
         CachePolicyElement policy = config.CachePolicy;
         if (policy != null)
         {
             try
             {
                 if (policy.CacheName.IsNullOrEmpty())
                 {
                     Logger.Instance.TraceError("Cache Id cannot be null or empty string");
                 }
                 else
                 {
                     Cache = new NCache.Integrations.EntityFramework.Caching.NCache(policy.CacheName);
                 }
             }
             catch (Exception exc)
             {
                 Logger.Instance.TraceError(exc.ToString());
             }
         }
         else
         {
             Logger.Instance.TraceError("No 'cache-policy' found in confgiruation file");
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// Load application configuration
        /// </summary>
        /// <param name="config">Application configuration settings</param>
        public void LoadConfiguration(ApplicationConfigurationElement config)
        {
            this.Mode = ApplicationMode.Passthru;
            if (config != null)
            {
                switch (config.Mode)
                {
                case ApplicationConfigurationElement.AppMode.Analysis:
                    this.Mode = ApplicationMode.Analysis;
                    break;

                case ApplicationConfigurationElement.AppMode.Caching:
                    this.Mode = ApplicationMode.Cache;
                    break;
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Load application configuration
        /// </summary>
        private void LoadConfiguration()
        {
            ///Cannot load configuration if no app-id is found in web.config or app.config
            if (this.ApplicationId.IsNullOrEmpty())
            {
                Logger.Instance.TraceError("app-id not found in application config");
                return;
            }

            ///Load configuration
            EFCachingConfigurationElement   config    = EFCachingConfiguration.Instance.LoadConfiguration();
            ApplicationConfigurationElement appConfig = null;

            if (config != null)
            {
                appConfig = config.GetAppConfig(this.ApplicationId);
                this.LoadConfiguration(appConfig);

                if (appConfig != null)
                {
                    CachePolicy.LoadConfig(appConfig.CachePolicy);
                    AnalysisPolicy.LoadConfig(appConfig.AnalysisPolicy);
                    //QueryLevelCachePolicy.LoadConfig(appConfig.QueryLevelCachePolicy);
                    this.InitializeCache(appConfig);

                    ///Start analysis
                    if (this.Mode == ApplicationMode.Analysis)
                    {
                        AnalysisManager.Instance.Start(AnalysisPolicy.GetEffectivePolicy());
                    }
                }
                else
                {
                    Logger.Instance.TraceError("No 'app-config' found in configuration file for the application-id = " + this.ApplicationId);
                }
            }
        }