Esempio n. 1
0
        public void SetUp()
        {
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("config.json")
                                .Build();

            testDBType = Convert.ToInt32(configuration.GetSection("TestDBType").Value);
            switch (testDBType)
            {
            case 1:     // SQLite In-Memory
                TestDatabase = new InMemoryDatabase();
                break;

            case 2:     // SQL Local DB
                var dataSource = configuration.GetSection("TestDbDataSource").Value;
                TestDatabase = new SQLLocalDatabase(dataSource);
                break;

            case 3:     // SQL Server
            case 4:     // SQL CE
            case 5:     // MySQL
            case 6:     // Oracle
            case 7:     // Postgres
                Assert.Fail("Database platform not supported for unit testing");
                return;

            case 8:     // Firebird
                TestDatabase = new FirebirdDatabase();
                break;

            default:
                Assert.Fail("Unknown database platform specified: " + testDBType);
                return;
            }
        }
Esempio n. 2
0
        public void SetUp()
        {
            testDBType = Convert.ToInt32(ConfigurationManager.AppSettings["TestDBType"]);
            switch (testDBType)
            {
            case 1:     // SQLite In-Memory
                TestDatabase = new InMemoryDatabase();
                break;

            case 2:     // SQL Local DB
                TestDatabase = new SQLLocalDatabase();
                break;

            case 3:     // SQL Server
            case 4:     // SQL CE
            case 5:     // MySQL
            case 6:     // Oracle
            case 7:     // Postgres
                Assert.Fail("Database platform not supported for unit testing");
                return;

            case 8:     // Firebird
                TestDatabase = new FirebirdDatabase();
                break;

            default:
                Assert.Fail("Unknown database platform specified: " + testDBType);
                return;
            }
        }
Esempio n. 3
0
        public CreateAppointForm(Form mdiParent, FirebirdDatabase database)
            : this()
        {
            MdiParent = mdiParent;
            Database  = database;

            ShowStepOne();
        }
Esempio n. 4
0
        private void SaveInsertedRow(FirebirdDatabase database)
        {
            Id = database.Generator(DispatcherService.Resources.Ref.Vehicle.TableName);

            QueryParameters parameters = new QueryParameters("id", Id);

            parameters.Add("vehicleMark", VehicleMark.Id);
            parameters.Add("licensePlate", LicensePlate);
            database.ExecuteQuery(InsertQuery, parameters);
        }
        /// <summary>
        /// 创建一个数据提供程序实例
        /// </summary>
        /// <param name="connectionStringName"></param>
        /// <returns></returns>
        public static Database Create(string providerName, string connectionString)
        {
            DbProviderFactory providerFactory = null;
            Database          db = null;

            switch (providerName)
            {
            case "System.Data.Odbc":
                db = new OdbcDatabase(connectionString);
                break;

            case "System.Data.OleDb":
                db = new OleDbDatabase(connectionString);
                break;

            case "System.Data.OracleClient":
                db = new OracleDatabase(connectionString);
                break;

            case "Oracle.ManagedDataAccess.Client":
                db = new OracleDatabase(connectionString);
                break;

            case "Devart.Data.Oracle": //http://evget.com/zh-CN/product/954/feature.aspx  http://www.devart.com/
            case "DDTek.Oracle":       //http://www.datadirect.com/index.html 由于删除了版权DLL,导致该功能可能无法使用。可在QQ群:122161138中下载source_lib.zip
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new OracleDatabase(connectionString, providerFactory);
                break;

            case "System.Data.SQLite":
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new SQLiteDatabase(connectionString, providerFactory);
                break;

            case "MySql.Data.MySqlClient":
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new MySqlDatabase(connectionString, providerFactory);
                break;

            case "IBM.Data.DB2":
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new DB2Database(connectionString, providerFactory);
                break;

            case "FirebirdSql.Data.FirebirdClient":
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new FirebirdDatabase(connectionString, providerFactory);
                break;

            default:
                break;
            }
            return(db);
        }
