Exemplo n.º 1
0
 public void SetUp()
 {
     if (poster != null)
     {
         return;
     }
     poster = new HttpPoster();
     HttpApp.AddMessageMvcHttpClient(DependencyHelper.ServiceCollection);
     DependencyHelper.Flush();
 }
        public HttpApp ToEntity()
        {
            var entity = new HttpApp()
            {
                Description = this.Description,
                AppID       = this.AppID,
                Name        = this.Name
            };

            if (!string.IsNullOrWhiteSpace(this.ID))
            {
                entity.SetID(Guid.Parse(this.ID));
                entity.RowVersion = this.RowVersion;
            }
            var moudleName = new List <string>();

            for (int i = 0; i < Moudles.Count; i++)
            {
                moudleName.Add(Moudles[i].ToString());
            }
            entity.SetMoudles(moudleName);
            return(entity);
        }
Exemplo n.º 3
0
Arquivo: Cms.cs Projeto: 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();
            }
        }