Ejemplo n.º 1
0
        /// <summary>
        /// Inserts a user into the database to keep track of how many users RemindMe has (after version 2.6.02)
        /// </summary>
        /// <param name="uniqueString"></param>
        public static void InsertOrUpdateUser(string uniqueString)
        {
            try
            {
                new Thread(() =>
                {
                    //Don't do anything without internet
                    if (!BLIO.HasInternetAccess())
                    {
                        return;
                    }

                    if (!string.IsNullOrWhiteSpace(uniqueString))
                    {
                        DLOnlineDatabase.InsertOrUpdateUser(uniqueString, IOVariables.RemindMeVersion);
                    }
                    else
                    {
                        BLIO.Log("Invalid uniqueString version string parameter in BLOnlineDatabase.InsertUser(). String: " + uniqueString);
                    }
                }).Start();
            }
            catch (Exception exc)
            {
                BLIO.Log("BLOnlineDatabase.InsertUser() failed: exception occured: " + exc.ToString());
                BLIO.WriteError(exc, "BLOnlineDatabase.InsertUser() failed: exception occured: " + exc.ToString(), false);
            }
        }
Ejemplo n.º 2
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)
        {
            try
            {
                new Thread(() =>
                {
                    //Don't do anything without internet
                    if (!BLIO.HasInternetAccess())
                    {
                        return;
                    }

                    if (ex != null && ex.Message != null && ex.StackTrace != null && exceptionDate != null)
                    {
                        DLOnlineDatabase.AddException(ex, exceptionDate, pathToSystemLog);
                    }
                    else
                    {
                        BLIO.Log("BLOnlineDatabase.AddException() failed: parameter(s) null");
                    }
                }).Start();
            }
            catch (Exception exc)
            {
                BLIO.Log("BLOnlineDatabase.AddException() failed: exception occured: " + exc.ToString());
                BLIO.WriteError(exc, "BLOnlineDatabase.AddException() failed: exception occured: " + exc.ToString(), false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a new entry to the database where a user updates their RemindMe version
        /// </summary>
        /// <param name="updateDate">Date of update</param>
        /// <param name="previousVersion">The previously installed RemindMe version on his/her machine</param>
        /// <param name="updateVersion">The version the user updated to</param>
        public static void AddNewUpgrade(DateTime updateDate, string previousVersion, string updateVersion)
        {
            try
            {
                new Thread(() =>
                {
                    //Don't do anything without internet
                    if (!BLIO.HasInternetAccess())
                    {
                        return;
                    }

                    if (!string.IsNullOrWhiteSpace(previousVersion) && !string.IsNullOrWhiteSpace(updateVersion))
                    {
                        DLOnlineDatabase.AddNewUpgrade(updateDate, previousVersion, updateVersion);
                    }
                    else
                    {
                        BLIO.Log("Invalid previous/update version string parameter in BLOnlineDatabase.AddNewUpdate()");
                    }
                }).Start();
            }
            catch (Exception exc)
            {
                BLIO.Log("BLOnlineDatabase.AddNewUpdate() failed: exception occured: " + exc.ToString());
                BLIO.WriteError(exc, "BLOnlineDatabase.AddNewUpdate() failed: exception occured: " + exc.ToString(), false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Inserts the contents of the local errorlog.txt into the database
        /// </summary>
        /// <param name="uniqueString">The unique user identifier</param>
        /// <param name="logContents">The contents of errorlog.txt</param>
        /// <param name="lineCount">The amount of lines in errorlog.txt</param>
        public static void InsertLocalErrorLog(string uniqueString, string logContents, int lineCount)
        {
            try
            {
                new Thread(() =>
                {
                    //Don't do anything without internet
                    if (!BLIO.HasInternetAccess())
                    {
                        return;
                    }

                    if (!string.IsNullOrWhiteSpace(uniqueString))
                    {
                        DLOnlineDatabase.InsertLocalErrorLog(uniqueString, logContents, lineCount);
                    }
                    else
                    {
                        BLIO.Log("Invalid uniqueString version string parameter in BLOnlineDatabase.InsertLocalErrorLog(). String: " + uniqueString);
                    }
                }).Start();
            }
            catch (Exception exc)
            {
                BLIO.Log("BLOnlineDatabase.InsertLocalErrorLog() failed: exception occured: " + exc.ToString());
                BLIO.WriteError(exc, "BLOnlineDatabase.InsertLocalErrorLog() failed: exception occured: " + exc.ToString(), false);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Inserts an e-mail into the database. In case sending the e-mail didn't work, it is still registered in the db
        /// </summary>
        /// <param name="uniqueString">The user's unique string</param>
        /// <param name="emailMessage">The e-mail message</param>
        /// <param name="emailSubject">The e-mail subject</param>
        /// <param name="eMailAddress">The users e-mail address. This is optional</param>
        public static void InsertEmailAttempt(string uniqueString, string emailMessage, string emailSubject, string eMailAddress = "")
        {
            try
            {
                new Thread(() =>
                {
                    //Don't do anything without internet
                    if (!BLIO.HasInternetAccess())
                    {
                        return;
                    }

                    if (!string.IsNullOrWhiteSpace(uniqueString))
                    {
                        DLOnlineDatabase.InsertEmailAttempt(uniqueString, emailMessage, emailSubject, eMailAddress);
                    }
                    else
                    {
                        BLIO.Log("Invalid uniqueString version string parameter in BLOnlineDatabase.InsertEmailAttempt(). String: " + uniqueString);
                    }

                    MessageCount++;
                }).Start();
            }
            catch (Exception exc)
            {
                BLIO.Log("BLOnlineDatabase.InsertEmailAttempt() failed: exception occured: " + exc.ToString());
                BLIO.WriteError(exc, "BLOnlineDatabase.InsertEmailAttempt() failed: exception occured: " + exc.ToString(), false);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Export a list of reminders to a .remindme file
        /// </summary>
        /// <param name="reminders"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public static Exception ExportReminders(List <Reminder> reminders, string path)
        {
            try
            {
                if (!string.IsNullOrEmpty(path))
                {
                    SerializeRemindersToFile(reminders, path + "\\Backup reminders " + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second + ".remindme");
                }

                new Thread(() =>
                {
                    //Log an entry to the database, for data!
                    try
                    {
                        BLOnlineDatabase.ExportCount++;
                    }
                    catch (ArgumentException ex)
                    {
                        BLIO.Log("Exception at BLOnlineDatabase.ExportCount++. -> " + ex.Message);
                        BLIO.WriteError(ex, ex.Message, true);
                    }
                }).Start();

                return(null);
            }
            catch (UnauthorizedAccessException ex)
            {
                return(ex);
            }
            catch (Exception ex)
            {
                return(ex);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Inserts a user into the database to keep track of how many users RemindMe has (after version 2.6.02)
        /// </summary>
        /// <param name="uniqueString"></param>
        public static void InsertOrUpdateUser(string uniqueString)
        {
            new Thread(() =>
            {
                try
                {
                    //Don't do anything without internet
                    if (!BLIO.HasInternetAccess())
                        return;

                    if (BLIO.LastLogMessage != null && !BLIO.LastLogMessage.Contains("Updating user"))
                        BLIO.Log("Updating user");

                    if (!string.IsNullOrWhiteSpace(uniqueString))
                        DLOnlineDatabase.InsertOrUpdateUser(uniqueString, IOVariables.RemindMeVersion);
                    else
                        BLIO.Log("Invalid uniqueString version string parameter in BLOnlineDatabase.InsertUser(). String: " + uniqueString);

                }
                catch (Exception exc)
                {
                    BLIO.Log("BLOnlineDatabase.InsertUser() failed: exception occured: " + exc.GetType().ToString());
                    BLIO.WriteError(exc, "BLOnlineDatabase.InsertUser() failed: exception occured: " + exc.ToString(), false);
                }
            }).Start();
        }       
Ejemplo n.º 8
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();
        }