回答編集履歴
4
不要なものを削除
test
CHANGED
@@ -30,242 +30,216 @@
|
|
30
30
|
|
31
31
|
{
|
32
32
|
|
33
|
-
|
33
|
+
/// <summary>
|
34
|
+
|
34
|
-
|
35
|
+
/// 個人履歴(Excel)出力
|
36
|
+
|
37
|
+
/// </summary>
|
38
|
+
|
35
|
-
class res
|
39
|
+
public class HistoryGenerator : BaseReportGenerator
|
36
40
|
|
37
41
|
{
|
38
42
|
|
43
|
+
/// <summary>
|
44
|
+
|
45
|
+
/// コンストラクタ
|
46
|
+
|
47
|
+
/// </summary>
|
48
|
+
|
49
|
+
public ReportGeneratorService(DbSet dbcontext)
|
50
|
+
|
39
|
-
|
51
|
+
: base(dbcontext)
|
52
|
+
|
40
|
-
|
53
|
+
{}
|
54
|
+
|
41
|
-
public
|
55
|
+
public void Set()
|
56
|
+
|
42
|
-
|
57
|
+
{
|
58
|
+
|
59
|
+
DateTime start = new DateTime(1900, 1, 1);
|
60
|
+
|
61
|
+
DateTime next = new DateTime(1900, 1, 1);
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
int i_c = 1;
|
66
|
+
|
67
|
+
// 対象を設定します(今回は仮にAAAとします)
|
68
|
+
|
69
|
+
var target = (from t in DbContext.CHANGE_HIS
|
70
|
+
|
71
|
+
where t.name == "AAA"
|
72
|
+
|
73
|
+
orderby t.date ascending
|
74
|
+
|
43
|
-
|
75
|
+
select t).FirstOrDefault();
|
76
|
+
|
44
|
-
|
77
|
+
// CHANGE_HISの異動数を取得します
|
78
|
+
|
79
|
+
var m_c = (from m DbContext.CHANGE_HIS
|
80
|
+
|
81
|
+
where m.name == target.name
|
82
|
+
|
83
|
+
&& m.eve != "out"
|
84
|
+
|
85
|
+
select m).Count();
|
86
|
+
|
87
|
+
// outした対象のdateを取得します
|
88
|
+
|
89
|
+
var loss = (from l in DbContext.CHANGE_HIS
|
90
|
+
|
91
|
+
where l.name = target.name
|
92
|
+
|
93
|
+
&& l.eve = "out"
|
94
|
+
|
95
|
+
orderby l.date ascending
|
96
|
+
|
97
|
+
select l.date).FirstOrDefault();
|
98
|
+
|
99
|
+
// 出力対象の経歴コレクションの作成
|
100
|
+
|
101
|
+
var add_col = (from a in DbContext.TEAM_HIS
|
102
|
+
|
103
|
+
orderby a.date ascending
|
104
|
+
|
105
|
+
select a)
|
106
|
+
|
107
|
+
// AddRange関数を使用するためにList型にキャスト
|
108
|
+
|
109
|
+
List<TEAM_HIS> col = new List<TEAM_HIS>();
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
// 履歴のコレクションを作成
|
114
|
+
|
115
|
+
foreach (var forlist in t_col)
|
116
|
+
|
117
|
+
{
|
118
|
+
|
119
|
+
// カウントが1の時はnextが設定されていないため
|
120
|
+
|
121
|
+
if(i_c == 1);
|
122
|
+
|
123
|
+
{
|
124
|
+
|
125
|
+
start = (from s in DbContext.CHANGE_HIS
|
126
|
+
|
127
|
+
where s.team = forlist.team
|
128
|
+
|
129
|
+
&& s.date >= start
|
130
|
+
|
131
|
+
orderby s.date, no ascending
|
132
|
+
|
133
|
+
select s.date).FirstOrDefault();
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
else
|
138
|
+
|
139
|
+
{
|
140
|
+
|
141
|
+
start = next;
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
// カウントがMAXでない場合は計算する
|
146
|
+
|
147
|
+
if (m_c >= i_c)
|
148
|
+
|
149
|
+
{
|
150
|
+
|
151
|
+
// TEAMの移動が無い場合は次の時間をセット(ただし1回目は除く)
|
152
|
+
|
153
|
+
if(i_c != 1 & start == next)
|
154
|
+
|
155
|
+
{
|
156
|
+
|
157
|
+
next = (from n in DbContext.CHANGE_HIS
|
158
|
+
|
159
|
+
where n.team == forlist.team
|
160
|
+
|
45
|
-
|
161
|
+
&& n.date > start
|
162
|
+
|
46
|
-
|
163
|
+
orderby n.date, n.team ascending
|
164
|
+
|
165
|
+
select n.date).FirstOrDefault();
|
166
|
+
|
167
|
+
}else{
|
168
|
+
|
169
|
+
next = (from n in DbContext.CHANGE_HIS
|
170
|
+
|
171
|
+
where n.team == forlist.team
|
172
|
+
|
173
|
+
&& n.date >= start
|
174
|
+
|
175
|
+
orderby n.date, n.team ascending
|
176
|
+
|
177
|
+
select n.date).FirstOrDefault();
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
}else{
|
182
|
+
|
47
|
-
|
183
|
+
next = DateTime.Now;
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
// TEAM毎の個人履歴をセット
|
188
|
+
|
189
|
+
addcol = from a in DbContext.TEAM_HIS
|
190
|
+
|
191
|
+
where a.team == forlist.team
|
192
|
+
|
193
|
+
&& a.start < next
|
194
|
+
|
195
|
+
&& a.start >= start
|
196
|
+
|
197
|
+
&& a.start < loss
|
198
|
+
|
199
|
+
orderby a.start ascending
|
200
|
+
|
201
|
+
select a;
|
202
|
+
|
203
|
+
// 個人履歴に追加
|
204
|
+
|
205
|
+
if(addcol != null) col.AddRange(addcol);
|
206
|
+
|
207
|
+
++i_c;
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
foreach (var his in col)
|
216
|
+
|
217
|
+
{
|
218
|
+
|
219
|
+
var hist = new History(target);
|
220
|
+
|
221
|
+
hist.Name = target.name;
|
222
|
+
|
223
|
+
hist.Team = his.team;
|
224
|
+
|
225
|
+
hist.Project = his.project;
|
226
|
+
|
227
|
+
hist.Start = his.start;
|
228
|
+
|
229
|
+
hist.End = his.end;
|
230
|
+
|
231
|
+
target.Histories.Add(hist);
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
target.ColStartPos = cols;
|
236
|
+
|
237
|
+
cols += target.OutputWidth() + 1;
|
238
|
+
|
239
|
+
}
|
48
240
|
|
49
241
|
}
|
50
242
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
/// <summary>
|
60
|
-
|
61
|
-
/// 個人履歴(Excel)出力
|
62
|
-
|
63
|
-
/// </summary>
|
64
|
-
|
65
|
-
public class HistoryGenerator : BaseReportGenerator
|
66
|
-
|
67
|
-
{
|
68
|
-
|
69
|
-
/// <summary>
|
70
|
-
|
71
|
-
/// コンストラクタ
|
72
|
-
|
73
|
-
/// </summary>
|
74
|
-
|
75
|
-
public ReportGeneratorService(DbSet dbcontext)
|
76
|
-
|
77
|
-
: base(dbcontext)
|
78
|
-
|
79
|
-
{}
|
80
|
-
|
81
|
-
public void Set()
|
82
|
-
|
83
|
-
{
|
84
|
-
|
85
|
-
DateTime start = new DateTime(1900, 1, 1);
|
86
|
-
|
87
|
-
DateTime next = new DateTime(1900, 1, 1);
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
int i_c = 1;
|
92
|
-
|
93
|
-
// 対象を設定します(今回は仮にAAAとします)
|
94
|
-
|
95
|
-
var target = (from t in DbContext.CHANGE_HIS
|
96
|
-
|
97
|
-
where t.name == "AAA"
|
98
|
-
|
99
|
-
orderby t.date ascending
|
100
|
-
|
101
|
-
select t).FirstOrDefault();
|
102
|
-
|
103
|
-
// CHANGE_HISの異動数を取得します
|
104
|
-
|
105
|
-
var m_c = (from m DbContext.CHANGE_HIS
|
106
|
-
|
107
|
-
where m.name == target.name
|
108
|
-
|
109
|
-
&& m.eve != "out"
|
110
|
-
|
111
|
-
select m).Count();
|
112
|
-
|
113
|
-
// outした対象のdateを取得します
|
114
|
-
|
115
|
-
var loss = (from l in DbContext.CHANGE_HIS
|
116
|
-
|
117
|
-
where l.name = target.name
|
118
|
-
|
119
|
-
&& l.eve = "out"
|
120
|
-
|
121
|
-
orderby l.date ascending
|
122
|
-
|
123
|
-
select l.date).FirstOrDefault();
|
124
|
-
|
125
|
-
// 出力対象の経歴コレクションの作成
|
126
|
-
|
127
|
-
var add_col = (from a in DbContext.TEAM_HIS
|
128
|
-
|
129
|
-
orderby a.date ascending
|
130
|
-
|
131
|
-
select a)
|
132
|
-
|
133
|
-
// AddRange関数を使用するためにList型にキャスト
|
134
|
-
|
135
|
-
List<TEAM_HIS> col = new List<TEAM_HIS>();
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
// 履歴のコレクションを作成
|
140
|
-
|
141
|
-
foreach (var forlist in t_col)
|
142
|
-
|
143
|
-
{
|
144
|
-
|
145
|
-
// カウントが1の時はnextが設定されていないため
|
146
|
-
|
147
|
-
if(i_c == 1);
|
148
|
-
|
149
|
-
{
|
150
|
-
|
151
|
-
start = (from s in DbContext.CHANGE_HIS
|
152
|
-
|
153
|
-
where s.team = forlist.team
|
154
|
-
|
155
|
-
&& s.date >= start
|
156
|
-
|
157
|
-
orderby s.date, no ascending
|
158
|
-
|
159
|
-
select s.date).FirstOrDefault();
|
160
|
-
|
161
|
-
}
|
162
|
-
|
163
|
-
else
|
164
|
-
|
165
|
-
{
|
166
|
-
|
167
|
-
start = next;
|
168
|
-
|
169
|
-
}
|
170
|
-
|
171
|
-
// カウントがMAXでない場合は計算する
|
172
|
-
|
173
|
-
if (m_c >= i_c)
|
174
|
-
|
175
|
-
{
|
176
|
-
|
177
|
-
// TEAMの移動が無い場合は次の時間をセット(ただし1回目は除く)
|
178
|
-
|
179
|
-
if(i_c != 1 & start == next)
|
180
|
-
|
181
|
-
{
|
182
|
-
|
183
|
-
next = (from n in DbContext.CHANGE_HIS
|
184
|
-
|
185
|
-
where n.team == forlist.team
|
186
|
-
|
187
|
-
&& n.date > start
|
188
|
-
|
189
|
-
orderby n.date, n.team ascending
|
190
|
-
|
191
|
-
select n.date).FirstOrDefault();
|
192
|
-
|
193
|
-
}else{
|
194
|
-
|
195
|
-
next = (from n in DbContext.CHANGE_HIS
|
196
|
-
|
197
|
-
where n.team == forlist.team
|
198
|
-
|
199
|
-
&& n.date >= start
|
200
|
-
|
201
|
-
orderby n.date, n.team ascending
|
202
|
-
|
203
|
-
select n.date).FirstOrDefault();
|
204
|
-
|
205
|
-
}
|
206
|
-
|
207
|
-
}else{
|
208
|
-
|
209
|
-
next = DateTime.Now;
|
210
|
-
|
211
|
-
}
|
212
|
-
|
213
|
-
// TEAM毎の個人履歴をセット
|
214
|
-
|
215
|
-
addcol = from a in DbContext.TEAM_HIS
|
216
|
-
|
217
|
-
where a.team == forlist.team
|
218
|
-
|
219
|
-
&& a.start < next
|
220
|
-
|
221
|
-
&& a.start >= start
|
222
|
-
|
223
|
-
&& a.start < loss
|
224
|
-
|
225
|
-
orderby a.start ascending
|
226
|
-
|
227
|
-
select a;
|
228
|
-
|
229
|
-
// 個人履歴に追加
|
230
|
-
|
231
|
-
if(addcol != null) col.AddRange(addcol);
|
232
|
-
|
233
|
-
++i_c;
|
234
|
-
|
235
|
-
}
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
foreach (var his in col)
|
242
|
-
|
243
|
-
{
|
244
|
-
|
245
|
-
var hist = new History(target);
|
246
|
-
|
247
|
-
hist.Name = target.name;
|
248
|
-
|
249
|
-
hist.Team = his.team;
|
250
|
-
|
251
|
-
hist.Project = his.project;
|
252
|
-
|
253
|
-
hist.Start = his.start;
|
254
|
-
|
255
|
-
hist.End = his.end;
|
256
|
-
|
257
|
-
target.Histories.Add(hist);
|
258
|
-
|
259
|
-
}
|
260
|
-
|
261
|
-
target.ColStartPos = cols;
|
262
|
-
|
263
|
-
cols += target.OutputWidth() + 1;
|
264
|
-
|
265
|
-
}
|
266
|
-
|
267
|
-
}
|
268
|
-
|
269
243
|
}
|
270
244
|
|
271
245
|
```
|
3
インデントがあってなかったので修正
test
CHANGED
@@ -122,13 +122,13 @@
|
|
122
122
|
|
123
123
|
select l.date).FirstOrDefault();
|
124
124
|
|
125
|
-
|
125
|
+
// 出力対象の経歴コレクションの作成
|
126
|
-
|
126
|
+
|
127
|
-
var add_col = (from
|
127
|
+
var add_col = (from a in DbContext.TEAM_HIS
|
128
|
-
|
128
|
+
|
129
|
-
orderby
|
129
|
+
orderby a.date ascending
|
130
|
-
|
130
|
+
|
131
|
-
select
|
131
|
+
select a)
|
132
132
|
|
133
133
|
// AddRange関数を使用するためにList型にキャスト
|
134
134
|
|
2
抜けや書きミスを修正
test
CHANGED
@@ -122,9 +122,9 @@
|
|
122
122
|
|
123
123
|
select l.date).FirstOrDefault();
|
124
124
|
|
125
|
-
|
125
|
+
// 出力対象の経歴コレクションの作成
|
126
|
-
|
126
|
+
|
127
|
-
var
|
127
|
+
var add_col = (from t in DbContext.TEAM_HIS
|
128
128
|
|
129
129
|
orderby t.date ascending
|
130
130
|
|
1
AddからAddRangeに変更
test
CHANGED
@@ -122,39 +122,87 @@
|
|
122
122
|
|
123
123
|
select l.date).FirstOrDefault();
|
124
124
|
|
125
|
+
// 出力対象の経歴コレクションの作成
|
126
|
+
|
127
|
+
var t_col = (from t in DbContext.TEAM_HIS
|
128
|
+
|
129
|
+
orderby t.date ascending
|
130
|
+
|
131
|
+
select t)
|
132
|
+
|
133
|
+
// AddRange関数を使用するためにList型にキャスト
|
134
|
+
|
125
135
|
List<TEAM_HIS> col = new List<TEAM_HIS>();
|
126
136
|
|
127
137
|
|
128
138
|
|
129
139
|
// 履歴のコレクションを作成
|
130
140
|
|
131
|
-
foreach (var forlist in
|
141
|
+
foreach (var forlist in t_col)
|
132
142
|
|
133
143
|
{
|
134
144
|
|
145
|
+
// カウントが1の時はnextが設定されていないため
|
146
|
+
|
147
|
+
if(i_c == 1);
|
148
|
+
|
149
|
+
{
|
150
|
+
|
135
|
-
start = (from s in DbContext.CHANGE_HIS
|
151
|
+
start = (from s in DbContext.CHANGE_HIS
|
136
|
-
|
152
|
+
|
137
|
-
where s.team = forlist.team
|
153
|
+
where s.team = forlist.team
|
138
|
-
|
154
|
+
|
139
|
-
&& s.date >= start
|
155
|
+
&& s.date >= start
|
140
|
-
|
156
|
+
|
141
|
-
orderby s.date, no ascending
|
157
|
+
orderby s.date, no ascending
|
142
|
-
|
158
|
+
|
143
|
-
select s.date).FirstOrDefault();
|
159
|
+
select s.date).FirstOrDefault();
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
else
|
164
|
+
|
165
|
+
{
|
166
|
+
|
167
|
+
start = next;
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
// カウントがMAXでない場合は計算する
|
144
172
|
|
145
173
|
if (m_c >= i_c)
|
146
174
|
|
147
175
|
{
|
148
176
|
|
177
|
+
// TEAMの移動が無い場合は次の時間をセット(ただし1回目は除く)
|
178
|
+
|
179
|
+
if(i_c != 1 & start == next)
|
180
|
+
|
181
|
+
{
|
182
|
+
|
149
|
-
next = (from n in DbContext.CHANGE_HIS
|
183
|
+
next = (from n in DbContext.CHANGE_HIS
|
150
|
-
|
184
|
+
|
151
|
-
where n.team == forlist.team
|
185
|
+
where n.team == forlist.team
|
186
|
+
|
152
|
-
|
187
|
+
&& n.date > start
|
188
|
+
|
189
|
+
orderby n.date, n.team ascending
|
190
|
+
|
191
|
+
select n.date).FirstOrDefault();
|
192
|
+
|
193
|
+
}else{
|
194
|
+
|
195
|
+
next = (from n in DbContext.CHANGE_HIS
|
196
|
+
|
197
|
+
where n.team == forlist.team
|
198
|
+
|
153
|
-
&& n.date >= start
|
199
|
+
&& n.date >= start
|
154
|
-
|
200
|
+
|
155
|
-
orderby n.date, n.team ascending
|
201
|
+
orderby n.date, n.team ascending
|
156
|
-
|
202
|
+
|
157
|
-
select n.date).FirstOrDefault();
|
203
|
+
select n.date).FirstOrDefault();
|
204
|
+
|
205
|
+
}
|
158
206
|
|
159
207
|
}else{
|
160
208
|
|
@@ -162,45 +210,25 @@
|
|
162
210
|
|
163
211
|
}
|
164
212
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
213
|
// TEAM毎の個人履歴をセット
|
172
214
|
|
173
|
-
|
215
|
+
addcol = from a in DbContext.TEAM_HIS
|
174
|
-
|
216
|
+
|
175
|
-
|
217
|
+
where a.team == forlist.team
|
176
|
-
|
218
|
+
|
177
|
-
|
219
|
+
&& a.start < next
|
178
|
-
|
220
|
+
|
179
|
-
|
221
|
+
&& a.start >= start
|
180
|
-
|
222
|
+
|
181
|
-
|
223
|
+
&& a.start < loss
|
182
|
-
|
224
|
+
|
183
|
-
|
225
|
+
orderby a.start ascending
|
184
|
-
|
226
|
+
|
185
|
-
|
227
|
+
select a;
|
186
228
|
|
187
229
|
// 個人履歴に追加
|
188
230
|
|
189
|
-
|
190
|
-
|
191
|
-
List<result> results = new List<result>();
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
f
|
231
|
+
if(addcol != null) col.AddRange(addcol);
|
196
|
-
|
197
|
-
{
|
198
|
-
|
199
|
-
col.Add(col_for);
|
200
|
-
|
201
|
-
}
|
202
|
-
|
203
|
-
|
204
232
|
|
205
233
|
++i_c;
|
206
234
|
|