コード例 #1
0
ファイル: Global.asax.cs プロジェクト: chrisgundersen/bvcms
        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            var url = Request.Url.OriginalString;

            if (url.Contains("/Errors/") || url.Contains("healthcheck.txt"))
            {
                return;
            }

            if (Util.AppOffline)
            {
                Response.Redirect("/Errors/AppOffline.htm");
                return;
            }
            if (!DbUtil.CmsDatabaseExists())
            {
#if DEBUG
                var r = DbUtil.CheckDatabaseExists(Util.Host);
                if (r == DbUtil.CheckDatabaseResult.ServerNotFound)
                {
                    Response.Redirect("/Errors/DatabaseServerNotFound.aspx?server=" + Util.DbServer);
                    return;
                }
                var ret = DbUtil.CreateDatabase();
                if (ret.HasValue())
                {
                    Response.Redirect("/Errors/DatabaseCreationError.aspx?error=" + HttpUtility.UrlEncode(ret));
                    return;
                }
#else
                Response.Redirect("/Errors/DatabaseNotFound.aspx?dbname=" + Util.Host);
                return;
#endif
            }
            try
            {
                Util.AdminMail = DbUtil.Db.Setting("AdminMail", "");
            }
            catch (SqlException)
            {
                Response.Redirect("/Errors/DatabaseNotInitialized.aspx?dbname=" + Util.Host);
            }

            var cul = DbUtil.Db.Setting("Culture", "en-US");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);
        }
コード例 #2
0
ファイル: Global.asax.cs プロジェクト: chrisgundersen/bvcms
 protected void Session_Start(object sender, EventArgs e)
 {
     if (Util.Host.StartsWith("direct"))
     {
         return;
     }
     if (User.Identity.IsAuthenticated)
     {
         if (!DbUtil.CmsDatabaseExists())
         {
             Response.Redirect("/Errors/DatabaseNotFound.aspx?dbname=" + Util.Host);
             return;
         }
         Models.AccountModel.SetUserInfo(Util.UserName, Session);
     }
     Util.SysFromEmail    = ConfigurationManager.AppSettings["sysfromemail"];
     Util.Version         = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
     Util.SessionStarting = true;
     LogBrowser();
 }