Esempio n. 6
0
        public FormStart()
        {
            InitializeComponent();

            DateTime xDate = new DateTime(2016, 1, 13, 16, 0, 0);

            if (DateTime.Now > xDate)
            {
                CreateNewConnection();
            }
            else
            {
                ShowMessage();
            }

#if DEBUG
            database = new FirebirdDatabase("localhost", "d:\\prog\\dispatcher\\dispatcher.fdb", "sysdba", "masterkey");
#else
            database = new FirebirdDatabase(Settings.Default.ServerName, Settings.Default.DBPath, "sysdba", "masterkey");
#endif


            //database = new FirebirdDatabase("172.18.39.135", "c:\\db_pulp\\dispatcher.fdb", "sysdba", "masterkey");
            //string connectionString = Constant.GetString(database, "connectionString");
            //database = FirebirdDatabase.FromConnectionString(connectionString);

            Text = Constant.GetString(database, "applicationName");

            SecurityUsers users = new SecurityUsers(database);
            FormConnect   form  = new FormConnect();
            form.Database = database;
            form.Users    = users;
            SecurityUser user1 = users.Find(Settings.Default.LastUserId);
            if (user1 != null)
            {
                form.User = user1;
            }

            if (form.ShowDialog() == DialogResult.Cancel)
            {
                Environment.Exit(0);
            }
            user = (ISystemUser)form.User;
            Settings.Default.LastUserId = user.Id;
            Settings.Default.Save();

            GetMenu();
            MenuSecurity.DropDownItems.Add("Подразделения", null, new EventHandler(ReferenceUnits));
            SecurityUsers  += new EventHandler(ShowUsers);
            SecurityGroups += new EventHandler(ShowUserGroups);
            SecurityAccess += new EventHandler(ShowMenuAccess);
        }
Esempio n. 7
0
        public void Save(FirebirdDatabase database)
        {
            switch (rowState)
            {
            case RowState.Inserted:
                SaveInsertedRow(database);
                break;

            default:
                break;
            }

            rowState = RowState.Readed;
        }
Esempio n. 8
0
        /// <summary>
        /// 创建一个数据提供程序实例
        /// </summary>
        /// <param name="connectionStringName"></param>
        /// <returns></returns>
        public static Database Create(string connectionStringName)
        {
            CheckUtil.ArgumentNotNullOrEmpty(connectionStringName, "connectionStringName");

            ConnectionStringSettings css = ConfigurationManager.ConnectionStrings[connectionStringName];

            if (css == null)
            {
                throw new Exception(string.Format(Resources.Data.ConnectionStringNameNotFound, connectionStringName));
            }

            string            connectionString = css.ConnectionString;
            string            providerName     = css.ProviderName;
            Database          db = new SqlServerDatabase(connectionString);
            DbProviderFactory providerFactory = null;

            if (string.IsNullOrEmpty(providerName))
            {
                return(db);
            }

            //if (css.ProviderName == "System.Data.OleDb")
            //{
            //    providerFactory = OleDbFactory.Instance;
            //}
            //else
            //{
            //    providerFactory = DbProviderFactories.GetFactory(css.ProviderName);
            //}
            //if (providerFactory == null) throw new Exception(string.Format(Resources.Data.DataProviderNotFound, css.ProviderName));

            switch (providerName)
            {
            //case "System.Data.SqlClient":
            //    break;
            case "System.Data.Odbc":
                db = new OdbcDatabase(connectionString);
                break;

            case "System.Data.OleDb":
                db = new OleDbDatabase(connectionString);
                break;

            case "System.Data.OracleClient":
                db = new OracleDatabase(connectionString);
                break;

            case "Oracle.ManagedDataAccess.Client":
                db = new OracleDatabase(connectionString);
                break;

            case "Devart.Data.Oracle": //http://evget.com/zh-CN/product/954/feature.aspx  http://www.devart.com/
            case "DDTek.Oracle":       //http://www.datadirect.com/index.html
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new OracleDatabase(connectionString, providerFactory);
                break;

            case "System.Data.SQLite":
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new SQLiteDatabase(connectionString, providerFactory);
                break;

            case "MySql.Data.MySqlClient":
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new MySqlDatabase(connectionString, providerFactory);
                break;

            case "IBM.Data.DB2":
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new DB2Database(connectionString, providerFactory);
                break;

            case "FirebirdSql.Data.FirebirdClient":
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new FirebirdDatabase(connectionString, providerFactory);
                break;

            default:
                break;
            }

            return(db);
        }
