private void InitializePrivateVariables()
        {
            //Try and get the Portal settings from context
            //If an error occurs getting the context then set the variables to -1
            try
            {
                var context        = HttpContext.Current;
                var portalSettings = PortalController.Instance.GetCurrentPortalSettings();
                var innerException = new Exception(Message, this);
                while (innerException.InnerException != null)
                {
                    innerException = innerException.InnerException;
                }
                var exceptionInfo = Exceptions.GetExceptionInfo(innerException);

                AssemblyVersion = DotNetNukeContext.Current.Application.Version.ToString(3);
                if (portalSettings != null)
                {
                    PortalID      = portalSettings.PortalId;
                    PortalName    = portalSettings.PortalName;
                    ActiveTabID   = portalSettings.ActiveTab.TabID;
                    ActiveTabName = portalSettings.ActiveTab.TabName;
                }
                else
                {
                    PortalID      = -1;
                    PortalName    = "";
                    ActiveTabID   = -1;
                    ActiveTabName = "";
                }

                var currentUserInfo = UserController.Instance.GetCurrentUserInfo();
                UserID = (currentUserInfo != null) ? currentUserInfo.UserID : -1;

                if (UserID != -1)
                {
                    currentUserInfo = UserController.GetUserById(PortalID, UserID);
                    UserName        = currentUserInfo != null ? currentUserInfo.Username : "";
                }
                else
                {
                    UserName = "";
                }

                if (context != null)
                {
                    RawURL      = context.Request.RawUrl;
                    AbsoluteURL = context.Request.Url.AbsolutePath;
                    if (context.Request.UrlReferrer != null)
                    {
                        AbsoluteURLReferrer = context.Request.UrlReferrer.AbsoluteUri;
                    }
                    UserAgent = context.Request.UserAgent;
                }
                else
                {
                    RawURL              = "";
                    AbsoluteURL         = "";
                    AbsoluteURLReferrer = "";
                    UserAgent           = "";
                }
                try
                {
                    ProviderConfiguration objProviderConfiguration = ProviderConfiguration.GetProviderConfiguration("data");
                    string strTypeName = ((Provider)objProviderConfiguration.Providers[objProviderConfiguration.DefaultProvider]).Type;
                    DefaultDataProvider = strTypeName;
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);

                    DefaultDataProvider = "";
                }

                ExceptionGUID = Guid.NewGuid().ToString();

                if (exceptionInfo != null)
                {
                    FileName         = exceptionInfo.FileName;
                    FileLineNumber   = exceptionInfo.FileLineNumber;
                    FileColumnNumber = exceptionInfo.FileColumnNumber;
                    Method           = exceptionInfo.Method;
                }
                else
                {
                    FileName         = "";
                    FileLineNumber   = -1;
                    FileColumnNumber = -1;
                    Method           = "";
                }

                try
                {
                    m_StackTrace = StackTrace;
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);

                    m_StackTrace = "";
                }
                try
                {
                    m_Message = Message;
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);

                    m_Message = "";
                }
                try
                {
                    m_Source = Source;
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);

                    m_Source = "";
                }
            }
            catch (Exception exc)
            {
                PortalID            = -1;
                UserID              = -1;
                AssemblyVersion     = "-1";
                ActiveTabID         = -1;
                ActiveTabName       = "";
                RawURL              = "";
                AbsoluteURL         = "";
                AbsoluteURLReferrer = "";
                UserAgent           = "";
                DefaultDataProvider = "";
                ExceptionGUID       = "";
                FileName            = "";
                FileLineNumber      = -1;
                FileColumnNumber    = -1;
                Method              = "";
                m_StackTrace        = "";
                m_Message           = "";
                m_Source            = "";
                Logger.Error(exc);
            }
        }
        private void InitializePrivateVariables()
        {
            // Try and get the Portal settings from context
            // If an error occurs getting the context then set the variables to -1
            try
            {
                var context        = HttpContext.Current;
                var portalSettings = PortalController.Instance.GetCurrentPortalSettings();
                var innerException = new Exception(this.Message, this);
                while (innerException.InnerException != null)
                {
                    innerException = innerException.InnerException;
                }

                var exceptionInfo = Exceptions.GetExceptionInfo(innerException);

                this.AssemblyVersion = DotNetNukeContext.Current.Application.Version.ToString(3);
                if (portalSettings != null)
                {
                    this.PortalID      = portalSettings.PortalId;
                    this.PortalName    = portalSettings.PortalName;
                    this.ActiveTabID   = portalSettings.ActiveTab.TabID;
                    this.ActiveTabName = portalSettings.ActiveTab.TabName;
                }
                else
                {
                    this.PortalID      = -1;
                    this.PortalName    = string.Empty;
                    this.ActiveTabID   = -1;
                    this.ActiveTabName = string.Empty;
                }

                var currentUserInfo = UserController.Instance.GetCurrentUserInfo();
                this.UserID = (currentUserInfo != null) ? currentUserInfo.UserID : -1;

                if (this.UserID != -1)
                {
                    currentUserInfo = UserController.GetUserById(this.PortalID, this.UserID);
                    this.UserName   = currentUserInfo != null ? currentUserInfo.Username : string.Empty;
                }
                else
                {
                    this.UserName = string.Empty;
                }

                if (context != null)
                {
                    this.RawURL      = HttpUtility.HtmlEncode(context.Request.RawUrl);
                    this.AbsoluteURL = HttpUtility.HtmlEncode(context.Request.Url.AbsolutePath);
                    if (context.Request.UrlReferrer != null)
                    {
                        this.AbsoluteURLReferrer = HttpUtility.HtmlEncode(context.Request.UrlReferrer.AbsoluteUri);
                    }

                    this.UserAgent = HttpUtility.HtmlEncode(context.Request.UserAgent ?? string.Empty);
                }
                else
                {
                    this.RawURL              = string.Empty;
                    this.AbsoluteURL         = string.Empty;
                    this.AbsoluteURLReferrer = string.Empty;
                    this.UserAgent           = string.Empty;
                }

                try
                {
                    ProviderConfiguration objProviderConfiguration = ProviderConfiguration.GetProviderConfiguration("data");
                    string strTypeName = ((Provider)objProviderConfiguration.Providers[objProviderConfiguration.DefaultProvider]).Type;
                    this.DefaultDataProvider = strTypeName;
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);

                    this.DefaultDataProvider = string.Empty;
                }

                this.ExceptionGUID = Guid.NewGuid().ToString();

                if (exceptionInfo != null)
                {
                    this.FileName         = exceptionInfo.FileName;
                    this.FileLineNumber   = exceptionInfo.FileLineNumber;
                    this.FileColumnNumber = exceptionInfo.FileColumnNumber;
                    this.Method           = exceptionInfo.Method;
                }
                else
                {
                    this.FileName         = string.Empty;
                    this.FileLineNumber   = -1;
                    this.FileColumnNumber = -1;
                    this.Method           = string.Empty;
                }

                try
                {
                    this.m_StackTrace = this.StackTrace;
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);

                    this.m_StackTrace = string.Empty;
                }

                try
                {
                    this.m_Message = this.Message;
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);

                    this.m_Message = string.Empty;
                }

                try
                {
                    this.m_Source = this.Source;
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);

                    this.m_Source = string.Empty;
                }
            }
            catch (Exception exc)
            {
                this.PortalID            = -1;
                this.UserID              = -1;
                this.AssemblyVersion     = "-1";
                this.ActiveTabID         = -1;
                this.ActiveTabName       = string.Empty;
                this.RawURL              = string.Empty;
                this.AbsoluteURL         = string.Empty;
                this.AbsoluteURLReferrer = string.Empty;
                this.UserAgent           = string.Empty;
                this.DefaultDataProvider = string.Empty;
                this.ExceptionGUID       = string.Empty;
                this.FileName            = string.Empty;
                this.FileLineNumber      = -1;
                this.FileColumnNumber    = -1;
                this.Method              = string.Empty;
                this.m_StackTrace        = string.Empty;
                this.m_Message           = string.Empty;
                this.m_Source            = string.Empty;
                Logger.Error(exc);
            }
        }
