Пример #1
0
        /// <summary>
        /// ボタン〔データ復旧〕押下処理
        /// </summary>
        private async void RestoreCommandExecute()
        {
            string restorePathAndFileName = this.RestorePathAndFileName.Value;

            var metroDialogSettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "はい",
                NegativeButtonText    = "いいえ",
                AnimateHide           = true,
                AnimateShow           = true,
                ColorScheme           = MetroDialogColorScheme.Theme,
            };

            var diagResult = await this.MainWindow.ShowMessageAsync("データ復旧の確認", "現在のデータを全て消去し、バックアップファイル " + Path.GetFileName(restorePathAndFileName) + " で上書きしますがよろしいですか?", MessageDialogStyle.AffirmativeAndNegative, metroDialogSettings);

            if (diagResult != MessageDialogResult.Affirmative)
            {
                return;
            }

            // 復旧用データを取得
            DataSet restoreSheets = XlsxReader.GetXLSheets(restorePathAndFileName);

            // 復旧用データを検証
            var checkRestoreSheetsResult = FileViewRestoreValidator.CheckRestoreSheets(restoreSheets);

            if (checkRestoreSheetsResult.Count > 0)
            {
                await this.MainWindow.ShowMessageAsync("データ復旧処理を中止しました", "バックアップファイルの形式が正しくありません。");

                return;
            }

            // 各テーブルのリストア処理
            FileViewRestoreLogic restoreLogic = new FileViewRestoreLogic(_dbAccessor_);

            restoreLogic.RestoreTables(restoreSheets);

            await this.MainWindow.ShowMessageAsync("データ復旧処理が完了しました", "バックアップファイル " + Path.GetFileName(restorePathAndFileName) + " からデータを復旧しました。");

            this.RestorePathAndFileName.Value = string.Empty;
        }
Пример #2
0
        /// <summary>
        /// ボタン〔インポート〕押下処理
        /// </summary>
        private async void ImportCommandExecute()
        {
            string importPathAndFileName = this.ImportPathAndFileName.Value;

            var metroDialogSettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "はい",
                NegativeButtonText    = "いいえ",
                AnimateHide           = true,
                AnimateShow           = true,
                ColorScheme           = MetroDialogColorScheme.Theme,
            };

            var diagResult = await this.MainWindow.ShowMessageAsync("データのインポート", "ファイル " + Path.GetFileName(importPathAndFileName) + " のインポート処理を行います。よろしいですか?", MessageDialogStyle.AffirmativeAndNegative, metroDialogSettings);

            if (diagResult != MessageDialogResult.Affirmative)
            {
                return;
            }

            // インポートデータを取得
            DataSet importSheets = XlsxReader.GetXLSheets(importPathAndFileName);

            // インポートデータを検証
            var checkImportSheetsResult = FileViewImportValidator.CheckImportSheets(importSheets);

            if (checkImportSheetsResult.Count > 0)
            {
                await this.MainWindow.ShowMessageAsync("データのインポートを中止しました", "ファイルの形式が正しくありません。");

                return;
            }

            // タスクテーブルインポート処理
            FileViewImportLogic importLogic = new FileViewImportLogic(_dbAccessor_);

            importLogic.ImportTodoTask(importSheets);

            await this.MainWindow.ShowMessageAsync("データのインポートが完了しました", "ファイル " + Path.GetFileName(importPathAndFileName) + " からデータをインポートしました。");

            this.ImportPathAndFileName.Value = string.Empty;
        }