/// <summary> /// Loads data into the properties controls /// </summary> private void LoadData() { try { // load the selected row if (_eventsListView.SelectedItems.Count == 0) { return; } EventLogRecord el = _eventsListView.SelectedItems[0].Tag as EventLogRecord; if (el != null) { EventAPI.EventLogRecord eventRecord = el.Record; DateTime eventTime = EventUtils.Time_T2DateTime(eventRecord.dwEventDateTime); eventTime = eventTime.ToLocalTime(); // setup fields tbDate.Text = eventTime.ToString("MM/dd/yyyy"); tbTime.Text = eventTime.ToLongTimeString();// ToString("hh:mm:ss"); tbType.Text = eventRecord.pszEventType; tbUser.Text = eventRecord.pszUser; tbComputer.Text = eventRecord.pszComputer; tbSource.Text = eventRecord.pszEventSource; tbCategory.Text = eventRecord.pszEventCategory; tbEventId.Text = eventRecord.dwEventSourceId.ToString(); tbDescription.Text = eventRecord.pszDescription; } } catch (Exception ex) { Logger.Log(ex.ToString(), Logger.LogLevel.Error); } }
private void btnCopy_Click(object sender, EventArgs e) { try { string eventData = "Event Type: {0}" + "\n" + "Event Source: {1}" + "\n" + "Event Category: {2}" + "\n" + "Event ID: {3}" + "\n" + "Date: {4}" + "\n" + "Time: {5}" + "\n" + "User: {6}" + "\n" + "Computer: {7}" + "\n" + "Description:" + "\n" + "{8}"; string clipBoardData = string.Empty; // load the selected row if (_eventsListView.SelectedItems.Count == 0) { return; } EventLogRecord el = _eventsListView.SelectedItems[0].Tag as EventLogRecord; if (el != null) { EventAPI.EventLogRecord eventRecord = el.Record; DateTime eventTime = EventUtils.Time_T2DateTime(eventRecord.dwEventDateTime); eventTime = eventTime.ToLocalTime(); // copy fields to clipboard clipBoardData = string.Format(eventData, eventRecord.pszEventType, eventRecord.pszEventSource, eventRecord.pszEventCategory, eventRecord.dwEventSourceId.ToString(), eventTime.ToString("MM/dd/yyyy"), eventTime.ToString("hh:mm:ss"), eventRecord.pszUser, eventRecord.pszComputer, eventRecord.pszDescription); } if (clipBoardData != "") { if (Clipboard.ContainsText()) { Clipboard.Clear(); } Clipboard.SetText(clipBoardData); } } catch (Exception ex) { Logger.Log(ex.ToString(), Logger.LogLevel.Error); } }