Exemplo n.º 1
0
        //#region "Initialize/close"

        /// <summary>
        /// Initializes the database connection
        /// </summary>
        public async Task InitializeDatabaseAsync()
        {
            //Create table schema if doesn't exist.
            //Note that is non-destructive and should not drop tables if they are already there

            await AsyncConnection.CreateTableAsync <DatabaseObjects.BankAccount>();

            await AsyncConnection.CreateTableAsync <DatabaseObjects.BankAccountTransaction>();

            int bankAccountCount = await AsyncConnection.Table <DatabaseObjects.BankAccount>().CountAsync();

            Log.ConsoleInfo(string.Format("seconomy: {0} clean - {1} accounts", _path, bankAccountCount));

            _ready = true;

            /*
             * return AsyncConnection.CreateTableAsync<DatabaseObjects.BankAccount>().ContinueWith((i) => {
             *  AsyncConnection.CreateTableAsync<DatabaseObjects.BankAccountTransaction>().ContinueWith((x) => {
             *      AsyncConnection.Table<DatabaseObjects.BankAccount>().CountAsync().ContinueWith((count) => {
             *          int bankAccountCount = count.Result;
             *          Log.ConsoleInfo(string.Format("seconomy: {0} clean - {1} accounts", _path, bankAccountCount));
             *
             *          _ready = true;
             *      });
             *  });
             * });
             */
        }
        public async Task <bool> DeleteFromDBAsync(FreeDiscItemDownload freeDiscDownloader)
        {
            if (freeDiscDownloader == null)
            {
                #if DEBUG
                Debug.Write("DeleteFromDBAsync: freeDiscDownloader == null");
                #endif
                return(false);
            }
            #if DEBUG
            Debug.Write("DeleteFromDB: ID" + freeDiscDownloader.DBID + " Title: " + freeDiscDownloader?.Title + " Status: " + freeDiscDownloader?.ItemStatus.ToString());
            #endif
            if (freeDiscDownloader.DBID == 0)
            {
                #if DEBUG
                Debug.Write("DeleteFromDB: freeDiscDownloader.DBID == 0 !");
                #endif
                return(false);
            }
            try
            {
                var conn = new SQLite.SQLiteAsyncConnection(App.AppSetting.DBDownloadPath);
                await conn.CreateTableAsync <FreeDiscItemDownload>();

                await conn.DeleteAsync(freeDiscDownloader);
            }
            catch (Exception e)
            {
                #if DEBUG
                Debug.Write("DeleteFromDB: Delete error ! : " + e.ToString());
                #endif
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        private async void Create()
        {
            Connection = new SQLiteAsyncConnection(dbpath);

            // create all tables
            Connection.CreateTableAsync<SQLite.Task>();
        }
        public async Task <bool> SaveToDBAsync(FreeDiscItemDownload freeDiscDownloader)
        {
            if (freeDiscDownloader == null)
            {
                #if DEBUG
                Debug.Write("SaveToDBAsync: freeDiscDownloader == null");
                #endif
                return(false);
            }
            #if DEBUG
            Debug.Write("SaveToDB: ID" + freeDiscDownloader.DBID + " Title: " + freeDiscDownloader?.Title + " Status: " + freeDiscDownloader?.ItemStatus.ToString());
            #endif
            try
            {
                var conn = new SQLite.SQLiteAsyncConnection(App.AppSetting.DBDownloadPath);
                await conn.CreateTableAsync <FreeDiscItemDownload>();

                await conn.InsertAsync(freeDiscDownloader);
            }
            catch (Exception e)
            {
                #if DEBUG
                Debug.Write("SaveToDB: Save error !");
                #endif
                return(false);
            }
            #if DEBUG
            Debug.Write("SaveToDB: Result ID" + freeDiscDownloader?.DBID ?? "NULL");
            #endif
            return(true);
        }
Exemplo n.º 5
0
 public async static void CheckAndCreateDatabase()
 {
     if (!await FileUtils.CheckFileExists(DbHelper.DB_NAME))
     {
         System.Diagnostics.Debug.WriteLine("creating tables");
         SQLiteAsyncConnection conn = new SQLiteAsyncConnection(DB_PATH);
         await conn.CreateTableAsync<Organization>();
         await conn.CreateTableAsync<Counter>();
         await conn.CreateTableAsync<Menu>();
         await conn.CreateTableAsync<Item>();
     }
     else
     {
         System.Diagnostics.Debug.WriteLine("tables exist");
     }
 }
Exemplo n.º 6
0
        private async void loadData()
        {
            //SQLiteAsyncConnection conn1 = new SQLiteAsyncConnection(System.IO.Path.Combine(ApplicationData.Current.LocalFolder.Path, "Appointment.db"), true);

            
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection(System.IO.Path.Combine(ApplicationData.Current.LocalFolder.Path, "Appointment.db"), true);
            conn.DropTableAsync<SampleAppointment>();

            await conn.CreateTableAsync<SampleAppointment>();

            DateTime temp = DateTime.Now;

            DateTime start = DateTime.Parse("06/08/2013 6:00 PM");
            DateTime end = DateTime.Parse("06/09/2013 6:00 PM");

            SampleAppointment appointment1 = new SampleAppointment
            {
                Subject = "MACF - App Camp",
                AdditionalInfo = "BRTN 291, RSVP Reguired",
                StartDate = start,
                EndDate = end
            };

            conn.InsertAsync(appointment1);

            SampleAppointment appointment2 = new SampleAppointment
            {
                StartDate = DateTime.Now.AddMinutes(30),
                EndDate = DateTime.Now.AddHours(1),
                Subject = "Appointment 376",
                AdditionalInfo = "Info 3"
            };

            conn.InsertAsync(appointment2);

            start = DateTime.Parse("06/05/2013 5:00 PM");
            end = DateTime.Parse("06/05/2013 6:00 PM");
            SampleAppointment appointment3 = new SampleAppointment
            {
                StartDate = DateTime.Now.AddHours(2),
                EndDate = DateTime.Now.AddHours(3),
                Subject = "Appointment uhy4",
                AdditionalInfo = "Info 4"
            };

            conn.InsertAsync(appointment3);

            SampleAppointment appointment4 = new SampleAppointment
            {
                Subject = "Malaysian Night",
                AdditionalInfo = "STEW Common, Members Only",
                StartDate = start,
                EndDate = end
            };

            conn.InsertAsync(appointment4);

            //this.OnDataLoaded();
        }
Exemplo n.º 7
0
        public StationRepository()
        {
            string DbFilePath = Path.Combine(
                System.Environment.GetFolderPath(
                    System.Environment.SpecialFolder.LocalApplicationData), "NorthWind.db");

            Database = new SQLiteAsyncConnection(DbFilePath);
            Database.CreateTableAsync <Entities.Station>().Wait();


            var Station1 = new Data.Entities.Station
            {
                ID          = 1,
                Name        = "1",
                Description = "EB - Central",
                Address     = "1",
                Phone       = "2739293",
                Lat         = "1",
                Lng         = "1"
            };

            var Station2 = new Data.Entities.Station
            {
                ID          = 2,
                Name        = "2",
                Description = "EB - Chapinero",
                Address     = "2",
                Phone       = "2839475",
                Lat         = "2",
                Lng         = "2"
            };

            var Station3 = new Data.Entities.Station
            {
                ID          = 3,
                Name        = "3",
                Description = "EB - Restrepo",
                Address     = "3",
                Phone       = "8938495",
                Lat         = "3",
                Lng         = "3"
            };

            var Station4 = new Data.Entities.Station
            {
                ID          = 4,
                Name        = "4",
                Description = "EB - Las Ferias",
                Address     = "4",
                Phone       = "1267384",
                Lat         = "4",
                Lng         = "4"
            };

            CreateStationAsync(Station1);
            CreateStationAsync(Station2);
            CreateStationAsync(Station3);
            CreateStationAsync(Station4);
        }
        async Task<int> connectDB()
        {
            var path = Windows.Storage.ApplicationData.Current.LocalFolder.Path + @"\beyondvincent.db";

            db = new SQLiteAsyncConnection(path);
            await db.DropTableAsync<User>();
            await db.CreateTableAsync<User>();
            return 0;
        }
Exemplo n.º 9
0
        public async void CreateDatabase()
        {
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "User.db"), true);
            await conn.CreateTableAsync<User>();

            SQLiteAsyncConnection conn1 = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "Appointment.db"), true);
            await conn1.CreateTableAsync<Appointment>();

        }
		public App (string dbPath)
		{
			// set up the database
			db = new SQLiteAsyncConnection (dbPath);
			db.CreateTableAsync<TaskItem> ().Wait ();

			// The root page of your application
			MainPage = new NavigationPage (new TasksPage (db));
		}
