Exemple #1
0
    private void PopulateTraceFileListView(bool firstRun)
    {
        if (CheckTraceFileDir(firstRun, traceFileDirComboBox.Text))
        {
            traceFileListView.Items.Clear();

            DirectoryInfo dir   = new DirectoryInfo(_traceFileDir);
            FileInfo[]    files = dir.GetFiles("*.*");

            Array.Sort(files, delegate(FileInfo a, FileInfo b)
            {
                return(b.CreationTime.CompareTo(a.CreationTime));
            });

            for (int i = 0; i < files.Length; i++)
            {
                if (files[i].Extension == ".trc" || (files[i].Extension == ".xel" && GenericHelper.SqlServerVersion >= 11))
                {
                    string[]     items = { "", (i + 1).ToString(), files[i].Name, GenericHelper.FormatWithThousandSeparator(Convert.ToInt32(files[i].Length / 1024)), GenericHelper.FormatDate(files[i].CreationTime) };
                    ListViewItem traceFileListViewItem = new ListViewItem(items, GetIcon(files[i].Extension));
                    traceFileListView.Items.Add(traceFileListViewItem);
                }
            }
        }

        if (ConfigHandler.UseTranslation)
        {
            traceFileCountLabel.Text = string.Format("{1} {0}", traceFileListView.Items.Count, Translator.GetText("traceFileCountLabel"));
        }
        else
        {
            traceFileCountLabel.Text = string.Format("Number of Trace Files: {0}", traceFileListView.Items.Count);
        }
    }
Exemple #2
0
    private void SetUserInterface()
    {
        DataSet  traceDataInfo      = _databaseOperation.GetTraceDataInfo();
        DateTime lastEventStartTime = _databaseOperation.GetLastEventStartTime();

        if (ConfigHandler.UseTranslation)
        {
            numberOfEventsLabel.Text = string.Format("{1} {0}", GenericHelper.FormatWithThousandSeparator(Convert.ToInt32(traceDataInfo.Tables[0].Rows[0]["TotalRows"])), Translator.GetText("numberOfEventsLabel"));
        }
        else
        {
            numberOfEventsLabel.Text = string.Format("Total Events: {0}", GenericHelper.FormatWithThousandSeparator(Convert.ToInt32(traceDataInfo.Tables[0].Rows[0]["TotalRows"])));
        }

        if (dataViewer1.GetSelectedRow() == null || Convert.ToInt32(traceDataInfo.Tables[0].Rows[0]["TotalRows"]) == 0)
        {
            textDataTextBox.Text = "";
        }
        else
        {
            textDataTextBox.Text = dataViewer1.GetSelectedRow()["TextData"].ToString();
        }

        _totalRows = Convert.ToInt32(traceDataInfo.Tables[0].Rows[0]["TotalRows"]);
        statisticUserControl1.SetTotalRows(_totalRows);

        textDataTextBox.ActiveTextAreaControl.Refresh();

        ResetFilters(traceDataInfo, lastEventStartTime);
        InitializeStatistics();
    }
