コード例 #1
0
        /// <summary>
        /// Initialize the event logs.
        /// </summary>
        public void InitializeEventLogs()
        {
            MainWindow.CloseChildForms();
            MainWindow.Cursor = Cursors.WaitCursor;

            ICommunicationEvent communicationEvent;

            // Initialize the communication interface.
            if (MainWindow.CommunicationInterface is CommunicationParent)
            {
                communicationEvent = new CommunicationEvent(MainWindow.CommunicationInterface);
            }
            else
            {
                communicationEvent = new CommunicationEventOffline(MainWindow.CommunicationInterface);
            }

            // Ask the user for confirmation.
            DialogResult dialogResult = MessageBox.Show(Resources.MBTConfirmInitializeEventLogs, Resources.MBCaptionQuestion, MessageBoxButtons.YesNo,
                                                        MessageBoxIcon.Question);
            if (MainWindow != null)
            {
                MainWindow.Update();
            }

            if (dialogResult == DialogResult.No)
            {
                MainWindow.Cursor = Cursors.Default;
                return;
            }

            // Clear each event logs.
            Log log;
            for (int logIndex = 0; logIndex < Lookup.LogTable.RecordList.Count; logIndex++)
            {
                log = Lookup.LogTable.RecordList[logIndex];

                // Only process those logs that have been defined.
                if (log != null)
                {
                    MainWindow.WriteStatusMessage(string.Format(Resources.SMEventLogsInitialize, log.Description));

                    try
                    {
                        communicationEvent.ChangeEventLog(log);
                        communicationEvent.InitializeEventLog();
                    }
                    catch (CommunicationException)
                    {
                        MessageBox.Show(Resources.MBTEventLogInitializeFailed, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    finally
                    {
                        MainWindow.WriteStatusMessage(string.Empty);
                        MainWindow.Cursor = Cursors.Default;
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the class. 
        /// </summary>
        /// <param name="communicationInterface">The communication interface that is to be used to communicate with the VCU.</param>
        /// <param name="log">The current event log.</param>
        public FormShowEventHistory(ICommunicationParent communicationInterface, Log log)
        {
            InitializeComponent();

            // Initialize the communication interface.
            if (communicationInterface is CommunicationParent)
            {
                CommunicationInterface = new CommunicationEvent(communicationInterface);
            }
            else
            {
                CommunicationInterface = new CommunicationEventOffline(communicationInterface);
            }
            Debug.Assert(CommunicationInterface != null);

            #region - [Size] -
            m_DataGridViewTextColumnEnableEvent.Visible = false;
            m_DataGridViewTextColumnStreamTriggered.Visible = false;
            m_DataGridViewTextColumnCumulativeHistory.Visible = true;
            m_DataGridViewTextColumnRecentHistory.Visible = true;

            // Get the combined width of all visible DataGridView columns.
            int dataGridViewWidth = 0;
            DataGridViewColumn dataGridViewColumn;
            for (int columnIndex = 0; columnIndex < m_DataGridViewEventStatus.Columns.Count; columnIndex++)
            {
                dataGridViewColumn = m_DataGridViewEventStatus.Columns[columnIndex];
                if (dataGridViewColumn.Visible == true)
                {
                    dataGridViewWidth += dataGridViewColumn.Width;
                }
            }

            m_PanelDataGridViewEventStatus.Width = dataGridViewWidth + MarginRightDataGridViewControl;

            Width = m_PanelDataGridViewEventStatus.Width + MarginRightPanelControl;
            #endregion - [Size] -

            #region - [Buttons] -
            // Only the OK button is required for this form, move the position of the OK button so that it hides the cancel button.
            m_ButtonCancel.Visible = false;
            m_ButtonOK.Location = m_ButtonCancel.Location;
            #endregion - [Buttons] -

            #region - [Context Menu] -
            // Disable those context menu options that are not applicable to this form.
            m_ContextMenuStripFlags.Items[ContextMenuItemIndexEnabled].Visible = false;
            m_ContextMenuStripFlags.Items[ContextMenuItemIndexStreamTriggered].Visible = false;
            #endregion - [Context Menu] -

            // ------------------------------------------------------------------
            // Get the list of events associated with the current event log.
            // ------------------------------------------------------------------
            List<EventRecord> foundEventRecordList = Lookup.EventTable.RecordList.FindAll(delegate(EventRecord eventRecord)
            {
                // Include a try/catch block in case an event record has not been defined.
                try
                {
                    // The LOGID field of the EVENTS table actually uses the log index value which is equal to the log identifier - 1.
                    return (eventRecord.LogIdentifier == log.Identifier - 1);
                }
                catch (Exception)
                {
                    return false;
                }
            });

            foundEventRecordList.Sort(CompareByTaskIDByEventIDAscending);

            try
            {
                FormGetFltHistInfo formGetFltHistInfo = new FormGetFltHistInfo(CommunicationInterface, foundEventRecordList, log);
                formGetFltHistInfo.CalledFrom = this;
                formGetFltHistInfo.ShowDialog();
            }
            catch (Exception)
            {
                throw new CommunicationException(Resources.EMGetFltHistInfoFailed);
            }

            AddList(EventStatusList);
        }