Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        private void updateDataGridView(SortedDictionary <int, DbBackupRecordTable> backupRecordList)
        {
            m_dataGridRecordCount = backupRecordList.Count;

            SortedDictionary <int, ArrayList> backupRecordLArrary = new SortedDictionary <int, ArrayList>();

            for (int i = 0; i < backupRecordList.Count; i++)
            {
                DbBackupRecordTable record = new DbBackupRecordTable();
                record = (DbBackupRecordTable)backupRecordList[i];

                ArrayList temp = new ArrayList();

                temp.Add(record.pkey);

                if (record.backType == 0)
                {
                    temp.Add("人为备份");
                }
                else
                {
                    temp.Add("自动备份");
                }

                temp.Add(record.backupTime);
                temp.Add(record.name);
                temp.Add(record.hostName);
                temp.Add(record.savePath1);
                temp.Add(record.savePath2);
                temp.Add(record.reason);
                temp.Add(record.note);
                temp.Add(record.state);

                backupRecordLArrary.Add(i, temp);
            }

            m_dateGridViewExtend.initDataGridViewData(backupRecordLArrary);
        }
Exemplo n.º 3
0
        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();
        }