예제 #1
0
        /// <summary>
        /// CMS初始化
        /// </summary>
        public static void Init()
        {
            //设置依赖反转
            ObjectFactory.Configure(x =>
            {
                //x.For<IArchiveModel>().Singleton().Use<ArchiveBLL>();
                // x.For<ICategoryModel>().Singleton().Use<CategoryBLL>();
                x.For <IComment>().Singleton().Use <CommentBLL>();
                // x.For<ILink>().Singleton().Use<LinkBLL>();
                x.For <Imember>().Singleton().Use <MemberBLL>();
                x.For <Imessage>().Singleton().Use <MessageBLL>();
                x.For <Imodule>().Singleton().Use <ModuleBLL>();
                //x.For<ISite>().Singleton().Use<SiteBLL>();
                // x.For<ITemplateBind>().Singleton().Use<TemplateBindBLL>();
                x.For <IUser>().Singleton().Use <UserBLL>();
                x.For <ITable>().Singleton().Use <TableBLL>();
            });

            //读取站点
            Cms.RegSites(SiteCacheManager.GetAllSites().ToArray());

            //内嵌资源释放
            SiteResourceInit.Init();

            //设置可写权限
            Cms.Utility.SetDirCanWrite(CmsVariables.RESOURCE_PATH);
            Cms.Utility.SetDirCanWrite("templates/");
            Cms.Utility.SetDirCanWrite(CmsVariables.FRAMEWORK_PATH);
            Cms.Utility.SetDirCanWrite(CmsVariables.PLUGIN_PATH);

            Cms.Utility.SetDirHidden("config");
            Cms.Utility.SetDirHidden("bin");
        }
예제 #2
0
        protected virtual void Application_Start()
        {
            try
            {
                Cms.OnInit += CmsEventRegister.Init;
                Cms.Init();
            }
            catch (Exception exc)
            {
                //Server.ClearError();
                //if (HttpContext.Current.Response != null)
                //{
                //    HttpContext.Current.Response.Write("<html><head></head><body style=\"text-align:center\"><h1 style=\"\">" + exc.Message
                //        + "</h1><hr /><span>ops.cms v" + Cms.Version
                //        + "</span><span style=\"display:none\">" + exc.StackTrace + "</span>"
                //        + "</body></html>");
                //    HttpRuntime.UnloadAppDomain();
                //}
                //else
                //{
                //    throw new Exception(exc.Message);
                //}
                try
                {
                    if (HttpContext.Current.Response != null)
                    {
                        HttpContext.Current.Response.Write(
                            "<html><head></head><body style=\"text-align:center\"><h1 style=\"\">" + exc.Message
                            + "</h1><hr /><span>ops.cms v" + Cms.Version
                            + "</span><span style=\"display:none\">" + exc.StackTrace + "</span>"
                            + "</body></html>");
                        Server.ClearError();
                    }
                }
                catch
                {
                }
                finally
                {
                    HttpRuntime.UnloadAppDomain();
                }
                return;
            }

            //注册路由;
            RouteCollection routes = RouteTable.Routes;

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //注册自定义路由
            RegisterRoutes(routes);

            //注册CMS路由
            Routes.RegisterCmsRoutes(routes, null);
            //RouteDebug.RouteDebugger.RewriteRoutesForTesting(routes);

            //注册定时任务
            CmsTask.Init();
        }
