Beispiel #1
0
        /// <summary>
        /// Logs an exception to the online database
        /// </summary>
        /// <param name="ex">The exception that is going to be logged</param>
        /// <param name="exceptionDate">The date the exception is logged at</param>
        public static void AddException(Exception ex, DateTime exceptionDate, string pathToSystemLog, string customMessage = null)
        {
            new Thread(() =>
            {
                try
                {
                    //Don't do anything without internet
                    if (!BLIO.HasInternetAccess())
                       return;
                   
                    //Don't log these kind of exceptions
                    if (ex is System.Data.Entity.Core.EntityException || ex is System.Data.Entity.Core.EntityCommandExecutionException
                     || ex is System.Data.SqlClient.SqlException)
                    {
                        BLIO.Log("AddException() Skipped. Exception is " + ex.GetType().ToString());
                        return;
                    }

                    //Write the system log contents to the .txt file, so that the database record contains the latest system log info
                    BLIO.DumpLogTxt(); 

                    if (ex != null && ex.Message != null && ex.StackTrace != null && exceptionDate != null)
                        DLOnlineDatabase.AddException(ex, exceptionDate, pathToSystemLog, customMessage);
                    else
                        BLIO.Log("BLOnlineDatabase.AddException() failed: parameter(s) null");

                }
                catch (Exception exc)
                {
                    BLIO.Log("BLOnlineDatabase.AddException() failed: exception occured: " + exc.GetType().ToString());
                    BLIO.WriteError(exc, "BLOnlineDatabase.AddException() failed: exception occured: " + exc.ToString(), false);
                }
            }).Start();
        }