• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

ファイル整理用ツールのPrism+WPFサンプル実装


Commit MetaInfo

Revisão3efb8167194b572d6c1931e2dedd2a4e2a2bddf2 (tree)
Hora2023-09-24 14:20:43
Autoryoshy <yoshy.org.bitbucket@gz.j...>
Commiteryoshy

Mensagem de Log

[MOD] ファイルシステム操作系インタラクタ・ロジック処理上で行っていたフォルダツリーの更新処理をプレゼンタに移譲

Mudança Sumário

Diff

--- /dev/null
+++ b/FolderCategorizer2.02UseCase/Boundary/FileSystemOperation/Presenter/IFileSystemCopyOperationPresenter.cs
@@ -0,0 +1,11 @@
1+using CleanAuLait.UseCase.Boundary.Presenter;
2+using FolderCategorizer2.UseCase.FileSystemOperation.Request;
3+using FolderCategorizer2.UseCase.FileSystemOperation.Response;
4+
5+namespace FolderCategorizer2.UseCase.Boundary.FileListOperation.Presenter
6+{
7+ public interface IFileSystemCopyOperationPresenter
8+ : IPresenter<FileSystemCopyOperationRequest, FileSystemCopyOperationResponse>
9+ {
10+ }
11+}
\ No newline at end of file
--- /dev/null
+++ b/FolderCategorizer2.02UseCase/Boundary/FileSystemOperation/Presenter/IFileSystemMoveOperationPresenter.cs
@@ -0,0 +1,11 @@
1+using CleanAuLait.UseCase.Boundary.Presenter;
2+using FolderCategorizer2.UseCase.FileSystemOperation.Request;
3+using FolderCategorizer2.UseCase.FileSystemOperation.Response;
4+
5+namespace FolderCategorizer2.UseCase.Boundary.FileListOperation.Presenter
6+{
7+ public interface IFileSystemMoveOperationPresenter
8+ : IPresenter<FileSystemMoveOperationRequest, FileSystemMoveOperationResponse>
9+ {
10+ }
11+}
\ No newline at end of file
--- a/FolderCategorizer2.02UseCase/FileSystemOperation/Interactor/FileSystemCopyOperationInteractor.cs
+++ b/FolderCategorizer2.02UseCase/FileSystemOperation/Interactor/FileSystemCopyOperationInteractor.cs
@@ -1,13 +1,12 @@
11 using CleanAuLait.UseCase.Interactor;
22 using CleanAuLait.UseCase.Response;
3-using FolderCategorizer2.Domain.Boundary.Service;
43 using FolderCategorizer2.Domain.Service.Dto;
4+using FolderCategorizer2.UseCase.Boundary.FileListOperation.Presenter;
55 using FolderCategorizer2.UseCase.Boundary.FileSystemOperation.Interactor;
66 using FolderCategorizer2.UseCase.FileSystemOperation.Request;
77 using FolderCategorizer2.UseCase.FileSystemOperation.Response;
88 using FolderCategorizer2.UseCase.Internal;
99 using System.Collections.Generic;
10-using System.Linq;
1110
1211 namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor
1312 {
@@ -20,18 +19,18 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor
2019 private readonly IFileSystemOperationLogic operation;
2120 private readonly IFileSystemVerifyLogic verifier;
2221 private readonly IFileSystemDialogLogic dialog;
23- private readonly IFolderTreeService folderTree;
22+ private readonly IFileSystemCopyOperationPresenter presenter;
2423
2524 public FileSystemCopyOperationInteractor(
2625 IFileSystemOperationLogic operation,
2726 IFileSystemVerifyLogic verifier,
2827 IFileSystemDialogLogic dialog,
29- IFolderTreeService folderTree)
28+ IFileSystemCopyOperationPresenter presenter)
3029 {
3130 this.operation = operation;
3231 this.verifier = verifier;
3332 this.dialog = dialog;
34- this.folderTree = folderTree;
33+ this.presenter = presenter;
3534 }
3635
3736 public override FileSystemCopyOperationResponse Interact(FileSystemCopyOperationRequest req)
@@ -65,18 +64,10 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor
6564 return UseCaseResponse.Abort<FileSystemCopyOperationResponse>("エラーのため処理が中止されました");
6665 }
6766
68- SelectNode(sourceTargetEntries);
67+ FileSystemCopyOperationResponse res = new(sourceTargetEntries);
6968
70- return new();
69+ return this.presenter.Present(req, res);
7170 }
7271
73- private void SelectNode(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries)
74- {
75- FileSystemSourceFilesTargetFolder sourceTargetEntry = sourceTargetEntries.First();
76-
77- string treeId = sourceTargetEntry.TreeID;
78-
79- this.folderTree.SelectNode(treeId, sourceTargetEntry.TargetFolder.RelativePath);
80- }
8172 }
8273 }
--- a/FolderCategorizer2.02UseCase/FileSystemOperation/Interactor/FileSystemMoveOperationInteractor.cs
+++ b/FolderCategorizer2.02UseCase/FileSystemOperation/Interactor/FileSystemMoveOperationInteractor.cs
@@ -1,13 +1,12 @@
11 using CleanAuLait.UseCase.Interactor;
22 using CleanAuLait.UseCase.Response;
3-using FolderCategorizer2.Domain.Boundary.Service;
43 using FolderCategorizer2.Domain.Service.Dto;
4+using FolderCategorizer2.UseCase.Boundary.FileListOperation.Presenter;
55 using FolderCategorizer2.UseCase.Boundary.FileSystemOperation.Interactor;
66 using FolderCategorizer2.UseCase.FileSystemOperation.Request;
77 using FolderCategorizer2.UseCase.FileSystemOperation.Response;
88 using FolderCategorizer2.UseCase.Internal;
99 using System.Collections.Generic;
10-using System.Linq;
1110
1211 namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor
1312 {
@@ -20,18 +19,18 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor
2019 private readonly IFileSystemOperationLogic operation;
2120 private readonly IFileSystemVerifyLogic verifier;
2221 private readonly IFileSystemDialogLogic dialog;
23- private readonly IFolderTreeService folderTree;
22+ private readonly IFileSystemMoveOperationPresenter presenter;
2423
2524 public FileSystemMoveOperationInteractor(
2625 IFileSystemOperationLogic operation,
2726 IFileSystemVerifyLogic verifier,
2827 IFileSystemDialogLogic dialog,
29- IFolderTreeService folderTree)
28+ IFileSystemMoveOperationPresenter presenter)
3029 {
3130 this.operation = operation;
3231 this.verifier = verifier;
3332 this.dialog = dialog;
34- this.folderTree = folderTree;
33+ this.presenter = presenter;
3534 }
3635
3736 public override FileSystemMoveOperationResponse Interact(FileSystemMoveOperationRequest req)
@@ -65,21 +64,9 @@ namespace FolderCategorizer2.UseCase.FileSystemOperation.Interactor
6564 return UseCaseResponse.Abort<FileSystemMoveOperationResponse>("エラーのため処理が中止されました");
6665 }
6766
68- SelectNode(sourceTargetEntries);
67+ FileSystemMoveOperationResponse res = new(sourceTargetEntries);
6968
70- return new();
69+ return this.presenter.Present(req, res);
7170 }
72-
73- private void SelectNode(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries)
74- {
75- // FIX ME
76-
77- FileSystemSourceFilesTargetFolder sourceTargetEntry = sourceTargetEntries.First();
78-
79- string treeId = sourceTargetEntry.TreeID;
80-
81- this.folderTree.SelectNode(treeId, sourceTargetEntry.TargetFolder.RelativePath);
82- }
83-
8471 }
8572 }
--- a/FolderCategorizer2.02UseCase/FileSystemOperation/Response/FileSystemCopyOperationResponse.cs
+++ b/FolderCategorizer2.02UseCase/FileSystemOperation/Response/FileSystemCopyOperationResponse.cs
@@ -1,8 +1,16 @@
11 using CleanAuLait.UseCase.Response;
2+using FolderCategorizer2.Domain.Service.Dto;
3+using System.Collections.Generic;
4+using System.Linq;
25
36 namespace FolderCategorizer2.UseCase.FileSystemOperation.Response
47 {
5- public record class FileSystemCopyOperationResponse : UseCaseResponse
8+ public record class FileSystemCopyOperationResponse(
9+ IEnumerable<FileSystemSourceFilesTargetFolder> SourceTargetEntries) : UseCaseResponse
610 {
11+ public FileSystemCopyOperationResponse() : this(
12+ Enumerable.Empty<FileSystemSourceFilesTargetFolder>())
13+ {
14+ }
715 }
816 }
--- a/FolderCategorizer2.02UseCase/FileSystemOperation/Response/FileSystemMoveOperationResponse.cs
+++ b/FolderCategorizer2.02UseCase/FileSystemOperation/Response/FileSystemMoveOperationResponse.cs
@@ -1,8 +1,16 @@
11 using CleanAuLait.UseCase.Response;
2+using FolderCategorizer2.Domain.Service.Dto;
3+using System.Collections.Generic;
4+using System.Linq;
25
36 namespace FolderCategorizer2.UseCase.FileSystemOperation.Response
47 {
5- public record class FileSystemMoveOperationResponse : UseCaseResponse
8+ public record class FileSystemMoveOperationResponse(
9+ IEnumerable<FileSystemSourceFilesTargetFolder> SourceTargetEntries) : UseCaseResponse
610 {
11+ public FileSystemMoveOperationResponse() : this(
12+ Enumerable.Empty<FileSystemSourceFilesTargetFolder>())
13+ {
14+ }
715 }
816 }
--- a/FolderCategorizer2.02UseCase/Internal/FileSystemOperationLogic.cs
+++ b/FolderCategorizer2.02UseCase/Internal/FileSystemOperationLogic.cs
@@ -16,16 +16,13 @@ namespace FolderCategorizer2.UseCase.Internal
1616 private static readonly ILogger logger = LogManager.GetCurrentClassLogger();
1717
1818 private readonly IFileSystemService fileSystem;
19- private readonly IFolderTreeService folderTree;
2019 private readonly IUniversalDialogProxy dialog;
2120
2221 public FileSystemOperationLogic(
2322 IFileSystemService fileSystem,
24- IFolderTreeService folderTree,
2523 IUniversalDialogProxy dialog)
2624 {
2725 this.fileSystem = fileSystem;
28- this.folderTree = folderTree;
2926 this.dialog = dialog;
3027 }
3128
@@ -41,6 +38,9 @@ namespace FolderCategorizer2.UseCase.Internal
4138 string sourceFullPath = PathHelper.CreateCanonicalPath(sourceFolderPath, name);
4239 string targetFullPath = PathHelper.CreateCanonicalPath(targetFolderPath, name);
4340
41+ logger.Trace("copy: from {0}", sourceFullPath);
42+ logger.Trace("copy: to {0}", targetFullPath);
43+
4444 Retry:
4545 try
4646 {
@@ -65,12 +65,9 @@ namespace FolderCategorizer2.UseCase.Internal
6565 return false;
6666 }
6767 }
68- }
6968
70- string treeId = sourceTargetEntry.TreeID;
71-
72- this.folderTree.RefreshFolderTree(treeId, sourceTargetEntry.SourceFiles.RelativePath);
73- this.folderTree.RefreshFolderTree(treeId, sourceTargetEntry.TargetFolder.RelativePath);
69+ logger.Trace("copied.");
70+ }
7471 }
7572
7673 return true;
@@ -88,6 +85,9 @@ namespace FolderCategorizer2.UseCase.Internal
8885 string sourceFullPath = PathHelper.CreateCanonicalPath(sourceFolderPath, name);
8986 string targetFullPath = PathHelper.CreateCanonicalPath(targetFolderPath, name);
9087
88+ logger.Trace("move: from {0}", sourceFullPath);
89+ logger.Trace("move: to {0}", targetFullPath);
90+
9191 Retry:
9292 try
9393 {
@@ -112,12 +112,9 @@ namespace FolderCategorizer2.UseCase.Internal
112112 return false;
113113 }
114114 }
115- }
116115
117- string treeId = sourceTargetEntry.TreeID;
118-
119- this.folderTree.RefreshFolderTree(treeId, sourceTargetEntry.SourceFiles.RelativePath);
120- this.folderTree.RefreshFolderTree(treeId, sourceTargetEntry.TargetFolder.RelativePath);
116+ logger.Trace("moved.");
117+ }
121118 }
122119
123120 return true;
@@ -141,7 +138,7 @@ namespace FolderCategorizer2.UseCase.Internal
141138 catch (Exception e) when (e is IOException || e is InvalidOperationException)
142139 {
143140 string msg = string.Format(
144- "ファイルのコピー中に次のエラーが発生しました。\n{0}\n\n削除対象:{1}",
141+ "ファイルの削除中に次のエラーが発生しました。\n{0}\n\n削除対象:{1}",
145142 e.Message, sourceFullPath);
146143
147144 IDialogResult result = this.dialog.ShowAbortRetryIgnoreDialog("ファイルの削除 - エラー", msg, MessageBoxImage.Hand);
@@ -158,10 +155,6 @@ namespace FolderCategorizer2.UseCase.Internal
158155 }
159156 }
160157 }
161-
162- string treeId = sourceFiles.TreeID;
163-
164- this.folderTree.RefreshFolderTree(treeId, sourceFiles.RelativePath);
165158 }
166159
167160 return true;
@@ -197,10 +190,6 @@ namespace FolderCategorizer2.UseCase.Internal
197190 return false;
198191 }
199192 }
200-
201- string treeId = targetEntry.TreeID;
202-
203- this.folderTree.RefreshFolderTree(treeId, targetEntry.RelativePath);
204193 }
205194
206195 return true;
@@ -236,10 +225,6 @@ namespace FolderCategorizer2.UseCase.Internal
236225 return false;
237226 }
238227 }
239-
240- string treeId = targetEntry.TreeID;
241-
242- this.folderTree.RefreshFolderTree(treeId, targetEntry.RelativePath);
243228 }
244229
245230 return true;
@@ -276,10 +261,6 @@ namespace FolderCategorizer2.UseCase.Internal
276261 return false;
277262 }
278263 }
279-
280- string treeId = sourceFile.TreeID;
281-
282- this.folderTree.RefreshFolderTree(treeId, sourceFile.RelativePath);
283264 }
284265
285266 return true;
--- a/FolderCategorizer2.03Adaptor/AdaptorModule.cs
+++ b/FolderCategorizer2.03Adaptor/AdaptorModule.cs
@@ -102,6 +102,8 @@ namespace FolderCategorizer2.Adaptor
102102 containerRegistry.RegisterSingleton<IFolderTreeReplaceTreePresenter, FolderTreeReplaceTreePresenter>();
103103 containerRegistry.RegisterSingleton<IFileListReplaceListPresenter, FileListReplaceListPresenter>();
104104
105+ containerRegistry.RegisterSingleton<IFileSystemCopyOperationPresenter, FileSystemCopyOperationPresenter>();
106+ containerRegistry.RegisterSingleton<IFileSystemMoveOperationPresenter, FileSystemMoveOperationPresenter>();
105107 containerRegistry.RegisterSingleton<IFileSystemDeleteOperationPresenter, FileSystemDeleteOperationPresenter>();
106108 containerRegistry.RegisterSingleton<IFileSystemRenameOperationPresenter, FileSystemRenameOperationPresenter>();
107109 containerRegistry.RegisterSingleton<IFileSystemNewFolderOperationPresenter, FileSystemNewFolderOperationPresenter>();
--- /dev/null
+++ b/FolderCategorizer2.03Adaptor/Presenter/FileSystemCopyOperationPresenter.cs
@@ -0,0 +1,51 @@
1+using FolderCategorizer2.Domain.Boundary.Service;
2+using FolderCategorizer2.Domain.Service.Dto;
3+using FolderCategorizer2.UseCase.Boundary.FileListOperation.Presenter;
4+using FolderCategorizer2.UseCase.FileSystemOperation.Request;
5+using FolderCategorizer2.UseCase.FileSystemOperation.Response;
6+using System.Collections.Generic;
7+using System.Linq;
8+
9+namespace FolderCategorizer2.Adaptor.Presenter
10+{
11+ public class FileSystemCopyOperationPresenter : IFileSystemCopyOperationPresenter
12+ {
13+ private readonly IFolderTreeService folderTree;
14+
15+ public FileSystemCopyOperationPresenter(IFolderTreeService folderTree)
16+ {
17+ this.folderTree = folderTree;
18+ }
19+
20+ public FileSystemCopyOperationResponse Present(
21+ FileSystemCopyOperationRequest req, FileSystemCopyOperationResponse res)
22+ {
23+ IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries = res.SourceTargetEntries;
24+
25+ RefreshNodes(sourceTargetEntries);
26+ SelectNode(sourceTargetEntries);
27+
28+ return res;
29+ }
30+
31+ private void RefreshNodes(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries)
32+ {
33+ foreach (FileSystemSourceFilesTargetFolder sourceTargetEntry in sourceTargetEntries)
34+ {
35+ string treeId = sourceTargetEntry.TreeID;
36+
37+ this.folderTree.RefreshFolderTree(treeId, sourceTargetEntry.SourceFiles.RelativePath);
38+ this.folderTree.RefreshFolderTree(treeId, sourceTargetEntry.TargetFolder.RelativePath);
39+ }
40+ }
41+
42+ private void SelectNode(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries)
43+ {
44+ FileSystemSourceFilesTargetFolder sourceTargetEntry = sourceTargetEntries.First();
45+
46+ string treeId = sourceTargetEntry.TreeID;
47+
48+ this.folderTree.SelectNode(treeId, sourceTargetEntry.TargetFolder.RelativePath);
49+ }
50+ }
51+}
--- a/FolderCategorizer2.03Adaptor/Presenter/FileSystemDeleteOperationPresenter.cs
+++ b/FolderCategorizer2.03Adaptor/Presenter/FileSystemDeleteOperationPresenter.cs
@@ -1,25 +1,44 @@
11 using FolderCategorizer2.Adaptor.Boundary.ViewModel;
2+using FolderCategorizer2.Domain.Boundary.Service;
3+using FolderCategorizer2.Domain.Service.Dto;
24 using FolderCategorizer2.UseCase.Boundary.FileListOperation.Presenter;
35 using FolderCategorizer2.UseCase.FileSystemOperation.Request;
46 using FolderCategorizer2.UseCase.FileSystemOperation.Response;
7+using System.Collections.Generic;
58
69 namespace FolderCategorizer2.Adaptor.Presenter
710 {
811 public class FileSystemDeleteOperationPresenter : IFileSystemDeleteOperationPresenter
912 {
13+ private readonly IFolderTreeService folderTree;
1014 private readonly IFileListViewModel targetVm;
1115
12- public FileSystemDeleteOperationPresenter(IFileListViewModel targetVm)
16+ public FileSystemDeleteOperationPresenter(
17+ IFolderTreeService folderTree,
18+ IFileListViewModel targetVm)
1319 {
20+ this.folderTree = folderTree;
1421 this.targetVm = targetVm;
1522 }
1623
1724 public FileSystemDeleteOperationResponse Present(
1825 FileSystemDeleteOperationRequest req, FileSystemDeleteOperationResponse res)
1926 {
27+ RefreshNodes(req.SourceFilesList);
28+
2029 this.targetVm.ReplaceSource(res.Diff);
2130
2231 return res;
2332 }
33+
34+ private void RefreshNodes(IEnumerable<FileSystemSourceFiles> sourceFileList)
35+ {
36+ foreach (FileSystemSourceFiles sourceFiles in sourceFileList)
37+ {
38+ string treeId = sourceFiles.TreeID;
39+
40+ this.folderTree.RefreshFolderTree(treeId, sourceFiles.RelativePath);
41+ }
42+ }
2443 }
2544 }
--- /dev/null
+++ b/FolderCategorizer2.03Adaptor/Presenter/FileSystemMoveOperationPresenter.cs
@@ -0,0 +1,53 @@
1+using FolderCategorizer2.Domain.Boundary.Service;
2+using FolderCategorizer2.Domain.Service.Dto;
3+using FolderCategorizer2.UseCase.Boundary.FileListOperation.Presenter;
4+using FolderCategorizer2.UseCase.FileSystemOperation.Request;
5+using FolderCategorizer2.UseCase.FileSystemOperation.Response;
6+using System.Collections.Generic;
7+using System.Linq;
8+
9+namespace FolderCategorizer2.Adaptor.Presenter
10+{
11+ public class FileSystemMoveOperationPresenter : IFileSystemMoveOperationPresenter
12+ {
13+ private readonly IFolderTreeService folderTree;
14+
15+ public FileSystemMoveOperationPresenter(IFolderTreeService folderTree)
16+ {
17+ this.folderTree = folderTree;
18+ }
19+
20+ public FileSystemMoveOperationResponse Present(
21+ FileSystemMoveOperationRequest req, FileSystemMoveOperationResponse res)
22+ {
23+ IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries = res.SourceTargetEntries;
24+
25+ RefreshNodes(sourceTargetEntries);
26+
27+ // FIX ME: freeze screen
28+ //SelectNode(sourceTargetEntries);
29+
30+ return res;
31+ }
32+
33+ private void RefreshNodes(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries)
34+ {
35+ foreach (FileSystemSourceFilesTargetFolder sourceTargetEntry in sourceTargetEntries)
36+ {
37+ string treeId = sourceTargetEntry.TreeID;
38+
39+ this.folderTree.RefreshFolderTree(treeId, sourceTargetEntry.SourceFiles.RelativePath);
40+ this.folderTree.RefreshFolderTree(treeId, sourceTargetEntry.TargetFolder.RelativePath);
41+ }
42+ }
43+
44+ private void SelectNode(IEnumerable<FileSystemSourceFilesTargetFolder> sourceTargetEntries)
45+ {
46+ FileSystemSourceFilesTargetFolder sourceTargetEntry = sourceTargetEntries.First();
47+
48+ string treeId = sourceTargetEntry.TreeID;
49+
50+ this.folderTree.SelectNode(treeId, sourceTargetEntry.TargetFolder.RelativePath);
51+ }
52+ }
53+}
--- a/FolderCategorizer2.03Adaptor/Presenter/FileSystemNewFileOperationPresenter.cs
+++ b/FolderCategorizer2.03Adaptor/Presenter/FileSystemNewFileOperationPresenter.cs
@@ -1,25 +1,44 @@
11 using FolderCategorizer2.Adaptor.Boundary.ViewModel;
2+using FolderCategorizer2.Domain.Boundary.Service;
3+using FolderCategorizer2.Domain.Service.Dto;
24 using FolderCategorizer2.UseCase.Boundary.FileListOperation.Presenter;
35 using FolderCategorizer2.UseCase.FileSystemOperation.Request;
46 using FolderCategorizer2.UseCase.FileSystemOperation.Response;
7+using System.Collections.Generic;
58
69 namespace FolderCategorizer2.Adaptor.Presenter
710 {
811 public class FileSystemNewFileOperationPresenter : IFileSystemNewFileOperationPresenter
912 {
13+ private readonly IFolderTreeService folderTree;
1014 private readonly IFileListViewModel targetVm;
1115
12- public FileSystemNewFileOperationPresenter(IFileListViewModel targetVm)
16+ public FileSystemNewFileOperationPresenter(
17+ IFolderTreeService folderTree,
18+ IFileListViewModel targetVm)
1319 {
20+ this.folderTree = folderTree;
1421 this.targetVm = targetVm;
1522 }
1623
1724 public FileSystemNewFileOperationResponse Present(
1825 FileSystemNewFileOperationRequest req, FileSystemNewFileOperationResponse res)
1926 {
27+ RefreshNodes(req.Targets);
28+
2029 this.targetVm.ReplaceSource(res.Diff);
2130
2231 return res;
2332 }
33+
34+ private void RefreshNodes(IEnumerable<FileSystemPathEntry> targetEntries)
35+ {
36+ foreach (FileSystemPathEntry targetEntry in targetEntries)
37+ {
38+ string treeId = targetEntry.TreeID;
39+
40+ this.folderTree.RefreshFolderTree(treeId, targetEntry.RelativePath);
41+ }
42+ }
2443 }
2544 }
--- a/FolderCategorizer2.03Adaptor/Presenter/FileSystemNewFolderOperationPresenter.cs
+++ b/FolderCategorizer2.03Adaptor/Presenter/FileSystemNewFolderOperationPresenter.cs
@@ -1,25 +1,44 @@
11 using FolderCategorizer2.Adaptor.Boundary.ViewModel;
2+using FolderCategorizer2.Domain.Boundary.Service;
3+using FolderCategorizer2.Domain.Service.Dto;
24 using FolderCategorizer2.UseCase.Boundary.FileListOperation.Presenter;
35 using FolderCategorizer2.UseCase.FileSystemOperation.Request;
46 using FolderCategorizer2.UseCase.FileSystemOperation.Response;
7+using System.Collections.Generic;
58
69 namespace FolderCategorizer2.Adaptor.Presenter
710 {
811 public class FileSystemNewFolderOperationPresenter : IFileSystemNewFolderOperationPresenter
912 {
13+ private readonly IFolderTreeService folderTree;
1014 private readonly IFileListViewModel targetVm;
1115
12- public FileSystemNewFolderOperationPresenter(IFileListViewModel targetVm)
16+ public FileSystemNewFolderOperationPresenter(
17+ IFolderTreeService folderTree,
18+ IFileListViewModel targetVm)
1319 {
20+ this.folderTree = folderTree;
1421 this.targetVm = targetVm;
1522 }
1623
1724 public FileSystemNewFolderOperationResponse Present(
1825 FileSystemNewFolderOperationRequest req, FileSystemNewFolderOperationResponse res)
1926 {
27+ RefreshNodes(req.Targets);
28+
2029 this.targetVm.ReplaceSource(res.Diff);
2130
2231 return res;
2332 }
33+
34+ private void RefreshNodes(IEnumerable<FileSystemPathEntry> targetEntries)
35+ {
36+ foreach (FileSystemPathEntry targetEntry in targetEntries)
37+ {
38+ string treeId = targetEntry.TreeID;
39+
40+ this.folderTree.RefreshFolderTree(treeId, targetEntry.RelativePath);
41+ }
42+ }
2443 }
2544 }
--- a/FolderCategorizer2.03Adaptor/Presenter/FileSystemRenameOperationPresenter.cs
+++ b/FolderCategorizer2.03Adaptor/Presenter/FileSystemRenameOperationPresenter.cs
@@ -1,25 +1,44 @@
11 using FolderCategorizer2.Adaptor.Boundary.ViewModel;
2+using FolderCategorizer2.Domain.Boundary.Service;
3+using FolderCategorizer2.Domain.Service.Dto;
24 using FolderCategorizer2.UseCase.Boundary.FileListOperation.Presenter;
35 using FolderCategorizer2.UseCase.FileSystemOperation.Request;
46 using FolderCategorizer2.UseCase.FileSystemOperation.Response;
7+using System.Collections.Generic;
58
69 namespace FolderCategorizer2.Adaptor.Presenter
710 {
811 public class FileSystemRenameOperationPresenter : IFileSystemRenameOperationPresenter
912 {
13+ private readonly IFolderTreeService folderTree;
1014 private readonly IFileListViewModel targetVm;
1115
12- public FileSystemRenameOperationPresenter(IFileListViewModel targetVm)
16+ public FileSystemRenameOperationPresenter(
17+ IFolderTreeService folderTree,
18+ IFileListViewModel targetVm)
1319 {
20+ this.folderTree = folderTree;
1421 this.targetVm = targetVm;
1522 }
1623
1724 public FileSystemRenameOperationResponse Present(
1825 FileSystemRenameOperationRequest req, FileSystemRenameOperationResponse res)
1926 {
27+ RefreshNodes(req.SourceFileList);
28+
2029 this.targetVm.ReplaceSource(res.Diff);
2130
2231 return res;
2332 }
33+
34+ private void RefreshNodes(IEnumerable<FileSystemSourceFile> sourceFileList)
35+ {
36+ foreach (FileSystemSourceFile sourceFile in sourceFileList)
37+ {
38+ string treeId = sourceFile.TreeID;
39+
40+ this.folderTree.RefreshFolderTree(treeId, sourceFile.RelativePath);
41+ }
42+ }
2443 }
2544 }
--- a/FolderCategorizer2.04OuterEdge/Repository/OS/LocalFileSystemRepository.cs
+++ b/FolderCategorizer2.04OuterEdge/Repository/OS/LocalFileSystemRepository.cs
@@ -1,4 +1,5 @@
1-using FolderCategorizer2.Domain.Boundary.Repository;
1+using CleanAuLait.Core.IO;
2+using FolderCategorizer2.Domain.Boundary.Repository;
23 using FolderCategorizer2.Domain.Model.Const;
34 using FolderCategorizer2.Domain.Service.Dto;
45 using FolderCategorizer2.OuterEdge.Translator;
@@ -108,69 +109,160 @@ namespace FolderCategorizer2.OuterEdge.Repository.OS
108109
109110 public void MoveFile(string targetPath, string sourceFullPath)
110111 {
112+#if false
111113 if (Directory.Exists(sourceFullPath))
112114 {
113115 logger.Debug("FileSystem.MoveDirectory({0}, {1})", sourceFullPath, targetPath);
114- VBFileSystem.MoveDirectory(sourceFullPath, targetPath);
116+ VBFileSystem.MoveDirectory(sourceFullPath, targetPath, UIOption.AllDialogs);
115117 }
116118 else if (File.Exists(sourceFullPath))
117119 {
118120 logger.Debug("FileSystem.MoveFile({0}, {1})", sourceFullPath, targetPath);
119- VBFileSystem.MoveFile(sourceFullPath, targetPath);
121+ VBFileSystem.MoveFile(sourceFullPath, targetPath, UIOption.AllDialogs);
120122 }
121123 else
122124 {
123125 throw new FileNotFoundException($"{sourceFullPath}が存在しないか無効です");
124126 }
127+#else
128+ if (Directory.Exists(sourceFullPath))
129+ {
130+ logger.Debug("Directory.Move({0}, {1})", sourceFullPath, targetPath);
131+ Directory.Move(sourceFullPath, targetPath);
132+ }
133+ else if (File.Exists(sourceFullPath))
134+ {
135+ logger.Debug("File.Move({0}, {1})", sourceFullPath, targetPath);
136+ File.Move(sourceFullPath, targetPath);
137+ }
138+ else
139+ {
140+ throw new FileNotFoundException($"{sourceFullPath}が存在しないか無効です");
141+ }
142+#endif
125143 }
126144
127145 public void CopyFile(string targetPath, string sourceFullPath)
128146 {
147+#if false
129148 if (Directory.Exists(sourceFullPath))
130149 {
131150 logger.Debug("FileSystem.CopyDirectory({0}, {1})", sourceFullPath, targetPath);
132- VBFileSystem.CopyDirectory(sourceFullPath, targetPath);
151+ VBFileSystem.CopyDirectory(sourceFullPath, targetPath, UIOption.AllDialogs);
133152 }
134153 else if (File.Exists(sourceFullPath))
135154 {
136155 logger.Debug("FileSystem.CopyFile({0}, {1})", sourceFullPath, targetPath);
137- VBFileSystem.CopyFile(sourceFullPath, targetPath);
156+ VBFileSystem.CopyFile(sourceFullPath, targetPath, UIOption.AllDialogs);
138157 }
139158 else
140159 {
141160 throw new FileNotFoundException($"{sourceFullPath}が存在しないか無効です");
142161 }
162+#else
163+ if (Directory.Exists(sourceFullPath))
164+ {
165+ //logger.Debug("Directory.Copy({0}, {1})", sourceFullPath, targetPath);
166+ CopyDirectory(targetPath, sourceFullPath);
167+ }
168+ else if (File.Exists(sourceFullPath))
169+ {
170+ logger.Debug("File.Copy({0}, {1})", sourceFullPath, targetPath);
171+ File.Copy(sourceFullPath, targetPath);
172+ }
173+ else
174+ {
175+ throw new FileNotFoundException($"{sourceFullPath}が存在しないか無効です");
176+ }
177+#endif
178+ }
179+
180+ /// <see cref="https://learn.microsoft.com/ja-jp/dotnet/standard/io/how-to-copy-directories"/>
181+ private void CopyDirectory(string targetPath, string sourceFullPath)
182+ {
183+ // Get information about the source directory
184+ DirectoryInfo dir = new(sourceFullPath);
185+
186+ // Check if the source directory exists
187+ if (!dir.Exists)
188+ throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}");
189+
190+ // Cache directories before we start copying
191+ DirectoryInfo[] dirs = dir.GetDirectories();
192+
193+ // Create the destination directory
194+ logger.Debug("Directory.CreateDirectory({0})", targetPath);
195+ Directory.CreateDirectory(targetPath);
196+
197+ // Get the files in the source directory and copy to the destination directory
198+ foreach (FileInfo file in dir.GetFiles())
199+ {
200+ string targetFilePath = Path.Combine(targetPath, file.Name);
201+ logger.Debug("FileInfo({0}).CopyTo({1})", file.FullName, targetFilePath);
202+ file.CopyTo(targetFilePath);
203+ }
204+
205+ // Recursively call this method
206+ foreach (DirectoryInfo subDir in dirs)
207+ {
208+ string newDestinationDir = Path.Combine(targetPath, subDir.Name);
209+ CopyDirectory(newDestinationDir, subDir.FullName);
210+ }
143211 }
144212
145213 public void DeleteFile(string sourceFullPath)
146214 {
215+#if false
147216 if (Directory.Exists(sourceFullPath))
148217 {
149218 logger.Debug("FileSystem.DeleteDirectory({0})", sourceFullPath);
150- VBFileSystem.DeleteDirectory(sourceFullPath, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
219+ VBFileSystem.DeleteDirectory(sourceFullPath, UIOption.AllDialogs, RecycleOption.SendToRecycleBin);
151220 }
152221 else if (File.Exists(sourceFullPath))
153222 {
154223 logger.Debug("FileSystem.DeleteFile({0})", sourceFullPath);
155- VBFileSystem.DeleteFile(sourceFullPath, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
224+ VBFileSystem.DeleteFile(sourceFullPath, UIOption.AllDialogs, RecycleOption.SendToRecycleBin);
225+ }
226+ else
227+ {
228+ throw new FileNotFoundException($"{sourceFullPath}が存在しないか無効です");
229+ }
230+#else
231+ if (Directory.Exists(sourceFullPath))
232+ {
233+ logger.Debug("Directory.Delete({0})", sourceFullPath);
234+ Directory.Delete(sourceFullPath, true);
235+ }
236+ else if (File.Exists(sourceFullPath))
237+ {
238+ logger.Debug("File.Delete({0})", sourceFullPath);
239+ File.Delete(sourceFullPath);
156240 }
157241 else
158242 {
159243 throw new FileNotFoundException($"{sourceFullPath}が存在しないか無効です");
160244 }
245+#endif
161246 }
162247
163248 public void RenameFile(string sourceFullPath, string targetName)
164249 {
250+
165251 if (Directory.Exists(sourceFullPath))
166252 {
167- logger.Debug("FileSystem.RenameDirectory({0}, {1})", sourceFullPath, targetName);
168- VBFileSystem.RenameDirectory(sourceFullPath, targetName);
253+ DirectoryInfo di = new(sourceFullPath);
254+ string targetFullPath = PathHelper.CreateCanonicalRelativePath(di.Parent.FullName, targetName);
255+
256+ logger.Debug("Directory.Move({0}, {1})", sourceFullPath, targetFullPath);
257+ Directory.Move(sourceFullPath, targetFullPath);
169258 }
170259 else if (File.Exists(sourceFullPath))
171260 {
172- logger.Debug("FileSystem.RenameFile({0}, {1})", sourceFullPath, targetName);
173- VBFileSystem.RenameFile(sourceFullPath, targetName);
261+ DirectoryInfo di = new(sourceFullPath);
262+ string targetFullPath = PathHelper.CreateCanonicalRelativePath(di.Parent.FullName, targetName);
263+
264+ logger.Debug("File.Move({0}, {1})", sourceFullPath, targetFullPath);
265+ File.Move(sourceFullPath, targetFullPath);
174266 }
175267 else
176268 {
--- a/FolderCategorizer2.05Infra/FolderCategorizer2.05Infra.csproj
+++ b/FolderCategorizer2.05Infra/FolderCategorizer2.05Infra.csproj
@@ -14,13 +14,12 @@
1414 <None Remove="Resources\message.properties" />
1515 </ItemGroup>
1616 <ItemGroup>
17- <PackageReference Include="AutoMapper" Version="12.0.0" />
18- <PackageReference Include="gong-wpf-dragdrop" Version="3.2.0" />
19- <PackageReference Include="NLog" Version="5.0.4" />
17+ <PackageReference Include="AutoMapper" Version="12.0.1" />
18+ <PackageReference Include="gong-wpf-dragdrop" Version="3.2.1" />
2019 <PackageReference Include="Prism.Unity" Version="8.1.97" />
2120 <PackageReference Include="Prism.Wpf" Version="8.1.97" />
22- <PackageReference Include="ReactiveProperty" Version="8.1.2" />
23- <PackageReference Include="ReactiveProperty.WPF" Version="8.1.2" />
21+ <PackageReference Include="ReactiveProperty" Version="9.3.1" />
22+ <PackageReference Include="ReactiveProperty.WPF" Version="9.3.1" />
2423 </ItemGroup>
2524 <ItemGroup>
2625 <ProjectReference Include="..\..\CleanAuLait.ObservableCollectionsMod\CleanAuLait.ObservableCollectionsMod.csproj" />