Beispiel #1
0
        private async Task InitializeDbAsync(IMvxIoCProvider provider)
        {
            ISQLite sqlite    = provider.Resolve <ISQLite>();
            var     dbContext = new DbAsyncContext(sqlite.GetDatabasePath(Consts.DatabaseName));
            await dbContext.ConnectToDatabase();

            provider.RegisterSingleton <IDbAsyncContext>(dbContext);

            provider.ConstructAndRegisterSingleton <
                IDatabaseService <WeatherDbItem>, DatabaseService <WeatherDbItem, int> >();
            provider.ConstructAndRegisterSingleton <
                IDatabaseService <CountryDbItem>, DatabaseService <CountryDbItem, int> >();
        }
 public Task <bool> CreateBackup(string file)
 {
     try
     {//получим путь к папке
         Log.Logger.Info("begin create local backup");
         string titleSuccess     = Resource.SuccessStr;
         string backUpWasCreated = Resource.BackupWasCreatedInFolder + " ";
         string filePathDefault  = DependencyService.Get <IFileWorker>().CreateFolder(Constants.LOCAL_FOLDER_BACKUP, file);
         //создаем резервную копию передаем путь к БД и путь для сохранения резервной копиии
         bool succes = DependencyService.Get <IFileWorker>().WriteFile(_sqlite.GetDatabasePath(Constants.DATABASE_NAME), filePathDefault);
         return(Task.FromResult(succes));
     }
     catch (Exception er)
     {
         Log.Logger.Error(er);
         throw;
     }
 }
        public DAOsqlLiteRepository(string nameOC)
        {
            try
            {
                if (nameOC == null || nameOC == "")
                {
                    throw new Exception();
                }

                ISQLite sQLite = GetDbOS(nameOC);
                if (sQLite == null)
                {
                    throw new Exception();
                }

                string databasePath = sQLite.GetDatabasePath("VersionDroids.db3");
                database = new SQLiteConnection(databasePath);
                database.CreateTable <AndroidTable>();
            }
            catch (Exception)
            {
            }
        }
 public Task <bool> CreateBackup(string file)
 {
     try
     {
         //передаем название папки бэкапа.название файла которые нужно создать и путь к файлу БД
         bool success = DependencyService.Get <IGoogleDriveWorker>().CreateBackupGoogleDrive(Constants.LOCAL_FOLDER_BACKUP, file, _sqlite.GetDatabasePath(Constants.DATABASE_NAME), Resource.BackupWasCreatedGoogle, Resource.BackUpErrorCreated);
         return(Task.FromResult(success));
     }
     catch (Exception e)
     {
         Log.Logger.Error(e);
         throw;
     }
 }
Beispiel #5
0
 public UnitOfWork(ISQLite sqlite)
 {
     _dbpath    = sqlite.GetDatabasePath(DATABASE_NAME);
     _dbContext = new SQLiteContext(_dbpath);
 }