Ejemplo n.º 1
0
 public StatsService(ISQLite dbservices, IEventServices eventServices, ITimeServices timeServices)
 {
     this.dbservices = dbservices;
     Connection      = dbservices.GetConnection();
     EventServices   = eventServices;
     TimeServices    = timeServices;
 }
        /// <summary>
        /// Initializes a new instance of the ViewModelLocator class.
        /// </summary>
        public ViewModelLocator()
        {
            Resources.Resources.Culture = DependencyService.Get <ILocalize>()?.GetCurrentCultureInfo();

            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
            SimpleIoc.Default.Register <MainViewModel>();
            SimpleIoc.Default.Register <LayoutsViewModel>();
            SimpleIoc.Default.Register <DisplayingViewModel>();
            SimpleIoc.Default.Register <PagesViewModel>();
            SimpleIoc.Default.Register <LoginViewModel>();

            SimpleIoc.Default.Register <INavigationService>(() => new NavigationService(Navigation));
            SimpleIoc.Default.Register <INewsRepository>(() => new NewsRepository());

            ISQLite sqLiteService = DependencyService.Get <ISQLite>();

            SimpleIoc.Default.Register <ISQLite>(() => sqLiteService);

            INetworkService networkService = DependencyService.Get <INetworkService>();

            SimpleIoc.Default.Register <INetworkService>(() => networkService);

            IHubNotificationService hubNotificationService = DependencyService.Get <IHubNotificationService>();

            SimpleIoc.Default.Register <IHubNotificationService>(() => hubNotificationService);
        }
Ejemplo n.º 3
0
        public EditNotesPopup(AssetManager asset, Context context, int idNote) : base()
        {
            databaseHelper = new SQLiteAndroid(asset);
            note           = databaseHelper.FindNoteByID(idNote);

            string readRoomsOnFloor = string.Empty;

            using (ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(context))
            {
                readRoomsOnFloor = prefs.GetString("ReadRoomsOnFloor", "-1;0;1;2;3");
            }

            List <Room>   rooms     = databaseHelper.ReadRoomsOnFloor(3);
            List <int>    roomsID   = new List <int>();
            List <string> roomsName = new List <string>();

            foreach (var item in rooms)
            {
                if (readRoomsOnFloor.Contains(item.Floor.ToString()))
                {
                    roomsName.Add(item.Name);
                    roomsID.Add(item.ID);
                }
            }
            rooms.Clear();

            adapterRoomName = new ArrayAdapter(context, Resource.Layout.TextViewItem, roomsName.ToArray());
            adapterRoomID   = new ArrayAdapter(context, Resource.Layout.TextViewItem, roomsID.ToArray());
        }
Ejemplo n.º 4
0
        //приложение для одного активного пользователя в текущий момент
        //при добавлении нового юзера предыдущий удаляется из базы
        public App()
        {
            InitializeComponent();

            _iconnection = DependencyService.Get <ISQLite>();
            _dbManager   = new SQLiteManager(_iconnection);
            DbManager    = _dbManager;
            _dbManager.Initialize <User>();
            var recentLoggedUser = _dbManager.GetRecentLoggedUser <User>();

            if (recentLoggedUser != null && recentLoggedUser.IsLogged)
            {
                if (Device.OS == TargetPlatform.Android)
                {
                    MainPage = new MainDroidPage();
                }
                if (Device.OS == TargetPlatform.iOS)
                {
                    MainPage = new MainIosPage();
                }
            }
            else
            {
                MainPage = new LoginMasterPage();
            }
        }
