/// <summary> /// 设置应用程序,如在过程中发生异常则重启并提醒! /// </summary> public static void Init(BootFlag flag, string confPath) { PrepareCms(); BeforeInit(); if (!IsInstalled()) { return; } //初始化目录 ChkCreate(CmsVariables.TEMP_PATH); // 加载配置 Configuration.LoadCmsConfig(confPath); //设置数据库 CmsDataBase.Initialize($"{Settings.DB_TYPE}://{Settings.DB_CONN}", Settings.DB_PREFIX, Settings.SQL_PROFILE_TRACE); //清空临时文件 //resetTempFiles(); // 初始化键值存储 InitKvDb(); // 加载其他配置 LoadOtherConfig(); //获取静态服务器 //UpdateServerInfo(); // 正常模式启动 if ((flag & BootFlag.Normal) != 0) { BuildOEM = new BuildOEM(); // //TODO: // //检查网站激活状态 //SoftwareActivator.VerifyActivation(); //如果不存在模板文件夹,则创建目录 if (!Directory.Exists(PhysicPath + "templates/")) { Directory.CreateDirectory(PhysicPath + "templates/").Create(); //暂时网络安装默认模板(后可使用资源代替) Updater.InstallTemplate("default", "tpl_default.zip"); } // 初始化模板 Template = new CmsTemplate(_cache, TemplateNames.FileName); // 注册模板 Template.Register(CmsVariables.TEMPLATE_PATH); // 模板管理器 _templateManager = new TemplateManager(PhysicPath + CmsVariables.TEMPLATE_PATH); // 注册插件 //PluginConfig.PLUGIN_FILE_PARTTERN = "*.dll,*.so"; PluginConfig.PLUGIN_DIRECTORY = CmsVariables.PLUGIN_PATH; PluginConfig.PLUGIN_TMP_DIRECTORY = CmsVariables.TEMP_PATH + "plugin/"; PluginConfig.PLUGIN_LOG_OPENED = true; PluginConfig.PLUGIN_LOG_EXCEPT_FORMAT = "** {time} **:{message}\r\nSource:{source}\r\nAddress:{addr}\r\nStack:{stack}\r\n\r\n"; var pluginPhysicPath = PhysicPath + PluginConfig.PLUGIN_TMP_DIRECTORY; if (!Directory.Exists(pluginPhysicPath)) { Directory.CreateDirectory(pluginPhysicPath).Create(); } // 连接插件 //todo: plugin //CmsPluginContext.Connect(); // 设置验证码字体 VerifyCodeGenerator.SetFontFamily(PhysicPath + CmsVariables.FRAMEWORK_ASSETS_PATH + "fonts/comic.ttf"); } OnInit?.Invoke(); IsInitFinish = true; }