EveryDB2のデータベースを読み込んでWinFormでGUI表示するサンプル
Revisão | 8dff6653d920ee52bc887ab798815041ec08aadd (tree) |
---|---|
Hora | 2021-05-28 21:46:56 |
Autor | yoshy <yoshy@user...> |
Commiter | yoshy |
temp_20210528_2146
@@ -9,17 +9,20 @@ using UmaTest.Infra.Adaptor.Command; | ||
9 | 9 | using ICommand = UmaTest.Infra.Adaptor.Command.ICommand; |
10 | 10 | using UmaTest.Infra.Adaptor.Controller.Handler; |
11 | 11 | using UmaTest.Infra.Domain.UseCase; |
12 | +using System.Threading.Tasks; | |
12 | 13 | |
13 | 14 | namespace UmaTest.App.Adaptor.Controller |
14 | 15 | { |
15 | 16 | public class WindowController : IWindowController |
16 | 17 | { |
17 | 18 | private IUseCaseRouter router; |
19 | + private IAsyncUseCaseRouter asyncRouter; | |
18 | 20 | private IUserDialogProxy dialog; |
19 | 21 | |
20 | - public WindowController(IUseCaseRouter router, IUserDialogProxy dialog) | |
22 | + public WindowController(IUseCaseRouter router, IAsyncUseCaseRouter asyncRouter, IUserDialogProxy dialog) | |
21 | 23 | { |
22 | 24 | this.router = router; |
25 | + this.asyncRouter = asyncRouter; | |
23 | 26 | this.dialog = dialog; |
24 | 27 | |
25 | 28 | Events = new Dictionary<String, EventHandler>() |
@@ -59,6 +62,13 @@ namespace UmaTest.App.Adaptor.Controller | ||
59 | 62 | return HandleResponse(req, res); |
60 | 63 | } |
61 | 64 | |
65 | + public async Task<UseCaseResponse> ExecuteAsync(UseCaseRequest req) | |
66 | + { | |
67 | + UseCaseResponse res = await asyncRouter.HandleAsync(req); | |
68 | + | |
69 | + return HandleResponse(req, res); | |
70 | + } | |
71 | + | |
62 | 72 | private UseCaseResponse HandleResponse(UseCaseRequest req, UseCaseResponse res) |
63 | 73 | { |
64 | 74 | if (res == null) |
@@ -34,11 +34,12 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
34 | 34 | this.HorseList = "アドマイヤハダル\r\nエフフォーリア\r\nグラティアス\r\nグレートマジシャン\r\nサトノレイナス\r\nシャフリヤール\r\nステラヴェローチェ\r\nタイトルホルダー\r\nタイムトゥヘヴン\r\nダノンザキッド\r\nディープモンスター\r\nバジオウ\r\nバスラットレオン\r\nヨーホーレイク\r\nラーゴム\r\nレッドジェネシス\r\nワンダフルタウン\r\nヴィクティファルス\r\n"; |
35 | 35 | } |
36 | 36 | |
37 | - private void OnExecuteReadManualHorseList() | |
37 | + private async void OnExecuteReadManualHorseList() | |
38 | 38 | { |
39 | - LoadHorseRaceSummaryRequest req = new LoadHorseRaceSummaryRequest(HorseList); | |
39 | + //LoadHorseRaceSummaryRequest req = new LoadHorseRaceSummaryRequest(HorseList); | |
40 | + AsyncLoadHorseRaceSummaryRequest req = new AsyncLoadHorseRaceSummaryRequest(HorseList); | |
40 | 41 | Logger.Debug($"OnExecuteReadManualHorseList: {HorseList}"); |
41 | - wc.Execute(req); | |
42 | + await wc.ExecuteAsync(req); | |
42 | 43 | } |
43 | 44 | |
44 | 45 | private string _horseList; |
@@ -0,0 +1,152 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.ComponentModel; | |
4 | +using System.Linq; | |
5 | +using System.Text; | |
6 | +using System.Threading.Tasks; | |
7 | +using UmaTest.App.Adaptor.Gateway.ViewModel; | |
8 | +using UmaTest.App.Adaptor.Gateway.ViewModel.Dto; | |
9 | +using UmaTest.App.Domain.Model.Repository.Database.Dto; | |
10 | +using UmaTest.App.Domain.Model.Repository.Database.Entity.EveryDB2; | |
11 | +using UmaTest.App.Domain.UseCase.Request; | |
12 | +using UmaTest.App.Domain.UseCase.Response; | |
13 | +using UmaTest.Infra.Domain.UseCase; | |
14 | +using UmaTest.Infra.Helper; | |
15 | +using UmaTest.Infra.Log; | |
16 | + | |
17 | +namespace UmaTest.App.Gateway.Presenter | |
18 | +{ | |
19 | + public class AsyncLoadHorseRaceSummaryPresenter : IAsyncLoadHorseRaceSummaryPresenter | |
20 | + { | |
21 | + private IMainWindowViewModel vm; | |
22 | + | |
23 | + private List<UmaSummaryRowDto> umaSummaryList = new List<UmaSummaryRowDto>(); | |
24 | + private Dictionary<string, List<UmaRaceRowDto>> umaRaceMap = new Dictionary<string, List<UmaRaceRowDto>>(); | |
25 | + | |
26 | + | |
27 | + public AsyncLoadHorseRaceSummaryPresenter(IMainWindowViewModel vm) | |
28 | + { | |
29 | + this.vm = vm; | |
30 | + } | |
31 | + | |
32 | + public Task<UseCaseResponse> HandleAsync(UseCaseResponse baseRes) | |
33 | + { | |
34 | + return TaskHelper.RunWithContinuation<UseCaseResponse>(Task.Run<UseCaseResponse>(() => | |
35 | + { | |
36 | + LoadHorseRaceSummaryRequest req = baseRes.Request as LoadHorseRaceSummaryRequest; | |
37 | + LoadHorseRaceSummaryResponse res = baseRes as LoadHorseRaceSummaryResponse; | |
38 | + | |
39 | + List<string> kettoNums = res.KettoNums; | |
40 | + | |
41 | + // TODO 変換処理をtranslatorに委譲 | |
42 | + | |
43 | + foreach (string kettoNum in kettoNums) | |
44 | + { | |
45 | + Logger.Info($"血統登録番号: {kettoNum}"); | |
46 | + | |
47 | + UmaSummaryRowDto summaryDto; | |
48 | + | |
49 | + if (!res.Horses.TryGetValue(kettoNum, out NUma uma)) | |
50 | + { | |
51 | + Logger.Warn($"血統登録番号: {kettoNum} の馬情報が見つかりませんでした"); | |
52 | + continue; | |
53 | + } | |
54 | + | |
55 | + summaryDto = new UmaSummaryRowDto(uma); | |
56 | + | |
57 | + foreach (ChakudosuuSummary chakudosuu in res.Summaries[kettoNum]) | |
58 | + { | |
59 | + ChakudosuuByGradeRowDto chakudosuuByGrade; | |
60 | + | |
61 | + switch (chakudosuu.Key1) | |
62 | + { | |
63 | + case "1SHORT": | |
64 | + chakudosuuByGrade = summaryDto.Short; | |
65 | + break; | |
66 | + case "2MILE": | |
67 | + chakudosuuByGrade = summaryDto.Mile; | |
68 | + break; | |
69 | + case "3MIDDLE": | |
70 | + chakudosuuByGrade = summaryDto.Middle; | |
71 | + break; | |
72 | + case "4MIDDLELONG": | |
73 | + chakudosuuByGrade = summaryDto.MiddleLong; | |
74 | + break; | |
75 | + case "5LONG": | |
76 | + chakudosuuByGrade = summaryDto.Long; | |
77 | + break; | |
78 | + default: | |
79 | + continue; | |
80 | + } | |
81 | + | |
82 | + switch (chakudosuu.Key2) | |
83 | + { | |
84 | + case "G1": | |
85 | + chakudosuuByGrade.G1 = chakudosuu.Chakudosuu; | |
86 | + break; | |
87 | + case "G2": | |
88 | + chakudosuuByGrade.G2 = chakudosuu.Chakudosuu; | |
89 | + break; | |
90 | + case "G3": | |
91 | + chakudosuuByGrade.G3 = chakudosuu.Chakudosuu; | |
92 | + break; | |
93 | + case "ZZ": | |
94 | + chakudosuuByGrade.ZZ = chakudosuu.Chakudosuu; | |
95 | + continue; | |
96 | + } | |
97 | + | |
98 | + switch (chakudosuu.Key1) | |
99 | + { | |
100 | + case "1SHORT": | |
101 | + summaryDto.Short = chakudosuuByGrade; | |
102 | + break; | |
103 | + case "2MILE": | |
104 | + summaryDto.Mile = chakudosuuByGrade; | |
105 | + break; | |
106 | + case "3MIDDLE": | |
107 | + summaryDto.Middle = chakudosuuByGrade; | |
108 | + break; | |
109 | + case "4MIDDLELONG": | |
110 | + summaryDto.MiddleLong = chakudosuuByGrade; | |
111 | + break; | |
112 | + case "5LONG": | |
113 | + summaryDto.Long = chakudosuuByGrade; | |
114 | + break; | |
115 | + default: | |
116 | + break; | |
117 | + } | |
118 | + } | |
119 | + | |
120 | + Logger.Debug(summaryDto.ToString()); | |
121 | + | |
122 | + umaSummaryList.Add(summaryDto); | |
123 | + | |
124 | + if (!res.Races.TryGetValue(kettoNum, out IEnumerable<NUmaRaceWithNRace> umaRaces) || (umaRaces.Count() == 0)) | |
125 | + { | |
126 | + Logger.Warn($"血統登録番号: {kettoNum} の馬レース情報が見つかりませんでした"); | |
127 | + return res; | |
128 | + } | |
129 | + | |
130 | + List<UmaRaceRowDto> umaRaceList = new List<UmaRaceRowDto>(); | |
131 | + | |
132 | + foreach (NUmaRaceWithNRace umaRace in umaRaces) | |
133 | + { | |
134 | + NRace detail = umaRace.Race; | |
135 | + Logger.Debug($"{detail.Year}/{detail.Monthday.Substring(0, 2)}/{detail.Monthday.Substring(2, 2)} - {detail.Hondai} - {detail.Kyori} - {detail.Gradecd} - {detail.Jyokencd1} - {umaRace.Nyusenjyuni} - {umaRace.Kakuteijyuni}"); | |
136 | + | |
137 | + umaRaceList.Add(new UmaRaceRowDto(umaRace)); | |
138 | + } | |
139 | + | |
140 | + umaRaceMap.Add(kettoNum, umaRaceList); | |
141 | + } | |
142 | + | |
143 | + return res; | |
144 | + | |
145 | + }), | |
146 | + task => | |
147 | + { | |
148 | + vm.RefreshModel(umaSummaryList, umaRaceMap); | |
149 | + }); | |
150 | + } | |
151 | + } | |
152 | +} |
@@ -0,0 +1,8 @@ | ||
1 | +using Umatest.App.Presentation.Presenter; | |
2 | + | |
3 | +namespace UmaTest.App.Gateway.Presenter | |
4 | +{ | |
5 | + public interface IAsyncLoadHorseRaceSummaryPresenter : IAsyncPresenter | |
6 | + { | |
7 | + } | |
8 | +} | |
\ No newline at end of file |
@@ -67,6 +67,7 @@ namespace UmaTest.App.DI | ||
67 | 67 | /// |
68 | 68 | |
69 | 69 | di.Register<ILoadHorseRaceSummaryInteractor, LoadHorseRaceSummaryInteractor>(); |
70 | + di.Register<IAsyncLoadHorseRaceSummaryInteractor, AsyncLoadHorseRaceSummaryInteractor>(); | |
70 | 71 | |
71 | 72 | /// |
72 | 73 | /// Logics |
@@ -93,6 +94,7 @@ namespace UmaTest.App.DI | ||
93 | 94 | /// |
94 | 95 | |
95 | 96 | di.Register<ILoadHorseRaceSummaryPresenter, LoadHorseRaceSummaryPresenter>(); |
97 | + di.Register<IAsyncLoadHorseRaceSummaryPresenter, AsyncLoadHorseRaceSummaryPresenter>(); | |
96 | 98 | |
97 | 99 | /// |
98 | 100 | /// Router |
@@ -102,19 +104,38 @@ namespace UmaTest.App.DI | ||
102 | 104 | new UseCaseRouter(connector, di.GetInstance<IUserDialogProxy>()) |
103 | 105 | ); |
104 | 106 | |
105 | - di.RegisterInitializer<IUseCaseRouter>(x => | |
107 | + di.RegisterSingleton<IAsyncUseCaseRouter>(() => | |
108 | + new AsyncUseCaseRouter(connector, di.GetInstance<IUserDialogProxy>()) | |
109 | + ); | |
110 | + | |
111 | + Dictionary<Type, Type> routingMap = new Dictionary<Type, Type>() | |
106 | 112 | { |
107 | - x.RoutingMap = new Dictionary<Type, Type> | |
108 | 113 | { |
109 | - { | |
110 | - typeof(LoadHorseRaceSummaryRequest), | |
111 | - typeof(ILoadHorseRaceSummaryInteractor) | |
112 | - }, | |
113 | - { | |
114 | - typeof(LoadHorseRaceSummaryResponse), | |
115 | - typeof(ILoadHorseRaceSummaryPresenter) | |
116 | - }, | |
117 | - }; | |
114 | + typeof(LoadHorseRaceSummaryRequest), | |
115 | + typeof(ILoadHorseRaceSummaryInteractor) | |
116 | + }, | |
117 | + { | |
118 | + typeof(AsyncLoadHorseRaceSummaryRequest), | |
119 | + typeof(IAsyncLoadHorseRaceSummaryInteractor) | |
120 | + }, | |
121 | + { | |
122 | + typeof(LoadHorseRaceSummaryResponse), | |
123 | + typeof(ILoadHorseRaceSummaryPresenter) | |
124 | + }, | |
125 | + { | |
126 | + typeof(AsyncLoadHorseRaceSummaryResponse), | |
127 | + typeof(IAsyncLoadHorseRaceSummaryPresenter) | |
128 | + }, | |
129 | + }; | |
130 | + | |
131 | + di.RegisterInitializer<IUseCaseRouter>(x => | |
132 | + { | |
133 | + x.RoutingMap = routingMap; | |
134 | + }); | |
135 | + | |
136 | + di.RegisterInitializer<IAsyncUseCaseRouter>(x => | |
137 | + { | |
138 | + x.RoutingMap = routingMap; | |
118 | 139 | }); |
119 | 140 | |
120 | 141 | try |
@@ -1,4 +1,5 @@ | ||
1 | 1 | using System.Collections.Generic; |
2 | +using System.Threading.Tasks; | |
2 | 3 | using UmaTest.App.Domain.Model.Repository.Database.Entity.EveryDB2; |
3 | 4 | |
4 | 5 | namespace UmaTest.App.Domain.Model.Logic |
@@ -6,5 +7,6 @@ namespace UmaTest.App.Domain.Model.Logic | ||
6 | 7 | public interface IUmaLogic |
7 | 8 | { |
8 | 9 | Dictionary<string, NUma> LoadHorses(List<string> bameiList); |
10 | + Task<Dictionary<string, NUma>> LoadHorsesAsync(List<string> bameiList); | |
9 | 11 | } |
10 | 12 | } |
\ No newline at end of file |
@@ -1,4 +1,5 @@ | ||
1 | 1 | using System.Collections.Generic; |
2 | +using System.Threading.Tasks; | |
2 | 3 | using UmaTest.App.Domain.Model.Repository.Database.Dto; |
3 | 4 | |
4 | 5 | namespace UmaTest.App.Domain.Model.Logic |
@@ -7,5 +8,7 @@ namespace UmaTest.App.Domain.Model.Logic | ||
7 | 8 | { |
8 | 9 | Dictionary<string, IEnumerable<ChakudosuuSummary>> LoadChakudosuuSummaries(List<string> kettoNumList); |
9 | 10 | Dictionary<string, IEnumerable<NUmaRaceWithNRace>> LoadRaces(List<string> kettoNumList); |
11 | + Task<Dictionary<string, IEnumerable<ChakudosuuSummary>>> LoadChakudosuuSummariesAsync(List<string> kettoNumList); | |
12 | + Task<Dictionary<string, IEnumerable<NUmaRaceWithNRace>>> LoadRacesAsync(List<string> kettoNumList); | |
10 | 13 | } |
11 | 14 | } |
\ No newline at end of file |
@@ -20,9 +20,14 @@ namespace UmaTest.App.Domain.Model.Logic | ||
20 | 20 | |
21 | 21 | public Dictionary<string, NUma> LoadHorses(List<string> bameiList) |
22 | 22 | { |
23 | - return LogicHelper.tryLogic(() => | |
23 | + return TaskHelper.WaitSingle(LoadHorsesAsync(bameiList)); | |
24 | + } | |
25 | + | |
26 | + public async Task<Dictionary<string, NUma>> LoadHorsesAsync(List<string> bameiList) | |
27 | + { | |
28 | + return await LogicHelper.tryLogic(() => | |
24 | 29 | { |
25 | - return dao.findAllHorsesByBameiList(bameiList); | |
30 | + return dao.findAllHorsesByBameiListAsync(bameiList); | |
26 | 31 | }); |
27 | 32 | } |
28 | 33 | } |
@@ -20,25 +20,38 @@ namespace UmaTest.App.Domain.Model.Logic | ||
20 | 20 | |
21 | 21 | public Dictionary<string, IEnumerable<NUmaRaceWithNRace>> LoadRaces(List<string> kettoNumList) |
22 | 22 | { |
23 | - return LogicHelper.tryLogic(() => | |
23 | + return TaskHelper.WaitSingle(LoadRacesAsync(kettoNumList)); | |
24 | + } | |
25 | + | |
26 | + public async Task<Dictionary<string, IEnumerable<NUmaRaceWithNRace>>> LoadRacesAsync(List<string> kettoNumList) | |
27 | + { | |
28 | + return await LogicHelper.tryLogic(() => | |
24 | 29 | { |
25 | - return dao.findAllRacesByKettoNumList(kettoNumList); | |
30 | + return dao.findAllRacesByKettoNumListAsync(kettoNumList); | |
26 | 31 | }); |
27 | 32 | } |
28 | 33 | |
29 | 34 | public Dictionary<string, IEnumerable<ChakudosuuSummary>> LoadChakudosuuSummaries(List<string> kettoNumList) |
30 | 35 | { |
31 | - return LogicHelper.tryLogic(() => | |
32 | - { | |
33 | - Dictionary<string, IEnumerable<ChakudosuuSummary>> res = new Dictionary<string, IEnumerable<ChakudosuuSummary>>(); | |
36 | + return TaskHelper.WaitSingle(LoadChakudosuuSummariesAsync(kettoNumList)); | |
37 | + } | |
34 | 38 | |
35 | - foreach (string bamei in kettoNumList) | |
39 | + public Task<Dictionary<string, IEnumerable<ChakudosuuSummary>>> LoadChakudosuuSummariesAsync(List<string> kettoNumList) | |
40 | + { | |
41 | + return Task.Run<Dictionary<string, IEnumerable<ChakudosuuSummary>>>(() => | |
42 | + { | |
43 | + return LogicHelper.tryLogic(async () => | |
36 | 44 | { |
37 | - IEnumerable<ChakudosuuSummary> summaries = dao.findChakudosuuSummary(bamei); | |
38 | - res.Add(bamei, summaries); | |
39 | - } | |
45 | + Dictionary<string, IEnumerable<ChakudosuuSummary>> res = new Dictionary<string, IEnumerable<ChakudosuuSummary>>(); | |
46 | + | |
47 | + foreach (string kettoNum in kettoNumList) | |
48 | + { | |
49 | + IEnumerable<ChakudosuuSummary> summaries = await dao.findChakudosuuSummaryAsync(kettoNum); | |
50 | + res.Add(kettoNum, summaries); | |
51 | + } | |
40 | 52 | |
41 | - return res; | |
53 | + return res; | |
54 | + }); | |
42 | 55 | }); |
43 | 56 | } |
44 | 57 | } |
@@ -1,4 +1,5 @@ | ||
1 | 1 | using System.Collections.Generic; |
2 | +using System.Threading.Tasks; | |
2 | 3 | using UmaTest.App.Domain.Model.Repository.Database.Entity.EveryDB2; |
3 | 4 | |
4 | 5 | namespace UmaTest.App.Domain.Model.Repository.Database.Dao |
@@ -6,5 +7,6 @@ namespace UmaTest.App.Domain.Model.Repository.Database.Dao | ||
6 | 7 | public interface INUmaDao |
7 | 8 | { |
8 | 9 | Dictionary<string, NUma> findAllHorsesByBameiList(List<string> bameiList); |
10 | + Task<Dictionary<string, NUma>> findAllHorsesByBameiListAsync(List<string> bameiList); | |
9 | 11 | } |
10 | 12 | } |
\ No newline at end of file |
@@ -1,4 +1,5 @@ | ||
1 | 1 | using System.Collections.Generic; |
2 | +using System.Threading.Tasks; | |
2 | 3 | using UmaTest.App.Domain.Model.Repository.Database.Dto; |
3 | 4 | |
4 | 5 | namespace UmaTest.App.Domain.Model.Repository.Database.Dao |
@@ -7,5 +8,7 @@ namespace UmaTest.App.Domain.Model.Repository.Database.Dao | ||
7 | 8 | { |
8 | 9 | Dictionary<string, IEnumerable<NUmaRaceWithNRace>> findAllRacesByKettoNumList(List<string> kettoNumList); |
9 | 10 | IEnumerable<ChakudosuuSummary> findChakudosuuSummary(string kettoNum); |
11 | + Task<Dictionary<string, IEnumerable<NUmaRaceWithNRace>>> findAllRacesByKettoNumListAsync(List<string> kettoNumList); | |
12 | + Task<IEnumerable<ChakudosuuSummary>> findChakudosuuSummaryAsync(string kettoNum); | |
10 | 13 | } |
11 | 14 | } |
\ No newline at end of file |
@@ -21,31 +21,39 @@ namespace UmaTest.App.Domain.Model.Repository.Database.Dao | ||
21 | 21 | |
22 | 22 | public Dictionary<string, NUma> findAllHorsesByBameiList(List<string> bameiList) |
23 | 23 | { |
24 | - return DbHelper.tryQuery(() => | |
24 | + return TaskHelper.WaitSingle(findAllHorsesByBameiListAsync(bameiList)); | |
25 | + } | |
26 | + | |
27 | + public Task<Dictionary<string, NUma>> findAllHorsesByBameiListAsync(List<string> bameiList) | |
28 | + { | |
29 | + return Task.Run<Dictionary<string, NUma>>(() => | |
25 | 30 | { |
26 | - Dictionary<string, NUma> res = new Dictionary<string, NUma>(); | |
31 | + return DbHelper.tryQuery(() => | |
32 | + { | |
33 | + Dictionary<string, NUma> res = new Dictionary<string, NUma>(); | |
27 | 34 | |
28 | - string[] bameis = bameiList.ToArray(); | |
29 | - var sql = Sql.Builder | |
30 | - .Where("bamei in (@bameis)", new { bameis = bameis}) | |
31 | - .OrderBy("bamei, kettonum desc"); | |
35 | + string[] bameis = bameiList.ToArray(); | |
36 | + var sql = Sql.Builder | |
37 | + .Where("bamei in (@bameis)", new { bameis = bameis }) | |
38 | + .OrderBy("bamei, kettonum desc"); | |
32 | 39 | |
33 | - var horses = db.Query<NUma>(sql); | |
40 | + var horses = db.Query<NUma>(sql); | |
34 | 41 | |
35 | - foreach (NUma horse in horses) | |
36 | - { | |
37 | - if (!res.ContainsKey(horse.Kettonum)) | |
38 | - { | |
39 | - res.Add(horse.Kettonum, horse); | |
40 | - } | |
41 | - else | |
42 | + foreach (NUma horse in horses) | |
42 | 43 | { |
43 | - NUma dupHorse = res[horse.Kettonum]; | |
44 | - Logger.Warn($"NUmaテーブルの血統登録番号が重複しています: {horse.Kettonum} - {horse.Bamei}, {dupHorse.Bamei})"); | |
44 | + if (!res.ContainsKey(horse.Kettonum)) | |
45 | + { | |
46 | + res.Add(horse.Kettonum, horse); | |
47 | + } | |
48 | + else | |
49 | + { | |
50 | + NUma dupHorse = res[horse.Kettonum]; | |
51 | + Logger.Warn($"NUmaテーブルの血統登録番号が重複しています: {horse.Kettonum} - {horse.Bamei}, {dupHorse.Bamei})"); | |
52 | + } | |
45 | 53 | } |
46 | - } | |
47 | 54 | |
48 | - return res; | |
55 | + return res; | |
56 | + }); | |
49 | 57 | }); |
50 | 58 | } |
51 | 59 | } |
@@ -21,34 +21,50 @@ namespace UmaTest.App.Domain.Model.Repository.Database.Dao | ||
21 | 21 | |
22 | 22 | public Dictionary<string, IEnumerable<NUmaRaceWithNRace>> findAllRacesByKettoNumList(List<string> kettoNumList) |
23 | 23 | { |
24 | - return DbHelper.tryQuery(() => | |
25 | - { | |
26 | - Dictionary<string, IEnumerable<NUmaRaceWithNRace>> res = new Dictionary<string, IEnumerable<NUmaRaceWithNRace>>(); | |
24 | + return TaskHelper.WaitSingle(findAllRacesByKettoNumListAsync(kettoNumList)); | |
25 | + } | |
27 | 26 | |
28 | - foreach (string kettoNum in kettoNumList) | |
27 | + public Task<Dictionary<string, IEnumerable<NUmaRaceWithNRace>>> findAllRacesByKettoNumListAsync(List<string> kettoNumList) | |
28 | + { | |
29 | + return Task.Run<Dictionary<string, IEnumerable<NUmaRaceWithNRace>>>(() => | |
30 | + { | |
31 | + return DbHelper.tryQuery(() => | |
29 | 32 | { |
30 | - var sql = Sql.Builder | |
31 | - .Append("SELECT ur.*, r.*") | |
32 | - .From("n_uma_race ur") | |
33 | - .Append("INNER JOIN n_race r USING(year, jyocd, kaiji, nichiji, racenum)") | |
34 | - .Where("ur.kettonum = @0", kettoNum) | |
35 | - .OrderBy("ur.year desc, ur.monthday desc"); | |
36 | - | |
37 | - var races = db.Query<NUmaRace, NRace, NUmaRaceWithNRace>((ur, r) => new NUmaRaceWithNRace(ur, r), sql); | |
38 | - res.Add(kettoNum, races); | |
39 | - } | |
40 | - | |
41 | - return res; | |
33 | + Dictionary<string, IEnumerable<NUmaRaceWithNRace>> res = new Dictionary<string, IEnumerable<NUmaRaceWithNRace>>(); | |
34 | + | |
35 | + foreach (string kettoNum in kettoNumList) | |
36 | + { | |
37 | + var sql = Sql.Builder | |
38 | + .Append("SELECT ur.*, r.*") | |
39 | + .From("n_uma_race ur") | |
40 | + .Append("INNER JOIN n_race r USING(year, jyocd, kaiji, nichiji, racenum)") | |
41 | + .Where("ur.kettonum = @0", kettoNum) | |
42 | + .OrderBy("ur.year desc, ur.monthday desc"); | |
43 | + | |
44 | + var races = db.Query<NUmaRace, NRace, NUmaRaceWithNRace>((ur, r) => new NUmaRaceWithNRace(ur, r), sql); | |
45 | + res.Add(kettoNum, races); | |
46 | + } | |
47 | + | |
48 | + return res; | |
49 | + }); | |
42 | 50 | }); |
43 | 51 | } |
44 | 52 | |
45 | 53 | public IEnumerable<ChakudosuuSummary> findChakudosuuSummary(string kettoNum) |
46 | 54 | { |
47 | - return DbHelper.tryQuery(() => | |
55 | + return TaskHelper.WaitSingle(findChakudosuuSummaryAsync(kettoNum)); | |
56 | + } | |
57 | + | |
58 | + public Task<IEnumerable<ChakudosuuSummary>> findChakudosuuSummaryAsync(string kettoNum) | |
59 | + { | |
60 | + return Task.Run<IEnumerable<ChakudosuuSummary>>(() => | |
48 | 61 | { |
49 | - string sql = DbHelper.GetResourceSQLFile(this); | |
62 | + return DbHelper.tryQuery(() => | |
63 | + { | |
64 | + string sql = DbHelper.GetResourceSQLFile(this); | |
50 | 65 | |
51 | - return db.Query<ChakudosuuSummary>(sql, kettoNum).ToList(); | |
66 | + return db.Query<ChakudosuuSummary>(sql, kettoNum).ToList(); | |
67 | + }); | |
52 | 68 | }); |
53 | 69 | } |
54 | 70 | } |
@@ -0,0 +1,50 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | +using System.Threading.Tasks; | |
6 | +using UmaTest.App.Domain.Model.Logic; | |
7 | +using UmaTest.App.Domain.Model.Repository.Database.Dto; | |
8 | +using UmaTest.App.Domain.Model.Repository.Database.Entity.EveryDB2; | |
9 | +using UmaTest.App.Domain.Translator; | |
10 | +using UmaTest.App.Domain.UseCase.Request; | |
11 | +using UmaTest.App.Domain.UseCase.Response; | |
12 | +using UmaTest.Infra.Domain.UseCase; | |
13 | + | |
14 | +namespace UmaTest.App.Domain.UseCase.Interactor | |
15 | +{ | |
16 | + public class AsyncLoadHorseRaceSummaryInteractor : IAsyncLoadHorseRaceSummaryInteractor | |
17 | + { | |
18 | + IUmaLogic logicUma; | |
19 | + IUmaRaceLogic logicUmaRace; | |
20 | + ILoadHorseRaceSummaryTranslator translator; | |
21 | + public AsyncLoadHorseRaceSummaryInteractor(IUmaLogic logicUma, IUmaRaceLogic logicUmaRace, ILoadHorseRaceSummaryTranslator translator) : base() | |
22 | + { | |
23 | + this.logicUma = logicUma; | |
24 | + this.logicUmaRace = logicUmaRace; | |
25 | + this.translator = translator; | |
26 | + } | |
27 | + | |
28 | + public async Task<UseCaseResponse> InteractAsync(UseCaseRequest baseReq) | |
29 | + { | |
30 | + LoadHorseRaceSummaryRequest req = baseReq as LoadHorseRaceSummaryRequest; | |
31 | + LoadHorseRaceSummaryResponse res = req.Response as LoadHorseRaceSummaryResponse; | |
32 | + | |
33 | + List<string> bameiList = req.HorseList; | |
34 | + | |
35 | + if (bameiList.Count == 0) | |
36 | + { | |
37 | + return res.AbortWithSomeErrors("馬名リストが設定されていません"); | |
38 | + } | |
39 | + | |
40 | + Dictionary<string, NUma> horses = await logicUma.LoadHorsesAsync(req.HorseList); | |
41 | + | |
42 | + List<string> kettoNums = horses.Select(h => h.Value.Kettonum).OrderBy(k => k).ToList(); | |
43 | + | |
44 | + Dictionary<string, IEnumerable<NUmaRaceWithNRace>> races = await logicUmaRace.LoadRacesAsync(kettoNums); | |
45 | + Dictionary<string, IEnumerable<ChakudosuuSummary>> summaries = await logicUmaRace.LoadChakudosuuSummariesAsync(kettoNums); | |
46 | + | |
47 | + return translator.Translate(res, req, kettoNums, horses, races, summaries); | |
48 | + } | |
49 | + } | |
50 | +} |
@@ -0,0 +1,8 @@ | ||
1 | +using UmaTest.Infra.Domain.UseCase; | |
2 | + | |
3 | +namespace UmaTest.App.Domain.UseCase.Interactor | |
4 | +{ | |
5 | + public interface IAsyncLoadHorseRaceSummaryInteractor : IAsyncUseCaseInteractor | |
6 | + { | |
7 | + } | |
8 | +} | |
\ No newline at end of file |
@@ -0,0 +1,22 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | +using System.Threading.Tasks; | |
6 | +using UmaTest.App.Domain.UseCase.Response; | |
7 | +using UmaTest.Infra.Domain.UseCase; | |
8 | + | |
9 | +namespace UmaTest.App.Domain.UseCase.Request | |
10 | +{ | |
11 | + public class AsyncLoadHorseRaceSummaryRequest : LoadHorseRaceSummaryRequest | |
12 | + { | |
13 | + public AsyncLoadHorseRaceSummaryRequest(string horseList) : base(horseList) | |
14 | + { | |
15 | + } | |
16 | + | |
17 | + protected override UseCaseResponse CreateResponse() | |
18 | + { | |
19 | + return new AsyncLoadHorseRaceSummaryResponse(this); | |
20 | + } | |
21 | + } | |
22 | +} |
@@ -0,0 +1,19 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | +using System.Threading.Tasks; | |
6 | +using UmaTest.App.Domain.Model.Repository.Database.Dto; | |
7 | +using UmaTest.App.Domain.Model.Repository.Database.Entity.EveryDB2; | |
8 | +using UmaTest.App.Domain.UseCase.Request; | |
9 | +using UmaTest.Infra.Domain.UseCase; | |
10 | + | |
11 | +namespace UmaTest.App.Domain.UseCase.Response | |
12 | +{ | |
13 | + public class AsyncLoadHorseRaceSummaryResponse : LoadHorseRaceSummaryResponse | |
14 | + { | |
15 | + public AsyncLoadHorseRaceSummaryResponse(AsyncLoadHorseRaceSummaryRequest req) : base(req) | |
16 | + { | |
17 | + } | |
18 | + } | |
19 | +} |
@@ -1,5 +1,4 @@ | ||
1 | -using System; | |
2 | -using System.Collections.Generic; | |
1 | +using System.Collections.Generic; | |
3 | 2 | using System.Linq; |
4 | 3 | using System.Text; |
5 | 4 | using System.Threading.Tasks; |
@@ -0,0 +1,42 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using UmaTest.App.Repository.UI; | |
4 | +using UmaTest.Infra.DI; | |
5 | +using UmaTest.Infra.Log; | |
6 | + | |
7 | +namespace UmaTest.Infra.Adaptor.Controller.Handler | |
8 | +{ | |
9 | + public abstract class AbstractUseCaseRouter | |
10 | + { | |
11 | + protected IComponentConnector connector; | |
12 | + | |
13 | + protected IUserDialogProxy dlg; | |
14 | + | |
15 | + public IReadOnlyDictionary<Type, Type> RoutingMap { get; set; } | |
16 | + | |
17 | + public AbstractUseCaseRouter(IComponentConnector connector, IUserDialogProxy dialogRepository) | |
18 | + { | |
19 | + this.connector = connector; | |
20 | + this.dlg = dialogRepository; | |
21 | + } | |
22 | + | |
23 | + protected T GetComponent<T>(string label, object key) where T : class | |
24 | + { | |
25 | + if (RoutingMap == null) | |
26 | + { | |
27 | + Logger.Error("routing map must not be null."); | |
28 | + return null; | |
29 | + } | |
30 | + | |
31 | + RoutingMap.TryGetValue(key.GetType(), out Type type); | |
32 | + | |
33 | + if (type == null) | |
34 | + { | |
35 | + Logger.Trace($"{label} not regiestered. (key={key.GetType()})"); | |
36 | + return null; | |
37 | + } | |
38 | + | |
39 | + return connector.GetComponent<T>(type); | |
40 | + } | |
41 | + } | |
42 | +} | |
\ No newline at end of file |
@@ -0,0 +1,63 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using UmaTest.Infra.DI; | |
4 | +using UmaTest.App.Repository.UI; | |
5 | +using Umatest.App.Presentation.Presenter; | |
6 | +using SimpleInjector; | |
7 | +using UmaTest.Infra.Log; | |
8 | +using UmaTest.Infra.Domain.UseCase; | |
9 | +using System.Threading.Tasks; | |
10 | + | |
11 | +namespace UmaTest.Infra.Adaptor.Controller.Handler | |
12 | +{ | |
13 | + public class AsyncUseCaseRouter : AbstractUseCaseRouter, IAsyncUseCaseRouter | |
14 | + { | |
15 | + public AsyncUseCaseRouter(IComponentConnector connector, IUserDialogProxy dialogProxy) : base(connector, dialogProxy) | |
16 | + { | |
17 | + } | |
18 | + | |
19 | + public async Task<UseCaseResponse> HandleAsync(UseCaseRequest req) | |
20 | + { | |
21 | + try | |
22 | + { | |
23 | + using (connector.BeginAsyncComponentScope()) | |
24 | + { | |
25 | + IAsyncUseCaseInteractor asyncInteractor = GetComponent<IAsyncUseCaseInteractor>("async interactor", req); | |
26 | + | |
27 | + // routing map is null, or request type key not registered on routing map. | |
28 | + if (asyncInteractor == null) | |
29 | + { | |
30 | + Logger.Error("get interactor instance failed."); | |
31 | + return null; | |
32 | + } | |
33 | + | |
34 | + Logger.Trace($"asyncInteractor={asyncInteractor.ToString()}"); | |
35 | + | |
36 | + UseCaseResponse res = await asyncInteractor.InteractAsync(req); | |
37 | + | |
38 | + Logger.Trace($"response={res.ToString()}"); | |
39 | + | |
40 | + if (res.IsSuccess()) | |
41 | + { | |
42 | + IAsyncPresenter presenter = GetComponent<IAsyncPresenter>("async presenter", res); | |
43 | + | |
44 | + if (presenter != null) | |
45 | + { | |
46 | + Logger.Trace($"asyncPresenter={presenter.ToString()}"); | |
47 | + | |
48 | + return await presenter.HandleAsync(res); | |
49 | + } | |
50 | + } | |
51 | + | |
52 | + return res; | |
53 | + } | |
54 | + } | |
55 | + catch (ActivationException e) | |
56 | + { | |
57 | + // component concrete instance not registered on di container. | |
58 | + string msg = $"コンポーネントがDIコンテナに登録されていません:{DIExceptionHelper.SplitMessage(e)}"; | |
59 | + throw new ApplicationException(msg, e); | |
60 | + } | |
61 | + } | |
62 | + } | |
63 | +} |
@@ -0,0 +1,10 @@ | ||
1 | +using System.Threading.Tasks; | |
2 | +using UmaTest.Infra.Domain.UseCase; | |
3 | + | |
4 | +namespace UmaTest.Infra.Adaptor.Controller.Handler | |
5 | +{ | |
6 | + public interface IAsyncRequestHandler | |
7 | + { | |
8 | + Task<UseCaseResponse> HandleAsync(UseCaseRequest req); | |
9 | + } | |
10 | +} | |
\ No newline at end of file |
@@ -0,0 +1,9 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | + | |
4 | +namespace UmaTest.Infra.Adaptor.Controller.Handler | |
5 | +{ | |
6 | + public interface IAsyncUseCaseRouter : IRoutingMap, IAsyncRequestHandler | |
7 | + { | |
8 | + } | |
9 | +} | |
\ No newline at end of file |
@@ -0,0 +1,10 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | + | |
4 | +namespace UmaTest.Infra.Adaptor.Controller.Handler | |
5 | +{ | |
6 | + public interface IRoutingMap | |
7 | + { | |
8 | + IReadOnlyDictionary<Type, Type> RoutingMap { get; set; } | |
9 | + } | |
10 | +} | |
\ No newline at end of file |
@@ -3,8 +3,7 @@ using System.Collections.Generic; | ||
3 | 3 | |
4 | 4 | namespace UmaTest.Infra.Adaptor.Controller.Handler |
5 | 5 | { |
6 | - public interface IUseCaseRouter : IRequestHandler | |
6 | + public interface IUseCaseRouter : IRoutingMap, IRequestHandler | |
7 | 7 | { |
8 | - Dictionary<Type, Type> RoutingMap { get; set; } | |
9 | 8 | } |
10 | 9 | } |
\ No newline at end of file |
@@ -6,19 +6,14 @@ using Umatest.App.Presentation.Presenter; | ||
6 | 6 | using SimpleInjector; |
7 | 7 | using UmaTest.Infra.Log; |
8 | 8 | using UmaTest.Infra.Domain.UseCase; |
9 | +using System.Threading.Tasks; | |
9 | 10 | |
10 | 11 | namespace UmaTest.Infra.Adaptor.Controller.Handler |
11 | 12 | { |
12 | - public class UseCaseRouter : IUseCaseRouter | |
13 | + public class UseCaseRouter : AbstractUseCaseRouter, IUseCaseRouter, IRequestHandler | |
13 | 14 | { |
14 | - private IComponentConnector connector; | |
15 | - | |
16 | - private IUserDialogProxy dlg; | |
17 | - | |
18 | - public UseCaseRouter(IComponentConnector connector, IUserDialogProxy dialogRepository) | |
15 | + public UseCaseRouter(IComponentConnector connector, IUserDialogProxy dialogProxy) : base(connector, dialogProxy) | |
19 | 16 | { |
20 | - this.connector = connector; | |
21 | - this.dlg = dialogRepository; | |
22 | 17 | } |
23 | 18 | |
24 | 19 | public UseCaseResponse Handle(UseCaseRequest req) |
@@ -65,25 +60,5 @@ namespace UmaTest.Infra.Adaptor.Controller.Handler | ||
65 | 60 | } |
66 | 61 | } |
67 | 62 | |
68 | - private T GetComponent<T>(string label, object key) where T : class | |
69 | - { | |
70 | - if (RoutingMap == null) | |
71 | - { | |
72 | - Logger.Error("routing map must not be null."); | |
73 | - return null; | |
74 | - } | |
75 | - | |
76 | - RoutingMap.TryGetValue(key.GetType(), out Type type); | |
77 | - | |
78 | - if (type == null) | |
79 | - { | |
80 | - Logger.Trace($"{label} not regiestered. (key={key.GetType()})"); | |
81 | - return null; | |
82 | - } | |
83 | - | |
84 | - return connector.GetComponent<T>(type); | |
85 | - } | |
86 | - | |
87 | - public Dictionary<Type, Type> RoutingMap { get; set; } | |
88 | 63 | } |
89 | 64 | } |
@@ -1,5 +1,6 @@ | ||
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | +using System.Threading.Tasks; | |
3 | 4 | using System.Windows.Forms; |
4 | 5 | using UmaTest.Infra.Adaptor.Command; |
5 | 6 | using UmaTest.Infra.Domain.UseCase; |
@@ -13,5 +14,7 @@ namespace UmaTest.Infra.Adaptor.Controller | ||
13 | 14 | Dictionary<string, MouseEventHandler> MouseEvents { get; } |
14 | 15 | |
15 | 16 | UseCaseResponse Execute(UseCaseRequest req); |
17 | + | |
18 | + Task<UseCaseResponse> ExecuteAsync(UseCaseRequest req); | |
16 | 19 | } |
17 | 20 | } |
\ No newline at end of file |
@@ -0,0 +1,10 @@ | ||
1 | +using System.Threading.Tasks; | |
2 | +using UmaTest.Infra.Domain.UseCase; | |
3 | + | |
4 | +namespace Umatest.App.Presentation.Presenter | |
5 | +{ | |
6 | + public interface IAsyncPresenter | |
7 | + { | |
8 | + Task<UseCaseResponse> HandleAsync(UseCaseResponse baseRes); | |
9 | + } | |
10 | +} | |
\ No newline at end of file |
@@ -0,0 +1,9 @@ | ||
1 | +using System.Threading.Tasks; | |
2 | + | |
3 | +namespace UmaTest.Infra.Domain.UseCase | |
4 | +{ | |
5 | + public interface IAsyncUseCaseInteractor | |
6 | + { | |
7 | + Task<UseCaseResponse> InteractAsync(UseCaseRequest request); | |
8 | + } | |
9 | +} | |
\ No newline at end of file |
@@ -0,0 +1,23 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Threading.Tasks; | |
4 | +using UmaTest.App.Domain.Model.Repository.Database.Dto; | |
5 | + | |
6 | +namespace UmaTest.Infra.Helper | |
7 | +{ | |
8 | + internal class TaskHelper | |
9 | + { | |
10 | + public static TResult WaitSingle<TResult>(Task<TResult> task) | |
11 | + { | |
12 | + Task.WaitAll(new Task<TResult>[] { task }); | |
13 | + return task.Result; | |
14 | + } | |
15 | + | |
16 | + public static Task<TResult> RunWithContinuation<TResult>(Task<TResult> task, Action<Task<TResult>> action) | |
17 | + { | |
18 | + task.ContinueWith(action, TaskScheduler.FromCurrentSynchronizationContext()); | |
19 | + | |
20 | + return task; | |
21 | + } | |
22 | + } | |
23 | +} | |
\ No newline at end of file |
@@ -78,6 +78,30 @@ namespace UmaTest.Properties { | ||
78 | 78 | /// end as kyori |
79 | 79 | /// , case r.gradecd when ' [残りの文字列は切り詰められました]"; に類似しているローカライズされた文字列を検索します。 |
80 | 80 | /// </summary> |
81 | + internal static string NUmaRaceDao_findChakudosuuSummaryAsync { | |
82 | + get { | |
83 | + return ResourceManager.GetString("NUmaRaceDao_findChakudosuuSummaryAsync", resourceCulture); | |
84 | + } | |
85 | + } | |
86 | + | |
87 | + /// <summary> | |
88 | + /// select | |
89 | + /// kyori as key1 | |
90 | + /// , gradecd as key2 | |
91 | + /// , to_char(sum(jyuni1), 'FM99') || '.' || to_char(sum(jyuni2), 'FM99') || '.' | |
92 | + /// || to_char(sum(jyuni3), 'FM99') || '.' || to_char(sum(jyuni4ika), 'FM99') as chakudosuu | |
93 | + /// , sum(ijou) as ijou | |
94 | + ///from ( | |
95 | + ///select | |
96 | + /// case | |
97 | + /// when r.kyori >= '2800' then '5LONG' | |
98 | + /// when r.kyori >= '2200' then '4MIDDLELONG' | |
99 | + /// when r.kyori >= '1800' then '3MIDDLE' | |
100 | + /// when r.kyori >= '1400' then '2MILE' | |
101 | + /// else '1SHORT' | |
102 | + /// end as kyori | |
103 | + /// , case r.gradecd when ' [残りの文字列は切り詰められました]"; に類似しているローカライズされた文字列を検索します。 | |
104 | + /// </summary> | |
81 | 105 | internal static string NUmaRaceDao_findRaceSummary { |
82 | 106 | get { |
83 | 107 | return ResourceManager.GetString("NUmaRaceDao_findRaceSummary", resourceCulture); |
@@ -118,6 +118,9 @@ | ||
118 | 118 | <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
119 | 119 | </resheader> |
120 | 120 | <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
121 | + <data name="NUmaRaceDao_findChakudosuuSummaryAsync" type="System.Resources.ResXFileRef, System.Windows.Forms"> | |
122 | + <value>..\resources\sql\numaracedao_findchakudosuusummaryasync.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;shift_jis</value> | |
123 | + </data> | |
121 | 124 | <data name="NUmaRaceDao_findRaceSummary" type="System.Resources.ResXFileRef, System.Windows.Forms"> |
122 | 125 | <value>..\resources\sql\numaracedao_findchakudosuusummary.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;shift_jis</value> |
123 | 126 | </data> |
@@ -0,0 +1,33 @@ | ||
1 | +select | |
2 | + kyori as key1 | |
3 | + , gradecd as key2 | |
4 | + , to_char(sum(jyuni1), 'FM99') || '.' || to_char(sum(jyuni2), 'FM99') || '.' | |
5 | + || to_char(sum(jyuni3), 'FM99') || '.' || to_char(sum(jyuni4ika), 'FM99') as chakudosuu | |
6 | + , sum(ijou) as ijou | |
7 | +from ( | |
8 | +select | |
9 | + case | |
10 | + when r.kyori >= '2800' then '5LONG' | |
11 | + when r.kyori >= '2200' then '4MIDDLELONG' | |
12 | + when r.kyori >= '1800' then '3MIDDLE' | |
13 | + when r.kyori >= '1400' then '2MILE' | |
14 | + else '1SHORT' | |
15 | + end as kyori | |
16 | + , case r.gradecd when 'A' then 'G1' when 'B' then 'G2' when 'C' then 'G3' else 'ZZ' end as gradecd | |
17 | + , case when ur.kakuteijyuni = '01' then 1 else 0 end as jyuni1 | |
18 | + , case when ur.kakuteijyuni = '02' then 1 else 0 end as jyuni2 | |
19 | + , case when ur.kakuteijyuni = '03' then 1 else 0 end as jyuni3 | |
20 | + , case when ur.kakuteijyuni > '03' then 1 else 0 end as jyuni4ika | |
21 | + , case when ur.kakuteijyuni = '00' then 1 else 0 end as ijou | |
22 | +from | |
23 | + n_uma_race ur | |
24 | + inner join n_race r | |
25 | + using (year, jyocd, kaiji, nichiji, racenum) | |
26 | +where | |
27 | + ur.kettonum = @0 | |
28 | + /* and to_date(ur.year || ur.monthday, 'YYYYMMDD') > (select max(to_date(ur2.year || ur2.monthday, 'YYYYMMDD')) from n_uma_race ur2 where ur.bamei = ur2.bamei) - INTERVAL '1 year' */ | |
29 | +) v | |
30 | +group by | |
31 | + kyori, gradecd | |
32 | +order by | |
33 | + kyori, gradecd |
@@ -107,13 +107,26 @@ | ||
107 | 107 | <Compile Include="App\Adaptor\Gateway\ViewModel\Dto\UmaRaceRowDto.cs" /> |
108 | 108 | <Compile Include="App\Adaptor\Gateway\ViewModel\Dto\UmaSummaryRowDto.cs" /> |
109 | 109 | <Compile Include="App\Adaptor\Gateway\ViewModel\IMainWindowViewModel.cs" /> |
110 | + <Compile Include="App\Adaptor\Presenter\IAsyncLoadHorseRaceSummaryPresenter.cs" /> | |
110 | 111 | <Compile Include="App\Adaptor\Presenter\ILoadHorseRaceSummaryPresenter.cs" /> |
112 | + <Compile Include="App\Adaptor\Presenter\AsyncLoadHorseRaceSummaryPresenter.cs" /> | |
111 | 113 | <Compile Include="App\AppConfig.cs" /> |
112 | 114 | <Compile Include="App\AppConst.cs" /> |
113 | 115 | <Compile Include="App\Adaptor\Gateway\UI\ManualHorseListProxy.cs" /> |
114 | 116 | <Compile Include="App\Domain\Model\Logic\IUmaLogic.cs" /> |
115 | 117 | <Compile Include="App\Domain\Model\Logic\IUmaRaceLogic.cs" /> |
118 | + <Compile Include="App\Domain\UseCase\Response\AsyncLoadHorseRaceSummaryResponse.cs" /> | |
119 | + <Compile Include="Infra\Adaptor\Presenter\IAsyncPresenter.cs" /> | |
120 | + <Compile Include="Infra\Helper\TaskHelper.cs" /> | |
121 | + <Compile Include="App\Domain\UseCase\Interactor\IAsyncLoadHorseRaceSummaryInteractor.cs" /> | |
122 | + <Compile Include="App\Domain\UseCase\Interactor\AsyncLoadHorseRaceSummaryInteractor.cs" /> | |
123 | + <Compile Include="App\Domain\UseCase\Request\AsyncLoadHorseRaceSummaryRequest.cs" /> | |
116 | 124 | <Compile Include="Infra\Adaptor\Command\CompositeCommand.cs" /> |
125 | + <Compile Include="Infra\Adaptor\Controller\Handler\IAsyncRequestHandler.cs" /> | |
126 | + <Compile Include="Infra\Adaptor\Controller\Handler\IRoutingMap.cs" /> | |
127 | + <Compile Include="Infra\Adaptor\Controller\Handler\AsyncUseCaseRouter.cs" /> | |
128 | + <Compile Include="Infra\Adaptor\Controller\Handler\IAsyncUseCaseRouter.cs" /> | |
129 | + <Compile Include="Infra\Adaptor\Controller\Handler\AbstractUseCaseRouter.cs" /> | |
117 | 130 | <Compile Include="Infra\Adaptor\Gateway\UI\IShowChildWindoProxy.cs" /> |
118 | 131 | <Compile Include="Infra\Adaptor\Gateway\UI\ShowChildWindowProxy.cs" /> |
119 | 132 | <Compile Include="Infra\Domain\LogicException.cs" /> |
@@ -175,6 +188,7 @@ | ||
175 | 188 | <Compile Include="Infra\Adaptor\Controller\Handler\IRequestHandler.cs" /> |
176 | 189 | <Compile Include="Infra\Domain\Translator\ChildPropertyDescriptor.cs" /> |
177 | 190 | <Compile Include="Infra\Domain\Translator\NestedTypeDescriptor.cs" /> |
191 | + <Compile Include="Infra\Domain\UseCase\IAsyncUseCaseInteractor.cs" /> | |
178 | 192 | <Compile Include="Infra\Helper\BeanHelper.cs" /> |
179 | 193 | <Compile Include="Infra\Helper\CodeHelper.cs" /> |
180 | 194 | <Compile Include="Infra\Helper\LogicHelper .cs" /> |
@@ -230,6 +244,7 @@ | ||
230 | 244 | <ItemGroup> |
231 | 245 | <Content Include="Infra\Adaptor\Command\README.txt" /> |
232 | 246 | <EmbeddedResource Include="Resources\Sql\NUmaRaceDao_findChakudosuuSummary.sql" /> |
247 | + <EmbeddedResource Include="Resources\Sql\NUmaRaceDao_findChakudosuuSummaryAsync.sql" /> | |
233 | 248 | <Content Include="ToDo.txt" /> |
234 | 249 | </ItemGroup> |
235 | 250 | <ItemGroup /> |