public async Task MemoryCreateTestAsync()
        {
            // Assemble
            CreateConnection();

            var columnInfo = await _db.GetTableInfoAsync("DummyTable");

            // Act
            if (columnInfo != null && columnInfo.Count == 0)
            {
                // Consider..  <..>(CreateFlags.AllImplicit).Wait();
                _db.CreateTableAsync <DummyTable>().Wait();
            }

            var item = new DummyTable {
                // Id = 999,
                IdGuid       = "B7B18CA9-38B8-4BD9-B1ED-095FD2E1287B",
                Name         = "Item-Test1",
                LastSyncDttm = new System.DateTime(),
            };

            var id = await _db.InsertAsync(item);

            // Assert
            Assert.AreNotEqual(0, id);

            var dummyItem = await GetItemAsync(id);

            Assert.AreEqual(dummyItem.IdGuid, item.IdGuid, $"Incorrect guid for ItemId {id}");

            CloseConnection();
        }
Beispiel #2
0
        /**
         * Saves the given game
         * scoreOfThisPartie : the game statistics
         */
        public async static Task saveGameForStats(ScorePartie scoreOfThisPartie)
        {
            SQLite.SQLiteAsyncConnection connection = DependencyService.Get <ISQLiteDb>().GetConnectionAsync();
            await connection.CreateTableAsync <ScoreHole>();

            await connection.CreateTableAsync <ScorePartie>();

            await SQLiteNetExtensionsAsync.Extensions.WriteOperations.InsertOrReplaceWithChildrenAsync(connection, scoreOfThisPartie, false);
        }
Beispiel #3
0
 private void CreateDatabaseIfNotCreated()
 {
     try
     {
         _dbConnection.CreateTableAsync <Article>();
         _dbConnection.CreateTableAsync <CategoryDetailsModel>();
     }
     catch (Exception)
     {
     }
 }
        public async Task FileConnectionTestAsync()
        {
            var    guid   = System.Guid.NewGuid().ToString();
            string dbPath = $@"C:\temp\{guid}.db";

            if (System.IO.File.Exists(dbPath))
            {
                System.IO.File.Delete(dbPath);
            }

            _db = new SQLite.SQLiteAsyncConnection(dbPath);
            await _db.CreateTableAsync <DummyTable>().ConfigureAwait(false);

            bool exists = System.IO.File.Exists(dbPath);

            Assert.AreEqual(true, exists, "Make sure VS is in Admin mode");

            await _db.CloseAsync();

            if (File.Exists(dbPath))
            {
                File.Delete(dbPath);
            }

            if (File.Exists(dbPath))
            {
                Assert.Fail($"File '{dbPath}' was not deleted");
            }
        }
Beispiel #5
0
        public async Task <bool> DeleteFromDBAsync(FreeDiscItemDownload freeDiscDownloader)
        {
            if (freeDiscDownloader == null)
            {
                #if DEBUG
                Debug.Write("DeleteFromDBAsync: freeDiscDownloader == null");
                #endif
                return(false);
            }
            Debug.Write("DeleteFromDB: ID" + freeDiscDownloader.DBID + " Title: " + freeDiscDownloader?.Title + " Status: " + freeDiscDownloader?.ItemStatus.ToString());
            if (freeDiscDownloader.DBID == 0)
            {
                Debug.Write("DeleteFromDB: freeDiscDownloader.DBID == 0 !");
                return(false);
            }
            try
            {
                var conn = new SQLite.SQLiteAsyncConnection(App.AppSetting.DBDownloadPath);
                await conn.CreateTableAsync <FreeDiscItemDownload>();

                await conn.DeleteAsync(freeDiscDownloader);
            }
            catch (Exception e)
            {
                Debug.Write("DeleteFromDB: Delete error !");
                return(false);
            }
            return(true);
        }
Beispiel #6
0
        public async Task <bool> SaveToDBAsync(FreeDiscItemDownload freeDiscDownloader)
        {
            if (freeDiscDownloader == null)
            {
                #if DEBUG
                Debug.Write("SaveToDBAsync: freeDiscDownloader == null");
                #endif
                return(false);
            }
            Debug.Write("SaveToDB: ID" + freeDiscDownloader.DBID + " Title: " + freeDiscDownloader?.Title + " Status: " + freeDiscDownloader?.ItemStatus.ToString());
            try
            {
                var conn = new SQLite.SQLiteAsyncConnection(App.AppSetting.DBDownloadPath);
                await conn.CreateTableAsync <FreeDiscItemDownload>();

                await conn.InsertAsync(freeDiscDownloader);
            }
            catch (Exception e)
            {
                Debug.Write("SaveToDB: Save error !");
                return(false);
            }

            Debug.Write("SaveToDB: Result ID" + freeDiscDownloader?.DBID ?? "NULL");
            return(true);
        }
