Ejemplo n.º 1
0
        public void AddLog(Exception objException, ExceptionLogType LogType)
        {
            var objLogController = new LogController();
            var objLogInfo       = new LogInfo();

            objLogInfo.LogTypeKey = LogType.ToString();
            if (LogType == ExceptionLogType.SEARCH_INDEXER_EXCEPTION)
            {
                //Add SearchException Properties
                var objSearchException = (SearchException)objException;
                objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleId", objSearchException.SearchItem.ModuleId.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("SearchItemId", objSearchException.SearchItem.SearchItemId.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("Title", objSearchException.SearchItem.Title));
                objLogInfo.LogProperties.Add(new LogDetailInfo("SearchKey", objSearchException.SearchItem.SearchKey));
                objLogInfo.LogProperties.Add(new LogDetailInfo("GUID", objSearchException.SearchItem.GUID));
            }
            else if (LogType == ExceptionLogType.MODULE_LOAD_EXCEPTION)
            {
                //Add ModuleLoadException Properties
                var objModuleLoadException = (ModuleLoadException)objException;
                objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleId", objModuleLoadException.ModuleId.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleDefId", objModuleLoadException.ModuleDefId.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("FriendlyName", objModuleLoadException.FriendlyName));
                objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleControlSource", objModuleLoadException.ModuleControlSource));
            }
            else if (LogType == ExceptionLogType.SECURITY_EXCEPTION)
            {
                //Add SecurityException Properties
                var objSecurityException = (SecurityException)objException;
                objLogInfo.LogProperties.Add(new LogDetailInfo("Querystring", objSecurityException.Querystring));
                objLogInfo.LogProperties.Add(new LogDetailInfo("IP", objSecurityException.IP));
            }

            //Add BasePortalException Properties
            var objBasePortalException = new BasePortalException(objException.ToString(), objException);

            objLogInfo.LogProperties.Add(new LogDetailInfo("AssemblyVersion", objBasePortalException.AssemblyVersion));
            objLogInfo.LogProperties.Add(new LogDetailInfo("PortalID", objBasePortalException.PortalID.ToString()));
            objLogInfo.LogProperties.Add(new LogDetailInfo("PortalName", objBasePortalException.PortalName));
            objLogInfo.LogProperties.Add(new LogDetailInfo("UserID", objBasePortalException.UserID.ToString()));
            objLogInfo.LogProperties.Add(new LogDetailInfo("UserName", objBasePortalException.UserName));
            objLogInfo.LogProperties.Add(new LogDetailInfo("ActiveTabID", objBasePortalException.ActiveTabID.ToString()));
            objLogInfo.LogProperties.Add(new LogDetailInfo("ActiveTabName", objBasePortalException.ActiveTabName));
            objLogInfo.LogProperties.Add(new LogDetailInfo("RawURL", objBasePortalException.RawURL));
            objLogInfo.LogProperties.Add(new LogDetailInfo("AbsoluteURL", objBasePortalException.AbsoluteURL));
            objLogInfo.LogProperties.Add(new LogDetailInfo("AbsoluteURLReferrer", objBasePortalException.AbsoluteURLReferrer));
            objLogInfo.LogProperties.Add(new LogDetailInfo("UserAgent", objBasePortalException.UserAgent));
            objLogInfo.LogProperties.Add(new LogDetailInfo("DefaultDataProvider", objBasePortalException.DefaultDataProvider));
            objLogInfo.LogProperties.Add(new LogDetailInfo("ExceptionGUID", objBasePortalException.ExceptionGUID));
            objLogInfo.LogProperties.Add(new LogDetailInfo("InnerException", objBasePortalException.InnerException.Message));
            objLogInfo.LogProperties.Add(new LogDetailInfo("FileName", objBasePortalException.FileName));
            objLogInfo.LogProperties.Add(new LogDetailInfo("FileLineNumber", objBasePortalException.FileLineNumber.ToString()));
            objLogInfo.LogProperties.Add(new LogDetailInfo("FileColumnNumber", objBasePortalException.FileColumnNumber.ToString()));
            objLogInfo.LogProperties.Add(new LogDetailInfo("Method", objBasePortalException.Method));
            objLogInfo.LogProperties.Add(new LogDetailInfo("StackTrace", objBasePortalException.StackTrace));
            objLogInfo.LogProperties.Add(new LogDetailInfo("Message", objBasePortalException.Message));
            objLogInfo.LogProperties.Add(new LogDetailInfo("Source", objBasePortalException.Source));
            objLogInfo.LogPortalID = objBasePortalException.PortalID;
            objLogController.AddLog(objLogInfo);
        }