Ejemplo n.º 5
0
        public Datastore()
        {
            if (!File.Exists(datastoreLocation))
            {
                ApplicationDataStorage.Instance.FirstRun = true;
            }

            OSType osType = AggContext.OperatingSystem;

            switch (osType)
            {
            case OSType.Windows:
                dbSQLite = new SQLiteWin32.SQLiteConnection(datastoreLocation);
                break;

            case OSType.Mac:
                dbSQLite = new SQLiteUnix.SQLiteConnection(datastoreLocation);
                break;

            case OSType.X11:
                dbSQLite = new SQLiteUnix.SQLiteConnection(datastoreLocation);
                break;

            case OSType.Android:
                dbSQLite = new SQLiteAndroid.SQLiteConnection(datastoreLocation);
                break;

            default:
                throw new NotImplementedException();
            }
        }
 public SQLiteIncidentService()
 {
     localdb = DependencyService.Get<ISQLite> ();
     using(var conn = localdb.GetConnection ()) {
         conn.CreateTable<Incident> ();
     }
 }
    public DatabaseMigrationService(ISQLite sqlite, ISettingsService settings)
    {
        this.sqlite   = sqlite;
        this.settings = settings;

        SetupMigrations();
    }
Ejemplo n.º 8
0
        public UserService(ISlackRestClient restClient, ISQLite sqlite)
        {
            _restClient = restClient;
            _database   = sqlite.GetConnection();

            _database.CreateTable <User>();
            _database.CreateTable <UserProfile>();
        }
Ejemplo n.º 9
0
        public UserService(ISlackRestClient restClient, ISQLite sqlite)
        {
            _restClient = restClient;
            _database = sqlite.GetConnection();

            _database.CreateTable<User>();
            _database.CreateTable<UserProfile>();
        }
Ejemplo n.º 10
0
 public AddRunnerPageViewModel(ISQLite sQLite, IRunnerServices RunnerServices, INavigationService navigationService)
 {
     SqlServices         = sQLite;
     NavigationService   = navigationService;
     this.RunnerServices = RunnerServices;
     Connection          = SqlServices.GetConnection();
     SaveRunnerCommand   = new DelegateCommand(SaveRunnerMethod);
 }
Ejemplo n.º 11
0
        public Datastore()
        {
            if (TEST_FLAG)
            {
                //In test mode - attempt to delete the database entirely
                if (File.Exists(datastoreLocation))
                {
                    try
                    {
                        File.Delete(datastoreLocation);
                    }
                    catch (IOException)
                    {
                    }
                }
            }

            OSType osType = OsInformation.OperatingSystem;

            switch (osType)
            {
            case OSType.Windows:
                dbSQLite = new SQLiteWin32.SQLiteConnection(datastoreLocation);
                break;

            case OSType.Mac:
                dbSQLite = new SQLiteUnix.SQLiteConnection(datastoreLocation);
                break;

            case OSType.X11:
                dbSQLite = new SQLiteUnix.SQLiteConnection(datastoreLocation);
                break;

            case OSType.Android:
                dbSQLite = new SQLiteAndroid.SQLiteConnection(datastoreLocation);
                break;

            default:
                throw new NotImplementedException();
            }

            if (TEST_FLAG)
            {
                //In test mode - attempt to drop all tables (in case db was locked when we tried to delete it)
                foreach (Type table in dataStoreTables)
                {
                    try
                    {
                        this.dbSQLite.DropTable(table);
                    }
                    catch
                    {
                    }
                }
            }

            Debug.WriteLine(datastoreLocation);
        }
