示例#1
0
文件: BasePage.cs 项目: sunsiz/We7CMS
 /// <summary>
 /// 检测用户的数据库配置文件是否已经创建
 /// </summary>
 protected virtual void CheckInstallation()
 {
     if (!BaseConfigs.ConfigFileExist())
     {
         Response.Write("您的数据库配置文件尚未生成,看起来数据库尚未建立,您需要建立数据库配置文件或生成数据库。现在开始吗?<a href='/install/index.aspx'><u>现在配置数据库</u></a>");
         Response.End();
     }
 }
示例#2
0
 protected override void OnPreInit(EventArgs e)
 {
     base.OnPreInit(e);
     if (BaseConfigs.ConfigFileExist() && !SetupPage.LockFileExist())
     {
         Response.Redirect("upgrade.aspx", true);
     }
     Init();
 }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!BaseConfigs.ConfigFileExist())
            {
                Response.Write("您的数据库配置文件尚未生成,看起来数据库尚未建立,您需要建立数据库配置文件或生成数据库。现在开始吗?<a href='/install/index.aspx'><u>现在配置数据库</u></a>");
                Response.End();
            }

            AddStatistic(string.Empty, string.Empty);
        }
示例#4
0
 protected override void OnPreInit(EventArgs e)
 {
     base.OnPreInit(e);
     if (Request["from"] == null || Request["from"].ToString() != "upgrade.aspx")
     {
         if (BaseConfigs.ConfigFileExist())
         {
             Response.Redirect("upgrade.aspx", true);
         }
     }
     Init();
 }
示例#5
0
 protected override void OnPreInit(EventArgs e)
 {
     base.OnPreInit(e);
     if (SetupPage.LockFileExist() && BaseConfigs.ConfigFileExist())     //这个判断条件怎么理解,与index.aspx.cs中为何不同?
     {
         Init();
     }
     else
     {
         Response.Redirect("upgrade.aspx", true);
     }
 }
示例#6
0
        public static void ResetApplication()
        {
            lock (lockHelper)
            {
                HttpContext context = HttpContext.Current;
                context.Application.Clear();
                if (context.Session != null)
                {
                    context.Session.Clear();
                }

                BaseConfigs.ResetConfig();
                SiteConfigs.ResetConfig();
                GeneralConfigs.ResetConfig();
                context.Application["We7.Application.OnlinePeople.Key"] = 0;
                if (BaseConfigs.ConfigFileExist())
                {
                    BaseConfigInfo  baseconfig = BaseConfigs.GetBaseConfig();
                    string          root       = context.Server.MapPath("~/");
                    string          dataPath   = context.Server.MapPath("~/App_Data/XML");
                    ObjectAssistant assistant  = new ObjectAssistant();
                    try
                    {
                        if (baseconfig != null && baseconfig.DBConnectionString != "")
                        {
                            baseconfig.DBConnectionString = baseconfig.DBConnectionString.Replace("{$App}", AppDomain.CurrentDomain.BaseDirectory).Replace("\\\\", "\\");
                            assistant.LoadDBConnectionString(baseconfig.DBConnectionString, baseconfig.DBDriver);
                        }
                        assistant.LoadDataSource(dataPath);
                    }
                    catch (DataException ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        string s = string.Format("注意检查:/app_data/xml目录下的配置文件:\r\n错误代码:{0}\r\n错误消息:{1}",
                                                 ex.Errorcode, ex.Message);
                        LogHelper.WriteLog(typeof(ApplicationHelper), s);
                        throw ex;
                    }

                    HelperFactory factory = new HelperFactory();
                    factory.Assistant = assistant;
                    factory.Root      = root;
                    factory.Initialize();
                    context.Application["We7.HelperFactory"] = factory;
                }
            }
        }
示例#7
0
        protected override void OnLoad(EventArgs e)
        {
            Response.Expires = -1;  //设置浏览器缓存页面过期时间的优势,为什么要设置?(参考二十八条改善 ASP 性能和外观的技巧!)
            base.OnLoad(e);

            if (!BaseConfigs.ConfigFileExist())
            {
                Response.Write("您的数据库配置文件尚未生成,看起来数据库尚未建立,您需要建立数据库配置文件或生成数据库。现在开始吗?<a href='/install/index.aspx'><u>现在配置数据库</u></a>");
                Response.End();
            }
            if (UnLoginCheck() && Request.RawUrl.ToLower().Contains("login.aspx"))
            {
                We7.Framework.Util.Utils.Redirect("/login.aspx?returnURL=" + Server.UrlEncode(HttpContext.Current.Request.RawUrl));
            }

            Initialize();
        }