Ejemplo n.º 2
0
 public void AddLog(BasePortalException objBasePortalException)
 {
     if (objBasePortalException.GetType().Name == "ModuleLoadException")
     {
         AddLog(objBasePortalException, ExceptionLogType.MODULE_LOAD_EXCEPTION);
     }
     else if (objBasePortalException.GetType().Name == "PageLoadException")
     {
         AddLog(objBasePortalException, ExceptionLogType.PAGE_LOAD_EXCEPTION);
     }
     else if (objBasePortalException.GetType().Name == "SchedulerException")
     {
         AddLog(objBasePortalException, ExceptionLogType.SCHEDULER_EXCEPTION);
     }
     else if (objBasePortalException.GetType().Name == "SecurityException")
     {
         AddLog(objBasePortalException, ExceptionLogType.SECURITY_EXCEPTION);
     }
     else if (objBasePortalException.GetType().Name == "SearchException")
     {
         AddLog(objBasePortalException, ExceptionLogType.SEARCH_INDEXER_EXCEPTION);
     }
     else
     {
         AddLog(objBasePortalException, ExceptionLogType.GENERAL_EXCEPTION);
     }
 }
Ejemplo n.º 3
0
        protected override void OnError(System.EventArgs e)
        {
            base.OnError(e);
            Exception exc    = Server.GetLastError();
            string    strURL = Globals.ApplicationURL();

            if (object.ReferenceEquals(exc.GetType(), typeof(HttpException)))
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Server.Transfer("~/ErrorPage.aspx");
            }
            BasePortalException objBasePortalException = new BasePortalException(exc.ToString(), exc);

            if (Request.QueryString["error"] != null)
            {
                strURL += (strURL.IndexOf("?") == -1 ? "?" : "&").ToString() + "error=terminate";
            }
            else
            {
                strURL += (strURL.IndexOf("?") == -1 ? "?" : "&").ToString() + "error=" + Server.UrlEncode(exc.Message);
                if (!Globals.IsAdminControl())
                {
                    strURL += "&content=0";
                }
            }
            Exceptions.ProcessPageLoadException(exc, strURL);
        }
Ejemplo n.º 4
0
        public void AddLog(Exception objException, LogInfo log, ExceptionLogType logType)
        {
            log.LogTypeKey = logType.ToString();
            if (logType == ExceptionLogType.MODULE_LOAD_EXCEPTION)
            {
                //Add ModuleLoadException Properties
                var objModuleLoadException = (ModuleLoadException)objException;
                log.LogProperties.Add(new LogDetailInfo("ModuleId", objModuleLoadException.ModuleId.ToString()));
                log.LogProperties.Add(new LogDetailInfo("ModuleDefId", objModuleLoadException.ModuleDefId.ToString()));
                log.LogProperties.Add(new LogDetailInfo("FriendlyName", objModuleLoadException.FriendlyName));
                log.LogProperties.Add(new LogDetailInfo("ModuleControlSource", objModuleLoadException.ModuleControlSource));
            }
            else if (logType == ExceptionLogType.SECURITY_EXCEPTION)
            {
                //Add SecurityException Properties
                var objSecurityException = (SecurityException)objException;
                log.LogProperties.Add(new LogDetailInfo("Querystring", objSecurityException.Querystring));
                log.LogProperties.Add(new LogDetailInfo("IP", objSecurityException.IP));
            }

            //Add BasePortalException Properties
            var objBasePortalException = new BasePortalException(objException.ToString(), objException);

            log.LogProperties.Add(new LogDetailInfo("AbsoluteURL", objBasePortalException.AbsoluteURL));
            log.LogProperties.Add(new LogDetailInfo("DefaultDataProvider", objBasePortalException.DefaultDataProvider));
            log.LogProperties.Add(new LogDetailInfo("ExceptionGUID", objBasePortalException.ExceptionGUID));
            log.LogPortalID = objBasePortalException.PortalID;

            var sqlException = objException as SqlException;

            if (sqlException != null && (uint)sqlException.ErrorCode == 0x80131904 && sqlException.Number == 4060)
            {
                // This is to avoid stack-overflow exception when a database connection exception occurs
                // bercause the logger will try to write to the database and goes in a loop of failures.
                Trace.TraceError(log.Serialize());
            }
            else
            {
                Instance.AddLog(log);
            }

            //when current user is host user and exception is PageLoadException, try to log the log guid into cookies.
            //so that this log can be picked and do more action on it later.
            if (logType == ExceptionLogType.PAGE_LOAD_EXCEPTION && HttpContext.Current != null && UserController.Instance.GetCurrentUserInfo().IsSuperUser)
            {
                HttpContext.Current.Response.Cookies.Add(
                    new HttpCookie("LogGUID", log.LogGUID)
                {
                    HttpOnly = false, Path = (!string.IsNullOrEmpty(Globals.ApplicationPath) ? Globals.ApplicationPath : "/")
                });
            }
        }