Exemplo n.º 11
0
        public UserInfoRepository()
        {
            string DbFilePath = Path.Combine(
                System.Environment.GetFolderPath(
                    System.Environment.SpecialFolder.LocalApplicationData), "NorthWind.db");

            Database = new SQLiteAsyncConnection(DbFilePath);
            Database.CreateTableAsync <Entities.UserInfo>().Wait();
        }
Exemplo n.º 12
0
		public void UnicodePathsAsync()
		{
			var path = Path.GetTempFileName () + UnicodeText;
			
			var db = new SQLiteAsyncConnection (path, true);
			db.CreateTableAsync<OrderLine> ().Wait ();

			Assert.That (new FileInfo (path).Length, Is.GreaterThan (0), path);
		}
Exemplo n.º 13
0
        public async static Task<SQLiteAsyncConnection> ConnectToDatabase()
        {
            var databaseConnection = new SQLiteAsyncConnection(DatabaseFileName, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.NoMutex);

            var version = "1.3";
            var oldVersion = ApplicationSettings.DatabaseCreationVersion.Read();
            if (oldVersion != version)
            {
                await databaseConnection.CreateTableAsync<Song>();
                await databaseConnection.CreateTableAsync<SongGenre>();
                await databaseConnection.CreateTableAsync<Genre>();

                await databaseConnection.CreateTableAsync<CachedAlbumCover>();
                await databaseConnection.CreateTableAsync<CurrentPlaylistSong>();
                await databaseConnection.CreateTableAsync<SavedPlaylistSong>();
                await databaseConnection.CreateTableAsync<SavedPlaylist>();

                necessaryUpdatesForLibrary = new List<Func<MusicLibrary, Task>>();
                ApplicationSettings.IsDatabaseSettingUp.Save(true);
                if (oldVersion == "1.0" || oldVersion == "1.1" || oldVersion == "1.3")
                {
                     necessaryUpdatesForLibrary.Add(async library =>
                     {
                         foreach (var song in library.Songs)
                         {
                             try
                             {
                                 var storageFile = await StorageFile.GetFileFromPathAsync(song.FileName);
                                 TagLib.Tag tag = null;
                                 using (var stream = await storageFile.OpenStreamForReadAsync())
                                 {
                                     tag = await Task<TagLib.File>.Run(() =>
                                     {
                                         try
                                         {
                                             return TagLib.File.Create(new TagLib.StreamFileAbstraction(storageFile.Name, stream, null)).Tag;
                                         }
                                         catch { return null; }
                                     });
                                 }

                                 if (tag != null)
                                 { 
                                     library.localLibrarySource.UpdateSongMetadata(tag, song);
                                     await library.databaseConnection.UpdateAsync(song);
                                 }
                             }
                             catch { }
                         }
                     });
                }

                necessaryUpdatesForLibrary.Add(async library => { ApplicationSettings.DatabaseCreationVersion.Save(version); await Task.Delay(0); });

            }


            return databaseConnection;
        }