Beispiel #7
0
        protected override async void OnAppearing()
        {
            await _connection.CreateTableAsync <User>(); //gets or creates the table 'Users'

            //await _connection.Table<User>().ToListAsync(); //get the list of users from the database
            base.OnAppearing();
        }
        /**
         * This method is called when the button to valid the club list is clicked
         */
        private async void onValidClubSelection(object sender, EventArgs e)
        {
            Btn.IsEnabled = false;
            Btn.Text      = "En cours...";
            Btn.TextColor = Color.White;
            SQLite.SQLiteAsyncConnection connection = DependencyService.Get <ISQLiteDb>().GetConnectionAsync();
            await connection.CreateTableAsync <Club>();

            List <Club> clubselected       = new List <Club>();
            bool        atLeastOneSelected = false;

            foreach (Club c in listviewclub.ItemsSource)  //updates each club 'selected' attribute in the database
            {
                if (c.selected)
                {
                    atLeastOneSelected = true;
                }
                await SQLiteNetExtensionsAsync.Extensions.WriteOperations.UpdateWithChildrenAsync(connection, c);
            }
            if (!atLeastOneSelected)//checks if at least one club is selected
            {
                await DisplayAlert("Aucun club selectionné", "Vous devez selectionner au moins un club", "ok");
            }
            else
            {
                await Navigation.PopAsync();
            }
            Btn.IsEnabled = true;
            Btn.Text      = "Valider";
        }
Beispiel #9
0
        /// <summary>
        /// Inserts items, as lists
        /// </summary>
        /// <returns>The or update async.</returns>
        /// <param name="items">Items.</param>
        public async System.Threading.Tasks.Task <int> InsertOrUpdateAsync(System.Collections.Generic.List <CommunicationIcon> items)
        {
            database.DropTableAsync <CommunicationIcon>().Wait();
            database.CreateTableAsync <CommunicationIcon>().Wait();

            return(await database?.InsertAllAsync(items));
        }
Beispiel #10
0
        /**
         * Gets all the golf courses from the database
         */
        public async static Task <List <GolfCourse> > getGolfCourses()
        {
            SQLite.SQLiteAsyncConnection connection = DependencyService.Get <ISQLiteDb>().GetConnectionAsync();
            await connection.CreateTableAsync <GolfCourse>();

            List <GolfCourse> golfCourses = await SQLiteNetExtensionsAsync.Extensions.ReadOperations.GetAllWithChildrenAsync <GolfCourse>(connection);

            return(golfCourses);
        }
Beispiel #11
0
        /**
         * Gets all the shots in the database
         */
        public async static Task <List <Shot> > getShots()
        {
            SQLite.SQLiteAsyncConnection connection = DependencyService.Get <ISQLiteDb>().GetConnectionAsync();
            await connection.CreateTableAsync <Shot>();

            List <Shot> allShots = await SQLiteNetExtensionsAsync.Extensions.ReadOperations.GetAllWithChildrenAsync <Shot>(connection);

            return(allShots);
        }
Beispiel #12
0
        public TodoDatabase()
        {
            var location = "tododb.db3";

            location   = System.IO.Path.Combine(Root, location);
            Connection = new SQLite.SQLiteAsyncConnection(location);

            Connection.CreateTableAsync <ToDoItem>();
        }
Beispiel #13
0
        /**
         * Gets all the ScoreHole from the database
         */
        public async static Task <List <ScoreHole> > getScoreHoles()
        {
            SQLite.SQLiteAsyncConnection connection = DependencyService.Get <ISQLiteDb>().GetConnectionAsync();
            await connection.CreateTableAsync <ScoreHole>();

            List <ScoreHole> allScoreHoles = await SQLiteNetExtensionsAsync.Extensions.ReadOperations.GetAllWithChildrenAsync <ScoreHole>(connection, recursive : true);

            return(allScoreHoles);
        }
Beispiel #14
0
        public async Task InitializeAsync()
        {
            var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
            connectionString = loader.GetString("DataBasePath");

            if (!await DoesFileExistAsync(loader.GetString("DataBasePath")))
            {
                SQLite.SQLiteAsyncConnection context = new SQLite.SQLiteAsyncConnection(connectionString);
                await context.CreateTableAsync<Sugges.UI.Logic.DataModel.Item>();
            }
        }
