Ejemplo n.º 1
0
        /// <summary>
        /// Loads the settings of the queue.
        /// </summary>
        public void Load()
        {
            var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Softlex\SMS\" + Guid.ToString(), false);

            if (key == null)
            {
                return;
            }

            // Get the endpoint and token.
            Endpoint = (key.GetValue("Endpoint", "") as string) ?? "";
            Token    = (key.GetValue("Token", "") as string) ?? "";

            // Get the list of accepted countries.
            if (key.GetValue("Countries") is string[] countryCodes)
            {
                countryList = new List <Country>();
                foreach (string countryCode in countryCodes)
                {
                    var country = Countries.GetByCountryCode(countryCode);
                    if (country == null)
                    {
                        continue;
                    }

                    countryList.Add(country);
                }
            }

            // Check if country restrictions have been enabled.
            countryRestriction = Convert.ToInt32(key.GetValue("CountryRestriction", 0)) == 1;

            // Get the queue filter policy.
            queuePolicy       = (MessageQueueNumberPolicy)Convert.ToInt32(key.GetValue("NumberPolicy", 0));
            queuePolicyTarget = null;

            // Get the converstion target country.
            string queuePolicyTargetCode = key.GetValue("NumberPolicyTarget") as string ?? "";

            if (!string.IsNullOrWhiteSpace(queuePolicyTargetCode))
            {
                queuePolicyTarget = Countries.GetByCountryCode(queuePolicyTargetCode);
            }

            // Get the way in which the handle large messages.
            largeMessagePolicy = (int)key.GetValue("LargeMessagePolicy", 1);

            // Get the maximum message length.
            maxLength = (int)key.GetValue("MaxMessageSize", 160);
            if (maxLength < 1)
            {
                maxLength = 1;
            }
            else if (maxLength > 999)
            {
                maxLength = 999;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the settings of the message queue.
        /// </summary>
        void LoadSettings()
        {
            var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Softlex\SMS\" + guid.ToString(), false);

            if (key == null)
            {
                return;
            }

            // Get the endpoint and token.
            endpointTextBox.Text = (key.GetValue("Endpoint", "") as string) ?? "";
            tokenTextBox.Text    = (key.GetValue("Token", "") as string) ?? "";

            // Get the list of accepted countries.
            countriesListBox.Items.Clear();
            if (key.GetValue("Countries") is string[] countryCodes)
            {
                foreach (string countryCode in countryCodes)
                {
                    var country = Countries.GetByCountryCode(countryCode);
                    if (country == null)
                    {
                        continue;
                    }

                    countriesListBox.Items.Add(country);
                }
            }
            UpdateFormatList();

            // Check if country restrictions have been enabled.
            restrictCountriesCheckBox.Checked = Convert.ToInt32(key.GetValue("CountryRestriction", 0)) == 1;

            // Get the queue filter policy.
            var queuePolicy = (MessageQueueNumberPolicy)Convert.ToInt32(key.GetValue("NumberPolicy", 0));

            switch (queuePolicy)
            {
            case MessageQueueNumberPolicy.AcceptAndConvert:
                acceptRadioButton.Checked = true;
                break;

            case MessageQueueNumberPolicy.Reject:
                rejectRadioButton.Checked = true;
                break;
            }

            // Get the converstion target country.
            string queuePolicyTargetCode = key.GetValue("NumberPolicyTarget") as string ?? "";

            if (!string.IsNullOrWhiteSpace(queuePolicyTargetCode))
            {
                Country queuePolicyTarget = Countries.GetByCountryCode(queuePolicyTargetCode);
                if (queuePolicyTarget != null)
                {
                    countryComboBox.SelectedItem = queuePolicyTarget;
                }
            }

            // Get the way in which large messages received by this queue need to be handled.
            int largeMessagePolicy = (int)key.GetValue("LargeMessagePolicy", 1);

            switch (largeMessagePolicy)
            {
            case 1:
                splitLargeMessagesRadioButton.Checked = true;
                break;

            default:
                rejectLargeMessagesRadioButton.Checked = true;
                break;
            }

            // Get the maximum message length.
            int maxLength = (int)key.GetValue("MaxMessageSize", 160);

            if (maxLength < 1)
            {
                maxLength = 1;
            }
            else if (maxLength > 999)
            {
                maxLength = 999;
            }
            maxLengthTextBox.Text = maxLength.ToString();
        }