/// <summary>
 /// Initializes a new instance of the <see cref="EventViewerDialog"/> class.
 /// </summary>
 /// <param name="taskEvent">The <see cref="TaskEvent"/> to show initially.</param>
 /// <param name="log">The <see cref="TaskEventLog"/> for the task.</param>
 public EventViewerDialog(TaskEvent taskEvent = null, TaskEventLog log = null)
 {
     InitializeComponent();
     if (taskEvent != null)
     {
         Initialize(taskEvent, log);
     }
 }
        private ListViewItem BuildItem(TaskEvent item)
        {
            var kwds = new List <string>(item.EventRecord.KeywordsDisplayNames);

            return(new ListViewItem(new string[] { item.Level, item.TimeCreated.ToString(), item.EventId.ToString(),
                                                   item.TaskCategory, item.OpCode, item.ActivityId.ToString(), string.Join(", ", kwds.ToArray()), "TaskScheduler",
                                                   item.UserId.Translate(typeof(System.Security.Principal.NTAccount)).ToString(), item.EventRecord.LogName,
                                                   item.EventRecord.MachineName, item.ProcessId.ToString(), item.EventRecord.ThreadId.ToString() },
                                    item.EventRecord.Level.GetValueOrDefault(0))
            {
                Tag = item
            });
        }
 private void SelectItemChanged(int newSelIdx)
 {
     if (selectedIndex != newSelIdx)
     {
         selectedIndex = newSelIdx;
         ListViewItem lvi = vcache[selectedIndex];
         if (lvi != null)
         {
             TaskEvent ev = lvi.Tag as TaskEvent;
             historyDetailView.TaskEvent = ev;
             historyDetailTitleText.Text = ev == null ? string.Empty : string.Format(EditorProperties.Resources.EventDetailHeader, ev.EventId);
         }
     }
 }
        /// <summary>
        /// Initializes the dialog with the specified task event.
        /// </summary>
        /// <param name="taskEvent">The <see cref="TaskEvent"/> to show initially.</param>
        /// <param name="log">The <see cref="TaskEventLog"/> for the task.</param>
        public void Initialize(TaskEvent taskEvent, TaskEventLog log = null)
        {
            if (taskEvent == null)
            {
                throw new ArgumentNullException("taskEvent");
            }

            if (log != null)
            {
                eventEnum = log.GetEnumerator() as TaskEventEnumerator;
                eventEnum.Seek(CurrentEvent.EventRecord.Bookmark);
            }
            else
            {
                eventEnum = null;
            }
            CurrentEvent = taskEvent;
        }
Пример #5
0
        private void Watcher_EventRecordWritten(object sender, EventRecordWrittenEventArgs e)
        {
            try
            {
                var taskEvent = new TaskEvent(e.EventRecord);
                System.Diagnostics.Debug.WriteLine("Task event: " + taskEvent.ToString());

                // Get the task name and folder
                if (string.IsNullOrEmpty(taskEvent.TaskPath))
                {
                    return;
                }
                int    cpos = taskEvent.TaskPath.LastIndexOf('\\');
                string name = taskEvent.TaskPath.Substring(cpos + 1);
                string fld  = taskEvent.TaskPath.Substring(0, cpos + 1);

                // Check folder and name filters
                if (!string.IsNullOrEmpty(Filter.TaskName) && string.Compare(Filter.TaskName, taskEvent.TaskPath, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    if (Filter.Wildcard != null && !Filter.Wildcard.IsMatch(name))
                    {
                        return;
                    }
                    if (IncludeSubfolders && !fld.StartsWith(folder, StringComparison.OrdinalIgnoreCase))
                    {
                        return;
                    }
                    if (!IncludeSubfolders && string.Compare(folder, fld, StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        return;
                    }
                }

                OnEventRecorded(this, new TaskEventArgs(taskEvent, TaskService));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"{nameof(Watcher_EventRecordWritten)} has failed. Error: {ex.ToString()}");
            }
        }
        private ListViewItem BuildItem(TaskEvent item)
        {
            var kwds = new List <string>(item.EventRecord.KeywordsDisplayNames);
            var i    = new ListViewItem(new ListViewItem.ListViewSubItem[] {
                BuildSubItem(item.Level),
                BuildSubItem(item.TimeCreated),
                BuildSubItem(item.EventId),
                BuildSubItem(item.TaskCategory),
                BuildSubItem(item.OpCode),
                BuildSubItem(item.ActivityId),
                BuildSubItem(string.Join(", ", kwds.ToArray())),
                BuildSubItem("TaskScheduler"),
                BuildSubItem(item.UserId.Translate(typeof(System.Security.Principal.NTAccount))),
                BuildSubItem(item.EventRecord.LogName),
                BuildSubItem(item.EventRecord.MachineName),
                BuildSubItem(item.ProcessId),
                BuildSubItem(item.EventRecord.ThreadId)
            }, item.EventRecord.Level.GetValueOrDefault(0))
            {
                Tag = item
            };

            return(i);
        }
Пример #7
0
 internal TaskEventArgs([NotNull] TaskEvent evt, TaskService ts = null)
 {
     TaskEvent   = evt;
     TaskPath    = evt.TaskPath;
     taskService = ts;
 }