Esempio n. 1
0
        public bool HandleException(ref LocalState flowState)
        {
            Exception ex = Server.GetLastError();

            if (ex is LicensingException)
            {
                return(true);
            }

            HeContext heContext = Global.App.OsContext;
            string    errorKey  = "ContactManager.Private" + ex.GetType().ToString();

            if (heContext.VisitedExceptionHandlerFlows.Contains(errorKey))
            {
                return(false);
            }
            heContext.VisitedExceptionHandlerFlows.Add(errorKey);

            if (heContext.Session.EntryPoint == null)
            {
                heContext.Session.EntryPoint = HeContext.UnknownEntryPoint;
            }
            while (ex != null)
            {
                if (ex is System.Threading.ThreadAbortException)
                {
                    return(true);
                }
                ex = ex.InnerException;
            }
            ex = Server.GetLastError();
            if (ex is System.Reflection.TargetInvocationException)
            {
                ex = ex.InnerException;
            }

            heContext.Session["ExceptionMessage"] = ex.Message;

            heContext.Session[BuiltInFunction.ExceptionURLSessionName] = BuiltInFunction.GetBookmarkableURL();
            Response.Clear();

            if (isEmailScreen)
            {
                ErrorLog.LogApplicationError(ex, heContext, "");
                return(true);
            }

            if (heContext.CanUseCustomErrorHandler(ex))
            {
                return(new ssContactManager.Flows.FlowCommon.ExceptionHandler(page, isEmailScreen).HandleException());
            }
            DatabaseAccess.FreeupResources(false);

            Server.Transfer("_WebErrorPage.aspx");
            return(true);
        }
        public bool HandleException(ref LocalState flowState)
        {
            Exception ex = Server.GetLastError();

            if (ex is LicensingException)
            {
                return(true);
            }

            HeContext heContext = Global.App.OsContext;
            string    errorKey  = "ContactManager.Common" + ex.GetType().ToString();

            if (heContext.VisitedExceptionHandlerFlows.Contains(errorKey))
            {
                return(false);
            }
            heContext.VisitedExceptionHandlerFlows.Add(errorKey);

            if (heContext.Session.EntryPoint == null)
            {
                heContext.Session.EntryPoint = HeContext.UnknownEntryPoint;
            }
            while (ex != null)
            {
                if (ex is System.Threading.ThreadAbortException)
                {
                    return(true);
                }
                ex = ex.InnerException;
            }
            ex = Server.GetLastError();
            if (ex is System.Reflection.TargetInvocationException)
            {
                ex = ex.InnerException;
            }

            heContext.Session["ExceptionMessage"] = ex.Message;

            heContext.Session[BuiltInFunction.ExceptionURLSessionName] = BuiltInFunction.GetBookmarkableURL();
            Response.Clear();

            if (isEmailScreen)
            {
                ErrorLog.LogApplicationError(ex, heContext, "");
                return(true);
            }

            if (heContext.CanUseCustomErrorHandler(ex))
            {
                try {
                    if (heContext != null && heContext.RequestTracer != null)
                    {
                        heContext.RequestTracer.RegisterInternalCall("uQIbaBBWLUCv4agYss7epw.#FlowExceptionHandler", "OnException", "X0RMeX3yYU+0eg2nFEDfaA", "ContactManager");
                    }
                    if (ex is SecurityException)
                    {
                        heContext.ExceptionStack.Add(ex);
                        heContext.LastException = ex;
                        int    expCount;
                        string errorStack = ErrorLog.GenerateFullStack(ex, out expCount);
                        errorStack = errorStack.Length > ErrorLog.MAX_STACK_SIZE ? errorStack.Substring(0, ErrorLog.MAX_STACK_SIZE - 3) + "...": errorStack;
                        heContext.Session["ExceptionStack"] = errorStack + ErrorLog.GetStackEnvironmentInfo(Global.App, heContext);
                        Global.App.OsContext.Session["ExceptionMessage"] = ex.Message;
                        Server.ClearError();
                        // Error Handler

                        // Destination = InvalidPermissions

                        if (OSPage.IsAjaxRequest)
                        {
                            // go to target page
                            {
                                ((OSPage)Page).ClearErrorHandler();
                                if (heContext.AppInfo.eSpaceId == Global.eSpaceId)
                                {
                                    // get parameters
                                    heContext.Session["_ScreenParametersKey"] = "LHTNLbeWYk6ubxZEvKuVpQ";
                                    ArrayList screenParameters = new ArrayList();
                                    Global.App.OsContext.Session["ContactManager._ScreenParameters_InvalidPermissions"] = screenParameters;
                                    string sURLQuery = null;
                                    sURLQuery = (sURLQuery == null ? "": "?" + sURLQuery);
                                    string sURL = GetClientRedirectionUrlBasePath(Global.App.IsForcingSecurityForScreens(), AppUtils.Instance.getImagePath(), "", "") + "InvalidPermissions.aspx" + sURLQuery;
                                    DatabaseAccess.FreeupResources(true);
                                    ((OSPage)Page).Redirect(sURL);
                                }
                                else
                                {
                                    string sURLQuery = null;
                                    sURLQuery = (sURLQuery == null ? "": "?" + sURLQuery);
                                    string sURL = GetClientRedirectionUrlBasePath(Global.App.IsForcingSecurityForScreens(), AppUtils.Instance.getImagePath(), "", "") + "InvalidPermissions.aspx" + sURLQuery;
                                    DatabaseAccess.FreeupResources(true);
                                    ((OSPage)Page).Redirect(sURL);
                                }
                                return(true);
                            }
                        }
                        else
                        {
                            // go to target page
                            {
                                ((OSPage)Page).ClearErrorHandler();
                                if (heContext.AppInfo.eSpaceId == Global.eSpaceId)
                                {
                                    // get parameters
                                    heContext.Session["_ScreenParametersKey"] = "LHTNLbeWYk6ubxZEvKuVpQ";
                                    ArrayList screenParameters = new ArrayList();
                                    Global.App.OsContext.Session["ContactManager._ScreenParameters_InvalidPermissions"] = screenParameters;
                                    DatabaseAccess.FreeupResources(true);
                                    Server.Transfer("InvalidPermissions.aspx");
                                }
                                else
                                {
                                    string sURLQuery = null;
                                    sURLQuery = (sURLQuery == null ? "": "?" + sURLQuery);
                                    string sURL = GetClientRedirectionUrlBasePath(Global.App.IsForcingSecurityForScreens(), AppUtils.Instance.getImagePath(), "", "") + "InvalidPermissions.aspx" + sURLQuery;
                                    DatabaseAccess.FreeupResources(true);
                                    ((OSPage)Page).Redirect(sURL);
                                }
                                return(true);
                            }
                        }
                    }                     // end if (ex is SecurityException)
                    if (ex is Exception)
                    {
                        heContext.ExceptionStack.Add(ex);
                        heContext.LastException = ex;
                        int    expCount;
                        string errorStack = ErrorLog.GenerateFullStack(ex, out expCount);
                        errorStack = errorStack.Length > ErrorLog.MAX_STACK_SIZE ? errorStack.Substring(0, ErrorLog.MAX_STACK_SIZE - 3) + "...": errorStack;
                        heContext.Session["ExceptionStack"] = errorStack + ErrorLog.GetStackEnvironmentInfo(Global.App, heContext);
                        ErrorLog.LogApplicationError(ex, heContext, "");
                        DatabaseAccess.FreeupResources(false);
                        Global.App.OsContext.Session["ExceptionMessage"] = ex.Message;
                        Server.ClearError();
                        // Error Handler
                        DatabaseAccess.RollbackAllTransactions();

                        // Destination = InternalError

                        if (OSPage.IsAjaxRequest)
                        {
                            // go to target page
                            {
                                ((OSPage)Page).ClearErrorHandler();
                                if (heContext.AppInfo.eSpaceId == Global.eSpaceId)
                                {
                                    // get parameters
                                    heContext.Session["_ScreenParametersKey"] = "5iM2jMromEyrgtXKm6ia+g";
                                    ArrayList screenParameters = new ArrayList();
                                    Global.App.OsContext.Session["ContactManager._ScreenParameters_InternalError"] = screenParameters;
                                    string sURLQuery = null;
                                    sURLQuery = (sURLQuery == null ? "": "?" + sURLQuery);
                                    string sURL = GetClientRedirectionUrlBasePath(Global.App.IsForcingSecurityForScreens(), AppUtils.Instance.getImagePath(), "", "") + "InternalError.aspx" + sURLQuery;
                                    DatabaseAccess.FreeupResources(true);
                                    ((OSPage)Page).Redirect(sURL);
                                }
                                else
                                {
                                    string sURLQuery = null;
                                    sURLQuery = (sURLQuery == null ? "": "?" + sURLQuery);
                                    string sURL = GetClientRedirectionUrlBasePath(Global.App.IsForcingSecurityForScreens(), AppUtils.Instance.getImagePath(), "", "") + "InternalError.aspx" + sURLQuery;
                                    DatabaseAccess.FreeupResources(true);
                                    ((OSPage)Page).Redirect(sURL);
                                }
                                return(true);
                            }
                        }
                        else
                        {
                            // go to target page
                            {
                                ((OSPage)Page).ClearErrorHandler();
                                if (heContext.AppInfo.eSpaceId == Global.eSpaceId)
                                {
                                    // get parameters
                                    heContext.Session["_ScreenParametersKey"] = "5iM2jMromEyrgtXKm6ia+g";
                                    ArrayList screenParameters = new ArrayList();
                                    Global.App.OsContext.Session["ContactManager._ScreenParameters_InternalError"] = screenParameters;
                                    DatabaseAccess.FreeupResources(true);
                                    Server.Transfer("InternalError.aspx");
                                }
                                else
                                {
                                    string sURLQuery = null;
                                    sURLQuery = (sURLQuery == null ? "": "?" + sURLQuery);
                                    string sURL = GetClientRedirectionUrlBasePath(Global.App.IsForcingSecurityForScreens(), AppUtils.Instance.getImagePath(), "", "") + "InternalError.aspx" + sURLQuery;
                                    DatabaseAccess.FreeupResources(true);
                                    ((OSPage)Page).Redirect(sURL);
                                }
                                return(true);
                            }
                        }
                    }                     // end if (ex is Exception)
                } catch (System.Threading.ThreadAbortException) {
                    return(true);
                }
                return(new ssContactManager.Flows.FlowCommon.ExceptionHandler(page, isEmailScreen).HandleException());
            }
            DatabaseAccess.FreeupResources(false);

            Server.Transfer("_WebErrorPage.aspx");
            return(true);
        }