Exemplo n.º 14
0
        public ProductRepository()
        {
            string DbFilePath = Path.Combine(
                Environment.GetFolderPath(
                    Environment.SpecialFolder.LocalApplicationData),
                "NorthWind.db");

            _database = new SQLiteAsyncConnection(DbFilePath);
            _database.CreateTableAsync <Product>().Wait();
        }
Exemplo n.º 15
0
        public static async void insertProduct(Product product)
        {
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection(PRODUCTS_TABLE);

            await conn.CreateTableAsync<Product>();

            await conn.InsertAsync(product);


        }
Exemplo n.º 16
0
 private static async void createFavouritesTable()
 {
     String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite";
     SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);
     var count = await conn.ExecuteScalarAsync<int>("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='OCDirection'");
     if (count == 0)
     {
         await conn.CreateTableAsync<OCDirection>();
     }
 }
Exemplo n.º 17
0
        public SQLiteAsyncConnection GetConnection()
        {
            var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            //Se crea la Base de datos
            var path = Path.Combine(documentsPath, "NorthWind.db");

            _database = new SQLiteAsyncConnection(path);
            _database.CreateTableAsync <Product>().Wait();

            return(_database);
        }
Exemplo n.º 18
0
 public static async Task<List<Exam>> getExamsAsync()
 {
     if (exams.Count != 0)
     {
         return exams;
     }
     SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Windows.Storage.ApplicationData.Current.LocalFolder.Path + "\\Data.db");
     await conn.CreateTableAsync<Exam>();
     exams = await conn.Table<Exam>().OrderBy(exam => exam.ExamTime).ToListAsync();
     return exams;
 }
		public HouseImageCacheRepository ()
		{
			string folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
			db = new SQLiteAsyncConnection (System.IO.Path.Combine (folder, "houseImages.db"));
//			db.DropTableAsync<HouseImages> ().ContinueWith (t => {
//				Console.WriteLine ("Table Dropped!");
//			});
			db.CreateTableAsync<HouseImages>().ContinueWith (t => {
				Console.WriteLine ("Table created!");
			});

		}
