Пример #1
0
        private void AutoRefreshThreadStart(C1Connection connection, bool ignoreTimeouts, bool stayAlwaysConnected)
        {
            bool stopOnServiceActivationError = true;

            while (true)             // Supposed to be stopped by ThreadAbortException
            {
                Thread.Sleep(600);

                LogEntry[] newEntries;

                try
                {
                    DateTime serverTime;

                    using (var client = connection.Connect())
                    {
                        serverTime = client.Channel.GetServerTime();
                        newEntries = client.Channel.GetLogEntries(_lastRefreshingDate.AddTicks(1), serverTime, true,
                                                                  MaximimLogLinesCount);
                    }

                    if (newEntries.Length > 0)
                    {
                        _lastRefreshingDate = serverTime;
                    }

                    stopOnServiceActivationError = false;
                }
                catch (Exception ex)
                {
                    // Ignoring singular occurances of ServiceActivationException as they may occur during AppDomain recycling
                    if ((ex is ServiceActivationException) && !stopOnServiceActivationError)
                    {
                        Thread.Sleep(3000);
                        stopOnServiceActivationError = true;
                        continue;
                    }

                    if (stayAlwaysConnected || (ignoreTimeouts && ex is TimeoutException))
                    {
                        Thread.Sleep(5000);
                        continue;
                    }

                    _autoRefreshingException = ex;
                    return;
                }

                lock (_syncRoot)
                {
                    if (_loadedEntries == null)
                    {
                        _loadedEntries = new List <LogEntry>();
                    }
                    _loadedEntries.AddRange(newEntries);
                }
            }
        }
Пример #2
0
        private void ShowConnectionDialog()
        {
            var dialogResult = _connectionForm.ShowDialog();

            if (dialogResult != DialogResult.OK)
            {
                return;
            }

            _connection = ConnectionForm.CurrentConnection;

            string connectionTitle = _connection.Title;

            this.Text = (connectionTitle == string.Empty ? string.Empty : (connectionTitle + " - ")) + _title;

            _currentLogEntriesSet = new List <LogEntry>();
            RefreshGrid();

            btnStart.Enabled      = true;
            btnShowByDate.Enabled = true;

            lstDates.Enabled = true;
            DateTime[] logginDates;
            using (var client = _connection.Connect())
            {
                logginDates = client.Channel.GetLoggingDates();
            }

            lstDates.Items.Clear();

            lstDates.Items.Add("Today");
            foreach (DateTime date in logginDates)
            {
                lstDates.Items.Add(date.ToString(DateFormatString));
            }

            if (lstDates.Items.Count > 0)
            {
                lstDates.SelectedIndex = 0;
            }
        }
Пример #3
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            DisablePaging();

            if (_connection == null)
            {
                MessageBox.Show("Not connected");
                return;
            }

            // Checking whether we were showing entries before
            if (_lastRefreshingDate == DateTime.MinValue)
            {
                LogEntry[] entries;
                DateTime   serverTime;
                try
                {
                    using (var client = _connection.Connect())
                    {
                        DateTime lastStartUpTime = client.Channel.GetLastStartupTime();
                        serverTime = client.Channel.GetServerTime();

                        _currentlyShowFrom = lastStartUpTime;
                        _currentlyShowTo   = DateTime.MaxValue;

                        entries = client.Channel.GetLogEntries(lastStartUpTime, serverTime, true, MaximimLogLinesCount);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error message: " + ex.Message, "Failed to get data");
                    return;
                }

                if (entries != null)
                {
                    PopulateGrid(entries);

                    // Auto scrolling
                    if (cbxAutoScroll.Checked)
                    {
                        int rowsPerPage = tblLogEntries.DisplayedRowCount(false);
                        int lastRow     = tblLogEntries.Rows.Count - 1;

                        if (lastRow > rowsPerPage && tblLogEntries.FirstDisplayedScrollingRowIndex < lastRow - rowsPerPage + 1)
                        {
                            tblLogEntries.FirstDisplayedScrollingRowIndex = lastRow - rowsPerPage + 1;
                        }
                    }
                }

                _lastRefreshingDate = serverTime;
            }

            refreshTimer.Enabled = true;
            btnStart.Enabled     = false;
            btnPause.Enabled     = true;
            btnClear.Enabled     = true;

            _loadedEntries        = null;
            _autoRefreshingThread = new Thread(() => AutoRefreshThreadStart(_connection, chkIgnoreTimeouts.Checked, cbxStayConnected.Checked));
            _autoRefreshingThread.Start();
        }
Пример #4
0
        private void ShowConnectionDialog()
        {
            var dialogResult = _connectionForm.ShowDialog();

            if (dialogResult != DialogResult.OK)
            {
                return;
            }

            _connection = ConnectionForm.CurrentConnection;

            string connectionTitle = _connection.Title;
            this.Text = (connectionTitle == string.Empty ? string.Empty : (connectionTitle + " - ")) + _title;

            _currentLogEntriesSet = new List<LogEntry>();
            RefreshGrid();

            btnStart.Enabled = true;
            btnShowByDate.Enabled = true;

            lstDates.Enabled = true;
            DateTime[] logginDates;
            using (var client = _connection.Connect())
            {
                logginDates = client.Channel.GetLoggingDates();
            }

            lstDates.Items.Clear();

            lstDates.Items.Add("Today");
            foreach (DateTime date in logginDates)
            {
                lstDates.Items.Add(date.ToString(DateFormatString));
            }

            if (lstDates.Items.Count > 0)
            {
                lstDates.SelectedIndex = 0;
            }
        }
Пример #5
0
        private void AutoRefreshThreadStart(C1Connection connection, bool ignoreTimeouts, bool stayAlwaysConnected)
        {
            bool stopOnServiceActivationError = true;

            while (true) // Supposed to be stopped by ThreadAbortException
            {
                Thread.Sleep(600);

                LogEntry[] newEntries;

                try
                {
                    DateTime serverTime;

                    using (var client = connection.Connect())
                    {
                        serverTime = client.Channel.GetServerTime();
                        newEntries = client.Channel.GetLogEntries(_lastRefreshingDate.AddTicks(1), serverTime, true,
                                                                  MaximimLogLinesCount);
                    }

                    if (newEntries.Length > 0)
                    {
                        _lastRefreshingDate = serverTime;
                    }

                    stopOnServiceActivationError = false;
                }
                catch (Exception ex)
                {
                    // Ignoring singular occurances of ServiceActivationException as they may occur during AppDomain recycling
                    if ((ex is ServiceActivationException) && !stopOnServiceActivationError)
                    {
                        Thread.Sleep(3000);
                        stopOnServiceActivationError = true;
                        continue;
                    }

                    if (stayAlwaysConnected || (ignoreTimeouts && ex is TimeoutException))
                    {
                        Thread.Sleep(5000);
                        continue;
                    }

                    _autoRefreshingException = ex;
                    return;
                }

                lock (_syncRoot)
                {
                    if (_loadedEntries == null)
                    {
                        _loadedEntries = new List<LogEntry>();
                    }
                    _loadedEntries.AddRange(newEntries);
                }
            }
        }