/// <summary> /// Asynchronously logs an AppEvent in the SQLite database /// </summary> /// <param name="e">AppEvent to log</param> /// <returns>Number of rows added to database</returns> /// <remarks>Should return 1 for most calls</remarks> public static async Task <int> LogEventAsync(AppEvent e) { try { if (conn == null) { conn = new SQLiteAsyncConnection(path); } await conn.CreateTableAsync <AppEvent>(); Debug.Write($"PATH: {path}"); Debug.Write($"Inserted new {e.Type} event!"); return(await conn.InsertAsync(e)); } catch (Exception ex) { Debug.Write("Couldn't insert event!"); Debug.Write(ex.StackTrace); return(-1); } }
/// <summary> /// Static form of <see cref="Deserialize(char)"/> for deserializing other AppEvents /// </summary> /// <param name="e"><see cref="AppEvent"/> to deserialize</param> /// <param name="d">Delimiter <see langword="char"/> to use</param> /// <returns></returns> public static string Deserialize(AppEvent e, char d) { return(Enum.GetName(typeof(EventType), e.Type) + d + e.TimeStamp + d + e.Info); }