示例#8
0
        /// <summary>
        /// 前台页面载入
        /// </summary>
        protected override void OnLoad(EventArgs e)
        {
            try
            {
                Response.Expires = -1;
                base.OnLoad(e);

                if (!BaseConfigs.ConfigFileExist())
                {
                    Response.Write("您的数据库配置文件尚未生成,看起来数据库尚未建立,您需要建立数据库配置文件或生成数据库。现在开始吗?<a href='/install/index.aspx'><u>现在配置数据库</u></a>");
                    return;
                }

                if (UnLoginCheck())
                {
                    Response.Redirect("/login.aspx?returnURL=" + Server.UrlEncode(HttpContext.Current.Request.RawUrl), false);
                    return;
                }

                if (!CheckIPStrategy())
                {
                    Response.Write("IP受限,您的IP没有在受访范围内!");
                    return;
                }

                if (!CheckPermission())
                {
                    Response.Write("您没有权限访问此栏目!");
                    return;
                }

                Initialize();
            }
            catch (Exception ex)
            {
                We7.Framework.LogHelper.WriteLog(typeof(FrontBasePage), ex);
                DisplayError(ex.Message);
            }
        }
示例#9
0
        /// <summary>
        /// 重启应用程序
        /// </summary>
        public static void LoadHelperFactory()
        {
            lock (lockHelper2)
            {
                //如果数据库配置文件存在,加载配置
                if (BaseConfigs.ConfigFileExist())
                {
                    BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig();

                    //加载数据库映射表
                    string          root     = AppDomain.CurrentDomain.BaseDirectory;
                    string          dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/XML");
                    ObjectAssistant assistat = new ObjectAssistant();
                    try
                    {
                        if (baseconfig != null && baseconfig.DBConnectionString != "")
                        {
                            baseconfig.DBConnectionString = baseconfig.DBConnectionString.Replace("{$App}", AppDomain.CurrentDomain.BaseDirectory);
                            assistat.LoadDBConnectionString(baseconfig.DBConnectionString, baseconfig.DBDriver);
                        }
                        assistat.LoadDataSource(dataPath);
                    }
                    catch (Thinkment.Data.DataException ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        string source = "CD.Utils_CDHelper_ResetApplication";
                        EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error);
                        throw ex;
                    }

                    HelperFactory hf = new HelperFactory();

                    hf.Assistant = assistat;
                    hf.Root      = root;
                    hf.Initialize();
                    AppCtx.Cache.AddObject(HelperFactory.CacheKey, hf);
                }
            }
        }
