Пример #1
0
        public SessionIoCommandListControl(Control container, DiagnosticsStateManager diagnosticsStateManager, DiagSession session)
        {
            Container = container;
            Session   = session;

            _updater = new ControlUpdater <IoCommandModel>(null, container)
            {
                ItemFilter = ItemFilter,
            };

            _updater.CreateSearchBox(10, 10);

            ShowDbTransactionKind = new CheckBox()
            {
                Parent     = container,
                Bounds     = new Rectangle(_updater.SearchBox.Right + 20, _updater.SearchBox.Top, 130, _updater.SearchBox.Height),
                Text       = "DB transactions",
                CheckAlign = ContentAlignment.MiddleLeft,
            };

            ShowDbTransactionKind.CheckedChanged += (s, a) => _updater.RefreshItems(true);

            ShowDbConnectionKind = new CheckBox()
            {
                Parent     = container,
                Bounds     = new Rectangle(ShowDbTransactionKind.Right + 20, ShowDbTransactionKind.Top, 130, ShowDbTransactionKind.Height),
                Text       = "DB connections",
                CheckAlign = ContentAlignment.MiddleLeft,
            };

            ShowDbConnectionKind.CheckedChanged += (s, a) => _updater.RefreshItems(true);

            HideVeryFast = new CheckBox()
            {
                Parent     = container,
                Bounds     = new Rectangle(ShowDbConnectionKind.Right + 20, ShowDbTransactionKind.Top, 130, ShowDbTransactionKind.Height),
                Text       = "Hide very fast",
                CheckAlign = ContentAlignment.MiddleLeft,
                Checked    = true,
            };

            HideVeryFast.CheckedChanged += (s, a) => _updater.RefreshItems(true);

            _updater.ListView.Anchor        = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
            _updater.ListView.Bounds        = new Rectangle(Container.ClientRectangle.Left, Container.ClientRectangle.Top + 40, Container.ClientRectangle.Width, Container.ClientRectangle.Height - 40);
            _updater.ListView.ItemActivate += ListView_ItemActivate;

            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "ID",
                AspectGetter = x => (x as IoCommandModel)?.StartEvent.Uid,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text                    = "Timestamp",
                AspectGetter            = x => (x as IoCommandModel)?.Timestamp,
                AspectToStringConverter = x => ((DateTime)x).ToString("HH:mm:ss.fff", CultureInfo.InvariantCulture),
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Context",
                AspectGetter = x => (x as IoCommandModel)?.Playbook.DiagContext.Name,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Process",
                AspectGetter = x => (x as IoCommandModel)?.Process.Name,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Kind",
                AspectGetter = x => (x as IoCommandModel)?.Process.KindToString(),
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Type",
                AspectGetter = x => (x as IoCommandModel)?.Process.Type,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Topic",
                AspectGetter = x => (x as IoCommandModel)?.Process.Topic,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Transaction",
                AspectGetter = x => (x as IoCommandModel)?.StartEvent.TransactionId,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Command kind",
                AspectGetter = x => (x as IoCommandModel)?.StartEvent.Kind.ToString(),
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Location",
                AspectGetter = x => (x as IoCommandModel)?.StartEvent.Location,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Path",
                AspectGetter = x => (x as IoCommandModel)?.StartEvent.Path,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text            = "Timeout",
                AspectGetter    = x => (x as IoCommandModel)?.StartEvent.TimeoutSeconds,
                TextAlign       = HorizontalAlignment.Right,
                HeaderTextAlign = HorizontalAlignment.Right,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text                    = "Elapsed",
                AspectGetter            = x => (x as IoCommandModel)?.Elapsed,
                AspectToStringConverter = x => x is TimeSpan ts ? FormattingHelpers.RightAlignedTimeSpanToString(ts) : null,
                TextAlign               = HorizontalAlignment.Right,
                HeaderTextAlign         = HorizontalAlignment.Right,
            });
