最初のタイムインと最後のタイムアウトの取得次の日を過ぎると、バイオメトリック読み取りで構造化された最初のエントリと最後のエントリが取得できません。でる。私はこの
新しい生体認証をペアリングするlinqを使用するコレクション
IEnumerable<biometric> dtrs = new List<biometric>()
{
new biometric{Id = 1, InOut = 0, DateTime = new DateTime(2013,5,5,8,0,0)},
new biometric{Id = 2, InOut = 0, DateTime = new DateTime(2013,5,5,8,0,5)},
new biometric{Id = 3, InOut = 0, DateTime = new DateTime(2013,5,5,8,1,0)},
new biometric{Id = 4, InOut = 0, DateTime = new DateTime(2013,5,5,8,2,0)},
//here is my problem getting this paired to
new biometric{Id = 5, InOut = 0, DateTime = new DateTime(2013,5,5,18,0,0)},
new biometric{Id = 1, InOut = 1, DateTime = new DateTime(2013,5,5,18,0,0)},
new biometric{Id = 2, InOut = 1, DateTime = new DateTime(2013,5,5,17,5,5)},
new biometric{Id = 3, InOut = 1, DateTime = new DateTime(2013,5,5,17,5,10)},
new biometric{Id = 4, InOut = 1, DateTime = new DateTime(2013,5,5,17,10,0)},
//this Entry here
new biometric{Id = 5, InOut = 1, DateTime = new DateTime(2013,5,6,3,0,0)},
};
var asd = dtrs.GroupBy(x => new { x.Id, x.DateTime.Date }, (key, group) => new
{
Key1 = key.Date,
Key2 = key.Id,
Result = group.OrderBy(a => a.DateTime).ToList()
})
//checks if the grouping result has one timein and 1 timeout or more
.Where(a => a.Result.Where(z => z.InOut == 1).Count() >= 1 && a.Result.Where(z => z.InOut == 0).Count() >= 1)
.Select(a => new dtr() { employeeId = a.Key2, TimeIn = a.Result.FirstOrDefault(b => b.InOut == 1).DateTime, TimeOut = a.Result.LastOrDefault(c => c.InOut == 0).DateTime });
private class biometric
{
public int Id { get; set; }
public DateTime DateTime { get; set; }
public int InOut { get; set; }
}
private class dtr
{
public int employeeId { get; set; }
public DateTime TimeIn { get; set; }
public DateTime TimeOut { get; set; }
}
:で、タイムアウト時間が同じ日にある場合でも、私はここ
は私のコード..ですそれは私が望むようにフォーマットされ得ることができます{ID = 5、InOutの= 0、日時が新しい=日時(2013,5,5,18,0,0)}、この新しい生体{ID = 5から
、InOutの= 1、日時=新しいDateTime(2013,5,6,3,0,0)}、
回避策や提案はありますか?
ことができません 'Id'と' InOut'によって順序によって、あなただけのグループ? –
いいえ..毎日それを取得していました。 –