Ejemplo n.º 5
0
        public void AddLog(Exception objException, LogInfo log, ExceptionLogType logType)
        {
            log.LogTypeKey = logType.ToString();
            if (logType == ExceptionLogType.SEARCH_INDEXER_EXCEPTION)
            {
                //Add SearchException Properties
                var objSearchException = (SearchException)objException;
                log.LogProperties.Add(new LogDetailInfo("ModuleId", objSearchException.SearchItem.ModuleId.ToString()));
                log.LogProperties.Add(new LogDetailInfo("SearchItemId", objSearchException.SearchItem.SearchItemId.ToString()));
                log.LogProperties.Add(new LogDetailInfo("Title", objSearchException.SearchItem.Title));
                log.LogProperties.Add(new LogDetailInfo("SearchKey", objSearchException.SearchItem.SearchKey));
                log.LogProperties.Add(new LogDetailInfo("GUID", objSearchException.SearchItem.GUID));
            }
            else if (logType == ExceptionLogType.MODULE_LOAD_EXCEPTION)
            {
                //Add ModuleLoadException Properties
                var objModuleLoadException = (ModuleLoadException)objException;
                log.LogProperties.Add(new LogDetailInfo("ModuleId", objModuleLoadException.ModuleId.ToString()));
                log.LogProperties.Add(new LogDetailInfo("ModuleDefId", objModuleLoadException.ModuleDefId.ToString()));
                log.LogProperties.Add(new LogDetailInfo("FriendlyName", objModuleLoadException.FriendlyName));
                log.LogProperties.Add(new LogDetailInfo("ModuleControlSource", objModuleLoadException.ModuleControlSource));
            }
            else if (logType == ExceptionLogType.SECURITY_EXCEPTION)
            {
                //Add SecurityException Properties
                var objSecurityException = (SecurityException)objException;
                log.LogProperties.Add(new LogDetailInfo("Querystring", objSecurityException.Querystring));
                log.LogProperties.Add(new LogDetailInfo("IP", objSecurityException.IP));
            }

            //Add BasePortalException Properties
            var objBasePortalException = new BasePortalException(objException.ToString(), objException);

            log.LogProperties.Add(new LogDetailInfo("AbsoluteURL", objBasePortalException.AbsoluteURL));
            log.LogProperties.Add(new LogDetailInfo("DefaultDataProvider", objBasePortalException.DefaultDataProvider));
            log.LogProperties.Add(new LogDetailInfo("ExceptionGUID", objBasePortalException.ExceptionGUID));
            log.LogPortalID = objBasePortalException.PortalID;
            LogController.Instance.AddLog(log);

            //when current user is host user and exception is PageLoadException, try to log the log guid into cookies.
            //so that this log can be picked and do more action on it later.
            if (logType == ExceptionLogType.PAGE_LOAD_EXCEPTION && HttpContext.Current != null && UserController.Instance.GetCurrentUserInfo().IsSuperUser)
            {
                HttpContext.Current.Response.Cookies.Add(
                    new HttpCookie("LogGUID", log.LogGUID)
                {
                    HttpOnly = false, Path = (!string.IsNullOrEmpty(Globals.ApplicationPath) ? Globals.ApplicationPath : "/")
                });
            }
        }