Exemple #3
0
    private string GetBasedOnText()
    {
        string periodText;

        if (ConfigHandler.UseTranslation)
        {
            periodText = Translator.GetText("Period");
        }
        else
        {
            periodText = "Period:";
        }

        string totalEvents;

        if (ConfigHandler.UseTranslation)
        {
            totalEvents = Translator.GetText("TotalEvents");
        }
        else
        {
            totalEvents = "Based on {0} events";
        }

        string period;

        if (_minStartTime == DateTime.MinValue && _maxStartTime == DateTime.MinValue)
        {
            if (ConfigHandler.UseTranslation)
            {
                period = Translator.GetText("None");
            }
            else
            {
                period = "None";
            }
        }
        else
        {
            period = string.Format("{0} - {1}", GenericHelper.FormatLongDate(_minStartTime), GenericHelper.FormatLongDate(_maxStartTime));
        }

        totalEvents = string.Format(totalEvents, GenericHelper.FormatWithThousandSeparator(_totalRows));

        return(string.Format("{0} {1}, {2}", periodText, period, totalEvents));
    }
    private void PopulateSessionListView()
    {
        sessionListView.Items.Clear();

        DataTable existingSessions = _databaseOperation.GetSessionInfo(this);

        string existingSessionId = GenericHelper.GetSessionIdFromTableName();

        for (int i = 0; i < existingSessions.Rows.Count; i++)
        {
            if (existingSessions.Rows[i]["TableName"].ToString() != existingSessionId)
            {
                int          size  = Convert.ToInt32(existingSessions.Rows[i]["TableSizeInKB"]) + Convert.ToInt32(existingSessions.Rows[i]["IndexSizeInKB"]);
                string[]     items = { "", (i + 1).ToString(), existingSessions.Rows[i]["TableName"].ToString(), GenericHelper.FormatWithThousandSeparator(Convert.ToInt32(size)), GenericHelper.FormatDate(Convert.ToDateTime(existingSessions.Rows[i]["CreateDate"])) };
                ListViewItem sessionListViewItem = new ListViewItem(items, "database.png");

                SetCheckedListViewItems(existingSessions.Rows[i]["TableName"].ToString(), sessionListViewItem);

                sessionListView.Items.Add(sessionListViewItem);
            }
        }

        if (ConfigHandler.UseTranslation)
        {
            sessionCountLabel.Text = string.Format("{1} {0}", sessionListView.Items.Count, Translator.GetText("sessionCountLabel"));
        }
        else
        {
            sessionCountLabel.Text = string.Format("Number of Sessions: {0}", sessionListView.Items.Count);
        }

        FillExistingSessionsComboBox(existingSessions);
    }
    private void FillExistingSessionsComboBox(DataTable existingSessions)
    {
        string existingSessionId = GenericHelper.GetSessionIdFromTableName();

        string currentText = "Current";

        if (ConfigHandler.UseTranslation)
        {
            currentText = Translator.GetText("CurrentText");
        }

        string activeText = "Active";

        if (ConfigHandler.UseTranslation)
        {
            activeText = Translator.GetText("ActiveText");
        }

        string existingSessionSize = "0";

        for (int i = 0; i < existingSessions.Rows.Count; i++)
        {
            if (existingSessions.Rows[i]["TableName"].ToString() == existingSessionId)
            {
                int size = Convert.ToInt32(existingSessions.Rows[i]["TableSizeInKB"]) + Convert.ToInt32(existingSessions.Rows[i]["IndexSizeInKB"]);
                existingSessionSize = GenericHelper.FormatWithThousandSeparator(Convert.ToInt32(size));
                break;
            }
        }

        string existingText = string.Format("{2} - {0} ({1}, {3} KB)", existingSessionId, currentText, FormatSessionNumber(0, existingSessions.Rows.Count - 1), existingSessionSize);

        existingSessionsComboBox.Items.Clear();

        existingSessionsComboBox.Items.Add(new ComboBoxItem(existingText, false, true, existingSessionId));

        DataTable existingConnections = _databaseOperation.GetExistingConnections();

        for (int i = 0; i < existingSessions.Rows.Count; i++)
        {
            if (existingSessions.Rows[i]["TableName"].ToString() != existingSessionId)
            {
                string sessionText = existingSessions.Rows[i]["TableName"].ToString();
                bool   active      = false;

                foreach (DataRow existingConnection in existingConnections.Rows)
                {
                    if (existingConnection["sessionid"].ToString() == existingSessions.Rows[i]["TableName"].ToString())
                    {
                        sessionText = string.Format("{0} ({1})", existingSessions.Rows[i]["TableName"], activeText);
                        active      = true;
                        break;
                    }
                }

                sessionText = string.Format("{1} - {0}", sessionText, FormatSessionNumber(i + 1, existingSessions.Rows.Count - 1));

                existingSessionsComboBox.Items.Add(new ComboBoxItem(sessionText, active, false, existingSessions.Rows[i]["TableName"].ToString()));
            }
        }

        existingSessionsComboBox.SelectedIndex = 0;
    }