Ejemplo n.º 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.NotesPage);
            notifications  = new NotificationsAndroid(Assets, ApplicationContext);
            databaseHelper = new SQLiteAndroid(Assets);

            using (Button show = FindViewById <Button>(Resource.Id.button1))
            {
                show.Click += Show_Click;
            }

            List <Room>   rooms     = databaseHelper.ReadRoomsOnFloor(3);
            List <int>    roomsID   = new List <int>();
            List <string> roomsName = new List <string>();

            foreach (var item in rooms)
            {
                roomsName.Add(item.Name);
                roomsID.Add(item.ID);
            }
            rooms.Clear();

            using (Spinner spinner = FindViewById <Spinner>(Resource.Id.spinner1))
            {
                using (var ada = new ArrayAdapter(this, Resource.Layout.TextViewItem, roomsName.ToArray()))
                {
                    spinner.Adapter = ada;
                }
                spinner.ItemSelected += SpinnerRoom_ItemSelected;
            }
            using (Spinner spinner = FindViewById <Spinner>(Resource.Id.spinnerRoomID))
            {
                using (var ada = new ArrayAdapter(this, Resource.Layout.TextViewItem, roomsID.ToArray()))
                {
                    spinner.Adapter = ada;
                }
            }
            roomsID.Clear();
            roomsName.Clear();

            using (Button button = FindViewById <Button>(Resource.Id.button2))
            {
                button.Click += ButtonAdd_Click;
            }

            using (EditText timeOfNote = FindViewById <EditText>(Resource.Id.editTextTime))
            {
                timeOfNote.Text = DateTime.Now.ToString("HH:mm:ss");
            }
            using (EditText dateOfNote = FindViewById <EditText>(Resource.Id.editTextDate))
            {
                dateOfNote.Text = DateTime.Now.ToString("dd-MM-yyyy");
            }

            MakeList();
            SetFontSize();
        }
 public SQLiteRatingRepository(ISQLite sqlLite)
 {
     _sqlLite = sqlLite;
     //TESTING
     DropTable();
     //TESTING
     CreateTable();
     DataSet = _sqlLite.GetConnection().Table<Rating>();
 }
 public SQLiteCommentRepository(ISQLite sqlLite)
 {
     _sqlLite = sqlLite;
     //TESTING
     DropTable();
     //TESTING
     CreateTable();
     DataSet = _sqlLite.GetConnection().Table<Comment>();
 }
        public SQLiteSavedUserRepository(ISQLite sqlLite)
        {
            _sqlLite = sqlLite;
            //TESTING
//            _sqlLite.DeleteDatabase();
            //TESTING
            CreateTable();
            DataSet = _sqlLite.GetConnection().Table<SavedUser>();
        }
Ejemplo n.º 16
0
        public SQLiteRepository(ISQLite SQLite)
        {
            if (SQLite == null)
            {
                throw new ArgumentNullException("SQLite");
            }

            _SQLiteConnection = SQLite.GetAsyncConnection();
            _SQLiteConnection.CreateTableAsync <T>().Wait();
        }
Ejemplo n.º 17
0
        public UnitOfWork(ISQLite sqlite)
        {
            DB = sqlite.GetConnection();

            _AlunoRepository = new GenericRepository <Aluno, long>(DB, DBLocker);

            lock (DBLocker) {
                DB.CreateTable <Aluno>();
            }
        }
Ejemplo n.º 18
0
        public BaseRepository(ISQLite sqlite, IEventAggregator eventAggregator)
        {
            _connection      = sqlite.GetConnection();
            _asyncConnection = sqlite.GetAsyncConnection();
            _eventAggregator = eventAggregator;

            CreateTableIfNonExistent();

            _eventAggregator.GetEvent <LogoutEvent>().Subscribe(async() => await RemoveAllAsync());
        }
Ejemplo n.º 19
0
        public NotesPage()
        {
            notifications  = new NotificationsWindows();
            databaseHelper = new SQLiteWindows();
            this.InitializeComponent();

            this.navigationHelper            = new NavigationHelper(this);
            this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
            this.navigationHelper.SaveState += this.NavigationHelper_SaveState;
        }
Ejemplo n.º 20
0
        public static IDatabase OpenTest(this ISQLite sqlite, string path, OpenFlags flags, params string[] statements)
        {
            var db = sqlite.Open(path, flags);

            foreach (var s in statements)
            {
                db.Execute(s);
            }
            return(db);
        }
Ejemplo n.º 21
0
        public DatabaseService(ISQLite sqlite)
        {
            _sqlite = sqlite;

            var connection = _sqlite.GetConnection();

            UpdateDatabase(connection);

            _connection = _sqlite.GetAsyncConnection();
        }
