ファイル整理用ツールのPrism+WPFサンプル実装
Revisão | d9fc2802451b187ad87a9291b472ca2679fa5d68 (tree) |
---|---|
Hora | 2022-11-06 11:10:04 |
Autor | yoshy <yoshy.org.bitbucket@gz.j...> |
Commiter | yoshy |
[MOD] ファイルシステム操作系インタラクタのダイアログ処理を切り出し
@@ -1,5 +1,4 @@ | ||
1 | -using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog; | |
2 | -using CleanAuLait.UseCase.Interactor; | |
1 | +using CleanAuLait.UseCase.Interactor; | |
3 | 2 | using CleanAuLait.UseCase.Response; |
4 | 3 | using FolderCategorizer2.Domain.Boundary.Service; |
5 | 4 | using FolderCategorizer2.Domain.Model.Entity; |
@@ -10,10 +9,8 @@ using FolderCategorizer2.UseCase.Boundary.FileSystemOperation.Interactor; | ||
10 | 9 | using FolderCategorizer2.UseCase.FileSystemOperation.Request; |
11 | 10 | using FolderCategorizer2.UseCase.FileSystemOperation.Response; |
12 | 11 | using FolderCategorizer2.UseCase.Internal; |
13 | -using Prism.Services.Dialogs; | |
14 | 12 | using System.Collections.Generic; |
15 | 13 | using System.Linq; |
16 | -using System.Windows; | |
17 | 14 | |
18 | 15 | namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor |
19 | 16 | { |
@@ -23,18 +20,18 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
23 | 20 | { |
24 | 21 | //private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); |
25 | 22 | |
26 | - private readonly IFileSystemOperationLogic logic; | |
23 | + private readonly IFileSystemOperationLogic operation; | |
24 | + private readonly IFileSystemDialogLogic dialog; | |
27 | 25 | private readonly IFileListService fileList; |
28 | - private readonly IUniversalDialogProxy dialog; | |
29 | 26 | private readonly IFileSystemAutoFixFolderTimestampOperationPresenter presenter; |
30 | 27 | |
31 | 28 | public FileSystemAutoFixFolderTimestampOperationInteractor( |
32 | - IFileSystemOperationLogic logic, | |
33 | - IUniversalDialogProxy dialog, | |
29 | + IFileSystemOperationLogic operation, | |
30 | + IFileSystemDialogLogic dialog, | |
34 | 31 | IFileListService fileList, |
35 | 32 | IFileSystemAutoFixFolderTimestampOperationPresenter presenter) |
36 | 33 | { |
37 | - this.logic = logic; | |
34 | + this.operation = operation; | |
38 | 35 | this.dialog = dialog; |
39 | 36 | this.fileList = fileList; |
40 | 37 | this.presenter = presenter; |
@@ -44,13 +41,13 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
44 | 41 | { |
45 | 42 | IEnumerable<FileSystemSourceFile> SourceFileList = req.SourceFileList; |
46 | 43 | |
47 | - if (!Confirm(SourceFileList)) | |
44 | + if (!this.dialog.ConfirmAutoFixFolderTimestamp(SourceFileList)) | |
48 | 45 | { |
49 | 46 | // don't show abort dialog. |
50 | 47 | return new(); |
51 | 48 | } |
52 | 49 | |
53 | - if (!this.logic.AutoFixFolderTimestamp(SourceFileList)) | |
50 | + if (!this.operation.AutoFixFolderTimestamp(SourceFileList)) | |
54 | 51 | { |
55 | 52 | return UseCaseResponse.Abort<FileSystemAutoFixFolderTimestampOperationResponse>("エラーのため処理が中止されました"); |
56 | 53 | } |
@@ -60,27 +57,6 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
60 | 57 | return this.presenter.Present(req, res); |
61 | 58 | } |
62 | 59 | |
63 | - private bool Confirm(IEnumerable<FileSystemSourceFile> SourceFileList) | |
64 | - { | |
65 | - string msg = CreateConfirmMessage(SourceFileList); | |
66 | - | |
67 | - IDialogResult result = this.dialog.ShowYesNoDialog("フォルダのタイムスタンプを自動修正 - 確認", msg, MessageBoxImage.Question); | |
68 | - | |
69 | - return result.Result == ButtonResult.Yes; | |
70 | - } | |
71 | - | |
72 | - private static string CreateConfirmMessage(IEnumerable<FileSystemSourceFile> SourceFileList) | |
73 | - { | |
74 | - string msg = "【仮】フォルダのタイムスタンプを自動修正してもよろしいですか"; | |
75 | - | |
76 | - foreach (FileSystemSourceFile sourceFile in SourceFileList) | |
77 | - { | |
78 | - msg += "\n\n対象:" + sourceFile.SourceAbsolutePath; | |
79 | - } | |
80 | - | |
81 | - return msg; | |
82 | - } | |
83 | - | |
84 | 60 | private FileSystemAutoFixFolderTimestampOperationResponse CreateResponse(IEnumerable<FileSystemSourceFile> SourceFileList) |
85 | 61 | { |
86 | 62 | // FIX ME |
@@ -29,21 +29,21 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
29 | 29 | private const string DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm:ss"; |
30 | 30 | |
31 | 31 | private readonly IFileSystemService fileSystem; |
32 | + private readonly IFileSystemOperationLogic operation; | |
32 | 33 | private readonly ICategorizePromptViewProxy dialog; |
33 | - private readonly IFileSystemOperationLogic logic; | |
34 | 34 | private readonly IFileListService fileList; |
35 | 35 | private readonly IFileSystemBundleFileOperationPresenter presenter; |
36 | 36 | |
37 | 37 | public FileSystemBundleFileOperationInteractor( |
38 | 38 | IFileSystemService fileSystem, |
39 | + IFileSystemOperationLogic operation, | |
39 | 40 | ICategorizePromptViewProxy dialog, |
40 | - IFileSystemOperationLogic logic, | |
41 | 41 | IFileListService fileList, |
42 | 42 | IFileSystemBundleFileOperationPresenter presenter) |
43 | 43 | { |
44 | 44 | this.fileSystem = fileSystem; |
45 | + this.operation = operation; | |
45 | 46 | this.dialog = dialog; |
46 | - this.logic = logic; | |
47 | 47 | this.fileList = fileList; |
48 | 48 | this.presenter = presenter; |
49 | 49 | } |
@@ -69,8 +69,8 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
69 | 69 | return new(); |
70 | 70 | } |
71 | 71 | |
72 | - if (!this.logic.CreateFolder(sourceFilesList, targetName) | |
73 | - || !this.logic.OverwriteCreationAndLastWriteTime( | |
72 | + if (!this.operation.CreateFolder(sourceFilesList, targetName) | |
73 | + || !this.operation.OverwriteCreationAndLastWriteTime( | |
74 | 74 | sourceFilesList, targetName, createdAt, lastWriteAt)) |
75 | 75 | { |
76 | 76 | return UseCaseResponse.Abort<FileSystemBundleFileOperationResponse>("エラーのため処理が中止されました"); |
@@ -87,7 +87,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
87 | 87 | ) |
88 | 88 | ); |
89 | 89 | |
90 | - if (!this.logic.MoveFile(sourceTargetEntries)) | |
90 | + if (!this.operation.MoveFile(sourceTargetEntries)) | |
91 | 91 | { |
92 | 92 | return UseCaseResponse.Abort<FileSystemBundleFileOperationResponse>("エラーのため処理が中止されました"); |
93 | 93 | } |
@@ -1,5 +1,4 @@ | ||
1 | -using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog; | |
2 | -using CleanAuLait.UseCase.Interactor; | |
1 | +using CleanAuLait.UseCase.Interactor; | |
3 | 2 | using CleanAuLait.UseCase.Response; |
4 | 3 | using FolderCategorizer2.Domain.Boundary.Service; |
5 | 4 | using FolderCategorizer2.Domain.Service.Dto; |
@@ -7,10 +6,8 @@ using FolderCategorizer2.UseCase.Boundary.FileSystemOperation.Interactor; | ||
7 | 6 | using FolderCategorizer2.UseCase.FileSystemOperation.Request; |
8 | 7 | using FolderCategorizer2.UseCase.FileSystemOperation.Response; |
9 | 8 | using FolderCategorizer2.UseCase.Internal; |
10 | -using Prism.Services.Dialogs; | |
11 | 9 | using System.Collections.Generic; |
12 | 10 | using System.Linq; |
13 | -using System.Windows; | |
14 | 11 | |
15 | 12 | namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor |
16 | 13 | { |
@@ -21,20 +18,20 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
21 | 18 | //private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); |
22 | 19 | |
23 | 20 | private readonly IFileSystemService fileSystem; |
24 | - private readonly IFileSystemOperationLogic logic; | |
21 | + private readonly IFileSystemOperationLogic operation; | |
22 | + private readonly IFileSystemDialogLogic dialog; | |
25 | 23 | private readonly IFolderTreeService folderTree; |
26 | - private readonly IUniversalDialogProxy dialog; | |
27 | 24 | |
28 | 25 | public FileSystemCopyOperationInteractor( |
29 | 26 | IFileSystemService fileSystem, |
30 | - IFileSystemOperationLogic logic, | |
31 | - IFolderTreeService folderTree, | |
32 | - IUniversalDialogProxy dialog) | |
27 | + IFileSystemOperationLogic operation, | |
28 | + IFileSystemDialogLogic dialog, | |
29 | + IFolderTreeService folderTree) | |
33 | 30 | { |
34 | 31 | this.fileSystem = fileSystem; |
35 | - this.logic = logic; | |
36 | - this.folderTree = folderTree; | |
32 | + this.operation = operation; | |
37 | 33 | this.dialog = dialog; |
34 | + this.folderTree = folderTree; | |
38 | 35 | } |
39 | 36 | |
40 | 37 | public override FileSystemCopyOperationResponse Interact(FileSystemCopyOperationRequest req) |
@@ -57,13 +54,13 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
57 | 54 | IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries = |
58 | 55 | FileSystemSourceFilesTargetFolder.Join(targetFolders, sourceFilesList); |
59 | 56 | |
60 | - if (!Confirm(sourceTargetEntries)) | |
57 | + if (!this.dialog.ConfirmCopyFiles(sourceTargetEntries)) | |
61 | 58 | { |
62 | 59 | // don't show abort dialog. |
63 | 60 | return new(); |
64 | 61 | } |
65 | 62 | |
66 | - if (!this.logic.CopyFiles(sourceTargetEntries)) | |
63 | + if (!this.operation.CopyFiles(sourceTargetEntries)) | |
67 | 64 | { |
68 | 65 | return UseCaseResponse.Abort<FileSystemCopyOperationResponse>("エラーのため処理が中止されました"); |
69 | 66 | } |
@@ -129,32 +126,6 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
129 | 126 | return msg; |
130 | 127 | } |
131 | 128 | |
132 | - private bool Confirm(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries) | |
133 | - { | |
134 | - string msg = CreateConfirmMessage(sourceTargetEntries); | |
135 | - | |
136 | - IDialogResult result = this.dialog.ShowYesNoDialog("ファイルのコピー - 確認", msg, MessageBoxImage.Question); | |
137 | - | |
138 | - return result.Result == ButtonResult.Yes; | |
139 | - } | |
140 | - | |
141 | - private static string CreateConfirmMessage(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries) | |
142 | - { | |
143 | - string msg = "【仮】コピーしてもよろしいですか"; | |
144 | - | |
145 | - foreach (FileSystemSourceFilesTargetFolder sourceTargetEntry in sourceTargetEntries) | |
146 | - { | |
147 | - msg += "\n\nコピー元:" + sourceTargetEntry.SourceFiles.AbsolutePath; | |
148 | - foreach (string name in sourceTargetEntry.SourceFiles.Names) | |
149 | - { | |
150 | - msg += "\n・" + name; | |
151 | - } | |
152 | - msg += "\n↓\nコピー先:" + sourceTargetEntry.TargetFolder.AbsolutePath; | |
153 | - } | |
154 | - | |
155 | - return msg; | |
156 | - } | |
157 | - | |
158 | 129 | private void SelectNode(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries) |
159 | 130 | { |
160 | 131 | FileSystemSourceFilesTargetFolder sourceTargetEntry = sourceTargetEntries.First(); |
@@ -1,5 +1,4 @@ | ||
1 | -using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog; | |
2 | -using CleanAuLait.UseCase.Interactor; | |
1 | +using CleanAuLait.UseCase.Interactor; | |
3 | 2 | using CleanAuLait.UseCase.Response; |
4 | 3 | using FolderCategorizer2.Domain.Boundary.Service; |
5 | 4 | using FolderCategorizer2.Domain.Model.Entity; |
@@ -10,10 +9,8 @@ using FolderCategorizer2.UseCase.Boundary.FileSystemOperation.Interactor; | ||
10 | 9 | using FolderCategorizer2.UseCase.FileSystemOperation.Request; |
11 | 10 | using FolderCategorizer2.UseCase.FileSystemOperation.Response; |
12 | 11 | using FolderCategorizer2.UseCase.Internal; |
13 | -using Prism.Services.Dialogs; | |
14 | 12 | using System.Collections.Generic; |
15 | 13 | using System.Linq; |
16 | -using System.Windows; | |
17 | 14 | |
18 | 15 | namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor |
19 | 16 | { |
@@ -23,21 +20,18 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
23 | 20 | { |
24 | 21 | //private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); |
25 | 22 | |
26 | - private readonly IFileSystemService fileSystem; | |
27 | - private readonly IFileSystemOperationLogic logic; | |
28 | - private readonly IUniversalDialogProxy dialog; | |
23 | + private readonly IFileSystemOperationLogic operation; | |
24 | + private readonly IFileSystemDialogLogic dialog; | |
29 | 25 | private readonly IFileListService fileList; |
30 | 26 | private readonly IFileSystemDeleteOperationPresenter presenter; |
31 | 27 | |
32 | 28 | public FileSystemDeleteOperationInteractor( |
33 | - IFileSystemService fileSystem, | |
34 | - IFileSystemOperationLogic logic, | |
35 | - IUniversalDialogProxy dialog, | |
29 | + IFileSystemOperationLogic operation, | |
30 | + IFileSystemDialogLogic dialog, | |
36 | 31 | IFileListService fileList, |
37 | 32 | IFileSystemDeleteOperationPresenter presenter) |
38 | 33 | { |
39 | - this.fileSystem = fileSystem; | |
40 | - this.logic = logic; | |
34 | + this.operation = operation; | |
41 | 35 | this.dialog = dialog; |
42 | 36 | this.fileList = fileList; |
43 | 37 | this.presenter = presenter; |
@@ -47,13 +41,13 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
47 | 41 | { |
48 | 42 | IEnumerable<FileSystemSourceFiles> sourceFilesList = req.SourceFilesList; |
49 | 43 | |
50 | - if (!Confirm(sourceFilesList)) | |
44 | + if (!this.dialog.ConfirmDeleteFile(sourceFilesList)) | |
51 | 45 | { |
52 | 46 | // don't show abort dialog. |
53 | 47 | return new(); |
54 | 48 | } |
55 | 49 | |
56 | - if (!this.logic.DeleteFile(sourceFilesList)) | |
50 | + if (!this.operation.DeleteFile(sourceFilesList)) | |
57 | 51 | { |
58 | 52 | return UseCaseResponse.Abort<FileSystemDeleteOperationResponse>("エラーのため処理が中止されました"); |
59 | 53 | } |
@@ -63,30 +57,6 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
63 | 57 | return this.presenter.Present(req, res); |
64 | 58 | } |
65 | 59 | |
66 | - private bool Confirm(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
67 | - { | |
68 | - string msg = CreateConfirmMessage(sourceFilesList); | |
69 | - | |
70 | - IDialogResult result = this.dialog.ShowYesNoDialog("ファイルの削除 - 確認", msg, MessageBoxImage.Question); | |
71 | - | |
72 | - return result.Result == ButtonResult.Yes; | |
73 | - } | |
74 | - | |
75 | - private static string CreateConfirmMessage(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
76 | - { | |
77 | - string msg = "【仮】削除してもよろしいですか"; | |
78 | - foreach (FileSystemSourceFiles sourceFiles in sourceFilesList) | |
79 | - { | |
80 | - msg += "\n\n削除元:" + sourceFiles.AbsolutePath; | |
81 | - foreach (string name in sourceFiles.Names) | |
82 | - { | |
83 | - msg += "\n・" + name; | |
84 | - } | |
85 | - } | |
86 | - | |
87 | - return msg; | |
88 | - } | |
89 | - | |
90 | 60 | private FileSystemDeleteOperationResponse CreateResponse(IEnumerable<FileSystemSourceFiles> sourceFilesList) |
91 | 61 | { |
92 | 62 | // FIX ME |
@@ -21,18 +21,18 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
21 | 21 | : AbstractUseCaseInteractor<FileSystemExchangeCreationAndLastWriteTimeOperationRequest, FileSystemExchangeCreationAndLastWriteTimeOperationResponse> |
22 | 22 | , IFileSystemExchangeCreationAndLastWriteTimeOperationInteractor |
23 | 23 | { |
24 | - private readonly IFileSystemOperationLogic logic; | |
25 | - private readonly IUniversalDialogProxy dialog; | |
24 | + private readonly IFileSystemOperationLogic operation; | |
25 | + private readonly IFileSystemDialogLogic dialog; | |
26 | 26 | private readonly IFileListService fileList; |
27 | 27 | private readonly IFileSystemExchangeCreationAndLastWriteTimeOperationPresenter presenter; |
28 | 28 | |
29 | 29 | public FileSystemExchangeCreationAndLastWriteTimeOperationInteractor( |
30 | - IFileSystemOperationLogic logic, | |
31 | - IUniversalDialogProxy dialog, | |
30 | + IFileSystemOperationLogic operation, | |
31 | + IFileSystemDialogLogic dialog, | |
32 | 32 | IFileListService fileList, |
33 | 33 | IFileSystemExchangeCreationAndLastWriteTimeOperationPresenter presenter) |
34 | 34 | { |
35 | - this.logic = logic; | |
35 | + this.operation = operation; | |
36 | 36 | this.dialog = dialog; |
37 | 37 | this.fileList = fileList; |
38 | 38 | this.presenter = presenter; |
@@ -42,13 +42,13 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
42 | 42 | { |
43 | 43 | IEnumerable<FileSystemSourceFiles> sourceFilesList = req.SourceFilesList; |
44 | 44 | |
45 | - if (!Confirm(sourceFilesList)) | |
45 | + if (!this.dialog.ConfirmExchangeTimestamp(sourceFilesList)) | |
46 | 46 | { |
47 | 47 | // don't show abort dialog. |
48 | 48 | return new(); |
49 | 49 | } |
50 | 50 | |
51 | - if (!this.logic.ExchangeTimestamp(sourceFilesList)) | |
51 | + if (!this.operation.ExchangeTimestamp(sourceFilesList)) | |
52 | 52 | { |
53 | 53 | return UseCaseResponse.Abort<FileSystemExchangeCreationAndLastWriteTimeOperationResponse>("エラーのため処理が中止されました"); |
54 | 54 | } |
@@ -58,31 +58,6 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
58 | 58 | return this.presenter.Present(req, res); |
59 | 59 | } |
60 | 60 | |
61 | - private bool Confirm(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
62 | - { | |
63 | - string msg = CreateConfirmMessage(sourceFilesList); | |
64 | - | |
65 | - IDialogResult result = this.dialog.ShowYesNoDialog("作成日時と更新日時を入れ替え - 確認", msg, MessageBoxImage.Question); | |
66 | - | |
67 | - return result.Result == ButtonResult.Yes; | |
68 | - } | |
69 | - | |
70 | - private static string CreateConfirmMessage(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
71 | - { | |
72 | - string msg = "【仮】作成日時と更新日時を入れ替えてもよろしいですか"; | |
73 | - | |
74 | - foreach (FileSystemSourceFiles sourceFiles in sourceFilesList) | |
75 | - { | |
76 | - msg += "\n\n対象:" + sourceFiles.AbsolutePath; | |
77 | - foreach (string name in sourceFiles.Names) | |
78 | - { | |
79 | - msg += "\n・" + name; | |
80 | - } | |
81 | - } | |
82 | - | |
83 | - return msg; | |
84 | - } | |
85 | - | |
86 | 61 | private FileSystemExchangeCreationAndLastWriteTimeOperationResponse CreateResponse(IEnumerable<FileSystemSourceFiles> sourceFilesList) |
87 | 62 | { |
88 | 63 | // FIX ME |
@@ -1,5 +1,4 @@ | ||
1 | -using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog; | |
2 | -using CleanAuLait.UseCase.Interactor; | |
1 | +using CleanAuLait.UseCase.Interactor; | |
3 | 2 | using CleanAuLait.UseCase.Response; |
4 | 3 | using FolderCategorizer2.Domain.Boundary.Service; |
5 | 4 | using FolderCategorizer2.Domain.Service.Dto; |
@@ -7,10 +6,8 @@ using FolderCategorizer2.UseCase.Boundary.FileSystemOperation.Interactor; | ||
7 | 6 | using FolderCategorizer2.UseCase.FileSystemOperation.Request; |
8 | 7 | using FolderCategorizer2.UseCase.FileSystemOperation.Response; |
9 | 8 | using FolderCategorizer2.UseCase.Internal; |
10 | -using Prism.Services.Dialogs; | |
11 | 9 | using System.Collections.Generic; |
12 | 10 | using System.Linq; |
13 | -using System.Windows; | |
14 | 11 | |
15 | 12 | namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor |
16 | 13 | { |
@@ -21,20 +18,20 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
21 | 18 | //private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); |
22 | 19 | |
23 | 20 | private readonly IFileSystemService fileSystem; |
24 | - private readonly IFileSystemOperationLogic logic; | |
21 | + private readonly IFileSystemOperationLogic operation; | |
22 | + private readonly IFileSystemDialogLogic dialog; | |
25 | 23 | private readonly IFolderTreeService folderTree; |
26 | - private readonly IUniversalDialogProxy dialog; | |
27 | 24 | |
28 | 25 | public FileSystemMoveOperationInteractor( |
29 | 26 | IFileSystemService fileSystem, |
30 | - IFileSystemOperationLogic logic, | |
31 | - IFolderTreeService folderTree, | |
32 | - IUniversalDialogProxy dialog) | |
27 | + IFileSystemOperationLogic operation, | |
28 | + IFileSystemDialogLogic dialog, | |
29 | + IFolderTreeService folderTree) | |
33 | 30 | { |
34 | 31 | this.fileSystem = fileSystem; |
35 | - this.logic = logic; | |
36 | - this.folderTree = folderTree; | |
32 | + this.operation = operation; | |
37 | 33 | this.dialog = dialog; |
34 | + this.folderTree = folderTree; | |
38 | 35 | } |
39 | 36 | |
40 | 37 | public override FileSystemMoveOperationResponse Interact(FileSystemMoveOperationRequest req) |
@@ -57,13 +54,13 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
57 | 54 | IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries = |
58 | 55 | FileSystemSourceFilesTargetFolder.Join(targetFolders, sourceFilesList); |
59 | 56 | |
60 | - if (!Confirm(sourceTargetEntries)) | |
57 | + if (!this.dialog.ConfirmMoveFile(sourceTargetEntries)) | |
61 | 58 | { |
62 | 59 | // don't show abort dialog. |
63 | 60 | return new(); |
64 | 61 | } |
65 | 62 | |
66 | - if (!this.logic.MoveFile(sourceTargetEntries)) | |
63 | + if (!this.operation.MoveFile(sourceTargetEntries)) | |
67 | 64 | { |
68 | 65 | return UseCaseResponse.Abort<FileSystemMoveOperationResponse>("エラーのため処理が中止されました"); |
69 | 66 | } |
@@ -129,31 +126,6 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
129 | 126 | return msg; |
130 | 127 | } |
131 | 128 | |
132 | - private bool Confirm(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries) | |
133 | - { | |
134 | - string msg = CreateConfirmMessage(sourceTargetEntries); | |
135 | - | |
136 | - IDialogResult result = this.dialog.ShowYesNoDialog("ファイルの移動 - 確認", msg, MessageBoxImage.Question); | |
137 | - | |
138 | - return result.Result == ButtonResult.Yes; | |
139 | - } | |
140 | - | |
141 | - private static string CreateConfirmMessage(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries) | |
142 | - { | |
143 | - string msg = "【仮】移動してもよろしいですか"; | |
144 | - foreach (FileSystemSourceFilesTargetFolder sourceTargetEntry in sourceTargetEntries) | |
145 | - { | |
146 | - msg += "\n\n移動元:" + sourceTargetEntry.SourceFiles.AbsolutePath; | |
147 | - foreach (string name in sourceTargetEntry.SourceFiles.Names) | |
148 | - { | |
149 | - msg += "\n・" + name; | |
150 | - } | |
151 | - msg += "\n↓\n移動先:" + sourceTargetEntry.TargetFolder.AbsolutePath; | |
152 | - } | |
153 | - | |
154 | - return msg; | |
155 | - } | |
156 | - | |
157 | 129 | private void SelectNode(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries) |
158 | 130 | { |
159 | 131 | // FIX ME |
@@ -22,19 +22,19 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
22 | 22 | { |
23 | 23 | private const string DEFAULT_NEW_FILE_NAME = "新しいファイル.txt"; |
24 | 24 | |
25 | - private readonly IFileSystemOperationLogic logic; | |
26 | - private readonly INewFilePromptViewProxy prompt; | |
25 | + private readonly IFileSystemOperationLogic operation; | |
26 | + private readonly IFileSystemDialogLogic dialog; | |
27 | 27 | private readonly IFileListService fileList; |
28 | 28 | private readonly IFileSystemNewFileOperationPresenter presenter; |
29 | 29 | |
30 | 30 | public FileSystemNewFileOperationInteractor( |
31 | - IFileSystemOperationLogic logic, | |
32 | - INewFilePromptViewProxy prompt, | |
31 | + IFileSystemOperationLogic operation, | |
32 | + IFileSystemDialogLogic dialog, | |
33 | 33 | IFileListService fileList, |
34 | 34 | IFileSystemNewFileOperationPresenter presenter) |
35 | 35 | { |
36 | - this.logic = logic; | |
37 | - this.prompt = prompt; | |
36 | + this.operation = operation; | |
37 | + this.dialog = dialog; | |
38 | 38 | this.fileList = fileList; |
39 | 39 | this.presenter = presenter; |
40 | 40 | } |
@@ -43,7 +43,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
43 | 43 | { |
44 | 44 | IEnumerable<FileSystemPathEntry> targetEntries = req.Targets; |
45 | 45 | |
46 | - string targetName = AskTargetName(DEFAULT_NEW_FILE_NAME); | |
46 | + string targetName = this.dialog.AskNewFileName(DEFAULT_NEW_FILE_NAME); | |
47 | 47 | |
48 | 48 | if (string.IsNullOrEmpty(targetName)) |
49 | 49 | { |
@@ -53,7 +53,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
53 | 53 | |
54 | 54 | // TODO target already existing error, skip prompt |
55 | 55 | |
56 | - if (!this.logic.CreateFile(targetEntries, targetName)) | |
56 | + if (!this.operation.CreateFile(targetEntries, targetName)) | |
57 | 57 | { |
58 | 58 | return UseCaseResponse.Abort<FileSystemNewFileOperationResponse>("エラーのため処理が中止されました"); |
59 | 59 | } |
@@ -63,18 +63,6 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
63 | 63 | return this.presenter.Present(req, res); |
64 | 64 | } |
65 | 65 | |
66 | - private string AskTargetName(string targetName) | |
67 | - { | |
68 | - (IDialogResult result, targetName) = prompt.ShowPrompt(targetName); | |
69 | - | |
70 | - if (result.Result != ButtonResult.OK) | |
71 | - { | |
72 | - return string.Empty; | |
73 | - } | |
74 | - | |
75 | - return targetName; | |
76 | - } | |
77 | - | |
78 | 66 | private FileSystemNewFileOperationResponse CreateResponse(IEnumerable<FileSystemPathEntry> targetEntries) |
79 | 67 | { |
80 | 68 | // FIX ME |
@@ -6,11 +6,9 @@ using FolderCategorizer2.Domain.Service.Dto; | ||
6 | 6 | using FolderCategorizer2.Domain.Translator; |
7 | 7 | using FolderCategorizer2.UseCase.Boundary.FileListOperation.Presenter; |
8 | 8 | using FolderCategorizer2.UseCase.Boundary.FileSystemOperation.Interactor; |
9 | -using FolderCategorizer2.UseCase.Boundary.ViewProxy; | |
10 | 9 | using FolderCategorizer2.UseCase.FileSystemOperation.Request; |
11 | 10 | using FolderCategorizer2.UseCase.FileSystemOperation.Response; |
12 | 11 | using FolderCategorizer2.UseCase.Internal; |
13 | -using Prism.Services.Dialogs; | |
14 | 12 | using System.Collections.Generic; |
15 | 13 | using System.Linq; |
16 | 14 |
@@ -22,19 +20,19 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
22 | 20 | { |
23 | 21 | private const string DEFAULT_NEW_FOLDER_NAME = "新しいフォルダ"; |
24 | 22 | |
25 | - private readonly IFileSystemOperationLogic logic; | |
26 | - private readonly INewFolderPromptViewProxy prompt; | |
23 | + private readonly IFileSystemOperationLogic operation; | |
24 | + private readonly IFileSystemDialogLogic dialog; | |
27 | 25 | private readonly IFileListService fileList; |
28 | 26 | private readonly IFileSystemNewFolderOperationPresenter presenter; |
29 | 27 | |
30 | 28 | public FileSystemNewFolderOperationInteractor( |
31 | - IFileSystemOperationLogic logic, | |
29 | + IFileSystemOperationLogic operation, | |
30 | + IFileSystemDialogLogic dialog, | |
32 | 31 | IFileListService fileList, |
33 | - INewFolderPromptViewProxy prompt, | |
34 | 32 | IFileSystemNewFolderOperationPresenter presenter) |
35 | 33 | { |
36 | - this.logic = logic; | |
37 | - this.prompt = prompt; | |
34 | + this.operation = operation; | |
35 | + this.dialog = dialog; | |
38 | 36 | this.fileList = fileList; |
39 | 37 | this.presenter = presenter; |
40 | 38 | } |
@@ -43,7 +41,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
43 | 41 | { |
44 | 42 | IEnumerable<FileSystemPathEntry> targetEntries = req.Targets; |
45 | 43 | |
46 | - string targetName = AskTargetName(DEFAULT_NEW_FOLDER_NAME); | |
44 | + string targetName = this.dialog.AskNewFolderName(DEFAULT_NEW_FOLDER_NAME); | |
47 | 45 | |
48 | 46 | if (string.IsNullOrEmpty(targetName)) |
49 | 47 | { |
@@ -53,7 +51,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
53 | 51 | |
54 | 52 | // TODO target already existing error, skip prompt |
55 | 53 | |
56 | - if (!this.logic.CreateFolder(targetEntries, targetName)) | |
54 | + if (!this.operation.CreateFolder(targetEntries, targetName)) | |
57 | 55 | { |
58 | 56 | return UseCaseResponse.Abort<FileSystemNewFolderOperationResponse>("エラーのため処理が中止されました"); |
59 | 57 | } |
@@ -63,18 +61,6 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
63 | 61 | return this.presenter.Present(req, res); |
64 | 62 | } |
65 | 63 | |
66 | - private string AskTargetName(string targetName) | |
67 | - { | |
68 | - (IDialogResult result, targetName) = this.prompt.ShowPrompt(targetName); | |
69 | - | |
70 | - if (result.Result != ButtonResult.OK) | |
71 | - { | |
72 | - return string.Empty; | |
73 | - } | |
74 | - | |
75 | - return targetName; | |
76 | - } | |
77 | - | |
78 | 64 | private FileSystemNewFolderOperationResponse CreateResponse(IEnumerable<FileSystemPathEntry> targetEntries) |
79 | 65 | { |
80 | 66 | // FIX ME |
@@ -1,5 +1,4 @@ | ||
1 | -using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog; | |
2 | -using CleanAuLait.UseCase.Interactor; | |
1 | +using CleanAuLait.UseCase.Interactor; | |
3 | 2 | using CleanAuLait.UseCase.Response; |
4 | 3 | using FolderCategorizer2.Domain.Boundary.Service; |
5 | 4 | using FolderCategorizer2.Domain.Model.Entity; |
@@ -10,10 +9,8 @@ using FolderCategorizer2.UseCase.Boundary.FileSystemOperation.Interactor; | ||
10 | 9 | using FolderCategorizer2.UseCase.FileSystemOperation.Request; |
11 | 10 | using FolderCategorizer2.UseCase.FileSystemOperation.Response; |
12 | 11 | using FolderCategorizer2.UseCase.Internal; |
13 | -using Prism.Services.Dialogs; | |
14 | 12 | using System.Collections.Generic; |
15 | 13 | using System.Linq; |
16 | -using System.Windows; | |
17 | 14 | |
18 | 15 | namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor |
19 | 16 | { |
@@ -21,20 +18,20 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
21 | 18 | : AbstractUseCaseInteractor<FileSystemOverwriteCreationTimeOperationRequest, FileSystemOverwriteCreationTimeOperationResponse> |
22 | 19 | , IFileSystemOverwriteCreationTimeOperationInteractor |
23 | 20 | { |
24 | - private readonly IFileSystemOperationLogic logic; | |
25 | - private readonly IUniversalDialogProxy dialog; | |
21 | + private readonly IFileSystemOperationLogic operation; | |
22 | + private readonly IFileSystemDialogLogic dialog; | |
26 | 23 | private readonly IFileListService fileList; |
27 | 24 | private readonly IFileSystemOverwriteCreationTimeOperationPresenter presenter; |
28 | 25 | |
29 | 26 | public FileSystemOverwriteCreationTimeOperationInteractor( |
30 | - IFileSystemOperationLogic logic, | |
27 | + IFileSystemOperationLogic operation, | |
28 | + IFileSystemDialogLogic dialog, | |
31 | 29 | IFileListService fileList, |
32 | - IUniversalDialogProxy dialog, | |
33 | 30 | IFileSystemOverwriteCreationTimeOperationPresenter presenter) |
34 | 31 | { |
35 | - this.logic = logic; | |
36 | - this.fileList = fileList; | |
32 | + this.operation = operation; | |
37 | 33 | this.dialog = dialog; |
34 | + this.fileList = fileList; | |
38 | 35 | this.presenter = presenter; |
39 | 36 | } |
40 | 37 |
@@ -42,13 +39,13 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
42 | 39 | { |
43 | 40 | IEnumerable<FileSystemSourceFiles> sourceFilesList = req.SourceFilesList; |
44 | 41 | |
45 | - if (!Confirm(sourceFilesList)) | |
42 | + if (!this.dialog.ConfirmOverwriteCreationTime(sourceFilesList)) | |
46 | 43 | { |
47 | 44 | // don't show abort dialog. |
48 | 45 | return new(); |
49 | 46 | } |
50 | 47 | |
51 | - if (!this.logic.OverwriteCreationTime(sourceFilesList)) | |
48 | + if (!this.operation.OverwriteCreationTime(sourceFilesList)) | |
52 | 49 | { |
53 | 50 | return UseCaseResponse.Abort<FileSystemOverwriteCreationTimeOperationResponse>("エラーのため処理が中止されました"); |
54 | 51 | } |
@@ -58,30 +55,6 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
58 | 55 | return this.presenter.Present(req, res); |
59 | 56 | } |
60 | 57 | |
61 | - private bool Confirm(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
62 | - { | |
63 | - string msg = CreateConfirmMessage(sourceFilesList); | |
64 | - | |
65 | - IDialogResult result = this.dialog.ShowYesNoDialog("作成日時を更新日時で上書き - 確認", msg, MessageBoxImage.Question); | |
66 | - | |
67 | - return result.Result == ButtonResult.Yes; | |
68 | - } | |
69 | - | |
70 | - private static string CreateConfirmMessage(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
71 | - { | |
72 | - string msg = "【仮】作成日時を更新日時で上書きしてもよろしいですか"; | |
73 | - foreach (FileSystemSourceFiles sourceFiles in sourceFilesList) | |
74 | - { | |
75 | - msg += "\n\n対象:" + sourceFiles.AbsolutePath; | |
76 | - foreach (string name in sourceFiles.Names) | |
77 | - { | |
78 | - msg += "\n・" + name; | |
79 | - } | |
80 | - } | |
81 | - | |
82 | - return msg; | |
83 | - } | |
84 | - | |
85 | 58 | private FileSystemOverwriteCreationTimeOperationResponse CreateResponse(IEnumerable<FileSystemSourceFiles> sourceFilesList) |
86 | 59 | { |
87 | 60 | // FIX ME |
@@ -1,5 +1,4 @@ | ||
1 | -using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog; | |
2 | -using CleanAuLait.UseCase.Interactor; | |
1 | +using CleanAuLait.UseCase.Interactor; | |
3 | 2 | using CleanAuLait.UseCase.Response; |
4 | 3 | using FolderCategorizer2.Domain.Boundary.Service; |
5 | 4 | using FolderCategorizer2.Domain.Model.Entity; |
@@ -10,11 +9,8 @@ using FolderCategorizer2.UseCase.Boundary.FileSystemOperation.Interactor; | ||
10 | 9 | using FolderCategorizer2.UseCase.FileSystemOperation.Request; |
11 | 10 | using FolderCategorizer2.UseCase.FileSystemOperation.Response; |
12 | 11 | using FolderCategorizer2.UseCase.Internal; |
13 | -using NLog; | |
14 | -using Prism.Services.Dialogs; | |
15 | 12 | using System.Collections.Generic; |
16 | 13 | using System.Linq; |
17 | -using System.Windows; | |
18 | 14 | |
19 | 15 | namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor |
20 | 16 | { |
@@ -22,22 +18,22 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
22 | 18 | : AbstractUseCaseInteractor<FileSystemOverwriteLastWriteTimeOperationRequest, FileSystemOverwriteLastWriteTimeOperationResponse> |
23 | 19 | , IFileSystemOverwriteLastWriteTimeOperationInteractor |
24 | 20 | { |
25 | - private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); | |
21 | + //private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); | |
26 | 22 | |
27 | - private readonly IFileSystemOperationLogic logic; | |
23 | + private readonly IFileSystemOperationLogic operation; | |
24 | + private readonly IFileSystemDialogLogic dialog; | |
28 | 25 | private readonly IFileListService fileList; |
29 | - private readonly IUniversalDialogProxy dialog; | |
30 | 26 | private readonly IFileSystemOverwriteLastWriteTimeOperationPresenter presenter; |
31 | 27 | |
32 | 28 | public FileSystemOverwriteLastWriteTimeOperationInteractor( |
33 | - IFileSystemOperationLogic logic, | |
29 | + IFileSystemOperationLogic operation, | |
30 | + IFileSystemDialogLogic dialog, | |
34 | 31 | IFileListService fileList, |
35 | - IUniversalDialogProxy dialog, | |
36 | 32 | IFileSystemOverwriteLastWriteTimeOperationPresenter presenter) |
37 | 33 | { |
38 | - this.logic = logic; | |
39 | - this.fileList = fileList; | |
34 | + this.operation = operation; | |
40 | 35 | this.dialog = dialog; |
36 | + this.fileList = fileList; | |
41 | 37 | this.presenter = presenter; |
42 | 38 | } |
43 | 39 |
@@ -45,13 +41,13 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
45 | 41 | { |
46 | 42 | IEnumerable<FileSystemSourceFiles> sourceFilesList = req.SourceFilesList; |
47 | 43 | |
48 | - if (!Confirm(sourceFilesList)) | |
44 | + if (!this.dialog.ConfirmOverwriteLastWriteTime(sourceFilesList)) | |
49 | 45 | { |
50 | 46 | // don't show abort dialog. |
51 | 47 | return new(); |
52 | 48 | } |
53 | 49 | |
54 | - if (!this.logic.OverwriteLastWriteTime(sourceFilesList)) | |
50 | + if (!this.operation.OverwriteLastWriteTime(sourceFilesList)) | |
55 | 51 | { |
56 | 52 | return UseCaseResponse.Abort<FileSystemOverwriteLastWriteTimeOperationResponse>("エラーのため処理が中止されました"); |
57 | 53 | } |
@@ -61,30 +57,6 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
61 | 57 | return this.presenter.Present(req, res); |
62 | 58 | } |
63 | 59 | |
64 | - private bool Confirm(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
65 | - { | |
66 | - string msg = CreateConfirmMessage(sourceFilesList); | |
67 | - | |
68 | - IDialogResult result = this.dialog.ShowYesNoDialog("更新日時を作成日時で上書き - 確認", msg, MessageBoxImage.Question); | |
69 | - | |
70 | - return result.Result == ButtonResult.Yes; | |
71 | - } | |
72 | - | |
73 | - private static string CreateConfirmMessage(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
74 | - { | |
75 | - string msg = "【仮】更新日時を作成日時で上書きしてもよろしいですか"; | |
76 | - foreach (FileSystemSourceFiles sourceFiles in sourceFilesList) | |
77 | - { | |
78 | - msg += "\n\n対象:" + sourceFiles.AbsolutePath; | |
79 | - foreach (string name in sourceFiles.Names) | |
80 | - { | |
81 | - msg += "\n・" + name; | |
82 | - } | |
83 | - } | |
84 | - | |
85 | - return msg; | |
86 | - } | |
87 | - | |
88 | 60 | private FileSystemOverwriteLastWriteTimeOperationResponse CreateResponse(IEnumerable<FileSystemSourceFiles> sourceFilesList) |
89 | 61 | { |
90 | 62 | // FIX ME |
@@ -1,5 +1,4 @@ | ||
1 | -using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog; | |
2 | -using CleanAuLait.UseCase.Interactor; | |
1 | +using CleanAuLait.UseCase.Interactor; | |
3 | 2 | using CleanAuLait.UseCase.Response; |
4 | 3 | using FolderCategorizer2.Domain.Boundary.Service; |
5 | 4 | using FolderCategorizer2.Domain.Model.Entity; |
@@ -7,14 +6,11 @@ using FolderCategorizer2.Domain.Service.Dto; | ||
7 | 6 | using FolderCategorizer2.Domain.Translator; |
8 | 7 | using FolderCategorizer2.UseCase.Boundary.FileListOperation.Presenter; |
9 | 8 | using FolderCategorizer2.UseCase.Boundary.FileSystemOperation.Interactor; |
10 | -using FolderCategorizer2.UseCase.Boundary.ViewProxy; | |
11 | 9 | using FolderCategorizer2.UseCase.FileSystemOperation.Request; |
12 | 10 | using FolderCategorizer2.UseCase.FileSystemOperation.Response; |
13 | 11 | using FolderCategorizer2.UseCase.Internal; |
14 | -using Prism.Services.Dialogs; | |
15 | 12 | using System.Collections.Generic; |
16 | 13 | using System.Linq; |
17 | -using System.Windows; | |
18 | 14 | |
19 | 15 | namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor |
20 | 16 | { |
@@ -24,22 +20,18 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
24 | 20 | { |
25 | 21 | //private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); |
26 | 22 | |
27 | - private readonly IFileSystemOperationLogic logic; | |
28 | - private readonly IRenamePromptViewProxy prompt; | |
29 | - private readonly IUniversalDialogProxy dialog; | |
23 | + private readonly IFileSystemOperationLogic operation; | |
24 | + private readonly IFileSystemDialogLogic dialog; | |
30 | 25 | private readonly IFileListService fileList; |
31 | 26 | private readonly IFileSystemRenameOperationPresenter presenter; |
32 | 27 | |
33 | 28 | public FileSystemRenameOperationInteractor( |
34 | - IFileSystemOperationLogic logic, | |
35 | - IFolderTreeService folderTree, | |
29 | + IFileSystemOperationLogic operation, | |
30 | + IFileSystemDialogLogic dialog, | |
36 | 31 | IFileListService fileList, |
37 | - IUniversalDialogProxy dialog, | |
38 | - IRenamePromptViewProxy prompt, | |
39 | 32 | IFileSystemRenameOperationPresenter presenter) |
40 | 33 | { |
41 | - this.logic = logic; | |
42 | - this.prompt = prompt; | |
34 | + this.operation = operation; | |
43 | 35 | this.dialog = dialog; |
44 | 36 | this.fileList = fileList; |
45 | 37 | this.presenter = presenter; |
@@ -49,7 +41,7 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
49 | 41 | { |
50 | 42 | IEnumerable<FileSystemSourceFile> sourceFileList = req.SourceFileList; |
51 | 43 | |
52 | - string targetName = AskTargetName(req.SourceFileList.First().Name); | |
44 | + string targetName = this.dialog.AskRenameFileName(req.SourceFileList.First().Name); | |
53 | 45 | |
54 | 46 | if (string.IsNullOrEmpty(targetName)) |
55 | 47 | { |
@@ -57,13 +49,13 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
57 | 49 | return new(); |
58 | 50 | } |
59 | 51 | |
60 | - if (!Confirm(sourceFileList, targetName)) | |
52 | + if (!this.dialog.ConfirmRenameFile(sourceFileList, targetName)) | |
61 | 53 | { |
62 | 54 | // don't show abort dialog. |
63 | 55 | return new(); |
64 | 56 | } |
65 | 57 | |
66 | - if (!this.logic.RenameFile(sourceFileList, targetName)) | |
58 | + if (!this.operation.RenameFile(sourceFileList, targetName)) | |
67 | 59 | { |
68 | 60 | return UseCaseResponse.Abort<FileSystemRenameOperationResponse>("エラーのため処理が中止されました"); |
69 | 61 | } |
@@ -73,41 +65,6 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor | ||
73 | 65 | return this.presenter.Present(req, res); |
74 | 66 | } |
75 | 67 | |
76 | - private string AskTargetName(string targetName) | |
77 | - { | |
78 | - (IDialogResult result, targetName) = prompt.ShowPrompt(targetName); | |
79 | - | |
80 | - if (result.Result != ButtonResult.OK) | |
81 | - { | |
82 | - return string.Empty; | |
83 | - } | |
84 | - | |
85 | - return targetName; | |
86 | - } | |
87 | - | |
88 | - private bool Confirm(IEnumerable<FileSystemSourceFile> sourceFileList, string targetName) | |
89 | - { | |
90 | - string msg = CreateConfirmMessage(sourceFileList, targetName); | |
91 | - | |
92 | - IDialogResult result = this.dialog.ShowYesNoDialog("ファイル名の変更 - 確認", msg, MessageBoxImage.Question); | |
93 | - | |
94 | - return result.Result == ButtonResult.Yes; | |
95 | - } | |
96 | - | |
97 | - private static string CreateConfirmMessage(IEnumerable<FileSystemSourceFile> sourceFileList, string targetName) | |
98 | - { | |
99 | - string msg = "【仮】名前を変更してもよろしいですか"; | |
100 | - | |
101 | - foreach (FileSystemSourceFile sourceFile in sourceFileList) | |
102 | - { | |
103 | - msg += "\n\n対象:" + sourceFile.SourceFolderAbsolutePath; | |
104 | - msg += "\n変更前:" + sourceFile.Name; | |
105 | - msg += "\n変更後:" + targetName; | |
106 | - } | |
107 | - | |
108 | - return msg; | |
109 | - } | |
110 | - | |
111 | 68 | private FileSystemRenameOperationResponse CreateResponse(IEnumerable<FileSystemSourceFile> sourceFileList) |
112 | 69 | { |
113 | 70 | // FIX ME |
@@ -0,0 +1,262 @@ | ||
1 | +using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog; | |
2 | +using FolderCategorizer2.Domain.Service.Dto; | |
3 | +using FolderCategorizer2.UseCase.Boundary.ViewProxy; | |
4 | +using Prism.Services.Dialogs; | |
5 | +using System; | |
6 | +using System.Collections.Generic; | |
7 | +using System.Linq; | |
8 | +using System.Text; | |
9 | +using System.Threading.Tasks; | |
10 | +using System.Windows; | |
11 | + | |
12 | +namespace FolderCategorizer2.UseCase.Internal | |
13 | +{ | |
14 | + internal class FileSystemDialogLogic : IFileSystemDialogLogic | |
15 | + { | |
16 | + private readonly INewFilePromptViewProxy newFilePrompt; | |
17 | + private readonly INewFolderPromptViewProxy newFolderPrompt; | |
18 | + private readonly IRenamePromptViewProxy renamePrompt; | |
19 | + private readonly IUniversalDialogProxy dialog; | |
20 | + | |
21 | + public FileSystemDialogLogic( | |
22 | + INewFilePromptViewProxy newFilePrompt, | |
23 | + INewFolderPromptViewProxy newFolderPrompt, | |
24 | + IRenamePromptViewProxy renamePrompt, | |
25 | + IUniversalDialogProxy dialog) | |
26 | + { | |
27 | + this.newFilePrompt = newFilePrompt; | |
28 | + this.newFolderPrompt = newFolderPrompt; | |
29 | + this.renamePrompt = renamePrompt; | |
30 | + this.dialog = dialog; | |
31 | + } | |
32 | + | |
33 | + public string AskNewFileName(string targetName) | |
34 | + { | |
35 | + (IDialogResult result, targetName) = newFilePrompt.ShowPrompt(targetName); | |
36 | + | |
37 | + if (result.Result != ButtonResult.OK) | |
38 | + { | |
39 | + return string.Empty; | |
40 | + } | |
41 | + | |
42 | + return targetName; | |
43 | + } | |
44 | + | |
45 | + public string AskNewFolderName(string targetName) | |
46 | + { | |
47 | + (IDialogResult result, targetName) = this.newFolderPrompt.ShowPrompt(targetName); | |
48 | + | |
49 | + if (result.Result != ButtonResult.OK) | |
50 | + { | |
51 | + return string.Empty; | |
52 | + } | |
53 | + | |
54 | + return targetName; | |
55 | + } | |
56 | + | |
57 | + public string AskRenameFileName(string targetName) | |
58 | + { | |
59 | + (IDialogResult result, targetName) = renamePrompt.ShowPrompt(targetName); | |
60 | + | |
61 | + if (result.Result != ButtonResult.OK) | |
62 | + { | |
63 | + return string.Empty; | |
64 | + } | |
65 | + | |
66 | + return targetName; | |
67 | + } | |
68 | + | |
69 | + public bool ConfirmCopyFiles(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries) | |
70 | + { | |
71 | + string msg = CreateConfirmMessageCopyFiles(sourceTargetEntries); | |
72 | + | |
73 | + IDialogResult result = this.dialog.ShowYesNoDialog("ファイルのコピー - 確認", msg, MessageBoxImage.Question); | |
74 | + | |
75 | + return result.Result == ButtonResult.Yes; | |
76 | + } | |
77 | + | |
78 | + private static string CreateConfirmMessageCopyFiles(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries) | |
79 | + { | |
80 | + string msg = "【仮】コピーしてもよろしいですか"; | |
81 | + | |
82 | + foreach (FileSystemSourceFilesTargetFolder sourceTargetEntry in sourceTargetEntries) | |
83 | + { | |
84 | + msg += "\n\nコピー元:" + sourceTargetEntry.SourceFiles.AbsolutePath; | |
85 | + foreach (string name in sourceTargetEntry.SourceFiles.Names) | |
86 | + { | |
87 | + msg += "\n・" + name; | |
88 | + } | |
89 | + msg += "\n↓\nコピー先:" + sourceTargetEntry.TargetFolder.AbsolutePath; | |
90 | + } | |
91 | + | |
92 | + return msg; | |
93 | + } | |
94 | + | |
95 | + public bool ConfirmMoveFile(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries) | |
96 | + { | |
97 | + string msg = CreateConfirmMessageMoveFile(sourceTargetEntries); | |
98 | + | |
99 | + IDialogResult result = this.dialog.ShowYesNoDialog("ファイルの移動 - 確認", msg, MessageBoxImage.Question); | |
100 | + | |
101 | + return result.Result == ButtonResult.Yes; | |
102 | + } | |
103 | + | |
104 | + private static string CreateConfirmMessageMoveFile(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries) | |
105 | + { | |
106 | + string msg = "【仮】移動してもよろしいですか"; | |
107 | + foreach (FileSystemSourceFilesTargetFolder sourceTargetEntry in sourceTargetEntries) | |
108 | + { | |
109 | + msg += "\n\n移動元:" + sourceTargetEntry.SourceFiles.AbsolutePath; | |
110 | + foreach (string name in sourceTargetEntry.SourceFiles.Names) | |
111 | + { | |
112 | + msg += "\n・" + name; | |
113 | + } | |
114 | + msg += "\n↓\n移動先:" + sourceTargetEntry.TargetFolder.AbsolutePath; | |
115 | + } | |
116 | + | |
117 | + return msg; | |
118 | + } | |
119 | + | |
120 | + public bool ConfirmDeleteFile(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
121 | + { | |
122 | + string msg = CreateConfirmMessageDeleteFile(sourceFilesList); | |
123 | + | |
124 | + IDialogResult result = this.dialog.ShowYesNoDialog("ファイルの削除 - 確認", msg, MessageBoxImage.Question); | |
125 | + | |
126 | + return result.Result == ButtonResult.Yes; | |
127 | + } | |
128 | + | |
129 | + private static string CreateConfirmMessageDeleteFile(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
130 | + { | |
131 | + string msg = "【仮】削除してもよろしいですか"; | |
132 | + foreach (FileSystemSourceFiles sourceFiles in sourceFilesList) | |
133 | + { | |
134 | + msg += "\n\n削除元:" + sourceFiles.AbsolutePath; | |
135 | + foreach (string name in sourceFiles.Names) | |
136 | + { | |
137 | + msg += "\n・" + name; | |
138 | + } | |
139 | + } | |
140 | + | |
141 | + return msg; | |
142 | + } | |
143 | + | |
144 | + public bool ConfirmRenameFile(IEnumerable<FileSystemSourceFile> sourceFileList, string targetName) | |
145 | + { | |
146 | + string msg = CreateConfirmMessageRenameFile(sourceFileList, targetName); | |
147 | + | |
148 | + IDialogResult result = this.dialog.ShowYesNoDialog("ファイル名の変更 - 確認", msg, MessageBoxImage.Question); | |
149 | + | |
150 | + return result.Result == ButtonResult.Yes; | |
151 | + } | |
152 | + | |
153 | + private static string CreateConfirmMessageRenameFile(IEnumerable<FileSystemSourceFile> sourceFileList, string targetName) | |
154 | + { | |
155 | + string msg = "【仮】名前を変更してもよろしいですか"; | |
156 | + | |
157 | + foreach (FileSystemSourceFile sourceFile in sourceFileList) | |
158 | + { | |
159 | + msg += "\n\n対象:" + sourceFile.SourceFolderAbsolutePath; | |
160 | + msg += "\n変更前:" + sourceFile.Name; | |
161 | + msg += "\n変更後:" + targetName; | |
162 | + } | |
163 | + | |
164 | + return msg; | |
165 | + } | |
166 | + | |
167 | + public bool ConfirmOverwriteCreationTime(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
168 | + { | |
169 | + string msg = CreateConfirmMessageOverwriteCreationTime(sourceFilesList); | |
170 | + | |
171 | + IDialogResult result = this.dialog.ShowYesNoDialog("作成日時を更新日時で上書き - 確認", msg, MessageBoxImage.Question); | |
172 | + | |
173 | + return result.Result == ButtonResult.Yes; | |
174 | + } | |
175 | + | |
176 | + private static string CreateConfirmMessageOverwriteCreationTime(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
177 | + { | |
178 | + string msg = "【仮】作成日時を更新日時で上書きしてもよろしいですか"; | |
179 | + foreach (FileSystemSourceFiles sourceFiles in sourceFilesList) | |
180 | + { | |
181 | + msg += "\n\n対象:" + sourceFiles.AbsolutePath; | |
182 | + foreach (string name in sourceFiles.Names) | |
183 | + { | |
184 | + msg += "\n・" + name; | |
185 | + } | |
186 | + } | |
187 | + | |
188 | + return msg; | |
189 | + } | |
190 | + | |
191 | + public bool ConfirmOverwriteLastWriteTime(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
192 | + { | |
193 | + string msg = CreateConfirmMessageOverwriteLastWriteTime(sourceFilesList); | |
194 | + | |
195 | + IDialogResult result = this.dialog.ShowYesNoDialog("更新日時を作成日時で上書き - 確認", msg, MessageBoxImage.Question); | |
196 | + | |
197 | + return result.Result == ButtonResult.Yes; | |
198 | + } | |
199 | + | |
200 | + private static string CreateConfirmMessageOverwriteLastWriteTime(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
201 | + { | |
202 | + string msg = "【仮】更新日時を作成日時で上書きしてもよろしいですか"; | |
203 | + foreach (FileSystemSourceFiles sourceFiles in sourceFilesList) | |
204 | + { | |
205 | + msg += "\n\n対象:" + sourceFiles.AbsolutePath; | |
206 | + foreach (string name in sourceFiles.Names) | |
207 | + { | |
208 | + msg += "\n・" + name; | |
209 | + } | |
210 | + } | |
211 | + | |
212 | + return msg; | |
213 | + } | |
214 | + | |
215 | + public bool ConfirmExchangeTimestamp(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
216 | + { | |
217 | + string msg = CreateConfirmMessageExchangeTimestamp(sourceFilesList); | |
218 | + | |
219 | + IDialogResult result = this.dialog.ShowYesNoDialog("作成日時と更新日時を入れ替え - 確認", msg, MessageBoxImage.Question); | |
220 | + | |
221 | + return result.Result == ButtonResult.Yes; | |
222 | + } | |
223 | + | |
224 | + private static string CreateConfirmMessageExchangeTimestamp(IEnumerable<FileSystemSourceFiles> sourceFilesList) | |
225 | + { | |
226 | + string msg = "【仮】作成日時と更新日時を入れ替えてもよろしいですか"; | |
227 | + | |
228 | + foreach (FileSystemSourceFiles sourceFiles in sourceFilesList) | |
229 | + { | |
230 | + msg += "\n\n対象:" + sourceFiles.AbsolutePath; | |
231 | + foreach (string name in sourceFiles.Names) | |
232 | + { | |
233 | + msg += "\n・" + name; | |
234 | + } | |
235 | + } | |
236 | + | |
237 | + return msg; | |
238 | + } | |
239 | + | |
240 | + public bool ConfirmAutoFixFolderTimestamp(IEnumerable<FileSystemSourceFile> SourceFileList) | |
241 | + { | |
242 | + string msg = CreateConfirmMessageAutoFixFolderTimestamp(SourceFileList); | |
243 | + | |
244 | + IDialogResult result = this.dialog.ShowYesNoDialog("フォルダのタイムスタンプを自動修正 - 確認", msg, MessageBoxImage.Question); | |
245 | + | |
246 | + return result.Result == ButtonResult.Yes; | |
247 | + } | |
248 | + | |
249 | + private static string CreateConfirmMessageAutoFixFolderTimestamp(IEnumerable<FileSystemSourceFile> SourceFileList) | |
250 | + { | |
251 | + string msg = "【仮】フォルダのタイムスタンプを自動修正してもよろしいですか"; | |
252 | + | |
253 | + foreach (FileSystemSourceFile sourceFile in SourceFileList) | |
254 | + { | |
255 | + msg += "\n\n対象:" + sourceFile.SourceAbsolutePath; | |
256 | + } | |
257 | + | |
258 | + return msg; | |
259 | + } | |
260 | + | |
261 | + } | |
262 | +} |
@@ -0,0 +1,20 @@ | ||
1 | +using FolderCategorizer2.Domain.Service.Dto; | |
2 | +using System.Collections.Generic; | |
3 | + | |
4 | +namespace FolderCategorizer2.UseCase.Internal | |
5 | +{ | |
6 | + internal interface IFileSystemDialogLogic | |
7 | + { | |
8 | + string AskNewFileName(string targetName); | |
9 | + string AskNewFolderName(string targetName); | |
10 | + string AskRenameFileName(string targetName); | |
11 | + bool ConfirmCopyFiles(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries); | |
12 | + bool ConfirmMoveFile(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries); | |
13 | + bool ConfirmDeleteFile(IEnumerable<FileSystemSourceFiles> sourceFilesList); | |
14 | + bool ConfirmRenameFile(IEnumerable<FileSystemSourceFile> sourceFileList, string targetName); | |
15 | + bool ConfirmOverwriteCreationTime(IEnumerable<FileSystemSourceFiles> sourceFilesList); | |
16 | + bool ConfirmOverwriteLastWriteTime(IEnumerable<FileSystemSourceFiles> sourceFilesList); | |
17 | + bool ConfirmExchangeTimestamp(IEnumerable<FileSystemSourceFiles> sourceFilesList); | |
18 | + bool ConfirmAutoFixFolderTimestamp(IEnumerable<FileSystemSourceFile> SourceFileList); | |
19 | + } | |
20 | +} | |
\ No newline at end of file |
@@ -62,10 +62,11 @@ namespace FolderCategorizer2.UseCase | ||
62 | 62 | containerRegistry.Register<IOSShellShowPropertyInteractor, OSShellShowPropertyInteractor>(); |
63 | 63 | |
64 | 64 | // |
65 | - // IFileSystemOperationLogic | |
65 | + // Internal Logic | |
66 | 66 | // |
67 | 67 | |
68 | 68 | containerRegistry.Register<IFileSystemOperationLogic, FileSystemOperationLogic>(); |
69 | + containerRegistry.Register<IFileSystemDialogLogic, FileSystemDialogLogic>(); | |
69 | 70 | |
70 | 71 | logger.Trace("RegisterTypes end"); |
71 | 72 | } |