Пример #2
0
        public LogListControl(Control container, DiagnosticsStateManager diagnosticsStateManager, DiagSession session)
        {
            Container = container;
            Session   = session;

            _updater = new ControlUpdater <LogModel>(null, Container)
            {
                ItemFilter = ItemFilter,
            };

            _updater.CreateSearchBox(10, 10);

            ShowDebugLevel = new CheckBox()
            {
                Parent     = container,
                Bounds     = new Rectangle(_updater.SearchBox.Right + 20, _updater.SearchBox.Top, 200, _updater.SearchBox.Height),
                Text       = "Show debug level",
                CheckAlign = ContentAlignment.MiddleLeft,
            };

            ShowDebugLevel.CheckedChanged += (s, a) => _updater.RefreshItems(true);

            _updater.ListView.Anchor        = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
            _updater.ListView.Bounds        = new Rectangle(Container.ClientRectangle.Left, Container.ClientRectangle.Top + 40, Container.ClientRectangle.Width, Container.ClientRectangle.Height - 40);
            _updater.ListView.ItemActivate += ListView_ItemActivate;

            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text                    = "Timestamp",
                AspectGetter            = x => (x as LogModel)?.Timestamp,
                AspectToStringConverter = x => ((DateTime)x).ToString("HH:mm:ss.fff", CultureInfo.InvariantCulture),
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Severity",
                AspectGetter = x => (x as LogModel)?.Event.Severity.ToShortString(),
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Context",
                AspectGetter = x => (x as LogModel)?.Playbook.DiagContext.Name,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Process",
                AspectGetter = x => (x as LogModel)?.Process?.Name,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Kind",
                AspectGetter = x => (x as LogModel)?.Process?.KindToString(),
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Type",
                AspectGetter = x => (x as LogModel)?.Process?.Type,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Topic",
                AspectGetter = x => (x as LogModel)?.Process?.Topic,
            });
            _updater.ListView.Columns.Add(new OLVColumn()
            {
                Text         = "Message",
                AspectGetter = x => (x as LogModel)?.Text,
            });

            _updater.Start();

            diagnosticsStateManager.OnDiagContextCreated += ec =>
            {
                if (ec.Session == session)
                {
                    ec.WholePlaybook.OnEventsAdded += OnEventsAdded;
                }
            };
        }