Beispiel #15
0
 public PortfolioData(string dbPath)
 {
     try
     {
         conn = new SQLite.SQLiteAsyncConnection(dbPath);
         //   conn.DropTableAsync<Portfolio>().Wait();
         conn.CreateTableAsync <Portfolio>().Wait();
     }
     catch (Exception e)
     {
         StatusMessage = string.Format(e.Message);
     }
 }
        /**
         * Gets a list of golf courses using a filter
         * if the filter is null, then all golf courses are returned
         */
        public static async Task <List <GolfCourse> > getListGolfsAsync(Func <GolfCourse, bool> filtre)
        {
            if (filtre == null)
            {
                filtre = x => true;
            }

            SQLite.SQLiteAsyncConnection connection = DependencyService.Get <ISQLiteDb>().GetConnectionAsync();
            await connection.CreateTableAsync <Hole>();

            await connection.CreateTableAsync <MyPosition>();

            await connection.CreateTableAsync <GolfCourse>();

            List <GolfCourse> gfcs = (await SQLiteNetExtensionsAsync.Extensions.ReadOperations.GetAllWithChildrenAsync <GolfCourse>(connection, recursive: true));

            if (gfcs.Count == 0)//if no golf courses in the datatbase
            {
                //parse the default golf courses of Rennes from the XML files and add them (Ressources/GolfCourses)
                gfcs = GolfXMLReader.getListGolfCourseFromXMLFiles();
                await SQLiteNetExtensionsAsync.Extensions.WriteOperations.InsertOrReplaceAllWithChildrenAsync(connection, gfcs, true);
            }
            return(gfcs);
        }
        /**
         * Gets a list of clubs using a filter
         * if the filter is null, then all clubs are returned
         * */
        public static async Task <List <Club> > getListClubsAsync(Func <Club, bool> filtre)
        {
            if (filtre == null)
            {
                filtre = x => true;
            }

            SQLite.SQLiteAsyncConnection connection = DependencyService.Get <ISQLiteDb>().GetConnectionAsync();
            List <Club> clubs = new List <Club>();
            await connection.CreateTableAsync <Club>();

            clubs = (await SQLiteNetExtensionsAsync.Extensions.ReadOperations.GetAllWithChildrenAsync <Club>(connection));

            if (clubs.Count == 0)//if no clubs in the datatbase
            {
                //parse the default clubs from the XML files and add them (Ressources/Clubs)
                clubs = GolfXMLReader.getListClubFromXMLFiles();
                await connection.InsertAllAsync(clubs);
            }
            return(clubs);
        }
Beispiel #18
0
 private async void CreateTableCliente()
 {
     await _connection.CreateTableAsync <Cliente>();
 }
Beispiel #19
0
 public Database(string dbPath)
 {
     _database = new SQLite.SQLiteAsyncConnection(dbPath);
     _database.CreateTableAsync <User>().Wait();
 }
Beispiel #20
0
 public Repositorio()
 {
     string DbFilePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "localdb.db3");
     DataBase = new SQLite.SQLiteAsyncConnection(DbFilePath);
     DataBase.CreateTableAsync<Logs>().Wait();
 }
 async void CreateUsuarioTable()
 {
     await _connection.CreateTableAsync <Usuario>();
 }
Beispiel #22
0
 public PersonDatabase(String dbPath)
 {
     databaseConnection = new SQLite.SQLiteAsyncConnection(dbPath);
     databaseConnection.CreateTableAsync <Person>().Wait();
 }
 public async Task InitializeDb()
 {
     await _connection.CreateTableAsync <FavoriteRow> ();
 }
 public Task InitializeDb()
 {
     return(_connection.CreateTableAsync <FavoriteRow> ());
 }
Beispiel #25
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dbFilePath"></param>
 public ApplicationDatabase(string dbFilePath)
 {
     database = new SQLite.SQLiteAsyncConnection(dbFilePath);
     database.CreateTableAsync <CommunicationSettings>().Wait();
     database.CreateTableAsync <CommunicationIcon>().Wait();
 }
Beispiel #26
0
 async public Task<List<TrashImage>> GetTrashImagesAsync()
 {
     SQLite.SQLiteAsyncConnection context = new SQLite.SQLiteAsyncConnection(connectionString);
     await context.CreateTableAsync<Sugges.UI.Logic.DataModel.TrashImage>();
     List<TrashImage> result = await context.Table<TrashImage>().ToListAsync();
     return result;
 }
 public async Task ClearFavoriteMessages()
 {
     var db = new SQLite.SQLiteAsyncConnection(this.DBPath);
     await db.DropTableAsync<FavoriteMessageSettings>();
     await db.CreateTableAsync<FavoriteMessageSettings>();
     await refreshFavoriteMessages();
 }
 public DatabaseExpense(string dbPath)
 {
     database = new SQLite.SQLiteAsyncConnection(dbPath);
     database.CreateTableAsync <MonthExpense>().Wait();
     database.CreateTableAsync <MonthExpense.Expense>().Wait();
 }