Ejemplo n.º 22
0
 public RunnerPageViewModel(ISQLite dbservices, IRunnerServices runnerServices, INavigationService navigationService)
 {
     NavigationService = navigationService;
     NavigateToAddRunnerPageCommand = new DelegateCommand(NavigateToAddRunnerPage);
     NavigateToStatsCommand         = new DelegateCommand <Runner>(NavigateToStatsMethod);
     SqlServices    = dbservices;
     RunnerServices = runnerServices;
     Connection     = SqlServices.GetConnection();
     IsBusy         = true;
 }
Ejemplo n.º 23
0
        private void InitApp(ISQLite sqlitePath)
        {
            _container = LocatorService.Boot(sqlitePath);
            var init = _container.GetInstance <IInitDefaultDb>();

            Task.Run(() => init.LoadDefaultData());
            if (Device.RuntimePlatform == Device.UWP)
            {
                InitNavigation();
            }
        }
Ejemplo n.º 24
0
        public PersonRepository()
        {
            ISQLite sqlService = DependencyService.Get <ISQLite> ();

            if (sqlService.DatabaseExists() == false || sqlService.TableExists("Person") == false)
            {
                using (SQLiteConnection con = DependencyService.Get <ISQLite> ().GetConnection()) {
                    con.CreateTable <Person> ();
                }
            }
        }
Ejemplo n.º 25
0
        public DbContext(ISQLite connection)
        {
            _connection = connection.GetConnection();

            Token        = new DbSet <AuthToken>(_connection);
            Client       = new DbSet <Client>(_connection);
            UsageItem    = new DbSet <UsageItem>(_connection);
            Location     = new DbSet <Location>(_connection);
            User         = new DbSet <User>(_connection);
            UserTask     = new DbSet <UserTask>(_connection);
            UserTaskTime = new DbSet <UserTaskTime>(_connection);
        }
Ejemplo n.º 26
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> >();
        }
Ejemplo n.º 27
0
 public MainPageViewModel(INavigationService navigationService, ISQLite dbservices, IEventServices eventServices, IPdfServices pdfServices)
     : base(navigationService)
 {
     Title = "Main Menu";
     NavigateToRunnerPageCommand = new DelegateCommand(NavigateToRunnerPage);
     DeleteAllCommand            = new DelegateCommand(DeleteAllMethod);
     NavigateToEventsPageCommand = new DelegateCommand(NavigateToEventsPage);
     this.navigationService      = navigationService;
     this.dbservices             = dbservices;
     Connection = dbservices.GetConnection();
     dbservices.CreateTables(Connection);
     this.EventServices = eventServices;
     GetNotRanEvents();
 }
Ejemplo n.º 28
0
        private void PrepareDatabase()
        {
            ISQLite db = null;

            using (var scope = Container.BeginLifetimeScope())
                db = scope.Resolve <ISQLite>();

            if (db == null)
            {
                return;
            }

            db.GetConnection().CreateTable <ClienteModel>();
        }
Ejemplo n.º 29
0
        public Datastore()
        {
            if (TEST_FLAG)
            {
                //In test mode - attempt to delete the database entirely
                if (File.Exists(datastoreLocation))
                {
                    try
                    {
                        File.Delete(datastoreLocation);
                    }
                    catch (IOException)
                    {
                    }
                }
            }

            switch (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType())
            {
            case Agg.UI.WindowsFormsAbstract.OSType.Windows:
                dbSQLite = new SQLiteWin32.SQLiteConnection(datastoreLocation);
                break;

            case Agg.UI.WindowsFormsAbstract.OSType.Mac:
                dbSQLite = new SQLiteUnix.SQLiteConnection(datastoreLocation);
                break;

            default:
                throw new NotImplementedException();
            }

            if (TEST_FLAG)
            {
                //In test mode - attempt to drop all tables (in case db was locked when we tried to delete it)
                foreach (Type table in dataStoreTables)
                {
                    try
                    {
                        this.dbSQLite.DropTable(table);
                    }
                    catch
                    {
                    }
                }
            }

            Debug.WriteLine(datastoreLocation);
        }
