/// <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); } }
/// <summary> /// Gets the RemindMe messages from the database, sent by the creator of RemindMe /// </summary> public static Database.Entity.RemindMeMessages GetRemindMeMessageById(int id) { //Don't do anything without internet if (!BLIO.HasInternetAccess()) { return(null); } Data_Access_Layer.RemindMeMessages dbObject = DLOnlineDatabase.GetRemindMeMessageById(id); if (dbObject == null) { return(null); } Database.Entity.RemindMeMessages message = new Database.Entity.RemindMeMessages(); message.Id = dbObject.Id; message.MeantForSpecificVersion = dbObject.MeantForSpecificVersion; message.Message = dbObject.Message; message.NotificationDuration = dbObject.NotificationDuration; message.NotificationOnTop = dbObject.NotificationOnTop; message.NotificationType = dbObject.NotificationType; message.ReadByAmountOfUsers = dbObject.ReadByAmountOfUsers; message.DateOfCreation = dbObject.DateOfCreation; return(message); }
/// <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); } }
/// <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); } }
/// <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); } }
/// <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); } }
/// <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(); }
/// <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(); }