Example #1
0
    //----------------------------------------------------------------------------------------------
    /// <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);
    }
Example #2
0
    //----------------------------------------------------------------------------------------------
    /// <summary>XML形式のドキュメントを作成する</summary>
    /// <return>XMLドキュメント</return>
    public XmlDocument GetXml(DateTime from, DateTime to)
    {
        XmlDocument   xml     = new XmlDocument();
        EventReader   reader  = EventReader.getInstance();
        List <string> xmlList = reader.GetXmlList(from, to);
        StringBuilder sb      = new StringBuilder();

        sb.Append(Constants.XML_HEADER);
        foreach (string element in xmlList)
        {
            sb.Append(element);
            sb.Append("\r\n");
        }
        sb.Append(Constants.XML_FOOTER);
        xml.LoadXml(sb.ToString());
        return(xml);
    }