Ejemplo n.º 1
0
        private DataTable loadFile()
        {
            string path = textBox1.Text;

            string[] filePaths = Directory.GetFiles(path, "*.bak",
                                                    SearchOption.TopDirectoryOnly);
            DataTable dtb = new DataTable();

            dtb.Columns.Add("name", typeof(String));
            dtb.Columns.Add("time", typeof(String));
            foreach (string a in filePaths)
            {
                DataRow dtr  = dtb.NewRow();
                string  name = Path.GetFileName(a);
                string  time = GetDateTime(name);
                if (time != "")
                {
                    dtr["name"] = name;
                    dtr["time"] = time;
                    DataTable dtb1 = BackupController.getDTB(name, path);
                    if (dtb1 != null)
                    {
                        string database = BackupController.getbase(dtb1.Rows[0][1].ToString());
                        dtb.Rows.Add(dtr);
                    }
                }
            }
            return(dtb);
        }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            int    ncheck   = 0;
            string database = "";

            if (s == 1)
            {
                database = FileConfig.config.database;
                ncheck   = BackupController.RestoreDatabase(database, selected_file, textBox1.Text);
            }
            else
            {
                database = "test";
                ncheck   = BackupController.RestoreDatabase1(database, selected_file, textBox1.Text);
            }
            if (ncheck >= -1)
            {
                MessageBox.Show("Restore thành công", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FileConfig.config.database = database;
                dataGridView1.DataSource   = loadFile();
                this.Close();
            }
            else
            {
                MessageBox.Show("Restore thất bại", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 3
0
        private void ChooseLevelTask(string levelName)
        {
            var reader = new JsonReader();

            BackupController.GetInstance().ClearBackup();
            reader.ConvertToObject(importPath + levelName);
            HideDialog();
        }
Ejemplo n.º 4
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (BackupController.BackupDatabase(textBox1.Text) >= -1)
     {
         MessageBox.Show("Backup thành công !", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         dataGridView1.DataSource = loadFile();
     }
 }
Ejemplo n.º 5
0
        protected override void OnStart(string[] args)
        {
            IObjectRepository    repository = new ObjectRepository();
            ControllerBackupBase controller = new BackupController(repository);

            mainProcess = new MainProcess(controller);
            Thread backupThread = new Thread(new ThreadStart(mainProcess.Start));

            backupThread.Start();
        }
Ejemplo n.º 6
0
    void Start()
    {
        map               = GameObject.Find("Map");
        dialog            = new UIInputBox(new Vector2(350, 350));
        dialogList        = new UIList();
        _backupController = BackupController.GetInstance();

        chooseDialog = new UIChooseBox();

        deletedElements = new Dictionary <string, List <string> >();
    }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            IObjectRepository    repo = new ObjectRepository();
            ControllerBackupBase con  = new BackupController(repo);

            MainProcess mainProcess  = new MainProcess(con);
            Thread      backupThread = new Thread(new ThreadStart(mainProcess.Start));

            backupThread.Start();

            ConsoleAppClass main = new ConsoleAppClass(con);

            main.ShowMainMenu();

            Console.ReadKey();
        }
Ejemplo n.º 8
0
        private void BackupSettingsToolStripMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(DirectoryPath.Text) || !Directory.Exists(DirectoryPath.Text + "client_resources\\"))
            {
                MessageBox.Show(Strings.InvalidDirectoryPathBackup, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (Properties.Settings.Default.BackupChatLogAutomatically)
            {
                if (!Properties.Settings.Default.DisableWarningPopups && MessageBox.Show(Strings.BackupWillBeOff, Strings.Warning, MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                {
                    return;
                }

                StatusLabel.Content = string.Format(Strings.BackupStatus, Strings.Disabled);
            }
            else
            if (!Properties.Settings.Default.DisableInformationPopups)
            {
                MessageBox.Show(Strings.SettingsAfterClose, Strings.Information, MessageBoxButton.OK, MessageBoxImage.Information);
            }

            BackupController.AbortAll();
            SaveSettings();

            if (backupSettings == null)
            {
                backupSettings = new BackupSettingsWindow(this);
                backupSettings.IsVisibleChanged += (s, args) =>
                {
                    if ((bool)args.NewValue)
                    {
                        return;
                    }
                    BackupController.Initialize();
                    StatusLabel.Content = string.Format(Strings.BackupStatus,
                                                        Properties.Settings.Default.BackupChatLogAutomatically ? Strings.Enabled : Strings.Disabled);
                };
                backupSettings.Closed += (s, args) =>
                {
                    backupSettings = null;
                };
            }

            backupSettings.ShowDialog();
        }
Ejemplo n.º 9
0
        private void OpenDirectoryDialogButton_Click(object sender, RoutedEventArgs args)
        {
            using var ofd = new OpenFileDialog { FileName = "SelectFolder", Filter = "Folder|.", CheckFileExists = false };
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                switch (((Button)sender).Tag)
                {
                case "OriginPath":
                    originPath.Text = BackupController.GetQualifiedDirectoryPath(Path.GetDirectoryName(ofd.FileName) ?? string.Empty);
                    break;

                case "DestPath":
                    destPath.Text = BackupController.GetQualifiedDirectoryPath(Path.GetDirectoryName(ofd.FileName) ?? string.Empty);
                    break;
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes the main window
        /// </summary>
        /// <param name="startMinimized"></param>
        public MainWindow(bool startMinimized)
        {
            client.SetRequestTimeout(new TimeSpan(0, 0, 0, Properties.Settings.Default.UpdateCheckTimeout));
            StartupController.InitializeShortcut();

            InitializeComponent();
            InitializeTrayIcon();

            if (startMinimized)
            {
                trayIcon.Visible = true;
            }

            // Also checks for the RAGEMP directory on the first start
            LoadSettings();

            SetupServerList();
            BackupController.Initialize();
            isLoading = false;
        }
Ejemplo n.º 11
0
 private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex != -1)
     {
         string path = textBox1.Text;
         selected_file = dataGridView1.Rows[e.RowIndex].Cells["name"].Value.ToString();
         DataTable dtb      = BackupController.getDTB(dataGridView1.Rows[e.RowIndex].Cells["name"].Value.ToString(), path);
         string    database = BackupController.getbase(dtb.Rows[0][1].ToString());
         if (database != null)
         {
             txtDatabaseName.Text = database;
             s = 1;
         }
         else
         {
             txtDatabaseName.Text = "Database không tồn tại";
             s = 2;
         }
     }
 }
Ejemplo n.º 12
0
        private async void StartBackupButton_ClickAsync(object sender, RoutedEventArgs args)
        {
            SaveStates();
            if (BackupManager.GetBackupIfRunning(originPath.Text.Trim(), destPath.Text.Trim()) != null)
            {
                MessageBox.Show("バックアップは既に実行中です。", $"{App.AssemblyName.Name} - 警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (!Directory.Exists(originPath.Text.Trim()))
            {
                MessageBox.Show($"{originPath.Text.Trim()}は存在しません。\n正しいディレクトリパスを入力してください。", $"{App.AssemblyName.Name} - 警告", MessageBoxButton.OK,
                                MessageBoxImage.Warning);
                return;
            }

            ButtonsIsEnabled = false;
            var settings = LoadCurrentSettings;

            if (settings.IsRecordPassword)
            {
                if (settings.IsDifferentPassword(password.Password) && settings.ProtectedPassword != null)
                {
                    var changePassword =
                        MessageBox.Show(
                            "前回のパスワードと異なります。\nパスワードを変更しますか?\n\n※パスワードを変更する場合、既存のバックアップやデータベースを削除し、\n 再度初めからバックアップし直すことをおすすめします。\n 異なるパスワードでバックアップされたファイルが共存する場合、\n 復元が難しくなります。",
                            $"{App.AssemblyName.Name} - パスワード変更の確認", MessageBoxButton.YesNoCancel);
                    switch (changePassword)
                    {
                    case MessageBoxResult.Yes:
                        // TODO: パスワード確認入力ウィンドウを出す
                        Logger.Info("パスワードを更新");
                        PasswordManager.SavePassword(settings, password.Password);
                        DeleteDatabase();
                        break;

                    case MessageBoxResult.No:
                        if (MessageBox.Show("前回のパスワードを使用します。", App.AssemblyName.Name, MessageBoxButton.OKCancel, MessageBoxImage.Information) ==
                            MessageBoxResult.OK && PasswordManager.TryLoadPassword(settings, out var pass))
                        {
                            password.Password = pass;
                        }
                        else
                        {
                            goto case MessageBoxResult.Cancel;
                        }
                        break;

                    case MessageBoxResult.Cancel:
                        ButtonsIsEnabled = true;
                        return;
                    }
                }
                else if (!string.IsNullOrWhiteSpace(password.Password))
                {
                    // TODO: パスワード確認入力ウィンドウを出す
                    PasswordManager.SavePassword(settings, password.Password);
                }
            }

            message.Text           = $"'{originPath.Text.Trim()}' => '{destPath.Text.Trim()}'";
            message.Text          += $"\nバックアップ開始: {DateTime.Now}\n";
            progressBar.Visibility = Visibility.Visible;
            var bc = new BackupController(originPath.Text.Trim(), destPath.Text.Trim(), password.Password, settings);
            var m  = message.Text;

            bc.Results.MessageChanged += (_, _) =>
            {
                _ = Dispatcher.InvokeAsync(() => { message.Text = m + bc.Results.Message + "\n"; },
                                           DispatcherPriority.ApplicationIdle);
            };
            try
            {
                using var results = await BackupManager.StartBackupAsync(bc);

                if (results != null)
                {
                    message.Text = m + results.Message + "\n";
                }
            }
            catch (OperationCanceledException)
            {
                message.Text = m + "バックアップはキャンセルされました。" + "\n";
            }
            finally
            {
                progressBar.Visibility = Visibility.Collapsed;
                ButtonsIsEnabled       = true;
            }
        }