Ejemplo n.º 30
0
        public Datastore()
        {
            if (!File.Exists(datastoreLocation))
            {
                ApplicationDataStorage.Instance.FirstRun = true;
            }

            OSType osType = OsInformation.OperatingSystem;

            switch (osType)
            {
            case OSType.Windows:
                dbSQLite = new SQLiteWin32.SQLiteConnection(datastoreLocation);
                break;

            case OSType.Mac:
                dbSQLite = new SQLiteUnix.SQLiteConnection(datastoreLocation);
                break;

            case OSType.X11:
                dbSQLite = new SQLiteUnix.SQLiteConnection(datastoreLocation);
                break;

            case OSType.Android:
                dbSQLite = new SQLiteAndroid.SQLiteConnection(datastoreLocation);
                break;

            default:
                throw new NotImplementedException();
            }

            if (TEST_FLAG)
            {
                //In test mode - attempt to drop all tables (in case db was locked when we tried to delete it)
                foreach (Type table in dataStoreTables)
                {
                    try
                    {
                        this.dbSQLite.DropTable(table);
                    }
                    catch
                    {
                        GuiWidget.BreakInDebugger();
                    }
                }
            }
        }
Ejemplo n.º 31
0
        internal static Container Boot(ISQLite sqlitePath)
        {
            var _container = new Container();

            _container.RegisterInstance(typeof(ISQLite), sqlitePath);
            _container.RegisterInstance(typeof(ILoggerService), new Log(DependencyService.Get <ILogManager>().GetLog()));

            _container.Register <IUnitOfWork, UnitOfWork>();
            _container.Register <IInitDefaultDb, InitDefaultDb>();
            _container.RegisterInstance(typeof(INavigationService), new NavigationService());
            _container.RegisterInstance(typeof(IDialogService), new DialogService());
            _container.Register <BackupGoogleService>();
            _container.Register <BackupLocalService>();
            _container.Register <IThemeService, ThemeChangeService>();
            _container.Register <IFirstLanguage, FirstLanguageService>();
            _container.Register <IKeyboardTranscriptionService, KeyboardTranscriptionChangeService>();
            _container.Register <IWebClient, WebClient>();
            _container.Register <IImportFile, ImportFileToDb>();
            _container.Register <IVolumeLanguageService, VolumeLanguageService>();
            _container.Register <IDictionaryNameLearningCreator, DictionaryNameLearningCreator>();
            _container.Register <IDictionaryTypeByName, DictionaryTypeByName>();
            _container.Register <IUnlearningWordsService, UnlerningWordsService>();
            _container.Register <INewVersionAppChecker, NewVersionAppChecker>();
            _container.Register <ILanguageLoaderFacade, LanguageLoader>();
            _container.Register <IAnimationService, AnimationService>();
            _container.Register <IEntryWordValidator, EntryWordValidator>();
            _container.Register <ITextToSpeech, SpeechService>();
            //register viewmodels
            _container.Register(typeof(MainViewModel));
            _container.Register(typeof(HelperViewModel));
            _container.Register(typeof(InstructionAddOneWordViewModel));
            _container.Register(typeof(InstructionImportFromFileViewModel));
            _container.Register(typeof(SettingsViewModel));
            _container.Register(typeof(LanguageFrNetViewModel));
            _container.Register(typeof(WordsListViewModel));
            _container.Register(typeof(RepeatingWordsViewModel));
            _container.Register(typeof(CreateWordViewModel));
            _container.Register(typeof(EntryTranscriptionViewModel));
            //must befor RepeatingWords
            _container.Register(typeof(WorkSpaceCardsViewModel));
            _container.Register(typeof(WorkSpaceEnterWordViewModel));
            _container.Register(typeof(WorkSpaceSelectWordViewModel));
            _container.Register(typeof(VolumeLanguagesViewModel));
            Container = _container;
            return(_container);
        }
