Esempio n. 1
0
        /**
         * Create a data provider.
         */
        public static Database createDataProvider()
        {
            //<option name="db_system" value="mysql"/>
            string dbsystem=Configuration.getValue("db_system", "mysql");

            switch(dbsystem.ToLower())
            {
                case "sqlite":
                    {
                        SQLite provider=new SQLite();
                        return provider;
                    }
                case "mysql":
                    {
                        string host=Configuration.getValue("mysql_hostname", "example.org");
                        int port=Convert.ToInt32(Configuration.getValue("mysql_port", "3306"));
                        string database=Configuration.getValue("mysql_database", "");
                        string username=Configuration.getValue("mysql_username", "");
                        string password=Configuration.getValue("mysql_password", "");

                        MySQL provider=new MySQL(host, port, database, username, password);
                        return provider;
                    }
                default:
                    {
                        throw new Exception();
                    }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Erstellt eine neue Datenbank
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void neueDatenbankerstellenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            saveFileDialog.Filter="Juliette Dateien (*.jdf)|*.jdf";
            saveFileDialog.DefaultExt="jdf";
            saveFileDialog.FileName="";

            if(saveFileDialog.ShowDialog()==DialogResult.OK)
            {
                #region Datenbank erzeugen
                SQLite InstSQLiteNewDB=new SQLite(saveFileDialog.FileName);
                #endregion

                #region Tabellen anlegen
                #region gtjlteMain
                DataTable InstDataTable=new DataTable("gtjlteMain");

                //Primärschlüssel
                InstDataTable.Columns.Add("IndexID", Type.GetType("System.UInt32"));
                InstDataTable.Columns["IndexID"].AllowDBNull=false;
                InstDataTable.Columns["IndexID"].Unique=true;
                InstDataTable.Columns["IndexID"].AutoIncrement=true;

                InstDataTable.Columns.Add("DmtLabel", Type.GetType("System.String")); //Bezeichnung
                InstDataTable.Columns.Add("DmtDescription", Type.GetType("System.String")); //Beschreibung
                InstDataTable.Columns.Add("DmtCategory", Type.GetType("System.UInt64")); //Kategorie
                InstDataTable.Columns.Add("DmtDate", Type.GetType("System.UInt64"));
                InstDataTable.Columns.Add("DmtSiteCount", Type.GetType("System.UInt64"));
                InstDataTable.Columns.Add("DmtTable", Type.GetType("System.String"));

                InstSQLiteNewDB.CreateTable(InstDataTable);
                #endregion

                #region gtjlteCategoryTree
                InstDataTable=new DataTable("gtjlteCategoryTree");

                //Primärschlüssel
                InstDataTable.Columns.Add("IndexID", Type.GetType("System.UInt32"));
                InstDataTable.Columns["IndexID"].AllowDBNull=false;
                InstDataTable.Columns["IndexID"].Unique=true;
                InstDataTable.Columns["IndexID"].AutoIncrement=true;

                InstDataTable.Columns.Add("ParentID", Type.GetType("System.UInt64")); //Kategorie
                InstDataTable.Columns.Add("ElementName", Type.GetType("System.String")); //Bezeichnung
                InstDataTable.Columns.Add("ElementDescription", Type.GetType("System.String")); //Beschreibung

                InstSQLiteNewDB.CreateTable(InstDataTable);
                #endregion
                #endregion
            }
        }