Ejemplo n.º 6
0
        public void AddLog(BasePortalException objBasePortalException)
        {
            var log = new LogInfo
            {
                Exception = Exceptions.GetExceptionInfo(objBasePortalException),
            };

            log.Exception.AssemblyVersion = objBasePortalException.AssemblyVersion;
            log.Exception.PortalId        = objBasePortalException.PortalID;
            log.Exception.UserId          = objBasePortalException.UserID;
            log.Exception.TabId           = objBasePortalException.ActiveTabID;
            log.Exception.RawUrl          = objBasePortalException.RawURL;
            log.Exception.Referrer        = objBasePortalException.AbsoluteURLReferrer;
            log.Exception.UserAgent       = objBasePortalException.UserAgent;
            if (objBasePortalException.GetType().Name == "ModuleLoadException")
            {
                this.AddLog(objBasePortalException, log, ExceptionLogType.MODULE_LOAD_EXCEPTION);
            }
            else if (objBasePortalException.GetType().Name == "PageLoadException")
            {
                this.AddLog(objBasePortalException, log, ExceptionLogType.PAGE_LOAD_EXCEPTION);
            }
            else if (objBasePortalException.GetType().Name == "SchedulerException")
            {
                this.AddLog(objBasePortalException, log, ExceptionLogType.SCHEDULER_EXCEPTION);
            }
            else if (objBasePortalException.GetType().Name == "SecurityException")
            {
                this.AddLog(objBasePortalException, log, ExceptionLogType.SECURITY_EXCEPTION);
            }
            else if (objBasePortalException.GetType().Name == "SearchException")
            {
                this.AddLog(objBasePortalException, log, ExceptionLogType.SEARCH_INDEXER_EXCEPTION);
            }
            else
            {
                this.AddLog(objBasePortalException, log, ExceptionLogType.GENERAL_EXCEPTION);
            }
        }
