private void InitializeFactory()
        {
            EventLog.WriteEntry("Application", "InitiliazeFactory e girdi", EventLogEntryType.Information, 9888);

            try
            {
                CacheFactoryName    = _applicationSettingService.GetSetting("CoherenceCacheFactoryName");
                CoherenceConfigPath = _applicationSettingService.GetSetting("CoherenceConfigPath");
                //programmatically coherence cache configuration
                string configEnvironmentDirectory = _applicationSettingService.GetSetting("CoherenceConfigPath");

                var    relativePath        = AssemblyDirectory;
                string coherenceConfigPath = string.Format(relativePath + @"\" + configEnvironmentDirectory);

                CacheFactory.DefaultCacheConfigPath       = string.Format("file://{0}/{1}", coherenceConfigPath, "coherence-cache-config.xml");
                CacheFactory.DefaultOperationalConfigPath = string.Format("file://{0}/{1}", coherenceConfigPath, @"coherence.xml");
                CacheFactory.DefaultPofConfigPath         = string.Format("file://{0}/{1}", coherenceConfigPath, @"pof-config.xml");
                CacheFactory.Configure(CacheFactory.DefaultCacheConfigPath, CacheFactory.DefaultOperationalConfigPath);

                EventLog.WriteEntry("Application", "InitiliazeFactory "
                                    + CacheFactory.DefaultCacheConfigPath + " "
                                    + CacheFactory.DefaultOperationalConfigPath + " "
                                    + CacheFactory.DefaultPofConfigPath, EventLogEntryType.Information, 9888);

                EventLog.WriteEntry("Application", string.Format("CacheFactoryName {0} ", CacheFactoryName), EventLogEntryType.Information, 9888);

                //dynamic set cachefactoryname
                var cache = CacheFactory.GetCache(CacheFactoryName);
                cache.Release();
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("Application", string.Format("Error : {0}", ex), EventLogEntryType.Error, 9888);
                throw;
            }
        }
Exemplo n.º 2
0
        private static void PrepareCms()
        {
#if NETSTANDARD
            IsNetStandard = true;
            if (_cache == null)
            {
                _cache = new MemoryCacheWrapper();
            }
#endif

            Version    = CmsVariables.VERSION;
            PhysicPath = EnvUtil.GetBaseDirectory();

            //获取编译生成的时间
            //DateTime builtDate = new DateTime(2000, 1, 1).AddDays(ver.Build).AddSeconds(ver.Revision*2);
            var filePath = typeof(Cms).Assembly.Location;
            if (string.IsNullOrEmpty(filePath))
            {
                filePath = PhysicPath + CmsVariables.FRAMEWORK_ASSEMBLY_PATH + "jrcms.dll";
            }
            var builtDate = File.GetLastWriteTime(filePath);
            BuiltTime = DateHelper.ToUnix(builtDate);


            //获取平台
            var platFormId = (int)Environment.OSVersion.Platform;
            if (platFormId == 4 || platFormId == 6 || platFormId == 128)
            {
                RunAtMono = true;
            }
            //初始化
            //todo: plugin
            //Plugins = new CmsPluginContext();

            // 初始化缓存工厂
            CmsCacheFactory.Configure(_cache);
            CacheFactory.Configure(_cache);
            // 初始化模板
            Template = new CmsTemplate(_cache, TemplateNames.FileName);
            Cache    = new CmsCache(CmsCacheFactory.Singleton);
            // 初始化内存缓存
            Utility  = new CmsUtility();
            Language = new CmsLanguagePackage();

            #region 缓存清除

            //
            //UNDONE: 弱引用
            //

            /*
             * WeakRefCache.OnLinkBuilting += () =>
             * {
             *  Cms.Cache.Clear(CacheSign.Link.ToString());
             * };
             *
             * WeakRefCache.OnModuleBuilting += () =>
             * {
             *  Cms.Cache.Clear(CacheSign.Module.ToString());
             * };
             *
             * WeakRefCache.OnPropertyBuilting += () =>
             * {
             *  Cms.Cache.Clear(CacheSign.Property.ToString());
             * };
             *
             * WeakRefCache.OnTemplateBindBuilting += () =>
             * {
             *  Cms.Cache.Clear(CacheSign.TemplateBind.ToString());
             * };
             *
             */

            #endregion
        }