private void AddRecords() { SqLiteUtilities utilities; int maxValue = 999; utilities = new SqLiteUtilities(dbPath); try { utilities.OpenConnection(); for (int i = 0; i <= maxValue; i++) { utilities.AddRecord("test", "person", i, "12345678901234567890123456789012345678901234567890"); } utilities.CloseConnection(); } catch (Exception ex) { var dlgException = new UIAlertView("Error", string.Format("An error has occurred adding records: " + ex.Message), new UIAlertViewDelegate(), "OK"); dlgException.Show(); return; } var dlgAlert = new UIAlertView("Success", string.Format("All records written to database"), new UIAlertViewDelegate(), "OK"); dlgAlert.Show(); return; }
public void SetDisplayType(SqLiteDisplayType displayType) { var directory = DependencyService.Get <IDirectoryLocation>().Directory; var utilities = new SqLiteUtilities(directory); utilities.OpenConnection(); switch (displayType) { case SqLiteDisplayType.ShowAll: ListItems = utilities.GetAllRecords(); break; case SqLiteDisplayType.ShowContaining1: ListItems = utilities.GetRecordsWith1(); break; default: throw new NotImplementedException("Invalid SqLiteDisplayType"); } utilities.CloseConnection(); }
private void CleanUp() { var sqlUtilities = new SqLiteUtilities(dbPath); try { sqlUtilities.DeleteFile(); sqlUtilities.OpenConnection(); sqlUtilities.CreateTable(); sqlUtilities.CloseConnection(); using (var fUtilities = new FileUtilities(dbPath)) { fUtilities.DeleteFile(); fUtilities.CreateFile(); fUtilities.CloseFile(); } } catch (Exception ex) { var dlgException = new UIAlertView("Error", string.Format("An error has occurred: " + ex.Message), new UIAlertViewDelegate(), "OK"); dlgException.Show(); return; } var dlgAlert = new UIAlertView("Cleanup and Prepare for Tests Successful", string.Format("Completed test setup"), new UIAlertViewDelegate(), "OK"); dlgAlert.Show(); return; }
private void LoadRecords() { SqLiteUtilities utilities; utilities = new SqLiteUtilities(this.dbPath); try { utilities.OpenConnection(); if (displayType == SqLiteDisplayType.ShowAll) { records = utilities.GetAllRecords(); } else { records = utilities.GetRecordsWith1(); } utilities.CloseConnection(); } catch (Exception ex) { // Bah, it's not production code... } }
private void AddRecords() { var directory = DependencyService.Get<IDirectoryLocation>().Directory; SqLiteUtilities utilities; int maxValue = 999; utilities = new SqLiteUtilities(directory); try { utilities.OpenConnection(); for (int i = 0; i <= maxValue; i++) { utilities.AddRecord("test", "person", i, "12345678901234567890123456789012345678901234567890"); } utilities.CloseConnection(); } catch (Exception ex) { if (DisplayMessage != null) { DisplayMessage(this, new DisplayMessageEventArgs( "Error", string.Format("An error has occurred adding records: {0}", ex.Message))); } return; } if (DisplayMessage != null) { DisplayMessage(this, new DisplayMessageEventArgs( "Success", "All records written to database")); } return; }
private void CleanUp() { var directory = DependencyService.Get<IDirectoryLocation>().Directory; var sqlUtilities = new SqLiteUtilities(directory); try { sqlUtilities.DeleteFile(); sqlUtilities.OpenConnection(); sqlUtilities.CreateTable(); sqlUtilities.CloseConnection(); using (var fUtilities = new FileUtilities(directory)) { fUtilities.DeleteFile(); fUtilities.CreateFile(); fUtilities.CloseFile(); } } catch (Exception ex) { if (DisplayMessage != null) DisplayMessage(this, new DisplayMessageEventArgs( "Error", string.Format("An error has occurred: {0}", ex.Message))); return; } if (DisplayMessage != null) DisplayMessage(this, new DisplayMessageEventArgs( "Cleanup and Prepare for Tests Successful", "Completed test setup")); return; }