public void initData(bool IsFile) { if (IsFile) { //if (Debugger.IsAttached == false) //{ config = new ConfigDB(); config.load(); //} //else //{ // config = new ConfigDB(); // config.server = ""; // config.databaseName = ""; // config.username = ""; // config.password = ""; // config.database = ""; //} } //Check it if (config.database == "") { if(config.server.Equals("DATA-PROTOCOL")){ embDB.Checked = true; } textServerName.EditValue = config.server; textDatabase.EditValue = config.databaseName; textUsername.EditValue = config.username; textPassword.EditValue = config.password; Cong.Text = config.port + ""; textServerName.Properties.ReadOnly = false; textDatabase.Properties.ReadOnly = false; textDatabase.Enabled = true; textUsername.Properties.ReadOnly = false; textPassword.Properties.ReadOnly = false; Cong.Properties.ReadOnly = false; btnSave.Text = "Lưu"; } else if (config.database.StartsWith("Security")) { textServerName.EditValue = "-- protocolvn.com --"; textDatabase.EditValue = "-- protocolvn.com --"; textUsername.EditValue = "-- protocolvn.com --"; textPassword.EditValue = "-- protocolvn.com --"; Cong.Text = "3050"; textServerName.Properties.ReadOnly = true; textDatabase.Properties.ReadOnly = true; textDatabase.Enabled = false; textUsername.Properties.ReadOnly = true; textPassword.Properties.ReadOnly = true; Cong.Properties.ReadOnly = true; btnSave.Text = "Mới"; } }
public void initData() { config = new ConfigDB(); config.load(); //Check it textServerName.EditValue = config.server; textDatabase.EditValue = config.databaseName; textUsername.EditValue = config.username; textPassword.EditValue = config.password; Cong.Text = config.port + ""; }
public void initData(bool IsFile) { if(IsFile){ config = new ConfigDB(); config.load(); } //Check it if (config.database == "") { textServerName.EditValue = config.server; textDatabase.EditValue = config.databaseName; textUsername.EditValue = config.username; textPassword.EditValue = config.password; Cong.Text = config.port + ""; textServerName.Properties.ReadOnly = false; textDatabase.Properties.ReadOnly = false; textDatabase.Enabled = true; textUsername.Properties.ReadOnly = false; textPassword.Properties.ReadOnly = false; Cong.Properties.ReadOnly = false; btnSave.Text = "Lưu"; } else if (config.database.StartsWith("Security")) { textServerName.EditValue = "-- protocolvn.com --"; textDatabase.EditValue = "-- protocolvn.com --"; textUsername.EditValue = "-- protocolvn.com --"; textPassword.EditValue = "-- protocolvn.com --"; Cong.Text = "3050"; textServerName.Properties.ReadOnly = true; textDatabase.Properties.ReadOnly = true; textDatabase.Enabled = false; textUsername.Properties.ReadOnly = true; textPassword.Properties.ReadOnly = true; Cong.Properties.ReadOnly = true; btnSave.Text = "Mới"; } }
private void initData(bool IsFile) { if (IsFile) { //if (Debugger.IsAttached == false) //{ config = new ConfigDB(); config.load(); //} //else //{ // config = new ConfigDB(); // config.server = ""; // config.databaseName = ""; // config.username = ""; // config.password = ""; // config.database = ""; //} } if (config.server == dbEMBServer) { if (config.databaseName == DB_DEMO) { chkCSDLMau.Checked = true; } else if (config.databaseName == DB_APP) { embDB.Checked = true; } } else { chkCSDLTuXa.Checked = true; } //Check it if (config.database == "") { if (chkCSDLTuXa.Checked) { textServerName.EditValue = config.server; textDatabase.EditValue = config.databaseName; textUsername.EditValue = config.username; textPassword.EditValue = config.password; Cong.Text = config.port + ""; } else { textServerName.EditValue = ""; textDatabase.EditValue = ""; textUsername.EditValue = ""; textPassword.EditValue = ""; Cong.Text = ""; } textServerName.Properties.ReadOnly = false; textDatabase.Properties.ReadOnly = false; //textDatabase.Enabled = true; textUsername.Properties.ReadOnly = false; textPassword.Properties.ReadOnly = false; Cong.Properties.ReadOnly = false; btnSave.Text = "Lưu"; } else if (config.database.StartsWith("Security")) { textServerName.EditValue = "-- protocolvn.com --"; textDatabase.EditValue = "-- protocolvn.com --"; textUsername.EditValue = "-- protocolvn.com --"; textPassword.EditValue = "-- protocolvn.com --"; Cong.Text = "3050"; textServerName.Properties.ReadOnly = true; textDatabase.Properties.ReadOnly = true; //textDatabase.Enabled = false; textUsername.Properties.ReadOnly = true; textPassword.Properties.ReadOnly = true; Cong.Properties.ReadOnly = true; btnSave.Text = "Mới"; chkCSDLTuXa.Enabled = false; chkCSDLMau.Enabled = false; embDB.Enabled = false; } }
//PHUOCNT NC Giải pháp chưa backup từ xa được để backup từ xa ta phải thay câu lệnh hiện tại thành câu lệnh //gbak -b -v protocolvn.info:E/mydb.gdb C:\mybackup.fbk -user SYSDBA -pass masterkey private bool backup(string FilePath) { ConfigDB config = new ConfigDB(); config.load(); #region usingGBACK if (frmBackupRestore.usingGBACK == true) { try { string arg = ""; if (config.databaseName == "") arg = " -v -t -user " + config.username + " -password \"" + config.password + "\" " + config.database + " " + FilePath; else arg = " -v -t -user " + config.username + " -password \"" + config.password + "\" " + config.databaseName + " " + FilePath; ProcessStartInfo psi = new ProcessStartInfo("gbak.exe", arg); psi.WindowStyle = ProcessWindowStyle.Hidden; Process p = Process.Start(psi); if (p == null) return false; while (p != null && !p.HasExited) { //NOOP } return (p.ExitCode == 0); } catch (Exception ex) { PLException.AddException(ex); return false; } } #endregion #region usingFile else { try { String dbFile = ""; if (config.databaseName == "") dbFile = config.database; else dbFile = config.databaseName; String dbCloneFile = ""; try { //Tạo 1 tập tin tương ứng với nội dung cần backup //dbCloneFile = dbFile.Substring(0, dbFile.LastIndexOf(".")) + DateTime.Now.ToString("yyyyMMddHHmm") // + ".gdb"; dbCloneFile = RadParams.RUNTIME_PATH + "\\temp\\" + dbFile.Substring(dbFile.LastIndexOf("\\") + 1); if (File.Exists(dbCloneFile)) File.Delete(dbCloneFile); File.Copy(dbFile, dbCloneFile); //Nén tập tin db lại bool result = ZipFile.Zip(dbCloneFile, FilePath); return result; } catch (Exception ex) { PLException.AddException(ex); } finally { //Xoa tập tin nếu đã tạo bảng sao. try { if (File.Exists(dbCloneFile)) File.Delete(dbCloneFile); } catch { } } } catch (Exception ex) { PLException.AddException(new PLException(ex)); } //Using Zip } #endregion return false; }
//PHUOCNT NC Giải pháp hiện tại chưa phục hồi từ xa được //để làm được thay thành câu lệnh bên dưới //gbak -c -v C:/backup_file.fbk protocolvn.info:E:/new_db.gdb -user sysdba -pass masterkey private bool restore(string filePath) { ConfigDB config = new ConfigDB(); config.load(); #region Dùng GBACK if (frmBackupRestore.usingGBACK == true) { try { string arg = ""; if (config.databaseName == "") { arg = " -r o -v -user " + config.username + " -password \"" + config.password + "\" " + filePath + " " + config.database + ".bak"; } else arg = " -r o -v -user " + config.username + " -password \"" + config.password + "\" " + filePath + " " + config.databaseName + ".bak"; ProcessStartInfo psi = new ProcessStartInfo("gbak.exe", arg); psi.WindowStyle = ProcessWindowStyle.Hidden; Process p = Process.Start(psi); if (p == null) return false; while (p != null && !p.HasExited) { //NOOP } return (p.ExitCode == 0); } catch (Exception ex) { PLException.AddException(ex); return false; } } #endregion #region else { //Chuẩn bị tham số string fullDBFileName = config.databaseName; string dbInfo = RadParams.server + ";" + RadParams.database + ";" + RadParams.port + ";" + RadParams.username + ";" + RadParams.password + ";" + filePath + ";" + fullDBFileName; //Đóng chương trình FrameworkParams.ExitApplication(FrameworkParams.EXIT_STATUS.NORMAL_NO_THANKS); //Gọi restore. Process p = new Process(); p.StartInfo.FileName = RadParams.RUNTIME_PATH + @"\update\RestoreDB.exe"; p.StartInfo.Arguments = FrameworkParams.ExecuteFileName + ";" + dbInfo; try { p.Start(); } catch { } } #endregion return false; }