示例#1
0
        private void OnEventsAdded(Playbook playbook, List <AbstractEvent> abstractEvents)
        {
            var events = abstractEvents.OfType <LogEvent>().ToList();

            if (events.Count == 0)
            {
                return;
            }

            foreach (var evt in events)
            {
                var text = evt.Text;
                if (evt.Arguments != null)
                {
                    foreach (var arg in evt.Arguments)
                    {
                        text = arg.Key.StartsWith("{spacing", StringComparison.OrdinalIgnoreCase)
                            ? text.Replace(arg.Key, "", StringComparison.InvariantCultureIgnoreCase)
                            : text.Replace(arg.Key, FormattingHelpers.ToDisplayValue(arg.Value), StringComparison.InvariantCultureIgnoreCase);
                    }
                }

                var item = new LogModel()
                {
                    Timestamp = new DateTime(evt.Timestamp),
                    Playbook  = playbook,
                    Event     = evt,
                    Process   = evt.ProcessInvocationUID != null
                        ? playbook.DiagContext.WholePlaybook.ProcessList[evt.ProcessInvocationUID.Value]
                        : null,
                    Text = text,
                };

                _updater.AddItem(item);
            }
        }
示例#2
0
 private void OnRowStoreStarted(Playbook playbook, TrackedStore store)
 {
     _updater.AddItem(store);
 }
示例#3
0
 private void OnSinkStarted(Playbook playbook, TrackedSink sink)
 {
     _updater.AddItem(sink);
 }
示例#4
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();
        }