Пример #3
0
        public ProcessRowListControl(Control container, TrackedProcessInvocation process, List <TrackedRow> rows)
        {
            Container = container;
            Process   = process;
            Rows      = rows;

            Updater = new ControlUpdater <ProcessRowModel>(null, Container, -1, 10)
            {
                ItemFilter   = ItemFilter,
                ContainsRows = true,
            };

            Updater.CreateSearchBox(10, 10);

            ShowAll = new RadioButton()
            {
                Parent     = container,
                Bounds     = new Rectangle(Updater.SearchBox.Right + 20, Updater.SearchBox.Top, 60, Updater.SearchBox.Height),
                Text       = "All",
                CheckAlign = ContentAlignment.MiddleLeft,
                Checked    = process.Kind != ProcessKind.mutator,
            };

            ShowChanged = new RadioButton()
            {
                Parent     = container,
                Bounds     = new Rectangle(ShowAll.Right + 20, Updater.SearchBox.Top, 75, Updater.SearchBox.Height),
                Text       = "Changed",
                CheckAlign = ContentAlignment.MiddleLeft,
                Checked    = process.Kind == ProcessKind.mutator,
            };

            ShowUnChanged = new RadioButton()
            {
                Parent     = container,
                Bounds     = new Rectangle(ShowChanged.Right + 20, Updater.SearchBox.Top, 100, Updater.SearchBox.Height),
                Text       = "Unchanged",
                CheckAlign = ContentAlignment.MiddleLeft,
                Checked    = false,
            };

            ShowRemoved = new RadioButton()
            {
                Parent     = container,
                Bounds     = new Rectangle(ShowUnChanged.Right + 20, Updater.SearchBox.Top, 75, Updater.SearchBox.Height),
                Text       = "Removed",
                CheckAlign = ContentAlignment.MiddleLeft,
                Checked    = false,
            };

            ShowAll.CheckedChanged       += (s, a) => Updater.RefreshItems(true);
            ShowRemoved.CheckedChanged   += (s, a) => Updater.RefreshItems(true);
            ShowChanged.CheckedChanged   += (s, a) => Updater.RefreshItems(true);
            ShowUnChanged.CheckedChanged += (s, a) => Updater.RefreshItems(true);

            Updater.ListView.Anchor              = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
            Updater.ListView.Bounds              = new Rectangle(Container.ClientRectangle.Left, Container.ClientRectangle.Top + 40, Container.ClientRectangle.Width, Container.ClientRectangle.Height - 40);
            Updater.ListView.FormatCell         += ListView_FormatCell;
            Updater.ListView.UseCellFormatEvents = true;
            Updater.ListView.CellToolTipShowing += ListView_CellToolTipShowing;

            Updater.ListView.AllColumns.Add(new OLVColumn()
            {
                Text         = "ID",
                AspectGetter = x => (x as ProcessRowModel)?.RowUid,
            });

            Updater.ListView.AllColumns.Add(new OLVColumn()
            {
                Text         = "Previous process",
                AspectGetter = x => (x as ProcessRowModel)?.TrackedRow.PreviousProcess?.Name,
            });

            Updater.ListView.AllColumns.Add(new OLVColumn()
            {
                Text         = "Next process",
                AspectGetter = x => (x as ProcessRowModel)?.TrackedRow.NextProcess?.Name,
            });

            Updater.ListView.Columns.AddRange(Updater.ListView.AllColumns.ToArray());

            _fixColumnCount = Updater.ListView.Columns.Count;

            var newColumns = new List <OLVColumn>();
            var items      = new List <ProcessRowModel>();

            foreach (var row in rows)
            {
                foreach (var kvp in row.NewValues)
                {
                    AddColumnByValue(newColumns, kvp);
                }

                if (row.PreviousValues != null)
                {
                    foreach (var kvp in row.PreviousValues)
                    {
                        AddColumnByValue(newColumns, kvp);
                    }
                }

                var item = new ProcessRowModel()
                {
                    TrackedRow     = row,
                    RowUid         = row.Uid,
                    NewValues      = new object[newColumns.Count / 2],
                    NewTypes       = new string[newColumns.Count / 2],
                    PreviousValues = row.PreviousValues != null ? new object[newColumns.Count / 2] : null,
                    PreviousTypes  = row.PreviousValues != null ? new string[newColumns.Count / 2] : null,
                };

                if (row.PreviousValues != null)
                {
                    foreach (var kvp in row.PreviousValues)
                    {
                        var valueIndex = _columnIndexes[kvp.Key] / 2;
                        item.PreviousValues[valueIndex] = kvp.Value;
                        item.PreviousTypes[valueIndex]  = kvp.Value?.GetType().GetFriendlyTypeName();
                    }

                    if (row.NewValues.Count == row.PreviousValues.Count)
                    {
                        foreach (var kvp in row.NewValues)
                        {
                            row.PreviousValues.TryGetValue(kvp.Key, out var previousValue);
                            row.NewValues.TryGetValue(kvp.Key, out var newValue);

                            if (!DefaultValueComparer.ValuesAreEqual(previousValue, newValue))
                            {
                                item.Changed = true;
                            }
                        }
                    }
                    else
                    {
                        item.Changed = true;
                    }
                }

                foreach (var kvp in row.NewValues)
                {
                    var valueIndex = _columnIndexes[kvp.Key] / 2;
                    item.NewValues[valueIndex] = kvp.Value;
                    item.NewTypes[valueIndex]  = kvp.Value?.GetType().GetFriendlyTypeName();
                }

                Updater.AddItem(item);
            }

            Updater.ListView.Columns.AddRange(newColumns.ToArray());

            Updater.Start();
        }