質問するログイン新規登録

回答編集履歴

4

不要なものを削除

2016/03/15 00:19

投稿

FitD
FitD

スコア40

answer CHANGED
@@ -14,19 +14,6 @@
14
14
 
15
15
  namespace A.Report.History
16
16
  {
17
-
18
- class result
19
- {
20
- public string Name;
21
- public string Team;
22
- public string Project;
23
- public DateTime Start;
24
- public DateTime end;
25
- }
26
-
27
-
28
-
29
-
30
17
  /// <summary>
31
18
  /// 個人履歴(Excel)出力
32
19
  /// </summary>
@@ -37,7 +24,7 @@
37
24
  /// </summary>
38
25
  public ReportGeneratorService(DbSet dbcontext)
39
26
  : base(dbcontext)
40
- {}
27
+ {}
41
28
  public void Set()
42
29
  {
43
30
  DateTime start = new DateTime(1900, 1, 1);

3

インデントがあってなかったので修正

2016/03/15 00:19

投稿

FitD
FitD

スコア40

answer CHANGED
@@ -60,10 +60,10 @@
60
60
  && l.eve = "out"
61
61
  orderby l.date ascending
62
62
  select l.date).FirstOrDefault();
63
-   // 出力対象の経歴コレクションの作成
63
+ // 出力対象の経歴コレクションの作成
64
- var add_col = (from t in DbContext.TEAM_HIS
64
+ var add_col = (from a in DbContext.TEAM_HIS
65
- orderby t.date ascending
65
+ orderby a.date ascending
66
- select t)
66
+ select a)
67
67
  // AddRange関数を使用するためにList型にキャスト
68
68
  List<TEAM_HIS> col = new List<TEAM_HIS>();
69
69
 

2

抜けや書きミスを修正

2016/03/15 00:14

投稿

FitD
FitD

スコア40

answer CHANGED
@@ -60,8 +60,8 @@
60
60
  && l.eve = "out"
61
61
  orderby l.date ascending
62
62
  select l.date).FirstOrDefault();
63
- // 出力対象の経歴コレクションの作成
63
+   // 出力対象の経歴コレクションの作成
64
- var t_col = (from t in DbContext.TEAM_HIS
64
+ var add_col = (from t in DbContext.TEAM_HIS
65
65
  orderby t.date ascending
66
66
  select t)
67
67
  // AddRange関数を使用するためにList型にキャスト

1

AddからAddRangeに変更

2016/03/14 05:02

投稿

FitD
FitD

スコア40

answer CHANGED
@@ -60,46 +60,60 @@
60
60
  && l.eve = "out"
61
61
  orderby l.date ascending
62
62
  select l.date).FirstOrDefault();
63
+ // 出力対象の経歴コレクションの作成
64
+ var t_col = (from t in DbContext.TEAM_HIS
65
+ orderby t.date ascending
66
+ select t)
67
+ // AddRange関数を使用するためにList型にキャスト
63
68
  List<TEAM_HIS> col = new List<TEAM_HIS>();
64
69
 
65
70
  // 履歴のコレクションを作成
66
- foreach (var forlist in DbContext.TEAM_HIS)
71
+ foreach (var forlist in t_col)
67
72
  {
73
+ // カウントが1の時はnextが設定されていないため
74
+ if(i_c == 1);
75
+ {
68
- start = (from s in DbContext.CHANGE_HIS
76
+ start = (from s in DbContext.CHANGE_HIS
69
- where s.team = forlist.team
77
+ where s.team = forlist.team
70
- && s.date >= start
78
+ && s.date >= start
71
- orderby s.date, no ascending
79
+ orderby s.date, no ascending
72
- select s.date).FirstOrDefault();
80
+ select s.date).FirstOrDefault();
81
+ }
82
+ else
83
+ {
84
+ start = next;
85
+ }
86
+ // カウントがMAXでない場合は計算する
73
87
  if (m_c >= i_c)
74
88
  {
89
+ // TEAMの移動が無い場合は次の時間をセット(ただし1回目は除く)
90
+ if(i_c != 1 & start == next)
91
+ {
75
- next = (from n in DbContext.CHANGE_HIS
92
+ next = (from n in DbContext.CHANGE_HIS
76
- where n.team == forlist.team
93
+ where n.team == forlist.team
94
+ && n.date > start
95
+ orderby n.date, n.team ascending
96
+ select n.date).FirstOrDefault();
97
+ }else{
98
+ next = (from n in DbContext.CHANGE_HIS
99
+ where n.team == forlist.team
77
- && n.date >= start
100
+ && n.date >= start
78
- orderby n.date, n.team ascending
101
+ orderby n.date, n.team ascending
79
- select n.date).FirstOrDefault();
102
+ select n.date).FirstOrDefault();
103
+ }
80
104
  }else{
81
105
  next = DateTime.Now;
82
106
  }
83
-
84
-
85
-
86
107
  // TEAM毎の個人履歴をセット
87
- var addcol = from a in DbContext.TEAM_HIS
108
+ addcol = from a in DbContext.TEAM_HIS
88
- where a.team == forlist.team
109
+ where a.team == forlist.team
89
- && a.start < next
110
+ && a.start < next
90
- && a.start >= start
111
+ && a.start >= start
91
- && a.start < loss
112
+ && a.start < loss
92
- orderby a.start ascending
113
+ orderby a.start ascending
93
- select a;
114
+ select a;
94
115
  // 個人履歴に追加
95
-
96
- List<result> results = new List<result>();
97
-
98
- foreach (var col_for in addcol)
116
+ if(addcol != null) col.AddRange(addcol);
99
- {
100
- col.Add(col_for);
101
- }
102
-
103
117
  ++i_c;
104
118
  }
105
119