Exemplo n.º 1
0
 private void logSourceLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     handler.ShowLogSource(thread.LogSource);
 }
        void Update()
        {
            updateFlag.Validate();

            ignoredLogSources.RemoveWhere(x => x.IsDisposed);
            logSourcesRequiringReordering.RemoveWhere(x => x.IsDisposed);

            if (currentReport != null)
            {
                currentReport.Dispose();
                currentReport = null;
            }

            var messageParts = new List <StatusReports.MessagePart>();

            messageParts.Add(
                new StatusReports.MessagePart(
                    string.Format("{0} {1} problem with timestamps. {2}",
                                  logSourcesRequiringReordering.Count,
                                  logSourcesRequiringReordering.Count > 1 ? "logs have" : "log has",
                                  Environment.NewLine
                                  )
                    )
                );
            int shownLogSourcesCount = 0;

            foreach (var logSource in logSourcesRequiringReordering)
            {
                if (ignoredLogSources.Contains(logSource))
                {
                    continue;
                }
                ++shownLogSourcesCount;

                var logName = logSource.GetShortDisplayNameWithAnnotation();
                if (string.IsNullOrEmpty(logName))
                {
                    logName = "log";
                }

                Func <bool> checkSourceIsOk = () =>
                {
                    if (logSource.IsDisposed)
                    {
                        updateInvokeHelper.Invoke();
                        return(false);
                    }
                    return(true);
                };

                if (shownLogSourcesCount > 1)
                {
                    messageParts.Add(new StatusReports.MessagePart(Environment.NewLine));
                }

                messageParts.AddRange(new[]
                {
                    new StatusReports.MessageLink(logName, () =>
                    {
                        if (!checkSourceIsOk())
                        {
                            return;
                        }
                        presentersFacade.ShowLogSource(logSource);
                    }),
                    new StatusReports.MessagePart("  "),
                    new StatusReports.MessageLink("reorder log", () =>
                    {
                        if (!checkSourceIsOk())
                        {
                            return;
                        }
                        var cp = preprocessingManager.AppendReorderingStep(
                            logSource.Provider.ConnectionParams, logSource.Provider.Factory);
                        if (cp != null)
                        {
                            logSource.Dispose();
                            preprocessingManager.Preprocess(
                                new MRU.RecentLogEntry(logSource.Provider.Factory, cp, "", null));
                        }
                    }),
                    new StatusReports.MessagePart("  "),
                    new StatusReports.MessageLink("ignore", () =>
                    {
                        ignoredLogSources.Add(logSource);
                        updateInvokeHelper.Invoke();
                    })
                });
            }

            if (shownLogSourcesCount != 0)
            {
                currentReport = statusReports.CreateNewStatusReport();
                currentReport.ShowStatusPopup(
                    "Log source problem",
                    messageParts,
                    autoHide: false
                    );
            }
        }