Exemplo n.º 20
0
        private void initExternalDB()
        {
            DBVersion dbVersion = null;

            mDatabase.CreateTableAsync <DBVersion>().Wait();

            var taskR = mDatabase.Table <DBVersion>().FirstOrDefaultAsync();

            dbVersion = taskR.Result;

            if (dbVersion == null || dbVersion.Version < 1)
            {
                dbVersion = new DBVersion();
                initExternalDBStruct_v1(dbVersion);
            }

            if (dbVersion.Version < 2)
            {
                updateExternalDBStruct_v2(dbVersion);
            }
        }
Exemplo n.º 21
0
 private static async void createSettingsTable()
 {
     String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite";
     SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);
     var count = await conn.ExecuteScalarAsync<int>("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='OCSettings'");
     if (count == 0)
     {
         await conn.CreateTableAsync<OCSettings>();
         OCSettings settings = OCSettings.newOCSettings(500);
         settings.id = 1;
         await conn.InsertAsync(settings);
     }
 }
Exemplo n.º 22
0
 private async Task<string> createDatabase(string path)
 {
     try
     {
         var connection = new SQLiteAsyncConnection(path);
         await connection.CreateTableAsync<Person>();
         return "Database created";
     }
     catch (SQLiteException ex)
     {
         return ex.Message;
     }
 }
Exemplo n.º 23
0
        private async void CreateDatabase ()
        {
            try
            {
                var connection = new SQLiteAsyncConnection (_path);
                await connection.CreateTableAsync<UserVideo> ();

            }
            catch (SQLiteException ex)
            {
                Log.Error(TAG, ex.Message);
            }
        }
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var path = ApplicationData.Current.LocalFolder.Path + @"\Users.db";
                var db = new SQLiteAsyncConnection(path);
                await db.CreateTableAsync<User>();
            }
            catch (Exception)
            { }

            //Button_Click_1.visibility = Visibility.Collapsed;
        }