Ejemplo n.º 32
0
        //Run initial checks and operations on sqlite datastore
        public void Initialize(ISQLite dbSQLite)
        {
            this.dbSQLite = dbSQLite;
            ValidateSchema();

            // Construct the root library collection if missing
            var rootLibraryCollection = Datastore.Instance.dbSQLite.Table <PrintItemCollection>().Where(v => v.Name == "_library").Take(1).FirstOrDefault();

            if (rootLibraryCollection == null)
            {
                rootLibraryCollection      = new PrintItemCollection();
                rootLibraryCollection.Name = "_library";
                rootLibraryCollection.Commit();
            }

            StartSession();
        }
        private ISQLite GetDbOS(string nameOC)
        {
            IUnityContainer unityContainer = new UnityContainer();
            ISQLite         sQLite         = null;

            try
            {
                switch (nameOC)
                {
                case "Android": sQLite = unityContainer
                                         .RegisterType <ISQLite, ConnectDbAndroid>()
                                         .Resolve <ConnectDbAndroid>(); break;
                }
            }
            catch (Exception) { }

            return(sQLite);
        }
Ejemplo n.º 34
0
 public DeviceListViewModel(IBluetoothLE bluetoothLe,
                            IAdapter adapter,
                            IUserDialogs userDialogs,
                            ISettings settings,
                            IPermissions permissions) : base(adapter)
 {
     _permissions = permissions;
     _bluetoothLe = bluetoothLe;
     _userDialogs = userDialogs;
     _settings    = settings;
     _bluetoothLe.StateChanged    += OnStateChanged;
     Adapter.DeviceDiscovered     += OnDeviceDiscovered;
     Adapter.ScanTimeoutElapsed   += Adapter_ScanTimeoutElapsed;
     Adapter.DeviceDisconnected   += OnDeviceDisconnected;
     Adapter.DeviceConnectionLost += OnDeviceConnectionLost;
     //Adapter.DeviceConnected += (sender, e) => Adapter.DisconnectDeviceAsync(e.Device);
     _advertisementDataRepository = DependencyService.Get <IAdvertisementDataRepository>();
     _sqliteProvider = DependencyService.Get <ISQLite>();
 }
Ejemplo n.º 35
0
 public SQLite(
     INavigation<Domain.Interfaces.NavigationModes> navigationService
     , IStorage storageService
     , ISettings settingsService
     , IUx uxService
     , ILocation locationService
     , IPeerConnector peerConnectorService
     , ISQLite sqliteService
     )
     : base(navigationService
     , storageService
     , settingsService
     , uxService
     , locationService
         , peerConnectorService)
 {
     this.AppName = International.Translation.AppName;
     this.PageTitle = International.Translation.SQLite_Title;
     _sqliteService = sqliteService;
 }
Ejemplo n.º 36
0
        public MainPage()
        {
            this.InitializeComponent();
            this.NavigationCacheMode = NavigationCacheMode.Required;

            databaseHelper = new SQLiteWinPhone();
            drawer         = new DrawerWinPhone();

            Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;

            comboBox.Items.Add(new ComboBoxItem()
            {
                Content  = "Przyziemie",
                Name     = "floor11",
                FontSize = App.FontSize
            });
            comboBox.Items.Add(new ComboBoxItem()
            {
                Content  = "Parter",
                Name     = "floor0",
                FontSize = App.FontSize
            });
            comboBox.Items.Add(new ComboBoxItem()
            {
                Content  = "1 piętro",
                Name     = "floor1",
                FontSize = App.FontSize
            });
            comboBox.Items.Add(new ComboBoxItem()
            {
                Content  = "2 piętro",
                Name     = "floor2",
                FontSize = App.FontSize
            });
            comboBox.Items.Add(new ComboBoxItem()
            {
                Content  = "3 piętro",
                Name     = "floor3",
                FontSize = App.FontSize
            });
        }
