private bool ItemAdd()
        {
            try
            {
                string strKey = GetNewKey();
                if (string.IsNullOrEmpty(strKey))
                {
                    return(false);
                }

                AlarmData       alarmData = new AlarmData();
                DataGridViewRow row       = new DataGridViewRow();
                alarmData.AlarmKey    = strKey;
                alarmData.AlarmName   = "Alarm_" + strKey;
                alarmData.AlarmSrc    = "PC";
                alarmData.AlarmMsg    = " ";
                alarmData.AlarmRemark = " ";

                DataGridViewTextBoxCell  keyCell      = new DataGridViewTextBoxCell();
                DataGridViewTextBoxCell  nameCell     = new DataGridViewTextBoxCell();
                DataGridViewComboBoxCell alarmSrcCell = new DataGridViewComboBoxCell();
                DataGridViewTextBoxCell  msgCell      = new DataGridViewTextBoxCell();
                DataGridViewTextBoxCell  remarkCell   = new DataGridViewTextBoxCell();

                alarmSrcCell.Items.Clear();
                alarmSrcCell.Items.Add("PC");
                foreach (HardwareData item in HardwareManage.docHardware.listHardwareData)
                {
                    alarmSrcCell.Items.Add(item.Name);
                }
                alarmSrcCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;

                keyCell.Value      = alarmData.AlarmKey;
                nameCell.Value     = alarmData.AlarmName;
                alarmSrcCell.Value = alarmData.AlarmSrc;
                msgCell.Value      = alarmData.AlarmMsg;
                remarkCell.Value   = alarmData.AlarmRemark;

                row.Cells.Add(keyCell);
                row.Cells.Add(nameCell);
                row.Cells.Add(alarmSrcCell);
                row.Cells.Add(msgCell);
                row.Cells.Add(remarkCell);
                dataGridView1.Rows.Add(row);

                MainModule.alarmManage.docAlarm.dicAlarmItems.Add(alarmData.AlarmKey, alarmData);
                MainModule.alarmManage.docAlarm.listAlarmItems.Add(alarmData);

                return(true);
            }
            catch (Exception)
            {
            }
            return(false);
        }
Esempio n. 2
0
        public void InsertAlarm(string strKey, string strAlarmMsg)
        {
            lock (_objLock)
            {
                try
                {
                    if (string.IsNullOrEmpty(strKey))
                    {
                        return;
                    }
                    if (_dicCurrAlarmMsg.ContainsKey(strKey))
                    {
                        return;
                    }

                    AlarmData alarmData = new AlarmData();
                    alarmData.AlarmMsg  = strAlarmMsg;
                    alarmData.AlarmTime = DateTime.Now;
                    alarmData.AlarmKey  = strKey;
                    _dicCurrAlarmMsg.Add(strKey, alarmData);

                    iStopReason = -1;
                    TextLogWrite.WriteAlarmLog(strAlarmMsg);
                    if (strKey != AlarmKeys.未选择停机原因 && null != eventAlarmInsert)
                    {
                        this.eventAlarmInsert(strKey);
                    }
                    if (_formAlarm != null)
                    {
                        _formAlarm.ShowAlarmMsg();
                    }
                    if (_formAlarmCatl != null)
                    {
                        _formAlarmCatl.ShowAlarmMsg();
                    }
                }
                catch (Exception)
                {
                }
            }
        }