Exemplo n.º 25
0
		private async Task PrepareDatabase()
		{
			var path = Path.Combine(Path.GetDirectoryName(typeof(TodoService).Assembly.Location), "todos.db");

			if (File.Exists(path))
				File.Delete(path);

			var db = new SQLiteAsyncConnection(path);
			await db.CreateTableAsync<TodoItem>();

			var count = await db.InsertAllAsync(Todos);
			Assert.Equal(Todos.Count, count);
		}
 //-----------Database is created---------//
 private string createDatabase(string path)
 {
     try
     {
         var connection = new SQLiteAsyncConnection(path);{
             connection.CreateTableAsync<User>();
             return "Database created";
         }
     }
     catch (SQLiteException ex)
     {
         return ex.Message;
     }
 }
Exemplo n.º 27
0
		async void FnInitializeView()
		{
			FnStartActivityIndicator ();
			sqlAsyncConnection =	DbConnectionClass.FnGetConnection (); 
			tableViewContactsList.Hidden=true; 
			await  sqlAsyncConnection.CreateTableAsync<PhoneContactClass> (); 
			var contactList=await FnGetAllContactList (); 
			FnStopActivityIndicator ();
			FnBindContactList (contactList);  
		
			btnAddContact.SetBackgroundImage ( UIImage.FromBundle ( "Images/iconAdd" ) , UIControlState.Normal ); 
			btnRefreshContactList.SetBackgroundImage ( UIImage.FromBundle ( "Images/iconRefreshImg" ) , UIControlState.Normal );
			tableViewContactsList.Layer.CornerRadius = 10; 
		}
Exemplo n.º 28
0
        public async void InitWithPath(string dbFile, string dbTempDir)
        {
            _dbFile = dbFile;
            _dbTempDir = dbTempDir;

            try {
                await ApplicationData.Current.LocalFolder.CreateFolderAsync(_dbTempDir);
            }
            catch (Exception) {} // exception thrown when folder already exists

            _db = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, _dbFile));

            await _db.CreateTableAsync<CacheLine>();
        }
Exemplo n.º 29
0
        public string createDB(string path)
        {
            try
            {

                var connection = new SQLiteAsyncConnection(System.IO.Path.Combine(path, "SQLiteTest.db"));
                connection.CreateTableAsync<Person>().ContinueWith(t => {
                    Console.WriteLine("Table created!");
                });
                return "Table created!";
            }
            catch (SQLiteException ex)
            {
                return ex.Message;
            }
        }
		void FnViewInitialize()
		{
			sqlAsyncConnection =	DbConnectionClass.FnGetConnection ();  
		    sqlAsyncConnection.CreateTableAsync<PhoneContactClass> ();
			btnDeleteContact.Hidden = true;

			if ( objPhoneContactClass != null )
			{
				txtContactName.Text = objPhoneContactClass.strContactName;
				txtContactNumber.Text = objPhoneContactClass.strContactNumber.ToString();
				btnDeleteContact.Hidden = false;
			}

			txtContactName.ShouldReturn += ( (textField ) => textField.ResignFirstResponder () );
			txtContactNumber.ShouldReturn += ( (textField ) => textField.ResignFirstResponder () );
			FnViewCustomization ();
		}
Exemplo n.º 31
0
        private async void Init()
        {
            var db = new SQLite.SQLiteAsyncConnection(dbPath);

            try
            {
                db.CreateTableAsync <Children>();
                db.CreateTableAsync <EveryDay>();

                db.CreateTableAsync <Reminder>();
                db.CreateTableAsync <Vaccine>();
                db.CreateTableAsync <Doctor>();
                db.CreateTableAsync <Action>();

                db.CreateTableAsync <Task>();

                db.CreateTableAsync <Favorite>();
                db.CreateTableAsync <Contact>();
            }
            catch (System.NullReferenceException e)
            {
            }
        }
