Beispiel #1
0
        public static void StartSession(HttpContext current)
        {
            if (UrlService.CheckDebugAddress(current.Request.RawUrl))
            {
                return;
            }

            // string errMsg = string.Empty;
            // string ercode = "";


            string errMsg = string.Empty;
            var    ercode = TryToReachDBAtStartSession();

            // do by error
            switch (ercode)
            {
            case DataBaseService.PingDbState.NoError:
                //if browser no suport cokkies
                if (!current.Request.Browser.Cookies)
                {
                    return;
                }
                SuccessStart(current);
                break;

            case DataBaseService.PingDbState.FailConnectionSqlDb:
                current.Response.Redirect(UrlService.GetAbsoluteLink("/info/SessionError.aspx?ErrorCode=1"), true);
                break;

            case DataBaseService.PingDbState.WrongDbVersion:
                current.Response.Redirect(UrlService.GetAbsoluteLink("/info/SessionError.aspx?ErrorCode=2"), true);
                break;

            //case DataBaseService.PingDbState.FailConnectionSqlDb:
            //    current.Response.Redirect(UrlService.GetAbsoluteLink("/info/SessionError.aspx?ErrorCode=3"), true);
            //    break;

            case DataBaseService.PingDbState.WrongDbStructure:
                current.Response.Redirect(UrlService.GetAbsoluteLink("/info/SessionError.aspx?ErrorCode=4"), true);
                break;

            case DataBaseService.PingDbState.Unknown:
                current.Response.Redirect(
                    UrlService.GetAbsoluteLink(string.Format("/info/SessionError.aspx?ErrorMsg={0}",
                                                             HttpUtility.UrlEncode((errMsg.Length > 1000 ? errMsg.Substring(0, 1000) : errMsg) + " at SessionStart"))),
                    true);
                break;
            }
        }