Exemple #1
0
        private void Update()
        {
            try
            {
                m_sipAccount.SIPPassword          = m_sipAccountPassword.Text;
                m_sipAccount.OutDialPlanName      = (m_outDialPlan.SelectedIndex != -1) ? m_outDialPlan.SelectedItem as string : null;
                m_sipAccount.InDialPlanName       = (m_inDialPlan.SelectedIndex != -1) ? m_inDialPlan.SelectedItem as string : null;
                m_sipAccount.IsIncomingOnly       = m_statusIncomingOnlyRadio.IsChecked.Value;
                m_sipAccount.SendNATKeepAlives    = m_keepAlivesCheckBox.IsChecked.Value;
                m_sipAccount.IsUserDisabled       = m_statusDisabledRadio.IsChecked.Value;
                m_sipAccount.NetworkID            = m_sipAccountNetworkId.Text.Trim();
                m_sipAccount.IPAddressACL         = m_sipAccountIPAddressACL.Text.Trim();
                m_sipAccount.IsSwitchboardEnabled = m_isSwitchboardEnabledCheckBox.IsChecked.Value;

                if (m_sipAccount.HasValidationErrors)
                {
                    WriteStatusMessage(MessageLevelsEnum.Warn, m_sipAccount.ValidationErrors.First().ErrorMessage);
                }
                else
                {
                    SIPAccount.Clean(m_sipAccount);
                    WriteStatusMessage(MessageLevelsEnum.Info, "Attempting to update SIP Account " + m_sipAccount.SIPUsername + "@" + m_sipAccount.SIPDomain + " please wait...");
                    UpdateSIPAccount_External(m_sipAccount);
                }
            }
            catch (Exception excp)
            {
                WriteStatusMessage(MessageLevelsEnum.Error, "Update SIPAccount Exception. " + excp.Message);
            }
        }
Exemple #2
0
        private void Add()
        {
            try
            {
                string username             = m_sipAccountUsername.Text.Trim();
                string password             = m_sipAccountPassword.Text.Trim();
                string domain               = m_domainNames.SelectedItem as string;
                string outDialPlan          = m_outDialPlan.SelectedItem as string;
                string inDialPlan           = (m_inDialPlan.SelectedIndex != -1) ? m_inDialPlan.SelectedItem as string : null;
                string networkId            = m_sipAccountNetworkId.Text.Trim();
                string ipAddressACL         = m_sipAccountIPAddressACL.Text.Trim();
                bool   sendKeepAlives       = m_keepAlivesCheckBox.IsChecked.Value;
                bool   isIncomingOnly       = m_statusIncomingOnlyRadio.IsChecked.Value;
                bool   isSwitchboardEnabled = m_isSwitchboardEnabledCheckBox.IsChecked.Value;

                SIPAccount sipAccount = new SIPAccount();
                sipAccount.ID                   = Guid.Empty.ToString(); // Will be set server side.
                sipAccount.Owner                = m_owner;               // Will be set server side.
                sipAccount.SIPDomain            = domain;
                sipAccount.SIPUsername          = username;
                sipAccount.SIPPassword          = password;
                sipAccount.OutDialPlanName      = outDialPlan;
                sipAccount.InDialPlanName       = inDialPlan;
                sipAccount.SendNATKeepAlives    = sendKeepAlives;
                sipAccount.IsIncomingOnly       = isIncomingOnly;
                sipAccount.NetworkID            = networkId;
                sipAccount.IPAddressACL         = ipAddressACL;
                sipAccount.IsSwitchboardEnabled = isSwitchboardEnabled;
                sipAccount.Inserted             = DateTime.UtcNow.ToString("o"); // Will be set server side.

                if (sipAccount.HasValidationErrors)
                {
                    WriteStatusMessage(MessageLevelsEnum.Warn, sipAccount.ValidationErrors.First().ErrorMessage);
                }
                else
                {
                    SIPAccount.Clean(sipAccount);
                    WriteStatusMessage(MessageLevelsEnum.Info, "Adding SIP Account please wait...");
                    AddSIPAccount_External(sipAccount);
                }
            }
            catch (Exception excp)
            {
                WriteStatusMessage(MessageLevelsEnum.Error, "Add SIPAccount Exception. " + excp.Message);
            }
        }