예제 #3
0
        protected virtual void Application_Start()
        {
            try
            {
                Cms.OnInit += CmsEventRegister.Init;
                Cms.Init();
            }
            catch (Exception exc)
            {
                if (exc.InnerException != null)
                {
                    exc = exc.InnerException;
                }
                try
                {
                    HttpContext.Current.Response.Write(@"<html><head></head>
                        <body style=""text-align:center""><h1 style="""">" + exc.Message
                                                       + "</h1><hr /><span>ops.cms v" + Cms.Version
                                                       + "</span><span style=\"display:none\">"
                                                       + exc.StackTrace + "</span>"
                                                       + "</body></html>");

                    Server.ClearError();
                }
                catch (Exception ex)
                {
                    throw exc;
                }
                finally
                {
                    HttpRuntime.UnloadAppDomain();
                }
                return;
            }

            //注册路由;
            RouteCollection routes = RouteTable.Routes;

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //注册自定义路由
            RegisterRoutes(routes);

            //注册CMS路由
            Routes.RegisterCmsRoutes(routes, null);
            //RouteDebug.RouteDebugger.RewriteRoutesForTesting(routes);

            //注册定时任务
            CmsTask.Init();


            //加载自定义插件
            //Cms.Plugins.Extends.LoadFromAssembly(typeof(sp.datapicker.CollectionExtend).Assembly);
        }
예제 #4
0
        /// <summary>
        /// 获取管理后台资源映射
        /// </summary>
        /// <returns></returns>
        public static string GetManagementMappingXml()
        {
            string mapTo = null;

            XmlNode node = SelectSingleNode("/maps/map[@for='management_resource']");

            if (node == null ||
                node.Attributes["to"] == null ||
                (mapTo = node.Attributes["to"].Value) == String.Empty)
            {
                Cms.TraceLog("management mapping lose!");
                return(null);
            }

            return(GetMapToPath(mapTo));
        }
예제 #5
0
파일: Cms.cs 프로젝트: jackjet870/cms
        /// <summary>
        /// 设置应用程序,如在过程中发生异常则重启并提醒!
        /// </summary>
        public static void Init()
        {
            //判断是否已经安装
            FileInfo insLockFile = new FileInfo(String.Format("{0}config/install.lock", Cms.PyhicPath));

            if (!insLockFile.Exists)
            {
                //HttpRuntime.UnloadAppDomain();

                global::System.Web.HttpContext context = global::System.Web.HttpContext.Current;
                string installUrl = "/install/install.html";
                context.Response.Redirect(installUrl, true);
                context.Response.End();
                return;
            }

            //初始化设置
            string   cmsConfigFile = String.Format("{0}config/cms.config", Cms.PyhicPath);
            FileInfo cfgFile       = new FileInfo(cmsConfigFile);

            if (cfgFile.Exists)
            {
                Configuration.Load(cmsConfigFile);
            }
            else
            {
                throw new Exception("CMS配置文件不存在");
            }

            //设置数据库
            CmsDataBase.Initialize(String.Format("{0}://{1}", Settings.DB_TYPE.ToString(), Settings.DB_CONN.ToString()), Settings.DB_PREFIX);

            //获取静态服务器
            //UpdateServerInfo();

            //
            //TODO:
            //
            //检查网站激活状态
            //SoftwareActivator.VerifyActivation();

            //如果不存在模板文件夹,则创建目录
            if (!Directory.Exists(Cms.PyhicPath + "templates/"))
            {
                Directory.CreateDirectory(Cms.PyhicPath + "templates/").Create();

                //暂时网络安装默认模板(后可使用资源代替)
                Updater.InstallTemplate("default", "tpl_default.zip");
            }

            //注册模板
            Template.Register("/templates/", true);


            //清空临时文件
            resetTempFiles();

            PluginConfig.PLUGIN_DIRECTORY         = CmsVariables.PLUGIN_PATH;
            PluginConfig.PLUGIN_TMP_DIRECTORY     = CmsVariables.TEMP_PATH;
            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";

            //连接插件
            CmsPluginContext.Connect();


            if (OnInit != null)
            {
                Cms.OnInit();
            }
        }
예제 #6
0
파일: Cms.cs 프로젝트: jooper/cms
        /// <summary>
        /// 设置应用程序,如在过程中发生异常则重启并提醒!
        /// </summary>
        public static void Init()
        {
            HttpContext context = HttpContext.Current;

            if (context != null)
            {
                //判断是否已经安装
                FileInfo insLockFile = new FileInfo(String.Format("{0}config/install.lock", Cms.PyhicPath));
                if (!insLockFile.Exists)
                {
                    //HttpRuntime.UnloadAppDomain();

                    const string installUrl = "/install/install.html";
                    context.Response.Redirect(installUrl, true);
                    context.Response.End();
                    return;
                }
                //设置应用路径
                HttpApp.SetApplicationPath(context.Request.ApplicationPath);
            }

            //初始化目录
            chkCreate(CmsVariables.TEMP_PATH);


            //初始化系统日志
            // logFile = new LogFile()

            //todo:

            //初始化设置
            string   cmsConfigFile = String.Format("{0}config/cms.config", Cms.PyhicPath);
            FileInfo cfgFile       = new FileInfo(cmsConfigFile);

            if (cfgFile.Exists)
            {
                Configuration.Load(cmsConfigFile);
            }
            else
            {
                throw new Exception("CMS配置文件不存在");
            }

            //设置数据库
            CmsDataBase.Initialize(String.Format("{0}://{1}", Settings.DB_TYPE.ToString(), Settings.DB_CONN.ToString()), Settings.DB_PREFIX);


            //清空临时文件
            //resetTempFiles();


            //注册KvDB
            string kvDir = Cms.PyhicPath + CmsVariables.TEMP_PATH + "data/.gca";

            if (Directory.Exists(kvDir))
            {
                Directory.Delete(kvDir, true);
            }
            Kvdb.SetPath(kvDir);

            //获取静态服务器
            //UpdateServerInfo();

            //
            //TODO:
            //
            //检查网站激活状态
            //SoftwareActivator.VerifyActivation();

            //如果不存在模板文件夹,则创建目录
            if (!Directory.Exists(Cms.PyhicPath + "templates/"))
            {
                Directory.CreateDirectory(Cms.PyhicPath + "templates/").Create();

                //暂时网络安装默认模板(后可使用资源代替)
                Updater.InstallTemplate("default", "tpl_default.zip");
            }

            //注册模板
            Template.Register("/templates/", true);

            //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";

            string pluginPhysicPath = Cms.PyhicPath + PluginConfig.PLUGIN_TMP_DIRECTORY;

            if (!Directory.Exists(pluginPhysicPath))
            {
                Directory.CreateDirectory(pluginPhysicPath).Create();
            }

            //连接插件
            CmsPluginContext.Connect();


            if (OnInit != null)
            {
                Cms.OnInit();
            }
        }