示例#3
0
        private void InitilizePrivateVariables()
        {
            //Try and get the Portal settings from context
            //If an error occurs getting the context then set the variables to -1
            try
            {
                HttpContext    _context        = HttpContext.Current;
                PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings();
                Exception      _objInnermostException;
                _objInnermostException = new Exception(this.Message, this);
                while (!(_objInnermostException.InnerException == null))
                {
                    _objInnermostException = _objInnermostException.InnerException;
                }
                ExceptionInfo _exceptionInfo = Exceptions.GetExceptionInfo(_objInnermostException);

                try
                {
                    m_AssemblyVersion = Globals.glbAppVersion;
                }
                catch
                {
                    m_AssemblyVersion = "-1";
                }

                try
                {
                    m_PortalID   = _portalSettings.PortalId;
                    m_PortalName = _portalSettings.PortalName;
                }
                catch
                {
                    m_PortalID   = -1;
                    m_PortalName = "";
                }

                try
                {
                    UserInfo objUserInfo = UserController.GetCurrentUserInfo();
                    m_UserID = objUserInfo.UserID;
                }
                catch
                {
                    m_UserID = -1;
                }

                try
                {
                    if (m_UserID != -1)
                    {
                        UserInfo objUserInfo = UserController.GetUser(m_PortalID, m_UserID, false);
                        if (objUserInfo != null)
                        {
                            m_UserName = objUserInfo.Username;
                        }
                        else
                        {
                            m_UserName = "";
                        }
                    }
                    else
                    {
                        m_UserName = "";
                    }
                }
                catch
                {
                    m_UserName = "";
                }

                try
                {
                    m_ActiveTabID = _portalSettings.ActiveTab.TabID;
                }
                catch (Exception)
                {
                    m_ActiveTabID = -1;
                }

                try
                {
                    m_ActiveTabName = _portalSettings.ActiveTab.TabName;
                }
                catch (Exception)
                {
                    m_ActiveTabName = "";
                }

                try
                {
                    m_RawURL = _context.Request.RawUrl;
                }
                catch
                {
                    m_RawURL = "";
                }

                try
                {
                    m_AbsoluteURL = _context.Request.Url.AbsolutePath;
                }
                catch
                {
                    m_AbsoluteURL = "";
                }

                try
                {
                    m_AbsoluteURLReferrer = _context.Request.UrlReferrer.AbsoluteUri;
                }
                catch
                {
                    m_AbsoluteURLReferrer = "";
                }

                try
                {
                    m_UserAgent = _context.Request.UserAgent;
                }
                catch (Exception)
                {
                    m_UserAgent = "";
                }

                try
                {
                    ProviderConfiguration objProviderConfiguration = ProviderConfiguration.GetProviderConfiguration("data");
                    string strTypeName = ((Provider)objProviderConfiguration.Providers[objProviderConfiguration.DefaultProvider]).Type;
                    m_DefaultDataProvider = strTypeName;
                }
                catch (Exception)
                {
                    m_DefaultDataProvider = "";
                }

                try
                {
                    m_ExceptionGUID = Guid.NewGuid().ToString();
                }
                catch (Exception)
                {
                    m_ExceptionGUID = "";
                }

                try
                {
                    m_FileName = _exceptionInfo.FileName;
                }
                catch
                {
                    m_FileName = "";
                }

                try
                {
                    m_FileLineNumber = _exceptionInfo.FileLineNumber;
                }
                catch
                {
                    m_FileLineNumber = -1;
                }

                try
                {
                    m_FileColumnNumber = _exceptionInfo.FileColumnNumber;
                }
                catch
                {
                    m_FileColumnNumber = -1;
                }

                try
                {
                    m_Method = _exceptionInfo.Method;
                }
                catch
                {
                    m_Method = "";
                }

                try
                {
                    m_StackTrace = this.StackTrace;
                }
                catch (Exception)
                {
                    m_StackTrace = "";
                }

                try
                {
                    m_Message = this.Message;
                }
                catch (Exception)
                {
                    m_Message = "";
                }

                try
                {
                    m_Source = this.Source;
                }
                catch (Exception)
                {
                    m_Source = "";
                }
            }
            catch (Exception)
            {
                m_PortalID            = -1;
                m_UserID              = -1;
                m_AssemblyVersion     = "-1";
                m_ActiveTabID         = -1;
                m_ActiveTabName       = "";
                m_RawURL              = "";
                m_AbsoluteURL         = "";
                m_AbsoluteURLReferrer = "";
                m_UserAgent           = "";
                m_DefaultDataProvider = "";
                m_ExceptionGUID       = "";
                m_FileName            = "";
                m_FileLineNumber      = -1;
                m_FileColumnNumber    = -1;
                m_Method              = "";
                m_StackTrace          = "";
                m_Message             = "";
                m_Source              = "";
            }
        }