//---------------------------------------------------------------------------------------------- /// <summary>ログオン、ログオフ時刻情報のリストを取得する</summary> /// <param name="from">検索期間の開始</param> /// <param name="to">検索基幹の終了</param> /// <return>ログオン、ログオフ時刻情報のリスト</return> public List <LogonAndLogoff> getLogonAndLogoffRecords(DateTime from, DateTime to) { EventReader reader = EventReader.getInstance(); List <LogonRecord> records = reader.GetLogonData(from, to); records.Sort(); List <LogonAndLogoff> list = new List <LogonAndLogoff>(); DateTime max = DateTime.MinValue; DateTime min = DateTime.MaxValue; foreach (LogonRecord record in records) { if (record.EventId == 2) { min = record.EventDatetime; } else if (record.EventId == 4) { max = record.EventDatetime; LogonAndLogoff dailyResult = new LogonAndLogoff(); dailyResult.UserId = record.UserId; dailyResult.StartDatetime = min; dailyResult.EndDatetime = max; if (min < DateTime.MaxValue && max > DateTime.MinValue) { list.Add(dailyResult); } min = DateTime.MinValue; max = DateTime.MaxValue; } } return(list); }