Пример #1
0
        /// <summary>
        /// Queries the current state of all temperature alarms on MooseBox.
        /// </summary>
        /// <returns>Current temperature alarm data.</returns>
        internal static async Task <TemperatureAlarm> QueryCurrentTemperatureAlarms()
        {
            IMooseBoxRESTAPI mooseBoxRESTAPI = MooseBoxRESTAPIFactory.Instance.Create();

            List <TemperatureAlarmConfig> registeredAlarms = await mooseBoxRESTAPI.ListTemperatureAlarmConfig();

            TemperatureAlarm temperatureAlarm = new TemperatureAlarm(mooseBoxRESTAPI, registeredAlarms);

            return(temperatureAlarm);
        }
        /// <summary>
        /// Queries the current state of all temperature alarms on MooseBox.
        /// </summary>
        /// <returns>Current temperature alarm data.</returns>
        internal static async Task<TemperatureAlarm> QueryCurrentTemperatureAlarms()
        {
            IMooseBoxRESTAPI mooseBoxRESTAPI = MooseBoxRESTAPIFactory.Instance.Create();

            List<TemperatureAlarmConfig> registeredAlarms = await mooseBoxRESTAPI.ListTemperatureAlarmConfig();

            TemperatureAlarm temperatureAlarm = new TemperatureAlarm(mooseBoxRESTAPI, registeredAlarms);

            return temperatureAlarm;
        }
        /// <summary>
        /// Worker method to reload all Temperature Alarmt data.
        /// </summary>
        private void LoadData(bool addEmailAddresses)
        {
            //Query the current state of all Temperature Alarms.
            m_temperatureAlarm = AsyncHelper.RunSync(() => { return TemperatureAlarm.QueryCurrentTemperatureAlarms(); });

            //Erase ComboBox listings and other components.
            comboBoxRegisteredEmails.Items.Clear();

            textBoxTemperatureMin.Text = string.Empty;
            textBoxTemperatureMax.Text = string.Empty;

            //Configure the ComboxBox now.
            try
            {
                if (addEmailAddresses == true)
                {
                    List<Tuple<string, Single, Single>> registeredAlarms = null;
                    TemperatureSensor selectedTemperatureSensor = GetSelectedTemperatureSensor();

                    if (m_temperatureAlarm.TryGetRegistrationInfo(selectedTemperatureSensor, out registeredAlarms) == true)
                    {
                        Debug.Assert(registeredAlarms != null);

                        var emails = registeredAlarms.Select(obj => obj.Item1).Distinct();

                        foreach (var email in emails)
                            comboBoxRegisteredEmails.Items.Add(email);
                    }
                }
            }
            catch { Debug.Assert(false); }
        }