private void Upgrade_Click(object sender, EventArgs e) { IniFile file = new IniFile(Constants.SetupConfigPath); if (this.Text == "تنصيب البرنامج") { if (!File.Exists(Constants.SetupConfigPath)) { file.Write("MySql", "Host", DBHost.Text); file.Write("MySql", "Username", DBUser.Text); file.Write("MySql", "Password", DBPass.Text); file.Write("MySql", "Database", DBName.Text); file.Write("Upgrade", "Version", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Replace(".", "")); if (!Directory.Exists(Application.StartupPath + @"BackUp\")) { Directory.CreateDirectory(Application.StartupPath + @"\BackUp\"); } DataHolder.CreateConnection(Program.INIDecrypt(file.ReadString("MySql", "Username")), Program.INIDecrypt(file.ReadString("MySql", "Password")), Program.INIDecrypt(file.ReadString("MySql", "Host"))); DataHolder.CreateConnection(Program.INIDecrypt(file.ReadString("MySql", "Username")), Program.INIDecrypt(file.ReadString("MySql", "Password")), Program.INIDecrypt(file.ReadString("MySql", "Database")), Program.INIDecrypt(file.ReadString("MySql", "Host"))); CreateDB.UpgradeTables(); MessageBox.Show("تم الترقية بنجاح\nمن فضلك انشاء حساب جديد لتتمكن من الدخول"); Register reg = new Register(); reg.ShowDialog(); this.Close(); } } else if (this.Text == "اعدادات البرنامج") { Upgrade.Enabled = false; } }
private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { (sender as BackgroundWorker)?.ReportProgress(5); Config co = new Config(); Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { co.Hostname = DbHost.Text; co.DbName = DbName.Text; co.DbUserName = DbUser.Text; co.DbUserPassword = DbPass.Text; co.AccountsLog = "1"; co.DrugsLog = "1"; co.Write(true, true); }); (sender as BackgroundWorker)?.ReportProgress(30); if (!Directory.Exists(Paths.BackupsPath)) { Directory.CreateDirectory(Paths.BackupsPath); } (sender as BackgroundWorker)?.ReportProgress(40); Dispatcher.Invoke((Action)(() => { DataHolder.CreateConnection(co.DbUserName, co.DbUserPassword, co.Hostname); CreateDB.Createdb(co.DbName); DataHolder.CreateConnection(co.DbUserName, co.DbUserPassword, co.DbName, co.Hostname); })); (sender as BackgroundWorker)?.ReportProgress(60); Dispatcher.Invoke((Action)(CreateDB.CreateTables)); (sender as BackgroundWorker)?.ReportProgress(95); }
/// <summary> /// Gets an existing database or creates a new one. /// </summary> /// <param name="name">The name of the database to get or create.</param> /// <param name="database">The database.</param> /// <returns>true if the database was opened, false if it was created.</returns> public static bool Get(string name, out Database database) { if (name == null) { throw new ArgumentNullException("name"); } if (name == String.Empty) { throw new ArgumentException("name"); } //Try to open or create the database database = null; try { database = Get(Open.open(name, Context)); return(true); } catch (Exception) { try { database = Get(CreateDB.create(name, Parser.emptyParser(Context.prop), Context)); return(false); } catch (Exception ex) { throw new ArgumentException("Could not create database.", ex); } } }
// GET: BuildDB public ActionResult Index() { var cDB = new CreateDB(); cDB.Database(); return(View()); }
static void Main() { Console.OutputEncoding = Encoding.Unicode; Console.InputEncoding = Encoding.Unicode; string connectionStr = "Data Source=serverpu816.database.windows.net;Initial Catalog=test;User ID=pu816;Password=Qwerty1*"; CreateDB c = new CreateDB(connectionStr); c.ExecuteQuery(); }
private void 重构数据库ToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("您确定要重构数据库吗?此操作将会清空数据库的所有数据!数据无价,谨慎操作!", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.OK) { CreateDB cdb = new CreateDB(); cdb.creatDatabase(); } }
public override void OnInspectorGUI() { serializedObject.Update(); _timingProperties.Clear(); GUIStyle boldStyle = new GUIStyle(); boldStyle.fontStyle = FontStyle.Bold; //displaying properties and button: DisplayRegularField(DATABASENAME); EditorGUILayout.Separator(); if (_properties[DATABASEPATH.name].stringValue.Length == 0) { _properties[DATABASEPATH.name].stringValue = "start typing antyhing in order to trigger popup window for selecting database path."; } EditorGUI.BeginChangeCheck(); DisplayRegularField(DATABASEPATH); if (EditorGUI.EndChangeCheck()) { string databasePath = PopUpSelectDatabasePathWindow(); if (databasePath != null && databasePath.Length > 0) { _properties[DATABASEPATH.name].stringValue = databasePath; //making sure that streaming assets folder exists in path EnsureStreamingAssetsFolderExists(databasePath); } } EditorGUILayout.Separator(); if (GUILayout.Button("Create Database")) { if (ValidateDatabaseFormInput()) { string databaseName = _properties[DATABASENAME.name].stringValue; string databasePath = _properties[DATABASEPATH.name].stringValue; if (!DoesDatabaseExist(databaseName)) { CreateDB.ConnectWithDatabaseInspector(databaseName, databasePath); } else { Debug.Log("database with name <i>" + databaseName + "</i> already exists in StreamingAssets folder."); } } } serializedObject.ApplyModifiedProperties(); }
public ActionResult Connect(ConnectionString model) { ////ilk açılış cache'i tetikledik //CreateCache.Create(); ////we are updating connection string on web.config var updatedResult = UpdateConfig.update(model.connectionString); CreateDB.create(); CreateCache.Create(); //return RedirectToAction("Product", "Index"); return(RedirectToAction("List", "Home")); }
//database private void SetB1_Click(object sender, RoutedEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { BackUp.NewDbBackup(); MessageBox.Show("تم اخذ نسخه احتياطيه من القاعده القديمه"); DataHolder.CreateConnection(co.DbUserName, co.DbUserPassword, co.Hostname); CreateDB.Createdb(co.DbName, DbName.Text); co.Write(); MessageBox.Show("تم الحفظ سيتم غلق البرنامج الان"); Environment.Exit(0); }); }
private void Install_Click(object sender, EventArgs e) { try { IniFile file = new IniFile(Constants.SetupConfigPath); if (this.Text == "تنصيب البرنامج") { if (!File.Exists(Constants.SetupConfigPath)) { file.Write("MySql", "Host", DBHost.Text); file.Write("MySql", "Username", DBUser.Text); file.Write("MySql", "Password", DBPass.Text); file.Write("MySql", "Database", DBName.Text); file.Write("Upgrade", "Version", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Replace(".", "")); if (!Directory.Exists(Application.StartupPath + @"BackUp\")) { Directory.CreateDirectory(Application.StartupPath + @"\BackUp\"); } DataHolder.CreateConnection(Program.INIDecrypt(file.ReadString("MySql", "Username")), Program.INIDecrypt(file.ReadString("MySql", "Password")), Program.INIDecrypt(file.ReadString("MySql", "Host"))); CreateDB.Createdb(DBName.Text); DataHolder.CreateConnection(Program.INIDecrypt(file.ReadString("MySql", "Username")), Program.INIDecrypt(file.ReadString("MySql", "Password")), Program.INIDecrypt(file.ReadString("MySql", "Database")), Program.INIDecrypt(file.ReadString("MySql", "Host"))); CreateDB.CreateTables(); MessageBox.Show("تم تنصيب الاعدادات\nمن فضلك انشاء حساب جديد لتتمكن من الدخول"); Register reg = new Register(); reg.ShowDialog(); this.Close(); } } else if (this.Text == "اعدادات البرنامج") { if (File.Exists(Constants.SetupConfigPath)) { BackUp.NewDbBackup(); DataHolder.CreateConnection(Program.INIDecrypt(file.ReadString("MySql", "Username")), Program.INIDecrypt(file.ReadString("MySql", "Password")), Program.INIDecrypt(file.ReadString("MySql", "Host"))); CreateDB.Createdb(file.ReadString("MySql", "Database"), DBName.Text); file.Write("MySql", "Host", DBHost.Text); file.Write("MySql", "Username", DBUser.Text); file.Write("MySql", "Password", DBPass.Text); file.Write("MySql", "Database", DBName.Text); DataHolder.CreateConnection(Program.INIDecrypt(file.ReadString("MySql", "Username")), Program.INIDecrypt(file.ReadString("MySql", "Password")), Program.INIDecrypt(file.ReadString("MySql", "Database")), Program.INIDecrypt(file.ReadString("MySql", "Host"))); BackUp.NewDbRestore(); BillsTable.LBN(); MessageBox.Show("تم تغيير الاعدادات"); } } } catch (Exception ee) { Program.SaveException(ee); } }
private void OnEnable() { _createDB = (CreateDB)target; //need this for button _properties.Clear(); SerializedProperty property = serializedObject.GetIterator(); while (property.NextVisible(true)) { _properties[property.name] = property.Copy(); } if (ValidateDatabaseFormInput()) { //connecting with the database: string databaseName = _properties[DATABASENAME.name].stringValue; string databasePath = _properties[DATABASEPATH.name].stringValue; CreateDB.ConnectWithDatabaseInspectorOnEnable(databaseName, databasePath); } }
public MerchantAPITestDbManager(ILogger <CreateDB> logger, IConfiguration configuration) { string scriptLocation = "..\\..\\..\\Database\\Scripts"; // Fix path for non windows os if (Path.DirectorySeparatorChar != '\\') { scriptLocation = scriptLocation.Replace('\\', Path.DirectorySeparatorChar); } aggregatorTestDb = new CreateDB(logger, DB_MAPI, RDBMS.Postgres, configuration["ConnectionStrings:DBConnectionStringDDL"], configuration["ConnectionStrings:DBConnectionStringMaster"], scriptLocation ); aggregatorDb = new CreateDB(logger, DB_MAPI, RDBMS.Postgres, configuration["ConnectionStrings:DBConnectionStringDDL"], configuration["ConnectionStrings:DBConnectionStringMaster"] ); }
public MerchantAPIDbManager(ILogger <CreateDB> logger, IConfiguration configuration) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); mapiDb = new CreateDB(logger, DB_MAPI, RDBMS.Postgres, configuration["ConnectionStrings:DBConnectionStringDDL"], configuration["ConnectionStrings:DBConnectionStringMaster"] ); mapiDbNoMaster = new CreateDB(logger, DB_MAPI, RDBMS.Postgres, configuration["ConnectionStrings:DBConnectionStringDDL"] ); var root = GetScriptsRootForUpgradeFromV12(); mapiDbUpgradeV12 = new CreateDB(logger, DB_MAPI, RDBMS.Postgres, configuration["ConnectionStrings:DBConnectionStringMaster"], configuration["ConnectionStrings:DBConnectionStringMaster"], root ); }
public void CreateDB_1()//Verifies a DB created and exists { appConnection.ConnectServer("mongodb://127.0.0.1:27017", null); string newDbName = "stasdb55"; string newcollection = "StasUnitTCreateColl5"; UnitTest1 existingdbname = new UnitTest1(); var result = existingdbname.DatabaseExists(newDbName); if (result == true)// DB already exists check { Fail("DB already exists"); } else { CreateDB create = new CreateDB(); create.CreateDBs(newDbName, newcollection, appConnection, "Field", "Value"); var result1 = existingdbname.DatabaseExists(newDbName); Assert.True(result1);//Checks true/false saved in "result" } }
public void CreateCollection_2()//Verifies a collection created in specific db { string newDbName1 = "stasdb55"; string newcollection1 = "StasUnitTCreateColl6"; appConnection.ConnectServer("mongodb://127.0.0.1:27017", null); UnitTest1 existingcollname = new UnitTest1(); var result = existingcollname.CollectionExists(newcollection1); if (result == true)// Collection already exists check { Fail("The Collectionn already exists"); } else { CreateDB create = new CreateDB(); create.CreateDBs(newDbName1, newcollection1, appConnection, "Field", "Value"); var result1 = existingcollname.DatabaseExists(newDbName1); Assert.True(result1);//Checks true/false saved in "result" } }
/// <summary> /// 如果本地数据库不存在则创建它 /// </summary> public void CreateDB() { #region 如果本地数据库不存在则创建它 CreateDB createDb = new CreateDB(); //获取本地连接信息 int k = createDb.IsExitDB(); //不存在数据库活着数据库没有附加上去 if (k == 0) { if (File.Exists("C:\\RepastErp_data.mdf")) { File.Delete("C:\\RepastErp_data.mdf"); } if (File.Exists("C:\\RepastErp_log.ldf")) { File.Delete("C:\\RepastErp_log.ldf"); } if (!createDb.CreateDatabase()) { MessageBox.Show("创建数据库失败!"); Application.Exit(); } } //本地信息配置有错误 else if (k == 2) { MessageBox.Show("创建数据库失败!有可能是本地数据库据端口、用户名及密码配置错误。配置完后重新启动系统。"); Environment.Exit(0); } //存在数据库 else { } #endregion }
/// <summary> /// Gets a new memory database. This database has no name and is not added to /// the database cache. It does not need to be dropped. /// </summary> /// <returns>A new in-memory database.</returns> public static Database Get() { MemData data = CreateDB.mainMem(Parser.emptyParser(Context.prop), Context); return(new Database(data)); }
public SQLtype Parser(string query) { //CREATE TABLE Column[] ct2 = new Column[10]; string[] ct3 = new string[10]; //* string ct1 = ""; Match matchcreate1 = Regex.Match(query, createTable1); Match matchcreate2 = Regex.Match(query, createTable2); if (matchcreate1.Success) { ct1 = matchcreate1.Groups[1].Value; ct3[0] = matchcreate1.Groups[2].Value; //ct2[0].name = matchcreate1.Groups[2].Value; //ct2[0].type = matchcreate1.Groups[2].Value; SQLtype sentencia = new CreateTable(ct1, ct3); //tipos de momento sin implementar* return(sentencia); } else if (matchcreate2.Success) { ct1 = matchcreate2.Groups[1].Value; ct3[0] = matchcreate2.Groups[2].Value; //* //ct2[0].name = matchcreate2.Groups[2].Value; //ct2[0].type = matchcreate2.Groups[2].Value; for (int i = 0; i < matchcreate2.Groups[5].Captures.Count; i++) { ct3[i + 1] = matchcreate2.Groups[5].Captures[i].Value; //* /*ct2[i + 1].name = matchcreate2.Groups[5].Captures[i].Value; * ct2[i + 1].type = matchcreate2.Groups[6].Captures[i].Value;*/ } SQLtype sentencia = new CreateTable(ct1, ct3); return(sentencia); } //BACKUP DB string backupDB1 = ""; string backupDB2 = ""; Match matchBPDB = Regex.Match(query, backupDB); if (matchBPDB.Success) { backupDB1 = matchBPDB.Groups[1].Value; backupDB2 = matchBPDB.Groups[2].Value; SQLtype sentencia = new BackUp(backupDB1, backupDB2); return(sentencia); } //CREATE DB string createDB1 = ""; Match matchcDB = Regex.Match(query, createDB); if (matchcDB.Success) { createDB1 = matchcDB.Groups[1].Value; SQLtype sentencia = new CreateDB(createDB1); return(sentencia); } //UPDATE string[] cupdate2 = new string[10]; string cupdate1 = ""; string[] cupdate3 = new string[10]; Match matchUp1 = Regex.Match(query, update1); Match matchUp2 = Regex.Match(query, update2); if (Regex.Match(query, update1).Success) { cupdate1 = matchUp1.Groups[1].Value; cupdate2[0] = matchUp1.Groups[2].Value; cupdate2[1] = matchUp1.Groups[3].Value; cupdate2[2] = matchUp1.Groups[4].Value; cupdate3[0] = matchUp1.Groups[5].Value; cupdate3[1] = matchUp1.Groups[6].Value; cupdate3[2] = matchUp1.Groups[7].Value; SQLtype sentencia = new Update(cupdate1, cupdate2, cupdate3); return(sentencia); } else if (Regex.Match(query, update2).Success) { cupdate1 = matchUp2.Groups[1].Value; //The first column of the set cupdate2[0] = matchUp2.Groups[2].Value; cupdate2[1] = matchUp2.Groups[3].Value; cupdate2[2] = matchUp2.Groups[4].Value; //The second column of the set cupdate2[3] = matchUp2.Groups[6].Value; cupdate2[4] = matchUp2.Groups[7].Value; cupdate2[5] = matchUp2.Groups[8].Value; cupdate3[0] = matchUp2.Groups[9].Value; cupdate3[1] = matchUp2.Groups[10].Value; cupdate3[2] = matchUp2.Groups[11].Value; SQLtype sentencia = new Update(cupdate1, cupdate2, cupdate3); return(sentencia); } //DELETE string delete1 = ""; string[] delete2 = new string[10]; Match matchDel = Regex.Match(query, delete); if (Regex.Match(query, delete).Success) { delete1 = matchDel.Groups[1].Value; delete2[0] = matchDel.Groups[2].Value; delete2[1] = matchDel.Groups[3].Value; delete2[2] = matchDel.Groups[4].Value; SQLtype sentencia = new Delete(delete1, delete2); return(sentencia); } //SELECT string[] camp1 = new string[10]; string camp2 = ""; string[] camp3 = new string[10]; Match matchS1 = Regex.Match(query, select1); Match matchS2 = Regex.Match(query, select2); Match matchS3 = Regex.Match(query, select3); Match matchS4 = Regex.Match(query, select4); Match matchS5 = Regex.Match(query, select5); Match matchS6 = Regex.Match(query, select6); if (Regex.Match(query, select1).Success) { camp1[0] = matchS1.Groups[1].Value; camp2 = matchS1.Groups[2].Value; SQLtype sentencia = new Select(camp2, camp1, camp3); return(sentencia); } else if (Regex.Match(query, select2).Success) { camp1[0] = matchS2.Groups[1].Value; camp2 = matchS2.Groups[2].Value; camp3[0] = matchS2.Groups[3].Value; camp3[1] = matchS2.Groups[4].Value; camp3[2] = matchS2.Groups[5].Value; SQLtype sentencia = new Select(camp2, camp1, camp3); return(sentencia); } else if (Regex.Match(query, select3).Success) { camp1[0] = matchS3.Groups[1].Value; camp2 = matchS3.Groups[2].Value; SQLtype sentencia = new Select(camp2, camp1, camp3); return(sentencia); } else if (Regex.Match(query, select4).Success) { camp1[0] = matchS4.Groups[1].Value; camp2 = matchS4.Groups[2].Value; camp3[0] = matchS4.Groups[3].Value; camp3[1] = matchS4.Groups[4].Value; camp3[2] = matchS4.Groups[5].Value; SQLtype sentencia = new Select(camp2, camp1, camp3); return(sentencia); } else if (Regex.Match(query, select5).Success) { camp1[0] = matchS5.Groups[1].Value; for (int i = 0; i < matchS5.Groups[3].Captures.Count; i++) { camp1[i + 1] = matchS5.Groups[3].Captures[i].Value; } camp2 = matchS5.Groups[4].Value; SQLtype sentencia = new Select(camp2, camp1, camp3); return(sentencia); } else if (Regex.Match(query, select6).Success) { camp1[0] = matchS6.Groups[1].Value; for (int i = 0; i < matchS6.Groups[3].Captures.Count; i++) { camp1[i + 1] = matchS6.Groups[3].Captures[i].Value; } camp2 = matchS6.Groups[4].Value; camp3[0] = matchS6.Groups[5].Value; camp3[1] = matchS6.Groups[6].Value; camp3[2] = matchS6.Groups[7].Value; SQLtype sentencia = new Select(camp2, camp1, camp3); return(sentencia); } //Drop table string campoDT1 = ""; Match matchDT = Regex.Match(query, dropTable); if (matchDT.Success) { campoDT1 = matchDT.Groups[1].Value; SQLtype sentencia = new DropTable(campoDT1); return(sentencia); } //Drop DB string campoDB1 = ""; Match matchDB = Regex.Match(query, dropDB); if (matchDB.Success) { campoDB1 = matchDB.Groups[1].Value; SQLtype sentencia = new DropDB(campoDB1); return(sentencia); } //Insert string cinsert1; string[] cinsert2 = new string[10]; string[] cinsert3 = new string[10]; Match matchI1 = Regex.Match(query, insert1); Match matchI2 = Regex.Match(query, insert2); Match matchI3 = Regex.Match(query, insert3); Match matchI4 = Regex.Match(query, insert4); if (Regex.Match(query, insert1).Success) { cinsert1 = matchI1.Groups[1].Value; //cinsert3[0] = matchI1.Groups[2].Value; SQLtype sentencia = new Insert(cinsert1, cinsert2, cinsert3); return(sentencia); } else if (Regex.Match(query, insert2).Success) { cinsert1 = matchI2.Groups[1].Value; cinsert3[0] = matchI2.Groups[2].Value; for (int i = 0; i < matchI2.Groups[4].Captures.Count; i++) { cinsert3[i + 1] = matchI2.Groups[4].Captures[i].Value; } SQLtype sentencia = new Insert(cinsert1, cinsert2, cinsert3); return(sentencia); } else if (Regex.Match(query, insert3).Success) { cinsert1 = matchI3.Groups[1].Value; cinsert3[0] = matchI3.Groups[3].Value; cinsert2[0] = matchI3.Groups[2].Value; SQLtype sentencia = new Insert(cinsert1, cinsert2, cinsert3); return(sentencia); } else if (Regex.Match(query, insert4).Success) { cinsert1 = matchI4.Groups[1].Value; cinsert3[0] = matchI4.Groups[5].Value; for (int i = 0; i < matchI4.Groups[7].Captures.Count; i++) { cinsert3[i + 1] = matchI4.Groups[7].Captures[i].Value; } cinsert2[0] = matchI4.Groups[2].Value; for (int i = 0; i < matchI4.Groups[4].Captures.Count; i++) { cinsert2[i + 1] = matchI4.Groups[4].Captures[i].Value; } SQLtype sentencia = new Insert(cinsert1, cinsert2, cinsert3); return(sentencia); } return(null); }
public void CreateDb(string dataBaseName) { DbServerProvider.ExcuteNonQuery(CommandType.Text, CreateDB.CreateDb(dataBaseName).ToSql().ToString()); }