Exemplo n.º 32
0
        public void Create()
        {
            _sqLiteConnection = new SQLiteAsyncConnection(Constants.BaseDirectory + "analyzer.s3db");

            _sqLiteConnection.CreateTableAsync<ChatLogEntry>()
                             .ContinueWith(results => LogHelper.Log(Logger, "ChatLogEntry Table Created", LogLevel.Trace));
            _sqLiteConnection.CreateTableAsync<Encounter>()
                             .ContinueWith(results => LogHelper.Log(Logger, "Encounter Table Created", LogLevel.Trace));
            _sqLiteConnection.CreateTableAsync<Events>()
                             .ContinueWith(results => LogHelper.Log(Logger, "Events Table Created", LogLevel.Trace));
            _sqLiteConnection.CreateTableAsync<MonsterEntity>()
                             .ContinueWith(results => LogHelper.Log(Logger, "MonsterEntity Table Created", LogLevel.Trace));
            _sqLiteConnection.CreateTableAsync<MonsterEntityUpdate>()
                             .ContinueWith(results => LogHelper.Log(Logger, "MonsterEntityUpdate Table Created", LogLevel.Trace));
            _sqLiteConnection.CreateTableAsync<MonsterStatusEntry>()
                             .ContinueWith(results => LogHelper.Log(Logger, "MonsterStatusEntry Table Created", LogLevel.Trace));
            _sqLiteConnection.CreateTableAsync<PartyMemberEntity>()
                             .ContinueWith(results => LogHelper.Log(Logger, "PartyMemberEntity Table Created", LogLevel.Trace));
            _sqLiteConnection.CreateTableAsync<PartyMemberStatusEntry>()
                             .ContinueWith(results => LogHelper.Log(Logger, "PartyMemberStatusEntry Table Created", LogLevel.Trace));
        }
Exemplo n.º 33
0
        public static async Task <SQLiteAsyncConnection> CreateCommDB()
        {
            var file = Path.Combine(SDKProperty.dbPath, "common.db");

            if (!Directory.Exists(Path.GetDirectoryName(file)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(file));
            }
            //if (!File.Exists(file))
            //{
            //    File.Create(file);
            //}

            var comconn = new SQLite.SQLiteAsyncConnection(file);

            await comconn.CreateTableAsync <DB.historyAccountDB>();

            return(comconn);
        }
Exemplo n.º 34
0
 public static async Task<SQLiteAsyncConnection> CheckOrCreateStorage()
 {
     string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "RememberIt.sqlite");
     SQLiteAsyncConnection dbConn = null;
     if (!(await IsFileExist(dbPath.ToString())))
     {
         //新建并初始化数据库
         dbConn = new SQLite.SQLiteAsyncConnection(dbPath);
         //新建记忆项表
         await dbConn.CreateTableAsync<RememberItem>();
         //其他数据表
         //...
     }
     else
     {
         //新建连接
         dbConn = new SQLite.SQLiteAsyncConnection(dbPath);
     }
     
     return dbConn;
 }
 protected void InitializeDatabase()
 {
     var dbName = "people";
     var conn = new SQLiteAsyncConnection (dbName);
     conn.CreateTableAsync<Person> ().ContinueWith ((task) =>
     {
         foreach (var i in Enumerable.Range (0,1000)) {
             var p = new Person ("Bob");
             conn.InsertAsync (p).ContinueWith ((task2) =>
             {
                 var id = p.Id;
                 this.InvokeOnMainThread (delegate {
                     this.recordCount.Text = id.ToString ();
                     this.recordCount.SetNeedsDisplay ();
                 }
                 );
             }
             );
         }
     }
     );
 }
Exemplo n.º 36
0
        async Task RunCreateTest()
        {
            var db = new SQLiteAsyncConnection(DatabasePath);
            await db.CreateTableAsync<Person>();
            await db.RunInTransactionAsync(async d =>
            {
                for (var i = 0; i < 10; i++)
                    await d.InsertAsync(new Person { FullName = "Person " + i.ToString() });
            });

            int count = 0;

            await db.RunInTransactionAsync(async d =>
            {
                var table = db.Table<Person>();
                count = await table.CountAsync();
            });

            var message = count == 10
                        ? "Completed!"
                        : string.Format("Only inserted {0} rows!", count);

            await dispatcher.RunIdleAsync(a => { CreateResult = message; });
        }
Exemplo n.º 37
0
 private async Task CreateDatabaseAsync()
 {
     conn = new SQLiteAsyncConnection("Details.db3");
     await conn.CreateTableAsync<Nutrition>();
 }
