Example #1
0
        public SpeciesListViewModel(IDatabaseHost iDatabaseHost)
        {
            IDatabaseHost = iDatabaseHost;

            SpeciesCollection = new System.Collections.ObjectModel.ObservableCollection <DBObject.Species>();
            Load();
        }
Example #2
0
        public static void OpenDatabase(IDatabaseHost databaseHost, string host, int port, bool useWindowsAuthentication, string userName, string password, string dbName)
        {
            string connectionString = MakeConnectionString(host, port, useWindowsAuthentication, userName, password, dbName);

            databaseHost.Database = new PetaPoco.Database(connectionString, "MySql");
            databaseHost.Database.OpenSharedConnection();
        }
        public static void CreateDatabase(IDatabaseHost databaseHost, string folder, string dbName)
        {
            string path = System.IO.Path.Combine(folder, dbName + ".sqlite");

            databaseHost.Database = new PetaPoco.Database("Data Source=" + path + ";Version=3;", "System.Data.SQLite");
            databaseHost.Database.OpenSharedConnection();
        }
Example #4
0
        public static void CreateDatabase(IDatabaseHost databaseHost, string host, int port, bool useWindowsAuthentication, string userName, string password, string dbName)
        {
            // Connect to the master DB to create the requested database

            OpenDatabase(databaseHost, host, port, useWindowsAuthentication, userName, password, "MySql");

            databaseHost.Database.Execute(@"CREATE DATABASE " + dbName);
            databaseHost.Database.CloseSharedConnection();

            // Connect to the new database

            OpenDatabase(databaseHost, host, port, useWindowsAuthentication, userName, password, dbName);
        }
        public static void CreateDatabase(IDatabaseHost databaseHost, string host, int port, bool useWindowsAuthentication, string userName, string password, string dbName)
        {
            // Connect to the master DB to create the requested database

            OpenDatabase(databaseHost, host, port, useWindowsAuthentication, userName, password, "postgres");

            databaseHost.Database.Execute(@"CREATE DATABASE " + dbName + @" WITH OWNER = postgres ENCODING = 'UTF8' CONNECTION LIMIT = -1;");
            databaseHost.Database.CloseSharedConnection();

            // Connect to the new database

            OpenDatabase(databaseHost, host, port, useWindowsAuthentication, userName, password, dbName);
        }
        public static void CreateDatabase(IDatabaseHost databaseHost, string dataSource, bool useWindowsAuthentication, string userName, string password, string folder, string dbName)
        {
            // Connect to the master DB to create the requested database

            OpenDatabase(databaseHost, true, dataSource, null, -1, useWindowsAuthentication, userName, password, "master");

            string filename = System.IO.Path.Combine(folder, dbName);

            databaseHost.Database.Execute("CREATE DATABASE " + dbName + " ON PRIMARY (Name=" + dbName + ", filename = \"" + filename + ".mdf\") LOG ON (name=" + dbName + "_log, filename=\"" + filename + ".ldf\")");
            databaseHost.Database.CloseSharedConnection();

            // Connect to the new database

            OpenDatabase(databaseHost, true, dataSource, null, -1, useWindowsAuthentication, userName, password, dbName);
        }
Example #7
0
        public static string GenerateRandomPassword(this IDatabaseHost _)
        {
            const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
                                 "abcdefghijklmnopqrstuvwxyz" +
                                 "0123456789";
            var rnd = new Random(DateTime.Now.Millisecond);

            var stringBuilder = new StringBuilder();

            for (var x = 0; x < 16; x++)
            {
                var index = rnd.Next(0, chars.Length - 1);
                stringBuilder.Append(chars[index]);
            }

            return(stringBuilder.ToString());
        }
Example #8
0
 public RepositoryBase(IDatabaseHost host)
 {
     _host = host;
 }
Example #9
0
 public PaymentRepository(IDatabaseHost host) : base(host)
 {
 }
Example #10
0
 public static void OpenDatabase(IDatabaseHost databaseHost, string filepath)
 {
     databaseHost.Database = new PetaPoco.Database("Data Source=" + filepath + ";Version=3;", "System.Data.SQLite");
     databaseHost.Database.OpenSharedConnection();
 }
Example #11
0
 public UserRepository(IDatabaseHost host)
     : base(host)
 {
 }