示例#10
0
        void Page_Init(object sender, System.EventArgs e)
        {
            if (!BaseConfigs.ConfigFileExist())
            {
                Response.Write("您的数据库配置文件尚未生成,看起来数据库尚未建立,您需要建立数据库配置文件或生成数据库。现在开始吗?<a href='/install/index.aspx'><u>现在配置数据库</u></a>");
                Response.End();
            }

            if (UnLoginCheck())
            {
                Response.Redirect("/go/login.aspx?returnURL=" + Server.UrlEncode(HttpContext.Current.Request.RawUrl));
            }

            Initialize();

            if (!CheckIPStrategy())
            {
                Response.Write("IP受限,您的IP没有在受访范围内!");
                Response.End();
                return;
            }

            if (TemplatePath != null)
            {
                if (File.Exists(Context.Server.MapPath(TemplatePath)))
                {
                    #region 页面处加缓存也需要对页面缓存进行三级划分
                    //绝不能用普通Cache的方法,去处理页面缓存,这里也需要
                    //分情况分种类去规划,然后找出模板自动加缓存的机制与方法。
                    #endregion

                    Control ctl = LoadControl(TemplatePath);

                    this.Controls.Add(ctl);

                    try
                    {
                        if (this.Title != null)
                        {
                            this.Title = GetCurrentPageTitle(ColumnID, ArticleID);
                        }
                        //meta标记
                        HtmlGenericControl KeywordsMeta = new HtmlGenericControl("meta");
                        KeywordsMeta.Attributes["name"] = "keywords";
                        string keyWordString = "";
                        keyWordString = CDHelper.Config.KeywordPageMeta;

                        HtmlGenericControl DescriptionMeta = new HtmlGenericControl("meta");
                        DescriptionMeta.Attributes["name"] = "description";
                        string descriptionWordString = "";
                        descriptionWordString = CDHelper.Config.DescriptionPageMeta;

                        if (ColumnID != "" && ArticleID != "")
                        {
                            Channel channel = ChannelHelper.GetChannel(ColumnID, null);
                            Article article = ArticleHelper.GetArticle(ArticleID);
                            if ((channel.KeyWord + article.KeyWord).Length > 0)
                            {
                                keyWordString = channel.KeyWord + article.KeyWord;
                            }
                            if ((channel.DescriptionKey + article.DescriptionKey).Length > 0)
                            {
                                descriptionWordString = channel.DescriptionKey + article.DescriptionKey;
                            }
                        }
                        else if (ColumnID == "" && ArticleID != "")
                        {
                            Article article = ArticleHelper.GetArticle(ArticleID);
                            if (article.KeyWord != null && article.KeyWord.Length > 0)
                            {
                                keyWordString = article.KeyWord;
                            }
                            if (article.DescriptionKey != null && article.DescriptionKey.Length > 0)
                            {
                                descriptionWordString = article.DescriptionKey;
                            }
                        }
                        else if (ColumnID != "" && ArticleID == "")
                        {
                            Channel channel = ChannelHelper.GetChannel(ColumnID, null);
                            if (channel.KeyWord != null && channel.KeyWord.Length > 0)
                            {
                                keyWordString = channel.KeyWord;
                            }
                            if (channel.DescriptionKey != null && channel.DescriptionKey.Length > 0)
                            {
                                descriptionWordString = channel.DescriptionKey;
                            }
                        }

                        KeywordsMeta.Attributes["content"] = keyWordString.ToString();
                        this.Header.Controls.Add(KeywordsMeta);

                        DescriptionMeta.Attributes["content"] = descriptionWordString.ToString();
                        this.Header.Controls.Add(DescriptionMeta);
                    }
                    catch (Exception ex)
                    {
                        We7.Framework.LogHelper.WriteLog(typeof(Go), ex);
                    }

                    //点击量统计
                    AddStatistic();
                }
                else
                {
                    Response.Write("警告:该栏目指定的模板不存在,请重新指定或检查模板的位置是否正确!");
                }
            }
        }
示例#11
0
        /// <summary>
        /// 重启网站
        /// </summary>
        public static void ResetApplication()
        {
            lock (lockHelper)
            {
                HttpContext context = HttpContext.Current;
                context.Application.Clear();

                if (context.Session != null)
                {
                    context.Session.Clear();
                }

                BaseConfigs.ResetConfig();
                SiteConfigs.ResetConfig();
                GeneralConfigs.ResetConfig();
                PluginManager.LoadPlugins();
                context.Application["We7.Application.OnlinePeople.Key"] = 0;

                //如果数据库配置文件存在,加载配置
                if (BaseConfigs.ConfigFileExist())
                {
                    BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig();

                    //加载数据库映射表
                    string          root     = context.Server.MapPath("~/");
                    string          dataPath = context.Server.MapPath("~/App_Data/XML");
                    ObjectAssistant assistat = new ObjectAssistant();
                    try
                    {
                        if (baseconfig != null && baseconfig.DBConnectionString != "")
                        {
                            baseconfig.DBConnectionString = baseconfig.DBConnectionString.
                                                            Replace("{$App}", AppDomain.CurrentDomain.BaseDirectory).Replace("\\\\", "\\");
                            assistat.LoadDBConnectionString(baseconfig.DBConnectionString, baseconfig.DBDriver);
                        }
                        assistat.LoadDataSource(dataPath);
                    }
                    catch (Thinkment.Data.DataException ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        string source = "CD.Utils_CDHelper_ResetApplication";
                        EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error);

                        string msg = string.Format("注意检查:/app_data/xml里的配置文件:\r\n错误代码:{0}\r\n错误消息:{1}"
                                                   , ex.ErrorCode, ex.Message);
                        We7.Framework.LogHelper.WriteLog(typeof(ApplicationHelper), msg);
                        throw ex;
                    }

                    HelperFactory hf = new HelperFactory();

                    /*
                     * 添加内容模型表结构(系统内置字段已在LoadDataSource里添加)
                     * author:丁乐
                     */
                    ModelHelper.ReCreateModelIndex();
                    MoudelMonitoring.SetModelDataDic(assistat);

                    hf.Assistant = assistat;
                    hf.Root      = root;
                    hf.Initialize();
                    context.Application.Add("We7.HelperFactory", hf);
                    AppCtx.Cache.AddObject(HelperFactory.CacheKey, hf);

                    MoudelMonitoring ml = new MoudelMonitoring();  //监控内容模型
                }
            }
        }