public static void ThreadFuction() { DbBackupRecordTable record = new DbBackupRecordTable(); // 当xx当xx用户第一次登录时,自动做一下数据备份 if (DbBackupRecord.getInctance().isBackTheDay()) { record.name = DbPublic.getInctance().getCurrentLoginUserName(); record.hostName = Dns.GetHostName(); record.backType = 0; record.reason = "数据库自动备份"; record.note = DbPublic.getInctance().getCurrentLoginUserName() + "于" + DateTime.Now.ToString("yyyyMMddHHmmss"); record.note += "在" + record.hostName + "电脑上进行数据库备份"; string dbFileBackPath = Directory.GetCurrentDirectory() + "\\back\\"; if (!Directory.Exists(dbFileBackPath)) { Directory.CreateDirectory(dbFileBackPath); } record.savePath1 = dbFileBackPath; if (DbBackupRecord.getInctance().databaseBack(record.savePath1, false)) { DbBackupRecord.getInctance().insert(record); } } }
private void backup_Click(object sender, EventArgs e) { DBBackup dbb = new DBBackup(); dbb.ShowDialog(); updateDataGridView(DbBackupRecord.getInctance().getAllRecord()); }
private void FormBaseDbBackupRecord_Load(object sender, EventArgs e) { m_dateGridViewExtend.addDataGridViewColumn("ID", 30); m_dateGridViewExtend.addDataGridViewColumn("备份方式", 100); m_dateGridViewExtend.addDataGridViewColumn("日期时间", 150); m_dateGridViewExtend.addDataGridViewColumn("备份人姓名", 120); m_dateGridViewExtend.addDataGridViewColumn("主机名", 100); m_dateGridViewExtend.addDataGridViewColumn("保存位置1", 300, false); m_dateGridViewExtend.addDataGridViewColumn("保存位置2", 300, false); m_dateGridViewExtend.addDataGridViewColumn("备份原因", 250); m_dateGridViewExtend.addDataGridViewColumn("备注", 150); m_dateGridViewExtend.addDataGridViewColumn("是否成功", 80); m_dateGridViewExtend.initDataGridViewColumn(this.dataGridViewBilConfigList); updateDataGridView(DbBackupRecord.getInctance().getAllRecord()); setPageActionEnable(); }
private void buttonSave_Click(object sender, EventArgs e) { if (this.textBoxFileDirectory.Text.Length == 0) { MessageBoxExtend.messageWarning(this.labelPath.Text + "不能为空,请填写"); return; } if (this.textBoxReason.Text.Length == 0) { MessageBoxExtend.messageWarning(this.labelReason.Text + "不能为空,请填写"); return; } if (m_isBackup) { DbBackupRecordTable record = new DbBackupRecordTable(); record.name = DbPublic.getInctance().getCurrentLoginUserName(); record.hostName = Dns.GetHostName(); record.backType = 0; record.reason = this.textBoxReason.Text; record.note = this.textBoxNode.Text; record.savePath1 = this.textBoxFileDirectory.Text; //DbBackupRecord.getInctance().insert(record); //string parameter = record.savePath1 + " #"; //// 启动DBBackup.exe //Process.Start(@"DBBackup.exe", parameter); if (DbBackupRecord.getInctance().databaseBack(record.savePath1)) { DbBackupRecord.getInctance().insert(record); } } else { DbRollbackRecordTable record = new DbRollbackRecordTable(); record.name = DbPublic.getInctance().getCurrentLoginUserName(); record.hostName = Dns.GetHostName(); record.reason = this.textBoxReason.Text; record.note = this.textBoxNode.Text; record.fileName = this.textBoxFileDirectory.Text; record.reason = this.textBoxReason.Text; record.note = this.textBoxNode.Text; //DbRollbackRecord.getInctance().insert(record); //string newRecordID = Convert.ToString(DbPublic.getInctance().getTableMaxPkey("BASE_DB_ROLLBACK_RECORD") + 1); //string parameter = record.fileName + " " + newRecordID; //// 启动DBBackup.exe //Process.Start(@"DBRollback.exe", parameter); if (DbRollbackRecord.getInctance().databaseRollback(record.fileName)) { DbRollbackRecord.getInctance().insert(record); } } this.Close(); }