예제 #1
0
        public void BtnBackup_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Random random = new Random();
                string currentBackupFileName = DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + "-" + FileNames.FILENAME_BACKUP + "-" + random.Next(1000, 9999) + ".bak";

                string path = FileNames.BACKUP_FILE_PATH + @"\" + currentBackupFileName;

                SqlBackup.Backup(path);
                Backup backup = new Backup()
                {
                    filename = currentBackupFileName,
                    filepath = path,
                    user_id  = User.id
                };
                int id = DB.AddBackup(backup);
                if (id > 0)
                {
                    backupList.Items.Add(currentBackupFileName + " / " + id.ToString());

                    result.Background = Brushes.Green;
                    result.Content    = Lang.BackupSuccessfully;
                    FillListBox();
                }
                else
                {
                    result.Background = Brushes.Red;
                    result.Content    = Lang.BackupFailed;
                }
            }
            catch (Exception ex)
            {
                DB.AddLog(new Log()
                {
                    error_page = "backup_buttonbackup", error_text = ex.Message,
                    log_date   = DateTime.Now, log_user = User.id
                });
            }
        }