Esempio n. 1
0
        public MainAlarm getMainAlarmByCode(string code)
        {
            MainAlarm mainAlarm = null;

            try
            {
                //查尋DataTable的欄位
                DataTable dt = SCApplication.getInstance().OHxCConfig.Tables[TableName_MAINALARM];
                if (dt != null)
                {
                    var query = from c in dt.AsEnumerable()
                                where c.Field <string>("CODE").Trim() == code.Trim()
                                select new MainAlarm
                    {
                        CODE        = c.Field <string>("CODE"),
                        DESCRIPTION = c.Field <string>("DESCRIPTION"),
                        ACTION      = c.Field <string>("ACTION"),
                    };
                    mainAlarm = query.SingleOrDefault();
                }
            }
            catch (Exception ex)
            {
                logger.Warn(ex);
            }
            return(mainAlarm);
        }
Esempio n. 2
0
        public string onMainAlarm(string mAlarmCode, params object[] args)
        {
            MainAlarm mainAlarm = mainAlarmDao.getMainAlarmByCode(mAlarmCode);
            bool      isAlarm   = false;
            string    msg       = string.Empty;

            try
            {
                if (mainAlarm != null)
                {
                    isAlarm = mainAlarm.CODE.StartsWith("A");
                    msg     = string.Format(mainAlarm.DESCRIPTION, args);
                    if (isAlarm)
                    {
                        msg = string.Format("[{0}]{2}", mainAlarm.CODE, Environment.NewLine, msg);
                        BCFApplication.onErrorMsg(msg);
                    }
                    else
                    {
                        msg = string.Format("[{0}]{2}", mainAlarm.CODE, Environment.NewLine, msg);
                        BCFApplication.onWarningMsg(msg);
                    }
                }
                else
                {
                    logger.Warn(string.Format("LFC alarm/warm happen, but no defin remark code:[{0}] !!!", mAlarmCode));
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception:");
            }
            return(msg);
        }