private static SQLiteAsyncConnection CreateDatabaseAsync() { // Create a new connection try { var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Storage.SQLite"); var connectionString = new SQLiteConnectionString(dbPath, true); var dbLockedCon = new SQLiteConnectionWithLock(platform, connectionString); var db = new SQLiteAsyncConnection(() => dbLockedCon); //Create the tables that do not exist Type[] tables = { typeof(Folders) , typeof(Accounts) , typeof(Emails) , typeof(EmailFrom) , typeof(EmailSender) , typeof(EmailReplyTo) , typeof(Settings) }; var d = db.CreateTablesAsync(tables).Result; return(db); } catch (Exception e) { var mess = e.Message; throw; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var dbFilePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "sqliteCipher.db3"); var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); ISecureDatabase database = new MyDatabase(platform, dbFilePath, new CryptoService()); var keySeed = "my very very secure key seed. You should use PCLCrypt strong random generator for this"; var user = new SampleUser() { Name = "Has AlTaiar", Password = "******", Bio = "Very cool guy :) ", Id = Guid.NewGuid().ToString() }; var inserted = database.SecureInsert <SampleUser>(user, keySeed); System.Diagnostics.Debug.WriteLine("Sample Object was inserted securely? {0} ", inserted); var userFromDb = database.SecureGet <SampleUser>(user.Id, keySeed); System.Diagnostics.Debug.WriteLine("User was accessed back from the database: username= {0}, password={1}", userFromDb.Name, userFromDb.Password); // need to establish a direct connection to the database and get the object to test the encrypted value. var directAccessDb = (SQLiteConnection)database; var userAccessedDirectly = directAccessDb.Query <SampleUser>("SELECT * FROM SampleUser").FirstOrDefault(); System.Diagnostics.Debug.WriteLine("User was accessed Directly from the database (with no decryption): username= {0}, password={1}", userAccessedDirectly.Name, userAccessedDirectly.Password); }
private static SQLiteAsyncConnection CreateDatabaseAsync() { // Create a new connection try { var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path,"Storage.SQLite"); var connectionString = new SQLiteConnectionString(dbPath, true); var dbLockedCon = new SQLiteConnectionWithLock(platform ,connectionString); var db = new SQLiteAsyncConnection(() => dbLockedCon); //Create the tables that do not exist Type[] tables = { typeof(Folders) , typeof(Accounts) , typeof(Emails) , typeof(EmailFrom) , typeof(EmailSender) , typeof(EmailReplyTo) , typeof(Settings) }; var d = db.CreateTablesAsync(tables).Result; return db; } catch(Exception e) { var mess = e.Message; throw; } }
public SQLiteConnection GetConnection() { var plat = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); SQLiteConnection conn = null; var path = GetFilePath(ApplicationData.Current.LocalCacheFolder.Path); try { conn = new SQLite.Net.SQLiteConnection(plat, path); } catch (Exception) { try { //Try to open the documents folder if the local cache folder is not available. path = GetFilePath(KnownFolders.DocumentsLibrary.Path); conn = new SQLiteConnection(plat, path); } catch (Exception) { //It is highly possible that the access to the documents library is denied, catch it. } } // Return the database connection return(conn); }
public SQLiteAsyncConnection GetConnection() { var plat = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); SQLiteAsyncConnection conn = null; var path = GetFilePath(ApplicationData.Current.LocalCacheFolder.Path); var connectionString = new SQLiteConnectionString(path, false); SQLiteConnectionWithLock synchronousConn; try { synchronousConn = new SQLiteConnectionWithLock(plat, connectionString); conn = new SQLiteAsyncConnection(() => synchronousConn); } catch (Exception) { try { //Try to open the documents folder if the local cache folder is not available. path = GetFilePath(KnownFolders.DocumentsLibrary.Path); connectionString = new SQLiteConnectionString(path, false); synchronousConn = new SQLiteConnectionWithLock(plat, connectionString); conn = new SQLiteAsyncConnection(() => synchronousConn); } catch (Exception) { //It is possible that the access to the documents library is denied, catch it. //TODO Handle exception } } // Return the database connection return(conn); }
public static string DB_PATH = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "THT.sqlite"));//DataBase Name /// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; if (!CheckFileExists("THT.sqlite").Result) { var plat = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); plat.SQLiteApi.Config(SQLite.Net.Interop.ConfigOption.MultiThread); using (var db = new SQLiteConnection(plat, DB_PATH)) { db.CreateTable <DeviceTypeEntity>(); db.CreateTable <DeviceEntity>(); db.CreateTable <InstructionEntity>(); db.CreateTable <ResultEntity>(); db.CreateTable <SiteEntity>(); db.CreateTable <UserEntity>(); db.CreateTable <DeviceDashboardItemEntity>(); db.CreateTable <DeviceInstructionFireEntity>(); db.CreateTable <SettingEntity>(); db.CreateTable <DashboardLogEntity>(); db.CreateTable <DashboardPriorityEntity>(); db.CreateTable <DashboardScenarioEntity>(); db.CreateTable <ErrorLogEntity>(); db.CreateTable <GPIOHistoryEntity>(); } } }
public static void Startup() { #if __MOBILE__ SQLite.Net.SQLiteConnection connection = null; SQLite.Net.Interop.ISQLitePlatform platform = null; string dbLocation = "videoDB.db3"; #endif #if XAMARIN_ANDROID var library = Environment.GetFolderPath(Environment.SpecialFolder.Personal); dbLocation = Path.Combine(library, dbLocation); platform = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid(); #elif XAMARIN_IOS var docsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var library = Path.Combine(docsPath, "../Library/"); dbLocation = Path.Combine(library, dbLocation); platform = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS(); #elif WINDOWS_PHONE platform = new SQLite.Net.Platform.WindowsPhone8.SQLitePlatformWP8(); #elif NETFX_CORE platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); #endif ServiceContainer.Register<IMovieService>(() => new MovieService()); #if __MOBILE__ connection = new SQLite.Net.SQLiteConnection(platform, dbLocation); ServiceContainer.Register<IStorageService>(() => new StorageService(connection)); ServiceContainer.Register<IMessageDialog>(() => new Video.PlatformSpecific.MessageDialog()); #endif ServiceContainer.Register<MoviesViewModel>(); ServiceContainer.Register<MovieViewModel>(); }
public DbConnection() { dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "AppStore.sqlite"); var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); connection = new SQLiteConnection(platform, dbPath); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var dbFilePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "sqliteCipher.db3"); var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); ISecureDatabase database = new MyDatabase(platform, dbFilePath, new CryptoService()); var keySeed = "my very very secure key seed. You should use PCLCrypt strong random generator for this"; var user = new SampleUser() { Name = "Has AlTaiar", Password = "******", Bio = "Very cool guy :) ", Id = Guid.NewGuid().ToString() }; var inserted = database.SecureInsert<SampleUser>(user, keySeed); System.Diagnostics.Debug.WriteLine("Sample Object was inserted securely? {0} ", inserted); var userFromDb = database.SecureGet<SampleUser>(user.Id, keySeed); System.Diagnostics.Debug.WriteLine("User was accessed back from the database: username= {0}, password={1}", userFromDb.Name, userFromDb.Password); // need to establish a direct connection to the database and get the object to test the encrypted value. var directAccessDb = (SQLiteConnection)database; var userAccessedDirectly = directAccessDb.Query<SampleUser>("SELECT * FROM SampleUser").FirstOrDefault(); System.Diagnostics.Debug.WriteLine("User was accessed Directly from the database (with no decryption): username= {0}, password={1}", userAccessedDirectly.Name, userAccessedDirectly.Password); }
public MainPage() { this.InitializeComponent(); var A = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); LoadApplication(new BlackCat.App()); }
public SQLiteConnection GetConnection() { var sqliteFilename = DatabaseName; string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename); var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var connection = new SQLiteConnection(platform, path); return(connection); }
public SQLiteConnection GetConnection() { var path = Path.Combine(ApplicationData. Current.LocalFolder.Path, Const.PhoneDataBaseName); var platformWindowsPhone = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); return(new SQLiteConnection(platformWindowsPhone, path)); }
private void InitializeStorage() { var storagePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, storageFileName); this.platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); this.connection = new SQLiteConnection(this.platform, storagePath); // Create the table if not exist. this.connection.CreateTable<PowerDistributionRecord>(); }
public SQLiteConnection GetConnection() { string sqliteFilename = "mFugitivos.db3"; string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename); var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); SQLiteConnection conn = new SQLiteConnection(platform, path); return(conn); }
public SQLite.Net.SQLiteConnection GetConnection() { var fileName = "Movies.db3"; var path = Path.Combine(ApplicationData.Current.LocalFolder.Path, fileName); var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var connection = new SQLite.Net.SQLiteConnection(platform, path); return(connection); }
public SQLite.Net.SQLiteConnection GetConnection(string pathN) { var fileName = "RandomThought.db3"; var path = Path.Combine(pathN, fileName); var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var connection = new SQLite.Net.SQLiteConnection(platform, path); return(connection); }
public SQLite.Net.SQLiteConnection GetConnection() { var sqliteFilename = "TodoSQLite.db3"; string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename); var plat = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var conn = new SQLite.Net.SQLiteConnection(plat, path); // Return the database connection return(conn); }
private void InitializeStorage() { var storagePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, storageFileName); this.platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); this.connection = new SQLiteConnection(this.platform, storagePath); // Create the table if not exist. this.connection.CreateTable <PowerDistributionRecord>(); }
public SQLite.Net.SQLiteConnection GetConnection() { var sqliteFilename = "TodoSQLite.db3"; string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename); var plat = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var conn = new SQLite.Net.SQLiteConnection(plat, path); // Return the database connection return conn; }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync( Microsoft.ApplicationInsights.WindowsCollectors.Metadata | Microsoft.ApplicationInsights.WindowsCollectors.Session); this.InitializeComponent(); this.Suspending += OnSuspending; SQLITE_PLATFORM = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); DBHelper = new DatabaseHelper(SQLITE_PLATFORM,DB_PATH); }
public App() { Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(); this.InitializeComponent(); this.Suspending += OnSuspending; SQLITE_PLATFORM = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); if (!CheckFileExists("timelineme.sqlite").Result) { using (var db = new SQLiteConnection(SQLITE_PLATFORM, DB_PATH)) { db.CreateTable<Media>(); } } }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; SQLITE_PLATFORM = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); if(!CheckFileExists("db.sqlite").Result) { using (var db = new SQLiteConnection(SQLITE_PLATFORM, DB_PATH)) { db.CreateTable<Models.MSPCrew>(); } } }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; SQLITE_PLATFORM = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); if (!CheckFileExists("db.sqlite").Result) { using (var db = new SQLiteConnection(SQLITE_PLATFORM, DB_PATH)) { db.CreateTable <Models.MSPCrew>(); } } }
public App() { Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(); this.InitializeComponent(); this.Suspending += OnSuspending; SQLITE_PLATFORM = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); if (!CheckFileExists("timelineme.sqlite").Result) { using (var db = new SQLiteConnection(SQLITE_PLATFORM, DB_PATH)) { db.CreateTable <Media>(); } } }
private void SetConnection() { try { var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, _databaseName); var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var param = new SQLiteConnectionString(path, false); _connectionToDatabaseAsync = new SQLiteAsyncConnection(() => new SQLiteConnectionWithLock(platform, param)); _connectionToDatabase = new SQLiteConnection(platform, path); } catch { _connectionToDatabaseAsync = null; } }
public SQLiteAsyncConnection GetConnection() { var dbFileName = "RailServeDb.db3"; string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, dbFileName); var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var param = new SQLiteConnectionString(path, false); // return db connection var connection = new SQLiteAsyncConnection(() => new SQLiteConnectionWithLock(platform, param)); return(connection); }
public SQLite.Net.SQLiteConnection GetConnection() { var sqliteFilename = "pokedex.db3"; string documentsPath = ApplicationData.Current.LocalFolder.Path; // Documents folder var path = Path.Combine(documentsPath, sqliteFilename); if (!File.Exists(path)) { File.Create(path); } var plat = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var conn = new SQLite.Net.SQLiteConnection(plat, path); // Return the database connection return(conn); }
public SQLiteConnection GetConnection() { string databaseDirectory = Path.Combine(CrossFileService.GetDefaultDirectory(), ApplicationSettingsConstant.DatabaseDirectory); databaseDirectory = CrossFileService.CreateDirectory(databaseDirectory); string path = Path.Combine(databaseDirectory, ApplicationSettingsConstant.DatabaseName); Debug.WriteLine("Database path: " + path); // Create the Connection var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var connection = new SQLiteConnection(platform, path); return(connection); }
public SQLiteAsyncConnection GetAsyncConnection() { var dbPath = GetDatabasePath(); var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var connectionFactory = new Func <SQLiteConnectionWithLock>( () => { if (_conn == null) { _conn = new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(dbPath, storeDateTimeAsTicks: true)); } return(_conn); }); return(new SQLiteAsyncConnection(connectionFactory)); }
public App() { Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync( Microsoft.ApplicationInsights.WindowsCollectors.Metadata | Microsoft.ApplicationInsights.WindowsCollectors.Session); this.InitializeComponent(); this.Suspending += OnSuspending; // Now create the tables and such required for the dbase SQLITE_PLATFORM = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); if (!CheckFileExists("db_v1.sqlite").Result) { using (var db = new SQLiteConnection(SQLITE_PLATFORM, DB_PATH)) { db.CreateTable <Trip>(); db.CreateTable <Car>(); } } }
public SQLiteConnection GetConnection() { var sqliteFilename = "todo.db3"; string documentsPath = KnownFolders.DocumentsLibrary.Path; //Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder //string libraryPath = Path.Combine(documentsPath, "..", "Library"); // Library folder var path = Path.Combine(documentsPath, sqliteFilename); // This is where we copy in the prepopulated database Debug.WriteLine(path); if (!File.Exists(path)) { File.Create(path); } var plat = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var conn = new SQLite.Net.SQLiteConnection(plat, path); // Return the database connection return(conn); }
public SQLiteAsyncConnection GetAsyncConnection() { lock (_connectionLock) { var sqliteFilename = DatabaseName; string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename); var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(); var connectionString = new SQLiteConnectionString(path, storeDateTimeAsTicks: false); var connectionFactory = new Func <SQLiteConnectionWithLock>( () => { if (_conn == null) { _conn = new SQLiteConnectionWithLock(platform, connectionString); } return(_conn); }); return(new SQLiteAsyncConnection(connectionFactory)); } }