Пример #1
0
        public void ApplyFilters(SearchObject InputData, ref LogObject selectedLog)
        {
            if (!string.IsNullOrWhiteSpace(InputData.Teller))
            {
                if (selectedLog != null)
                {
                    if (InputData.Teller != selectedLog.LogDetails.Teller)
                    {
                        selectedLog = null;
                    }
                }
            }
            if (!string.IsNullOrWhiteSpace(InputData.Transaction))
            {
                if (selectedLog != null)
                {
                    if (InputData.Transaction != selectedLog.LogDetails.Transaction)
                    {
                        selectedLog = null;
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(InputData.Branch))
            {
                if (selectedLog != null)
                {
                    if (InputData.Branch != selectedLog.LogDetails.Branch)
                    {
                        selectedLog = null;
                    }
                }
            }
        }
Пример #2
0
        private void ButtonSync_Click(object sender, EventArgs e)
        {
            if (CheckRequiredField())
            {
                if (listBoxLogs.Items.Count > 0)
                {
                    listBoxLogs.Items.Clear();
                }

                ClearFields();

                Cursor.Current = Cursors.WaitCursor;
                UtilityClass newUtility  = new UtilityClass();
                SearchObject InputObject = new SearchObject();
                Logs = new List <LogObject>();
                InputObject.LogName     = comboBoxLogs.Text;
                InputObject.LogComputer = comboBoxInstance.Text;
                InputObject.LogSource   = systemSource;

                if (checkBoxFilter.Checked)
                {
                    InputObject.StartTime = dateTimePickerStart.Value;
                    InputObject.EndTime   = dateTimePickerEnd.Value;

                    InputObject.Teller      = textBoxTeller.Text;
                    InputObject.Transaction = textBoxTransaction.Text;
                    InputObject.Branch      = textBoxBranch.Text;
                }
                else
                {
                    InputObject.StartTime = DateTime.MinValue;
                    InputObject.EndTime   = DateTime.MaxValue;
                }
                GetLogs(InputObject);
                //LoadLogs();
                Cursor.Current = Cursors.Default;
            }
            else
            {
                MessageBox.Show("Please enter the required field values", "Event Visualizer");
            }
        }
Пример #3
0
        public async void GetLogs(SearchObject InputData)
        {
            try
            {
                EventLog log = new EventLog(InputData.LogName, InputData.LogComputer, InputData.LogSource);

                await Task.Run(() =>
                {
                    for (int i = log.Entries.Count; i > 0; i--)
                    {
                        EventLogEntry entry = log.Entries[--i];
                        if (entry.Message.Length > 50 && entry.Source == InputData.LogSource && DateTime.Compare(entry.TimeWritten, InputData.StartTime) >= 0 && DateTime.Compare(InputData.EndTime, entry.TimeWritten) >= 0)
                        {
                            LogObject newLog   = new LogObject();
                            newLog.LogName     = InputData.LogName;
                            newLog.LogMessage  = entry.Message;
                            newLog.LogSource   = entry.Source;
                            newLog.LogEventId  = entry.InstanceId;
                            newLog.LogIndexId  = entry.Index;
                            newLog.LogLevel    = entry.EntryType;
                            newLog.LogTime     = Convert.ToDateTime(entry.TimeGenerated);
                            newLog.LogComputer = entry.MachineName;
                            newLog.LogDetails  = new HeaderObject();
                            SetLogDetails(newLog);
                            ApplyFilters(InputData, ref newLog);
                            if (newLog != null)
                            {
                                if (newLog.LogLevel == System.Diagnostics.EventLogEntryType.Information || newLog.LogLevel == System.Diagnostics.EventLogEntryType.Information)
                                {
                                    Logs.Add(newLog);
                                    UpdateUI(newLog);
                                }
                            }
                        }
                    }
                });
            }
            catch (Exception ex) { }
        }