Ejemplo n.º 1
0
        /// <summary>
        /// This Method will log Exception and Display Error message to the user
        /// </summary>
        /// <param name="ex">ex Object, containing Exception Information</param>
        /// <param name="category">Category- General</param>
        /// <param name="level">Logging Level- error, Warning or Information</param>
        /// <returns>bool value- True/False</returns>
        /// <CreatedBy>Piyush</CreatedBy>
        /// <CreatedOn>2nd August 2007</CreatedOn>
        public static bool LogException(System.Exception ex, LoggingCategory category, LoggingLevel level, Control Ctrl)
        {
            BaseActivityPage ObjectActivityPage = null;

            try
            {
                if (ex.GetType().FullName != "System.Threading.ThreadAbortException")
                {
                    ExceptionManager.Publish(ex);
                }
                //ExceptionManager.Publish(ex);
                // Following line of code added by Piyush on 2nd August 2007, so as to check Concurrency and SQl Exception and display the Exception to the user
                ObjectActivityPage = new BaseActivityPage();
                string ParseMessage = ex.Message;

                // Code Added by Piyush on 6th September 2007 so as to check error number emerged in case of business rule voilation
                string ErrorNumber = "";
                if (ParseMessage.IndexOf("*****") > 0)
                {
                    ErrorNumber = ParseMessage.Substring(0, ParseMessage.IndexOf("*****"));
                    Int32 Index = ParseMessage.IndexOf("*****") + 5;
                    ParseMessage = ParseMessage.Substring(Index);
                    ParseMessage = ParseMessage.Substring(0, ParseMessage.IndexOf("*****"));
                    ObjectActivityPage.ShowError(ParseMessage, true, Ctrl);
                }
                // Code Addition ends here by Piyush on 6th September 2007 so as to check error number emerged in case of business rule voilation
                else
                {
                    if (ex.Message.IndexOf("Concurrency") != -1)
                    {
                        ObjectActivityPage.ShowError("The information you are updating has been changed by another user. Please refresh the information you are updating.", true, Ctrl);
                    }
                    else if (ParseMessage.IndexOf("System.Data.SqlClient.SqlException:") > 0)
                    {
                        int SubstringLen = ParseMessage.IndexOf("\n") - ParseMessage.IndexOf("System.Data.SqlClient.SqlException:");
                        ParseMessage = ParseMessage.Substring(ParseMessage.IndexOf("System.Data.SqlClient.SqlException:") + 35, SubstringLen - 35);
                        ObjectActivityPage.ShowError(ParseMessage, true, Ctrl);
                    }

                    else
                    {
                        ObjectActivityPage.ShowError("Error Occurred - Please Contact Your System Administrator!", true, Ctrl);
                    }
                    // Addition ends here by Piyush on 2nd August 2007, so as to check Concurrency and SQl Exception and display the Exception to the user
                }
            }
            catch
            {
                string str = ex.Message.ToString();
            }
            finally
            {
                ObjectActivityPage = null;
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This Method will log Exception and Display Error message to the user
        /// </summary>
        /// <param name="ex">ex Object, containing Exception Information</param>
        /// <param name="category">Category- General</param>
        /// <param name="level">Logging Level- error, Warning or Information</param>
        /// <returns>bool value- True/False</returns>
        /// <CreatedBy>Chandan</CreatedBy>
        /// <CreatedOn>Feb 13 2008</CreatedOn>
        public static bool LogException(System.Exception ex, LoggingCategory category, LoggingLevel level, Control Ctrl)
        {
            BaseActivityPage ObjectActivityPage = null;

            try
            {
                ExceptionManager.Publish(ex);
                ObjectActivityPage = new BaseActivityPage();
                string ParseMessage = ex.Message;

                string ErrorNumber = "";
                if (ParseMessage.IndexOf("*****") > 0)
                {
                    ErrorNumber = ParseMessage.Substring(0, ParseMessage.IndexOf("*****"));
                    Int32 Index = ParseMessage.IndexOf("*****") + 5;
                    ParseMessage = ParseMessage.Substring(Index);
                    ParseMessage = ParseMessage.Substring(0, ParseMessage.IndexOf("*****"));
                    ObjectActivityPage.ShowError(ParseMessage, true, Ctrl);
                }
                else
                {
                    if (ex.Message.IndexOf("Concurrency") != -1)
                    {
                        ObjectActivityPage.ShowError("The information you are updating has been changed by another user. Please refresh the information you are updating.", true, Ctrl);
                    }
                    else if (ParseMessage.IndexOf("System.Data.SqlClient.SqlException:") > 0)
                    {
                        int SubstringLen = ParseMessage.IndexOf("\n") - ParseMessage.IndexOf("System.Data.SqlClient.SqlException:");
                        ParseMessage = ParseMessage.Substring(ParseMessage.IndexOf("System.Data.SqlClient.SqlException:") + 35, SubstringLen - 35);
                        ObjectActivityPage.ShowError(ParseMessage, true, Ctrl);
                    }

                    else
                    {
                        ObjectActivityPage.ShowError("Error Occurred - Please Contact Your System Administrator!", true, Ctrl);
                    }
                }
            }
            catch
            {
                string str = ex.Message.ToString();
                if (ObjectActivityPage == null)
                {
                    ObjectActivityPage = new BaseActivityPage();
                }
                ObjectActivityPage.ShowError("Error Occurred - Please Contact Your System Administrator!", true);
            }
            finally
            {
                ObjectActivityPage = null;
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This function logs the exception along with logging the Verbose Mode
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="category"></param>
        /// <param name="level"></param>
        /// <param name="VerboseMode"></param>
        /// <returns></returns>
        /// <CreatedBy>Chandan</CreatedBy>
        /// <CreatedOn>Feb 13 2008</CreatedOn>
        public static bool LogException(System.Exception ex, LoggingCategory category, LoggingLevel level, string VerboseMode)
        {
            BaseActivityPage ObjectActivityPage = null;

            try
            {
                ex.Data["CustomExceptionInformation"] = VerboseMode;
                ExceptionManager.Publish(ex);
                return(true);
            }
            catch
            {
                string str = ex.Message.ToString();
                ObjectActivityPage = new BaseActivityPage();
                ObjectActivityPage.ShowError("Error Occurred - Please Contact Your System Administrator!", true);
                throw;
            }
            finally
            {
                ObjectActivityPage = null;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This Method will log Exception and Display Error message to the user
        /// </summary>
        /// <param name="ex">ex Object, containing Exception Information</param>
        /// <param name="category">Category- General</param>
        /// <param name="level">Logging Level- error, Warning or Information</param>
        /// <returns>bool value- True/False</returns>
        /// <ModifiedBy>Piyush</ModifiedBy>
        /// <ModifiedOn>2nd August 2007</ModifiedOn>
        public static bool LogException(System.Exception ex, LoggingCategory category, LoggingLevel level)
        {
            BaseActivityPage ObjectActivityPage = null;

            try
            {
                ExceptionManager.Publish(ex);
                // Following line of code added by Piyush on 2nd August 2007, so as to check Concurrency and SQl Exception and display the Exception to the user
                ObjectActivityPage = new BaseActivityPage();
                string ParseMessage = ex.Message;
                if (ex.Message.IndexOf("Concurrency") != -1)
                {
                    ObjectActivityPage.ShowError("The information you are updating has been changed by another user. Please refresh the information you are updating.", true);
                }
                else if (ParseMessage.IndexOf("System.Data.SqlClient.SqlException:") > 0)
                {
                    int SubstringLen = ParseMessage.IndexOf("\n") - ParseMessage.IndexOf("System.Data.SqlClient.SqlException:");
                    ParseMessage = ParseMessage.Substring(ParseMessage.IndexOf("System.Data.SqlClient.SqlException:") + 35, SubstringLen - 35);
                    ObjectActivityPage.ShowError(ParseMessage, true);
                }
                else
                {
                    ObjectActivityPage.ShowError("Error Occurred - Please Contact Your System Administrator!", true);
                }
                // Addition ends here by Piyush on 2nd August 2007, so as to check Concurrency and SQl Exception and display the Exception to the user
            }
            catch
            {
                string str = ex.Message.ToString();
                //if (MessageBox.Show("Event Log is full Press Yes if you want to clear event log", "Streamline.ProviderClaim", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                //{
                //    System.Diagnostics.EventLog objLog = new System.Diagnostics.EventLog("Application");
                //    objLog.Clear();
                //    ExceptionManager.Publish(ex);

                //}
            }
            finally
            {
                ObjectActivityPage = null;
            }



            //			string message="";
            //
            //			message = "Error Message: " + ex.Message + "\n";
            //			message += "Source of Error: " + ex.Source + "\n";
            //			message += "Stack Trace: " +  ex.StackTrace;
            //
            //			// TODO: Implement Method - LogManager.LogMessage()
            //			if(_AuditLogLevel == level  || _AuditLogLevel < level)
            //			{
            //				LogEntry logEntry	= new LogEntry();
            //				logEntry.Message	= "Starting up the application";
            //				logEntry.Category = System.Convert.ToString(category);
            //				Logger.Write(message,System.Convert.ToString(category));
            //
            ////				MSDE obj = new MSDE();
            ////				obj.InsertIntoLog(logEntry);
            //			}
            //
            //			if(_AuditQueueLevel == level  || _AuditQueueLevel < level)
            //			{
            //				//Circular queue;
            //
            //			}
            return(true);
        }