Ejemplo n.º 1
0
        }         //

        public static int GetAppKeyValue(string keyName, int defaultValue)
        {
            int appValue = -1;

            try
            {
                appValue = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings[keyName]);

                // If we get here, then number is an integer, otherwise we will use the default
            }
            catch
            {
                appValue = defaultValue;
                if (HasMessageBeenPreviouslySent(keyName) == false)
                {
                    LoggingHelper.LogError(string.Format("@@@@ Error on appKey: {0},  using default of: {1}", keyName, defaultValue));
                }
            }

            return(appValue);
        }         //
Ejemplo n.º 2
0
        }         //

        public static decimal GetAppKeyValue(string keyName, decimal defaultValue)
        {
            decimal appValue = -1;

            try
            {
                var dv = GetAppKeyValue(keyName, "");
                appValue = decimal.Parse(dv);

                // If we get here, then number is an decimal, otherwise we will use the default
            }
            catch
            {
                appValue = defaultValue;
                if (HasMessageBeenPreviouslySent(keyName) == false)
                {
                    LoggingHelper.LogError(string.Format("@@@@ Error on appKey: {0},  using default of: {1}", keyName, defaultValue));
                }
            }

            return(appValue);
        }         //
Ejemplo n.º 3
0
        }         //

        /// <summary>
        /// Gets the value of an application key from web.config. Returns the default value if not found
        /// </summary>
        /// <remarks>This property is explicitly thread safe.</remarks>
        public static string GetAppKeyValue(string keyName, string defaultValue)
        {
            string appValue = "";

            try
            {
                appValue = System.Configuration.ConfigurationManager.AppSettings[keyName];
                if (appValue == null)
                {
                    appValue = defaultValue;
                }
            }
            catch
            {
                appValue = defaultValue;
                if (HasMessageBeenPreviouslySent(keyName) == false)
                {
                    LoggingHelper.LogError(string.Format("@@@@ Error on appKey: {0},  using default of: {1}", keyName, defaultValue));
                }
            }

            return(appValue);
        }         //
Ejemplo n.º 4
0
        /// <summary>
        /// Format an exception and message, and then log it
        /// </summary>
        /// <param name="ex">Exception</param>
        /// <param name="message">Additional message regarding the exception</param>
        /// <param name="notifyAdmin">If true, an email will be sent to admin</param>
        public static void LogError(Exception ex, string message, bool notifyAdmin, string subject = "Credential Finder Exception encountered")
        {
            //string userId = "";
            string sessionId    = "unknown";
            string remoteIP     = "unknown";
            string path         = "unknown";
            string queryString  = "unknown";
            string url          = "unknown";
            string parmsString  = "";
            string lRefererPage = "";

            try
            {
                if (UtilityManager.GetAppKeyValue("notifyOnException", "no").ToLower() == "yes")
                {
                    notifyAdmin = true;
                }
                if (HttpContext.Current != null)
                {
                    sessionId = HttpContext.Current.Session.SessionID.ToString();
                    remoteIP  = HttpContext.Current.Request.ServerVariables["REMOTE_HOST"];

                    if (HttpContext.Current.Request.UrlReferrer != null)
                    {
                        lRefererPage = HttpContext.Current.Request.UrlReferrer.ToString();
                    }
                    string serverName = UtilityManager.GetAppKeyValue("serverName", HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]);
                    path = serverName + HttpContext.Current.Request.Path;

                    if (IsValidRequestString() == true)
                    {
                        queryString = HttpContext.Current.Request.Url.AbsoluteUri.ToString();
                        //url = GetPublicUrl( queryString );

                        url = HttpContext.Current.Server.UrlDecode(queryString);
                        //if ( url.IndexOf( "?" ) > -1 )
                        //{
                        //    parmsString = url.Substring( url.IndexOf( "?" ) + 1 );
                        //    url = url.Substring( 0, url.IndexOf( "?" ) );
                        //}
                    }
                    else
                    {
                        url = "suspicious url encountered!!";
                    }
                }
                //????
                //userId = WUM.GetCurrentUserid();
            }
            catch
            {
                //eat any additional exception
            }

            try
            {
                string errMsg = message +
                                "\r\nType: " + ex.GetType().ToString() + ";" +
                                "\r\nSession Id - " + sessionId + "____IP - " + remoteIP +
                                "\r\rReferrer: " + lRefererPage + ";" +
                                "\r\nException: " + ex.Message.ToString() + ";" +
                                "\r\nStack Trace: " + ex.StackTrace.ToString() +
                                "\r\nServer\\Template: " + path +
                                "\r\nUrl: " + url;

                if (ex.InnerException != null && ex.InnerException.Message != null)
                {
                    errMsg += "\r\n****Inner exception: " + ex.InnerException.Message;

                    if (ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message != null)
                    {
                        errMsg += "\r\n@@@@@@Inner-Inner exception: " + ex.InnerException.InnerException.Message;
                    }
                }

                if (parmsString.Length > 0)
                {
                    errMsg += "\r\nParameters: " + parmsString;
                }

                LoggingHelper.LogError(errMsg, notifyAdmin, subject);
            }
            catch
            {
                //eat any additional exception
            }
        }         //