Exemplo n.º 38
0
        public EmergencyRepository()
        {
            string DbFilePath = Path.Combine(
                System.Environment.GetFolderPath(
                    System.Environment.SpecialFolder.LocalApplicationData), "NorthWind.db");

            Database = new SQLiteAsyncConnection(DbFilePath);
            Database.CreateTableAsync <Entities.Emergency>().Wait();

            //h ttps://www.flaticon.com/icon-packs/firefighter?style_id=15
            //h ttps://www.flaticon.com/packs/emergency-services-9

            var emergency1 = new Data.Entities.Emergency
            {
                ID          = 1,
                Type        = "Médico",
                LogoSource  = "ambulance.png",
                Description = "Trauma por accidente vehicular",
                Date        = "2018/11/10",
                Hour        = "22:05",
                Lat         = "1",
                Lng         = "1"
            };

            var emergency2 = new Data.Entities.Emergency
            {
                ID          = 2,
                Type        = "Incendio",
                Description = "Incendio forestal",
                LogoSource  = "fire.png",
                Date        = "2018/08/10",
                Hour        = "22:05",
                Lat         = "2",
                Lng         = "2"
            };
            var emergency3 = new Data.Entities.Emergency
            {
                ID          = 3,
                Type        = "Rescate",
                Description = "Persona atrapada",
                LogoSource  = "ax.png",
                Date        = "2018/11/10",
                Hour        = "22:05",
                Lat         = "3",
                Lng         = "3"
            };
            var emergency4 = new Data.Entities.Emergency
            {
                ID          = 4,
                Type        = "Administrativo",
                Description = "Presencia en concierto",
                LogoSource  = "form.png",
                Date        = "2018/05/03",
                Hour        = "22:05",
                Lat         = "4",
                Lng         = "4"
            };

            var emergency5 = new Data.Entities.Emergency
            {
                ID          = 5,
                Type        = "Sustancias",
                Description = "Fuga de gas",
                LogoSource  = "Chemical.png",
                Date        = "2018/02/28",
                Hour        = "22:05",
                Lat         = "5",
                Lng         = "5"
            };

            var emergency6 = new Data.Entities.Emergency
            {
                ID          = 6,
                Type        = "Incendio",
                Description = "Incendio en Habitación",
                LogoSource  = "fire.png",
                Date        = "2018/11/10",
                Hour        = "22:05",
                Lat         = "2",
                Lng         = "2"
            };

            CreateEmergencyAsync(emergency1);
            CreateEmergencyAsync(emergency2);
            CreateEmergencyAsync(emergency3);
            CreateEmergencyAsync(emergency4);
            CreateEmergencyAsync(emergency5);
            CreateEmergencyAsync(emergency6);
        }
Exemplo n.º 39
0
 private void CreateTables()
 {
     connection.CreateTableAsync <RandomModel>();
     connection.CreateTableAsync <Ingredient>();
     connection.CreateTableAsync <Measure>();
 }
Exemplo n.º 40
-1
 public static async Task CreateData()
 {
     SQLiteAsyncConnection connection = new SQLiteAsyncConnection(DbName);
     await connection.CreateTableAsync<DataBusLine>();
     await connection.CreateTableAsync<DataPoint>();
     System.Diagnostics.Debug.WriteLine("Create DB");
 }
Exemplo n.º 41
-2
 public DatabaseConnection(string dbPath)
 {
     conn = new SQLiteAsyncConnection(dbPath);
     conn.CreateTableAsync<Posting>().Wait();
     conn.CreateTableAsync<Search>().Wait();
     conn.CreateTableAsync<RecentCity>().Wait();
     conn.CreateTableAsync<FavoriteCategory>().Wait();
 }
Exemplo n.º 42
-2
        public DataStore()
        {
            Connection = new SQLiteAsyncConnection(Path.Combine(Root, location));

            //create tables

            Connection.CreateTableAsync<Trip>().Wait();
            Connection.CreateTableAsync<Itinerary>().Wait();
            Connection.CreateTableAsync<Event>().Wait();
        }