Exemple #1
0
        private void InitializeStorage()
        {
            string fullDbFilePath = FilenameService.GetDBPath();
            string connString     = GetConnectionString();

            lock (monitor)
            {
                try
                {
                    if (!File.Exists(fullDbFilePath))
                    {
                        SQLiteConnection.CreateFile(fullDbFilePath);
                    }

                    storageInitiated = true;
                }
                catch (Exception)
                {}
            }
        }
Exemple #2
0
        public StorageConnection GetConnection(bool skipInitiatedCheck = false)
        {
            if (!skipInitiatedCheck && !storageInitiated)
            {
                logger.Error("Cannot created connection to database: storage not initialized");
                statusService.Post("Помилка: база даний не ініційована, продовження роботи неможливе");
            }
            string fullDbFilePath = FilenameService.GetDBPath();
            string connString     = GetConnectionString();

            StorageConnection connection = new StorageConnection(connString);

            if (connection != null && (connection.State == System.Data.ConnectionState.Connecting || connection.State == System.Data.ConnectionState.Open))
            {
                return(connection);
            }
            else
            {
                throw new Exception(string.Format("Database is not available with connection string {0}", connString));
            }
        }
Exemple #3
0
 private string GetConnectionString()
 {
     return("Data Source=" + FilenameService.GetDBPath());
 }