Ejemplo n.º 7
0
        public void LogException(Exception ex, EventLogSeverity severity)
        {
            var logInfo = new LogInfo();
            var user    = DnnUserController.Instance.GetCurrentUserInfo();

            logInfo.LogUserID   = user != null ? user.UserID : -1;
            logInfo.LogPortalID = DnnGlobal.Instance.GetPortalId();
            logInfo.LogTypeKey  = LOGTYPE_EXCEPTION;
            logInfo.AddProperty("Severity", severity.ToString());

            var exception4 = new BasePortalException(ex.ToString(), ex);

            logInfo.LogProperties.Add(new LogDetailInfo("AssemblyVersion", exception4.AssemblyVersion));
            logInfo.LogProperties.Add(new LogDetailInfo("PortalID", exception4.PortalID.ToString()));
            logInfo.LogProperties.Add(new LogDetailInfo("PortalName", exception4.PortalName));
            logInfo.LogProperties.Add(new LogDetailInfo("UserID", exception4.UserID.ToString()));
            logInfo.LogProperties.Add(new LogDetailInfo("UserName", exception4.UserName));
            logInfo.LogProperties.Add(new LogDetailInfo("ActiveTabID", exception4.ActiveTabID.ToString()));
            logInfo.LogProperties.Add(new LogDetailInfo("ActiveTabName", exception4.ActiveTabName));
            logInfo.LogProperties.Add(new LogDetailInfo("RawURL", exception4.RawURL));
            logInfo.LogProperties.Add(new LogDetailInfo("AbsoluteURL", exception4.AbsoluteURL));
            logInfo.LogProperties.Add(new LogDetailInfo("AbsoluteURLReferrer", exception4.AbsoluteURLReferrer));
            logInfo.LogProperties.Add(new LogDetailInfo("UserAgent", exception4.UserAgent));
            logInfo.LogProperties.Add(new LogDetailInfo("DefaultDataProvider", exception4.DefaultDataProvider));
            logInfo.LogProperties.Add(new LogDetailInfo("ExceptionGUID", exception4.ExceptionGUID));
            logInfo.LogProperties.Add(new LogDetailInfo("InnerException", exception4.InnerException.Message));
            logInfo.LogProperties.Add(new LogDetailInfo("FileName", exception4.FileName));
            logInfo.LogProperties.Add(new LogDetailInfo("FileLineNumber", exception4.FileLineNumber.ToString()));
            logInfo.LogProperties.Add(new LogDetailInfo("FileColumnNumber", exception4.FileColumnNumber.ToString()));
            logInfo.LogProperties.Add(new LogDetailInfo("Method", exception4.Method));
            logInfo.LogProperties.Add(new LogDetailInfo("StackTrace", exception4.StackTrace));
            logInfo.LogProperties.Add(new LogDetailInfo("Message", exception4.Message));
            logInfo.LogProperties.Add(new LogDetailInfo("Source", exception4.Source));

            var log = new EventLogController();

            log.AddLog(logInfo);
        }
        public void AddLog(Exception objException, ExceptionLogType logType)
        {
            var log = new LogInfo {
                LogTypeKey = logType.ToString()
            };

            if (logType == ExceptionLogType.SEARCH_INDEXER_EXCEPTION)
            {
                //Add SearchException Properties
                var objSearchException = (SearchException)objException;
                log.LogProperties.Add(new LogDetailInfo("ModuleId", objSearchException.SearchItem.ModuleId.ToString()));
                log.LogProperties.Add(new LogDetailInfo("SearchItemId", objSearchException.SearchItem.SearchItemId.ToString()));
                log.LogProperties.Add(new LogDetailInfo("Title", objSearchException.SearchItem.Title));
                log.LogProperties.Add(new LogDetailInfo("SearchKey", objSearchException.SearchItem.SearchKey));
                log.LogProperties.Add(new LogDetailInfo("GUID", objSearchException.SearchItem.GUID));
            }
            else if (logType == ExceptionLogType.MODULE_LOAD_EXCEPTION)
            {
                //Add ModuleLoadException Properties
                var objModuleLoadException = (ModuleLoadException)objException;
                log.LogProperties.Add(new LogDetailInfo("ModuleId", objModuleLoadException.ModuleId.ToString()));
                log.LogProperties.Add(new LogDetailInfo("ModuleDefId", objModuleLoadException.ModuleDefId.ToString()));
                log.LogProperties.Add(new LogDetailInfo("FriendlyName", objModuleLoadException.FriendlyName));
                log.LogProperties.Add(new LogDetailInfo("ModuleControlSource", objModuleLoadException.ModuleControlSource));
            }
            else if (logType == ExceptionLogType.SECURITY_EXCEPTION)
            {
                //Add SecurityException Properties
                var objSecurityException = (SecurityException)objException;
                log.LogProperties.Add(new LogDetailInfo("Querystring", objSecurityException.Querystring));
                log.LogProperties.Add(new LogDetailInfo("IP", objSecurityException.IP));
            }

            //Add BasePortalException Properties
            var objBasePortalException = new BasePortalException(objException.ToString(), objException);

            log.LogProperties.Add(new LogDetailInfo("AssemblyVersion", objBasePortalException.AssemblyVersion));
            log.LogProperties.Add(new LogDetailInfo("PortalID", objBasePortalException.PortalID.ToString()));
            log.LogProperties.Add(new LogDetailInfo("PortalName", objBasePortalException.PortalName));
            log.LogProperties.Add(new LogDetailInfo("UserID", objBasePortalException.UserID.ToString()));
            log.LogProperties.Add(new LogDetailInfo("UserName", objBasePortalException.UserName));
            log.LogProperties.Add(new LogDetailInfo("ActiveTabID", objBasePortalException.ActiveTabID.ToString()));
            log.LogProperties.Add(new LogDetailInfo("ActiveTabName", objBasePortalException.ActiveTabName));
            log.LogProperties.Add(new LogDetailInfo("RawURL", objBasePortalException.RawURL));
            log.LogProperties.Add(new LogDetailInfo("AbsoluteURL", objBasePortalException.AbsoluteURL));
            log.LogProperties.Add(new LogDetailInfo("AbsoluteURLReferrer", objBasePortalException.AbsoluteURLReferrer));
            log.LogProperties.Add(new LogDetailInfo("UserAgent", objBasePortalException.UserAgent));
            log.LogProperties.Add(new LogDetailInfo("DefaultDataProvider", objBasePortalException.DefaultDataProvider));
            log.LogProperties.Add(new LogDetailInfo("ExceptionGUID", objBasePortalException.ExceptionGUID));
            log.LogProperties.Add(new LogDetailInfo("InnerException", objBasePortalException.InnerException.Message));
            log.LogProperties.Add(new LogDetailInfo("FileName", objBasePortalException.FileName));
            log.LogProperties.Add(new LogDetailInfo("FileLineNumber", objBasePortalException.FileLineNumber.ToString()));
            log.LogProperties.Add(new LogDetailInfo("FileColumnNumber", objBasePortalException.FileColumnNumber.ToString()));
            log.LogProperties.Add(new LogDetailInfo("Method", objBasePortalException.Method));
            log.LogProperties.Add(new LogDetailInfo("StackTrace", objBasePortalException.StackTrace));
            log.LogProperties.Add(new LogDetailInfo("Message", objBasePortalException.Message));
            log.LogProperties.Add(new LogDetailInfo("Source", objBasePortalException.Source));
            log.LogPortalID = objBasePortalException.PortalID;
            LogController.Instance.AddLog(log);

            //when current user is host user and exception is PageLoadException, try to log the log guid into cookies.
            //so that this log can be picked and do more action on it later.
            if (logType == ExceptionLogType.PAGE_LOAD_EXCEPTION && HttpContext.Current != null && UserController.Instance.GetCurrentUserInfo().IsSuperUser)
            {
                HttpContext.Current.Response.Cookies.Add(new HttpCookie("LogGUID", log.LogGUID)
                {
                    HttpOnly = false
                });
            }
        }