Ejemplo n.º 1
0
        private void RecalcFilterBox()
        {
            txtFilter.Text = "";
            lstCheckBox.Items.Clear();

            var qfDisplay = new ModelFilterHelper().CreateDisplayOfQuickFilters(_filter);

            qfDisplay.ForEach(p =>
            {
                lstCheckBox.Items.Add(p, true);
            });

            QuickFilterValues remove = null;

            _filter.QuickFilters.ForEach(p =>
            {
                if (p.ToBeModifiedInFilterEditor)
                {
                    txtFilter.Text          = p.FilterValue;
                    cboColumn.SelectedIndex = cboColumn.FindStringExact(p.ColumnName);
                    radRegex.Checked        = true;
                    remove = p;
                }
            });

            if (remove != null)
            {
                _filter.QuickFilters.Remove(remove);
            }
        }
Ejemplo n.º 2
0
        private Dictionary <string, ColumnHeaderWrapper <SenseLogInfo> > CreateHeaders()
        {
            var helper  = new ModelFilterHelper();
            var headers = new Dictionary <string, ColumnHeaderWrapper <SenseLogInfo> >
            {
                { "Name", helper.CreateColumnHeaderWrapper <SenseLogInfo, string>("Name", "Name") },
                { "LogFilePath", helper.CreateColumnHeaderWrapper <SenseLogInfo, string>("Path", "LogFilePath") },
                { "LastModified", helper.CreateColumnHeaderWrapper <SenseLogInfo, DateTime?>("Modified date", "LastModified") }
            };

            return(headers);
        }
        private void RecalcFilterBox(ModelFilterValues filter)
        {
            txtFilter.Text = "";

            var qfDisplay = new ModelFilterHelper().CreateDisplayOfQuickFilters(filter);

            qfDisplay.ForEach(p =>
            {
                txtFilter.Text += p + Environment.NewLine;
            });


            dteFrom.Value       = filter.DateFrom.Date;
            dteFromTime.Value   = filter.DateFrom;
            dteTo.Value         = filter.DateTo.Date;
            dteToTime.Value     = filter.DateTo;
            chkUseDate.Checked  = filter.UseDate;
            _currentGrid.Filter = filter;
        }
        private async Task <bool> LoadStuff()
        {
            var helper  = new ModelFilterHelper();
            var headers = new Dictionary <string, ColumnHeaderWrapper <EventLogEntryShort> >
            {
                { "Level", helper.CreateColumnHeaderWrapper <EventLogEntryShort, string>("Level", "Level") },
                { "Source", helper.CreateColumnHeaderWrapper <EventLogEntryShort, string>("Source", "Source") },
                { "Event Id", helper.CreateColumnHeaderWrapper <EventLogEntryShort, long?>("Event Id", "InstanceId") },
                { "Message", helper.CreateColumnHeaderWrapper <EventLogEntryShort, string>("Message", "Message").IgnoreInGrid() },
                { "User", helper.CreateColumnHeaderWrapper <EventLogEntryShort, string>("User", "User").IgnoreInGrid() },
                { "Date and time", helper.CreateColumnHeaderWrapper <EventLogEntryShort, DateTime?>("Date and time", "Logged") }
            };


            List <EventLogEntryShort> res = new List <EventLogEntryShort>();

            _gridAndData = new Dictionary <string, DataWrapper>();



            if (Switchboard.Instance.LogCollectorOutput?.GroupedServerInfo != null)
            {
                //var splash = SplashManager.Loader.ShowFloatingSplash(this,"Opening Windows logs..");
                ShowSplash("Opening Windows logs..");
                try
                {
                    _validationErrors = new List <string>();
                    res = await Switchboard.Instance.LogCollectorOutput.WindowsEventLogItems(JsonErrors);

                    if (_validationErrors.Any())
                    {
                        string err = _validationErrors.Take(5).Aggregate((curr, next) => curr + "\r\n" + next);
                        Mbox.Show($"We had problems parsing this Windows event log. We found {_validationErrors.Count} errors\r\n\r\n{err}", "Problems in parsing Windows event log");
                    }
                }
                catch (Exception e)
                {
                    Mbox.Show($"The Windows log is invalid.\r\n\r\n{e}", "Sorry we can't read this");
                }
                finally
                {
                    HideSplash();
                }
            }

            if (res == null)
            {
                return(false);
            }
            foreach (var item in res)
            {
                if (item.LogName == null)
                {
                    continue;
                }
                if (!_gridAndData.ContainsKey(item.LogName))
                {
                    _gridAndData.Add(item.LogName, new DataWrapper());
                    _gridAndData[item.LogName].GridAndDataWrapper.Data    = new List <EventLogEntryShort>();
                    _gridAndData[item.LogName].GridAndDataWrapper.Headers = headers;
                }
                _gridAndData[item.LogName].GridAndDataWrapper.Data.Add(item);
            }
            InvokeGrid(CtrlGridTabs.SelectedTab);
            return(true);
        }