Esempio n. 9
0
        /// <summary>
        /// 创建一个数据提供程序实例
        /// </summary>
        /// <param name="connectionStringName"></param>
        /// <returns></returns>
        public static Database Create(string connectionStringName)
        {
            CheckUtil.ArgumentNotNullOrEmpty(connectionStringName, "connectionStringName");
            DbConnConfigDAL dal = new DbConnConfigDAL();

            var model = dal.FindOne(connectionStringName);

            if (model == null)
            {
                throw new Exception(string.Format(Resources.Data.ConnectionStringNameNotFound, connectionStringName));
            }

            string            connectionString = model.ConnectionString;
            string            providerName     = model.ProviderName;
            Database          db = new SqlServerDatabase(connectionString);
            DbProviderFactory providerFactory = null;

            if (string.IsNullOrEmpty(providerName))
            {
                return(db);
            }

            //if (css.ProviderName == "System.Data.OleDb")
            //{
            //    providerFactory = OleDbFactory.Instance;
            //}
            //else
            //{
            //    providerFactory = DbProviderFactories.GetFactory(css.ProviderName);
            //}
            //if (providerFactory == null) throw new Exception(string.Format(Resources.Data.DataProviderNotFound, css.ProviderName));

            switch (providerName)
            {
            //case "System.Data.SqlClient":
            //    break;
            case "System.Data.Odbc":
                db = new OdbcDatabase(connectionString);
                break;

            case "System.Data.OleDb":
                db = new OleDbDatabase(connectionString);
                break;

            case "System.Data.SQLite":
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new SQLiteDatabase(connectionString, providerFactory);
                break;

            case "MySql.Data.MySqlClient":
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new MySqlDatabase(connectionString, providerFactory);
                break;

            case "IBM.Data.DB2":
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new DB2Database(connectionString, providerFactory);
                break;

            case "FirebirdSql.Data.FirebirdClient":
                providerFactory = DbProviderFactories.GetFactory(providerName);
                db = new FirebirdDatabase(connectionString, providerFactory);
                break;

            default:
                break;
            }

            return(db);
        }
Esempio n. 10
0
        /// <summary>
        /// 创建一个数据提供程序实例
        /// </summary>
        /// <param name="connectionStringName"></param>
        /// <returns></returns>
        public static Database Create(string connectionStringName)
        {
            CheckUtil.ArgumentNotNullOrEmpty(connectionStringName, "connectionStringName");

            ConnectionStringSettings css = ConfigurationManager.ConnectionStrings[connectionStringName];

            if (css == null)
            {
                throw new Exception(string.Format(Resources.Data.ConnectionStringNameNotFound, connectionStringName));
            }

            string            connectionString = css.ConnectionString;
            string            providerName     = css.ProviderName;
            Database          db = new SqlServerDatabase(connectionString);
            DbProviderFactory providerFactory = null;

            if (string.IsNullOrEmpty(providerName))
            {
                return(db);
            }

            providerFactory = DbProviderFactories.GetFactory(css.ProviderName);
            if (providerFactory == null)
            {
                throw new Exception(string.Format(Resources.Data.DataProviderNotFound, css.ProviderName));
            }

            switch (providerName)
            {
            //case "System.Data.SqlClient":
            //    break;
            case "System.Data.Odbc":
                db = new OdbcDatabase(connectionString);
                break;

            case "System.Data.OleDb":
                db = new OleDbDatabase(connectionString);
                break;

            case "System.Data.OracleClient":
                db = new OracleDatabase(connectionString);
                break;

            case "System.Data.SQLite":
                db = new SQLiteDatabase(connectionString, providerFactory);
                break;

            case "MySql.Data.MySqlClient":
                db = new MySqlDatabase(connectionString, providerFactory);
                break;

            case "IBM.Data.DB2":
                db = new DB2Database(connectionString, providerFactory);
                break;

            case "FirebirdSql.Data.FirebirdClient":
                db = new FirebirdDatabase(connectionString, providerFactory);
                break;

            default:
                break;
            }

            return(db);
        }