예제 #1
0
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of ExceptionLogs</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			07/27/2010 11:57:21 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static ExceptionLogs PopulateObjectsFromReader(IDataReader rdr,string connectionstring)
        {
            ExceptionLogs list = new ExceptionLogs();

            while (rdr.Read())
            {
                ExceptionLog obj = new ExceptionLog(connectionstring);
                PopulateObjectFromReader(obj,rdr);
                list.Add(obj);
            }
            return list;
        }
예제 #2
0
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of ExceptionLogs</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			07/27/2010 11:57:21 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static ExceptionLogs PopulateObjectsFromReaderWithCheckingReader(IDataReader rdr, DatabaseHelper oDatabaseHelper,string connectionstring)
        {
            ExceptionLogs list = new ExceptionLogs();

            if (rdr.Read())
            {
                ExceptionLog obj = new ExceptionLog(connectionstring);
                PopulateObjectFromReader(obj, rdr);
                list.Add(obj);
                while (rdr.Read())
                {
                    obj = new ExceptionLog(connectionstring);
                    PopulateObjectFromReader(obj, rdr);
                    list.Add(obj);
                }
                oDatabaseHelper.Dispose();
                return list;
            }
            else
            {
                oDatabaseHelper.Dispose();
                return null;
            }
        }
예제 #3
0
        //public void Page_Error(object sender, EventArgs e)
        //{
        //    // Get the source exception details
        //    Exception ex = Server.GetLastError();
        //    // Write the details to the event log for diagnostics
        //    ExceptionLogEntity objExlog = new ExceptionLogEntity();
        //    objExlog.TYPE = ex.GetType().FullName;
        //    objExlog.MESSAGE = ex.Message;
        //    objExlog.STACKTRACE = ex.StackTrace;
        //    objExlog.THREADID = System.Threading.Thread.CurrentThread.ManagedThreadId.ToString();
        //    objExlog.THREADUSER = System.Threading.Thread.CurrentPrincipal.Identity.Name;
        //    objExlog.EXCEPTIONSOURCE = ex.Source;
        //    objExlog.MACHINENAME = Environment.MachineName;
        //    objExlog.APPDOMAINNAME = Environment.UserDomainName;
        //    int result = BLLExceptionLog.InsertExceptionLog(objExlog);
        //    // Prevent the exception from propagating and generating an
        //    // application level event (Application.Error)
        //    Server.ClearError();
        //    Response.Redirect(@"..\Error.aspx");
        //}
        protected void Page_Error(object sender, EventArgs e)
        {
            try
            {
                if (Session["ConnectionString"] != null)
                {
                    string ConnectionString = Session["ConnectionString"].ToString();
                    // At this point we have information about the error
                    //this is used to log the exception in event logs
                    HttpContext ctx = HttpContext.Current;
                    Exception ex = ctx.Server.GetLastError();
                    EventLogPermission logPerm =
                        new System.Diagnostics.EventLogPermission(EventLogPermissionAccess.Write,
                                                                  Environment.MachineName);
                    EventLog.WriteEntry("Reply Positive", ex.Message, System.Diagnostics.EventLogEntryType.Error);

                    //this is used to log the exception in db
                    ExceptionLog objExceptionlog = new ExceptionLog(ConnectionString);
                    objExceptionlog.Date = DateTime.Now;
                    objExceptionlog.Message = ex.Message;
                    objExceptionlog.StackTrace = ex.ToString();
                    objExceptionlog.Type = EventLogEntryType.Error.ToString();
                    objExceptionlog.Insert();
                    Server.ClearError();
                    Response.Redirect(@"..\pages\ErrorPage.htm");
                }
            }
            catch (Exception ex)
            {

            }
        }