Ejemplo n.º 37
0
        public Datastore() 
        {
            if (TEST_FLAG)
            {
                //In test mode - attempt to delete the database entirely
                if (File.Exists(datastoreLocation))
                {
                    try
                    {
                        File.Delete(datastoreLocation);
                    }
                    catch (IOException)
                    {
                    }
                }
            }
            
            switch (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType())
            {
                case Agg.UI.WindowsFormsAbstract.OSType.Windows:
                    dbSQLite = new SQLiteWin32.SQLiteConnection(datastoreLocation);
                    break;

                case Agg.UI.WindowsFormsAbstract.OSType.Mac:
                    dbSQLite = new SQLiteUnix.SQLiteConnection(datastoreLocation);
                    break;

                default:
                    throw new NotImplementedException();
            }

            if (TEST_FLAG)
            {
                //In test mode - attempt to drop all tables (in case db was locked when we tried to delete it)
                foreach (Type table in dataStoreTables)
                {
                    try
                    {
                        this.dbSQLite.DropTable(table);
                    }
                    catch
                    {
                    }
                }
            }

            Debug.WriteLine(datastoreLocation);
        }
 public UserRepository()
 {
     _sqlite = Resolver.Resolve<ISQLite>();
     _connection = _sqlite.GetConnection();
     _connection.CreateTable<User>();
 }
Ejemplo n.º 39
0
		public Datastore()
		{
			if (!File.Exists(datastoreLocation))
			{
				ApplicationDataStorage.Instance.FirstRun = true;
			}

			OSType osType = OsInformation.OperatingSystem;
			switch (osType)
			{
				case OSType.Windows:
					dbSQLite = new SQLiteWin32.SQLiteConnection(datastoreLocation);
					break;

				case OSType.Mac:
					dbSQLite = new SQLiteUnix.SQLiteConnection(datastoreLocation);
					break;

				case OSType.X11:
					dbSQLite = new SQLiteUnix.SQLiteConnection(datastoreLocation);
					break;

				case OSType.Android:
					dbSQLite = new SQLiteAndroid.SQLiteConnection(datastoreLocation);
					break;

				default:
					throw new NotImplementedException();
			}

			if (TEST_FLAG)
			{
				//In test mode - attempt to drop all tables (in case db was locked when we tried to delete it)
				foreach (Type table in dataStoreTables)
				{
					try
					{
						this.dbSQLite.DropTable(table);
					}
					catch
					{
						GuiWidget.BreakInDebugger();
					}
				}
			}
		}
Ejemplo n.º 40
0
        public Datastore() 
        {
            if (TEST_FLAG)
            {
                //In test mode - attempt to delete the database entirely
                if (File.Exists(datastoreLocation))
                {
                    try
                    {
                        File.Delete(datastoreLocation);
                    }
                    catch (IOException)
                    {
                    }
                }
            }

            OSType osType = OsInformation.OperatingSystem;
			switch (osType)
            {
                case OSType.Windows:
                    dbSQLite = new SQLiteWin32.SQLiteConnection(datastoreLocation);
                    break;

                case OSType.Mac:
                    dbSQLite = new SQLiteUnix.SQLiteConnection(datastoreLocation);
                    break;

                case OSType.X11:
					dbSQLite = new SQLiteUnix.SQLiteConnection(datastoreLocation);
					break;

				case OSType.Android:
					dbSQLite = new SQLiteAndroid.SQLiteConnection(datastoreLocation);
					break;

                default:
                    throw new NotImplementedException();
            }

            if (TEST_FLAG)
            {
                //In test mode - attempt to drop all tables (in case db was locked when we tried to delete it)
                foreach (Type table in dataStoreTables)
                {
                    try
                    {
                        this.dbSQLite.DropTable(table);
                    }
                    catch
                    {
                    }
                }
            }

            Debug.WriteLine(datastoreLocation);
        }