示例#1
0
        public void UpdateRows(string columnName, object value)
        {
            var alarmdef = AlarmDataSet.GetActiveAlarmDefinitionTable(group_name);

            for (int i = 0; i < alarmdef.Count; i++)
            {
                if (!alarmdef[i].IsVirtual)
                {
                    alarmdef[i][columnName] = value;
                }
            }
            alarmdef.Save();
        }
示例#2
0
        internal void ProcessGroup(DateTime t)
        {
            alarmCount = 0;
            clearCount = 0;
            var alarmdef = AlarmDataSet.GetActiveAlarmDefinitionTable(group_name);

            if (useHydrometCache)
            {
                AlarmDataSet.PreloadInstantHydrometData(alarmdef, t);
            }
            string emailMsg         = "";
            string txtMsg           = "";
            string emailMessageBody = "";
            string txtMessageBody   = "";

            foreach (var row in alarmdef)
            {
                if (row.enabled)
                {
                    if (!row.active)
                    {
                        Alarm alarmCondition = AlarmFactory(row, "alarm_condition");
                        if (alarmCondition.Check(t))
                        {                       // set the alarm.
                            if (!row.IsVirtual) // don't set active on 'virtual' alarms
                            {
                                row.active = true;
                            }
                            alarmCount++;
                            alarmCondition.CreateMessage(out emailMsg, out txtMsg);
                            txtMessageBody   += " " + txtMsg;
                            emailMessageBody += "<br/>Hydromet Notification: \n<br>" + emailMsg;
                        }
                    }
                    else
                    {                                  // check if alarm can be cleared.
                        if (row.clear_condition != "") // without clear condition you must manually clear that alarm
                        {
                            Alarm clearCondition = AlarmFactory(row, "clear_condition");
                            if (clearCondition.Check(t))
                            { // clear the alarm.
                                if (row.IsVirtual)
                                {
                                    throw new ApplicationException("Assertion.... unexpected virtual rows");
                                }
                                row.active = false;

                                emailMessageBody += " The Alarm condition below has been CLEARED<br/> ";
                                clearCondition.CreateMessage(out emailMsg, out txtMsg);
                                emailMessageBody += "<br/>Hydromet Notification: \n<br>" + emailMsg;
                                txtMessageBody   += txtMsg;
                                clearCount++;
                            }
                        }
                    }
                }
            }

            if (ProcessCount > 0 && sendEmail)
            {
                emailMessageBody += "\n\n <a href=\"https://www.usbr.gov/pn/hydromet/disclaimer.html\">provisional data disclaimer</a>";
                SendEmailNotice(AlarmDataSet.EmailAddresses(group_name), group_name, emailMessageBody, txtMessageBody);
            }
            // phone ??
            alarmdef.Save();
        }