Exemplo n.º 1
0
        private void UpsertMonitorMonitorCommandLimits()
        {
            try
            {
                for (int item = 0; item < rptCommandLimits.Items.Count; item++)
                {
                    var monitorLimit = new MonitorCommandLimit();
                    var repeaterItem = rptCommandLimits.Items[item];

                    var command = repeaterItem.FindControl("lblType") as Label;
                    if (command == null)
                    {
                        return;
                    }
                    monitorLimit.Type = command.Text;

                    var warningLimit = repeaterItem.FindControl("txtWarningLimit") as TextBox;
                    if (warningLimit == null)
                    {
                        return;
                    }
                    monitorLimit.WarningLimit =
                        warningLimit.Text == string.Empty
                                    ? (int?)null
                                    : Convert.ToInt32(warningLimit.Text.Trim());

                    TextBox errorLimit = repeaterItem.FindControl("txtErrorLimit") as TextBox;
                    if (errorLimit == null)
                    {
                        return;
                    }
                    monitorLimit.ErrorLimit =
                        errorLimit.Text == string.Empty
                                    ? (int?)null
                                    : Convert.ToInt32(errorLimit.Text.Trim());

                    if (
                        (monitorLimit.WarningLimit == null) &&
                        (monitorLimit.ErrorLimit == null))
                    {
                        continue;
                    }
                    monitorDb.UpsertMonitorCommandLimit(monitorLimit);
                }
                LoadValues();
            }
            catch (Exception ex)
            {
                throw new Exception($"Exception: {ex.Message}");
            }
        }
Exemplo n.º 2
0
 public static bool IsMonitorValueLimitWarning(
     MonitorValue monitorValue,
     MonitorCommandLimit monitorCommandLimit)
 {
     if (monitorCommandLimit.WarningLimit != null)
     {
         if (!monitorCommandLimit.IsLowLimit)
         {
             if (monitorValue.Value > monitorCommandLimit.WarningLimit)
             {
                 return(true);
             }
         }
         else
         {
             if (monitorValue.Value < monitorCommandLimit.WarningLimit)
             {
                 return(true);
             }
         }
     }
     return(false);
 }