private void PopulateDataFields(SIPDialPlan dialPlan)
 {
     m_dialPlanId.Text = dialPlan.ID;
     m_dialPlanName.Text = dialPlan.DialPlanName;
     m_dialPlanTraceEmailAddress.Text = (dialPlan.TraceEmailAddress != null) ? dialPlan.TraceEmailAddress : String.Empty;
     m_dialPlanText.Text = (dialPlan.DialPlanScript != null) ? dialPlan.DialPlanScript : String.Empty;
     m_dialPlanScriptType.Text = dialPlan.ScriptTypeDescription;
     m_dialPlanAcceptNonInvite.IsChecked = dialPlan.AcceptNonInvite;
 }
        private void AddDialPlan(SIPDialPlan dialPlan)
        {
            if (dialPlan.ID == null || dialPlan.ID == Guid.Empty.ToString())
            {
                dialPlan.ID = Guid.NewGuid().ToString();
            }

            m_riaContext.SIPDialPlans.Add(dialPlan);
            m_riaContext.SubmitChanges(AddDialPlanComplete, dialPlan);
        }
        public SimpleWizardManager(
            ActivityMessageDelegate logActivityMessage,
            SIPDialPlan dialPlan,
            string owner,
            DialPlanUpdateDelegate dialPlanAdd,
            DialPlanUpdateDelegate dialPlanUpdate,
            ControlClosedDelegate closed,
            SIPEntitiesDomainContext riaContext)
        {
            InitializeComponent();

            LogActivityMessage_External = logActivityMessage;
            m_dialPlan = dialPlan;
            m_owner = owner;
            DialPlanAdd_External = dialPlanAdd;
            DialPlanUpdate_External = dialPlanUpdate;
            ControlClosed_External = closed;
            m_riaContext = riaContext;

            m_riaContext.RejectChanges();

            m_dialPlanName.Text = m_dialPlan.DialPlanName;
            _dialPlanNameTextBox.Text = m_dialPlan.DialPlanName;

            // Set up the outgoing rules grid.
            m_outgoingRulesUpdateControl.SetStatusMessage(SimpleWizardOutRuleControl.ADD_TEXT, false);
            m_outgoingRulesUpdateControl.SIPProviders = m_riaContext.SIPProviders.ToList();
            m_outgoingRulesUpdateControl.Add += AddRule;
            m_outgoingRulesUpdateControl.Update += UpdateRule;
            m_outgoingRulesPanel.SetTitle("Outgoing Call Rules");
            m_outgoingRulesPanel.MenuEnableFilter(false);
            m_outgoingRulesPanel.MenuEnableHelp(false);
            m_outgoingRulesPanel.MenuEnableAdd(false);
            m_outgoingRulesPanel.GetAssetList = GetOutgoingRules;
            //m_outgoingRulesPanel.Add += () => { m_outgoingRulesUpdateControl.SetRuleToUpdate(null); };

            // Set up the incoming rules grid.
            m_incomingRulesUpdateControl.SetStatusMessage(SimpleWizardInRuleControl.ADD_TEXT, false);
            m_incomingRulesUpdateControl.SIPProviders = m_riaContext.SIPProviders.ToList();
            m_incomingRulesUpdateControl.Add += AddRule;
            m_incomingRulesUpdateControl.Update += UpdateRule;
            m_incomingRulesUpdateControl.PopulateToSIPAccounts(m_riaContext.SIPAccounts);
            m_incomingRulesPanel.SetTitle("Incoming Call Rules");
            m_incomingRulesPanel.MenuEnableFilter(false);
            m_incomingRulesPanel.MenuEnableHelp(false);
            m_incomingRulesPanel.MenuEnableAdd(false);
            m_incomingRulesPanel.GetAssetList = GetIncomingRules;
            //m_incomingRulesPanel.Add += () => { m_incomingRulesUpdateControl.SetRuleToUpdate(null); };

            m_intialised = true;
            m_currentGrid = m_outgoingRulesDataGrid;

            m_outgoingRulesPanel.RefreshAsync();
        }
        public SIPDialPlan ToSIPDialPlan()
        {
            var entitySIPDialPlan = new SIPDialPlan()
            {
                Owner                 = String.Empty,
                ID                    = ID,
                DialPlanName          = DialPlanName,
                TraceEmailAddress     = TraceEmailAddress,
                DialPlanScript        = DialPlanScript,
                ScriptTypeDescription = ScriptTypeDescription,
                AcceptNonInvite       = AcceptNonInvite
            };

            return(entitySIPDialPlan);
        }
        public DialPlanUpdateControl(
            SIPDialPlan dialPlan,
            string owner,
            DialPlanUpdateDelegate dialPlanUpdate,
            ControlClosedDelegate closed)
        {
            InitializeComponent();

            m_owner = owner;
            m_dialPlan = dialPlan;

            DialPlanUpdate_External = dialPlanUpdate;
            ControlClosed_External = closed;

            PopulateDataFields(m_dialPlan);
        }
 private void AddDialPlan(SIPDialPlan dialPlan)
 {
     m_addAction(dialPlan);
 }
        public DialPlanWizard(
            ActivityMessageDelegate logActivityMessage,
            SIPDialPlan dialPlan,
            string owner,
            DialPlanUpdateDelegate dialPlanAdd,
            DialPlanUpdateDelegate dialPlanUpdate,
            ControlClosedDelegate closed,
            SIPEntitiesDomainContext riaContext)
        {
            InitializeComponent();

            LogActivityMessage_External = logActivityMessage;
            m_dialPlan = dialPlan;
            m_owner = owner;
            DialPlanAdd_External = dialPlanAdd;
            DialPlanUpdate_External = dialPlanUpdate;
            ControlClosed_External = closed;
            m_riaContext = riaContext;

            m_riaContext.RejectChanges();

            m_speedDialsPanel.SetTitle("Speed Dials");
            m_speedDialsPanel.MenuEnableFilter(false);
            m_speedDialsPanel.MenuEnableHelp(true);
            m_speedDialsPanel.MenuEnableAdd(false);
            m_speedDialsPanel.GetAssetList = GetSpeedDials;
            m_speedDialsPanel.Help += () => { ToggleSpeedDialsHelp(true); };
            ToggleSpeedDialsHelp(false);

            m_enumsPanel.SetTitle("ENUMs");
            m_enumsPanel.MenuEnableFilter(false);
            m_enumsPanel.MenuEnableHelp(true);
            m_enumsPanel.MenuEnableAdd(false);
            m_enumsPanel.GetAssetList = GetENUMs;
            m_enumsPanel.Help += () => { ToggleENUMHelp(true); };
            ToggleENUMHelp(false);

            m_cnamPanel.SetTitle("CNAMs");
            m_cnamPanel.MenuEnableFilter(false);
            m_cnamPanel.MenuEnableHelp(true);
            m_cnamPanel.MenuEnableAdd(false);
            m_cnamPanel.GetAssetList = GetCNAMs;
            m_cnamPanel.Help += () => { ToggleCNAMHelp(true); };
            ToggleCNAMHelp(false);

            m_providersPanel.SetTitle("Dial Plan Providers");
            m_providersPanel.MenuEnableFilter(false);
            m_providersPanel.MenuEnableHelp(true);
            m_providersPanel.MenuEnableAdd(false);
            m_providersPanel.GetAssetList = GetDialPlanProviders;
            m_providersPanel.Help += () => { ToggleDialPlanProvidersHelp(true); };
            ToggleDialPlanProvidersHelp(false);

            m_routesPanel.SetTitle("Routes");
            m_routesPanel.MenuEnableFilter(false);
            m_routesPanel.MenuEnableHelp(true);
            m_routesPanel.MenuEnableAdd(false);
            m_routesPanel.GetAssetList = GetRoutes;
            m_routesPanel.Help += () => { ToggleRoutesHelp(true); };
            ToggleRoutesHelp(false);

            m_intialised = true;

            m_speedDialsPanel.RefreshAsync();
        }
        private void AddButtonClicked(object sender, System.Windows.RoutedEventArgs e)
        {
            if (m_dialPlanName.Text.Trim().Length == 0)
            {
                WriteStatusMessage(MessageLevelsEnum.Warn, "The Dial Plan Name cannot be empty.");
            }
            else
            {
                SIPDialPlanScriptTypesEnum scriptType = SIPDialPlanScriptTypesEnum.Ruby;
                if (m_dialPlanTypeTelisWizard.IsChecked.Value)
                {
                    scriptType = SIPDialPlanScriptTypesEnum.TelisWizard;
                }
                else if (m_dialPlanTypeSimpleWizard.IsChecked.Value)
                {
                    scriptType = SIPDialPlanScriptTypesEnum.SimpleWizard;
                }

                SIPDialPlan dialPlan = new SIPDialPlan()
                {
                    ID = Guid.Empty.ToString(),
                    Owner = m_owner,
                    DialPlanName = m_dialPlanName.Text.Trim(),
                    ScriptTypeDescription = scriptType.ToString(),
                    Inserted = DateTimeOffset.UtcNow.ToString("o"),
                    LastUpdate = DateTimeOffset.UtcNow.ToString("o")
                };

                WriteStatusMessage(MessageLevelsEnum.Info, "Adding Dial Plan please wait...");

                AddDialPlan(dialPlan);
            }
        }
Esempio n. 9
0
        public void UpdateSIPDialPlan(string authUser, SIPDialPlan sipDialPlan)
        {
            if (authUser.IsNullOrBlank())
            {
                throw new ArgumentException("An authenticated user is required for UpdateSIPDialPlan.");
            }

            using (var sipSorceryEntities = new SIPSorceryEntities())
            {
                SIPDialPlan existingAccount = (from dp in sipSorceryEntities.SIPDialPlans where dp.ID == sipDialPlan.ID && dp.Owner.ToLower() == authUser.ToLower() select dp).FirstOrDefault();

                if (existingAccount == null)
                {
                    throw new ApplicationException("The SIP Dial Plan to update could not be found.");
                }
                else if (existingAccount.Owner != authUser.ToLower())
                {
                    logger.Warn("User " + authUser + " was not authorised to update dial plan " + existingAccount.DialPlanName + " belonging to " + existingAccount.Owner + ".");
                    throw new ApplicationException("Not authorised to update the SIP Dial Plan.");
                }
                else if (existingAccount.IsReadOnly)
                {
                    throw new ApplicationException("This Dial Plan is read-only. Please upgrade to a Premium service to enable it.");
                }

                logger.Debug("Updating SIP dialplan " + existingAccount.DialPlanName + " for " + existingAccount.Owner + ".");

                existingAccount.DialPlanScript = sipDialPlan.DialPlanScript;
                existingAccount.LastUpdate = DateTimeOffset.UtcNow.ToString("o");
                existingAccount.TraceEmailAddress = sipDialPlan.TraceEmailAddress;
                //existingAccount.ScriptTypeDescription = sipDialPlan.ScriptTypeDescription;
                existingAccount.AcceptNonInvite = sipDialPlan.AcceptNonInvite;

                if (existingAccount.DialPlanName != sipDialPlan.DialPlanName)
                {
                    // Need to update the SIP accounts using the dial plan.
                    string dialPlanName = existingAccount.DialPlanName;

                    UpdateSIPAccountsDialPlanName(sipSorceryEntities, authUser, existingAccount.DialPlanName, sipDialPlan.DialPlanName);

                    existingAccount.DialPlanName = sipDialPlan.DialPlanName;
                }
                //string validationError = SIPDialPlan.Validate(existingAccount);
                //if (validationError != null)
                //{
                //    throw new ApplicationException(validationError);
                //}

                sipSorceryEntities.SaveChanges();
            }
        }
Esempio n. 10
0
        public void DeleteSIPDialPlan(string authUser, SIPDialPlan sipDialPlan)
        {
            using (var sipSorceryEntities = new SIPSorceryEntities())
            {
                SIPDialPlan existingAccount = (from dp in sipSorceryEntities.SIPDialPlans where dp.ID == sipDialPlan.ID && dp.Owner == authUser.ToLower() select dp).FirstOrDefault();

                if (existingAccount == null)
                {
                    throw new ApplicationException("The SIP Dial Plan to delete could not be found.");
                }
                else if (existingAccount.Owner != authUser.ToLower())
                {
                    throw new ApplicationException("Not authorised to delete the SIP Dial Plan.");
                }

                sipSorceryEntities.SIPDialPlans.DeleteObject(existingAccount);
                sipSorceryEntities.SaveChanges();
            }
        }
Esempio n. 11
0
        public void InsertSIPDialPlan(string authUser, SIPDialPlan sipDialPlan)
        {
            if (authUser.IsNullOrBlank())
            {
                throw new ArgumentException("An authenticated user is required for InsertSIPDialPlan.");
            }

            //string validationError = SIPDialPlan.Validate(sipDialPlan);
            //if (validationError != null)
            //{
            //    throw new ApplicationException(validationError);
            //}

            using (var sipSorceryEntities = new SIPSorceryEntities())
            {
                string serviceLevel = (from cust in sipSorceryEntities.Customers where cust.Name.ToLower() == authUser.ToLower() select cust.ServiceLevel).FirstOrDefault();

                if (!serviceLevel.IsNullOrBlank() && serviceLevel.ToLower() == CustomerServiceLevels.Free.ToString().ToLower())
                {
                    // Check the number of Dial Plans is within limits.
                    if ((from dialPlan in sipSorceryEntities.SIPDialPlans
                         where dialPlan.Owner == authUser.ToLower() && !dialPlan.IsReadOnly
                         select dialPlan).Count() >= DIALPLAN_COUNT_FREE_SERVICE)
                    {
                        throw new ApplicationException("The Dial Plan cannot be added. You are limited to " + DIALPLAN_COUNT_FREE_SERVICE + " dial plan on a Free account. Please upgrade to a Premium service if you wish to create additional dial plans.");
                    }
                }

                sipDialPlan.ID = Guid.NewGuid().ToString();
                sipDialPlan.Owner = authUser.ToLower();
                sipDialPlan.Inserted = DateTimeOffset.UtcNow.ToString("o");
                sipDialPlan.LastUpdate = DateTimeOffset.UtcNow.ToString("o");
                sipDialPlan.MaxExecutionCount = SIPDialPlan.DEFAULT_MAXIMUM_EXECUTION_COUNT;

                if (sipDialPlan.ScriptType == SIPDialPlanScriptTypesEnum.TelisWizard)
                {
                    // Set the default script.
                    sipDialPlan.DialPlanScript = "require 'teliswizard'";

                    // Create a new SIP dialplan options record.
                    SIPDialplanOption options = sipSorceryEntities.SIPDialplanOptions.CreateObject();
                    options.ID = Guid.NewGuid().ToString();
                    options.Owner = sipDialPlan.Owner;
                    options.DialPlanID = sipDialPlan.ID;
                    sipSorceryEntities.SIPDialplanOptions.AddObject(options);
                }
                if (sipDialPlan.ScriptType == SIPDialPlanScriptTypesEnum.SimpleWizard)
                {
                    // Set the default script.
                    sipDialPlan.DialPlanScript = "require 'simplewizard'";
                }

                sipSorceryEntities.SIPDialPlans.AddObject(sipDialPlan);
                sipSorceryEntities.SaveChanges();
            }
        }
Esempio n. 12
0
        public void CopySIPDialPlan(string authUser, string sipDialPlanID)
        {
            if (authUser.IsNullOrBlank())
            {
                throw new ArgumentException("An authenticated user is required for CopySIPDialPlan.");
            }

            using (var sipSorceryEntities = new SIPSorceryEntities())
            {
                SIPDialPlan existingAccount = (from dp in sipSorceryEntities.SIPDialPlans where dp.ID == sipDialPlanID && dp.Owner.ToLower() == authUser.ToLower() select dp).FirstOrDefault();

                if (existingAccount == null)
                {
                    throw new ApplicationException("The SIP Dial Plan to copy could not be found.");
                }
                else if (existingAccount.Owner != authUser.ToLower())
                {
                    logger.Warn("User " + authUser + " was not authorised to copy dial plan " + existingAccount.DialPlanName + " belonging to " + existingAccount.Owner + ".");
                    throw new ApplicationException("Not authorised to copy the SIP Dial Plan.");
                }
                else if (existingAccount.IsReadOnly)
                {
                    throw new ApplicationException("This Dial Plan is read-only. Please upgrade to a Premium service to enable it.");
                }

                logger.Debug("Copying SIP dialplan " + existingAccount.DialPlanName + " for " + existingAccount.Owner + ".");

                string newDialPlanName = existingAccount.DialPlanName + " Copy";

                if (sipSorceryEntities.SIPDialPlans.Any(x => x.DialPlanName.ToLower() == newDialPlanName.ToLower() && x.Owner.ToLower() == authUser.ToLower()))
                {
                    int attempts = 2;
                    string newNameAttempt = newDialPlanName + " " + attempts.ToString();

                    while (sipSorceryEntities.SIPDialPlans.Any(x => x.DialPlanName.ToLower() == newNameAttempt.ToLower() && x.Owner.ToLower() == authUser.ToLower()) && attempts < 10)
                    {
                        attempts++;
                        newNameAttempt = newDialPlanName + " " + attempts.ToString();
                    }

                    if (attempts < 10)
                    {
                        newDialPlanName = newNameAttempt;
                    }
                    else
                    {
                        throw new ApplicationException("A new dial plan name could not be created for a dial plan copy operation.");
                    }
                }

                SIPDialPlan copy = new SIPDialPlan();
                copy.ID = Guid.NewGuid().ToString();
                copy.Owner = authUser.ToLower();
                copy.AdminMemberId = existingAccount.AdminMemberId;
                copy.Inserted = DateTimeOffset.UtcNow.ToString("o");
                copy.LastUpdate = DateTimeOffset.UtcNow.ToString("o");
                copy.MaxExecutionCount = SIPDialPlan.DEFAULT_MAXIMUM_EXECUTION_COUNT;
                copy.DialPlanName = newDialPlanName;
                copy.DialPlanScript = existingAccount.DialPlanScript;
                copy.ScriptTypeDescription = existingAccount.ScriptTypeDescription;
                copy.AuthorisedApps = existingAccount.AuthorisedApps;
                copy.AcceptNonInvite = existingAccount.AcceptNonInvite;

                sipSorceryEntities.SIPDialPlans.AddObject(copy);
                //sipSorceryEntities.SaveChanges();

                logger.Debug("A new dial plan copy was created for " + existingAccount.DialPlanName + ", new dial plan name " + copy.DialPlanName + ".");

                if (existingAccount.ScriptType == SIPDialPlanScriptTypesEnum.SimpleWizard)
                {
                    var simpleWizardRules = sipSorceryEntities.SimpleWizardRules.Where(x => x.Owner == authUser.ToLower() && x.DialPlanID == existingAccount.ID);

                    if (simpleWizardRules != null && simpleWizardRules.Count() > 0)
                    {
                        foreach (var rule in simpleWizardRules)
                        {
                            SimpleWizardRule copiedRule = new SimpleWizardRule();
                            copiedRule.ID = Guid.NewGuid().ToString();
                            copiedRule.DialPlanID = copy.ID;
                            copiedRule.Owner = authUser.ToLower();
                            copiedRule.ToMatchType = rule.ToMatchType;
                            copiedRule.ToMatchParameter = rule.ToMatchParameter;
                            copiedRule.Description = rule.Description;
                            copiedRule.Command = rule.Command;
                            copiedRule.CommandParameter1 = rule.CommandParameter1;
                            copiedRule.CommandParameter2 = rule.CommandParameter2;
                            copiedRule.CommandParameter3 = rule.CommandParameter3;
                            copiedRule.CommandParameter4 = rule.CommandParameter4;
                            copiedRule.Direction = rule.Direction;
                            copiedRule.PatternType = rule.PatternType;
                            copiedRule.Pattern = rule.Pattern;
                            copiedRule.Priority = rule.Priority;
                            copiedRule.IsDisabled = rule.IsDisabled;
                            copiedRule.TimePattern = rule.TimePattern;
                            copiedRule.ToSIPAccount = rule.ToSIPAccount;
                            copiedRule.ToProvider = rule.ToProvider;

                            sipSorceryEntities.SimpleWizardRules.AddObject(copiedRule);

                            logger.Debug("Copied simple wizard rule priority " + rule.Priority + " to dial plan " + copy.DialPlanName + ".");
                        }
                    }
                }

                sipSorceryEntities.SaveChanges();
            }
        }
 private void DetailsControlClosed()
 {
     m_dialPlansPanel.CloseDetailsPane();
     m_selectedDialPlan = null;
 }
Esempio n. 14
0
        public void InsertCustomer(Customer customer)
        {
            using (var sipSorceryEntities = new SIPSorceryEntities())
            {
                if (sipSorceryEntities.Customers.Any(x => x.Name == customer.Name.ToLower()))
                {
                    throw new ApplicationException("The username is already taken. Please choose a different one.");
                }
                else if (sipSorceryEntities.Customers.Any(x => x.EmailAddress.ToLower() == customer.EmailAddress.ToLower()))
                {
                    throw new ApplicationException("The email address is already associated with an account.");
                }
                else
                {
                    customer.ID = Guid.NewGuid().ToString();
                    customer.Inserted = DateTime.UtcNow.ToString("o");
                    customer.Name = customer.Name.Trim().ToLower();
                    customer.MaxExecutionCount = Customer.FREE_MAXIMUM_EXECUTION_COUNT;
                    customer.APIKey = Crypto.GetRandomByteString(Customer.API_KEY_LENGTH / 2);
                    customer.ServiceLevel = (customer.ServiceLevel == null) ? CustomerServiceLevels.Free.ToString() : customer.ServiceLevel;
                    customer.EmailAddressConfirmed = true;
                    customer.CreatedFromIPAddress = System.Web.HttpContext.Current.Request.UserHostAddress;

                    string plainTextassword = customer.CustomerPassword;

                    // Hash the password.
                    string salt = PasswordHash.GenerateSalt();
                    customer.CustomerPassword = PasswordHash.Hash(customer.CustomerPassword, salt);
                    customer.Salt = salt;

                    if (customer.ServiceRenewalDate != null)
                    {
                        DateTime renewalDate = DateTime.MinValue;
                        if (DateTime.TryParse(customer.ServiceRenewalDate, out renewalDate))
                        {
                            customer.ServiceRenewalDate = DateTime.SpecifyKind(renewalDate, DateTimeKind.Utc).ToUniversalTime().ToString("o");
                        }
                        else
                        {
                            throw new ApplicationException("The service renewal date could not be parsed as a valid date.");
                        }
                    }

                    if ((customer.EntityState != EntityState.Detached))
                    {
                        sipSorceryEntities.ObjectStateManager.ChangeObjectState(customer, EntityState.Added);
                    }
                    else
                    {
                        sipSorceryEntities.Customers.AddObject(customer);
                    }

                    sipSorceryEntities.SaveChanges();

                    logger.Debug("New customer record added for " + customer.Name + ".");

                    // Create a default dialplan.
                    SIPDialPlan defaultDialPlan = new SIPDialPlan()
                    {
                        ID = Guid.NewGuid().ToString(),
                        Owner = customer.Name,
                        DialPlanName = "default",
                        DialPlanScript = "sys.Log(\"Log message from default dialplan.\")\nsys.Dial(\"[email protected]\")\n",
                        ScriptTypeDescription = SIPDialPlanScriptTypesEnum.Ruby.ToString(),
                        Inserted = DateTimeOffset.UtcNow.ToString("o"),
                        LastUpdate = DateTimeOffset.UtcNow.ToString("o"),
                        MaxExecutionCount = SIPDialPlan.DEFAULT_MAXIMUM_EXECUTION_COUNT
                    };
                    sipSorceryEntities.SIPDialPlans.AddObject(defaultDialPlan);
                    sipSorceryEntities.SaveChanges();

                    logger.Debug("Default dialplan added for " + customer.Name + ".");

                    // Get default domain name.
                    string defaultDomain = sipSorceryEntities.SIPDomains.Where(x => x.AliasList.Contains("local")).Select(y => y.Domain).First();

                    // Create SIP account.
                    if (!sipSorceryEntities.SIPAccounts.Any(s => s.SIPUsername == customer.Name && s.SIPDomain == defaultDomain))
                    {
                        SIPAccount sipAccount = SIPAccount.Create(customer.Name, defaultDomain, customer.Name, plainTextassword, "default");
                        sipSorceryEntities.SIPAccounts.AddObject(sipAccount);
                        sipSorceryEntities.SaveChanges();
                        logger.Debug("SIP account " + sipAccount.SIPUsername + "@" + sipAccount.SIPDomain + " added for " + sipAccount.Owner + ".");
                    }
                    else
                    {
                        int attempts = 0;
                        while (attempts < 10)
                        {
                            string testUsername = customer.Name + Crypto.GetRandomString(4);
                            if (!sipSorceryEntities.SIPAccounts.Any(s => s.SIPUsername == testUsername && s.SIPDomain == defaultDomain))
                            {
                                SIPAccount sipAccount = SIPAccount.Create(customer.Name, defaultDomain, testUsername, plainTextassword, "default");
                                sipSorceryEntities.SIPAccounts.AddObject(sipAccount);
                                sipSorceryEntities.SaveChanges();
                                logger.Debug("SIP account " + sipAccount.SIPUsername + "@" + sipAccount.SIPDomain + " added for " + sipAccount.Owner + ".");
                                break;
                            }
                            else
                            {
                                attempts++;
                            }
                        }
                    }

                    if (!m_customerConfirmLink.IsNullOrBlank())
                    {
                        logger.Debug("Sending new account confirmation email to " + customer.EmailAddress + ".");
                        SIPSorcerySMTP.SendEmail(customer.EmailAddress, NEW_ACCOUNT_EMAIL_FROM_ADDRESS, NEW_ACCOUNT_EMAIL_SUBJECT, String.Format(NEW_ACCOUNT_EMAIL_BODY, customer.Firstname, m_customerConfirmLink, customer.ID));
                    }
                    else
                    {
                        logger.Debug("Customer confirmation email was not sent as no confirmation link has been set.");
                    }
                }
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the SIPDialPlans EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSIPDialPlans(SIPDialPlan sIPDialPlan)
 {
     base.AddObject("SIPDialPlans", sIPDialPlan);
 }
 private void DialPlansDataGrid_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     try
     {
         if (!m_dialPlansPanelRefreshInProgress && m_riaContext.SIPDialPlans.Count() > 0)
         {
             DataGrid dataGrid = (DataGrid)sender;
             if (dataGrid.CurrentColumn.Header as string != "Delete" && dataGrid.CurrentColumn.Header as string != "Copy")
             {
                 SIPDialPlan dialPlan = (SIPDialPlan)m_dialPlansDataGrid.SelectedItem;
                 EditDialPlan(dialPlan);
             }
         }
     }
     catch (Exception excp)
     {
         LogActivityMessage_External(MessageLevelsEnum.Error, "Exception showing DialPlan details. " + excp.Message);
         m_selectedDialPlan = null;
     }
 }
 private void DialPlansPanel_Add()
 {
     m_selectedDialPlan = null;
     m_addControl = new DialPlanAddControl(m_owner, DetailsControlClosed, AddDialPlan);
     m_dialPlansPanel.SetDetailsElement(m_addControl);
 }
 private void UpdateDialPlan(SIPDialPlan dialPlan)
 {
     m_riaContext.SubmitChanges(UpdateDialPlanComplete, dialPlan);
 }
        private void EditDialPlan(SIPDialPlan dialPlan)
        {
            if (m_selectedDialPlan == null || m_selectedDialPlan != dialPlan)
            {
                m_selectedDialPlan = dialPlan;

                if (m_selectedDialPlan.ScriptType == SIPDialPlanScriptTypesEnum.TelisWizard)
                {
                    if (m_wizardEditControl != null)
                    {
                        m_wizardEditControl.DisableSelectionChanges();
                    }

                    m_wizardEditControl = new DialPlanWizard(LogActivityMessage_External, m_selectedDialPlan, m_owner, null, UpdateDialPlan, DetailsControlClosed, m_riaContext);
                    m_dialPlansPanel.SetDetailsElement(m_wizardEditControl);
                }
                else if (m_selectedDialPlan.ScriptType == SIPDialPlanScriptTypesEnum.SimpleWizard)
                {
                    m_simpleWizardManager = new SimpleWizardManager(LogActivityMessage_External, m_selectedDialPlan, m_owner, null, UpdateDialPlan, DetailsControlClosed, m_riaContext);
                    m_dialPlansPanel.SetDetailsElement(m_simpleWizardManager);
                }
                else
                {
                    m_editControl = new DialPlanUpdateControl(m_selectedDialPlan, m_owner, UpdateDialPlan, DetailsControlClosed);
                    m_dialPlansPanel.SetDetailsElement(m_editControl);
                }
            }
        }
 /// <summary>
 /// Create a new SIPDialPlan object.
 /// </summary>
 /// <param name="dialPlanName">Initial value of the DialPlanName property.</param>
 /// <param name="executionCount">Initial value of the ExecutionCount property.</param>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="inserted">Initial value of the Inserted property.</param>
 /// <param name="lastUpdate">Initial value of the LastUpdate property.</param>
 /// <param name="maxExecutionCount">Initial value of the MaxExecutionCount property.</param>
 /// <param name="owner">Initial value of the Owner property.</param>
 /// <param name="scriptTypeDescription">Initial value of the ScriptTypeDescription property.</param>
 /// <param name="acceptNonInvite">Initial value of the AcceptNonInvite property.</param>
 /// <param name="isReadOnly">Initial value of the IsReadOnly property.</param>
 public static SIPDialPlan CreateSIPDialPlan(global::System.String dialPlanName, global::System.Int32 executionCount, global::System.String id, global::System.String inserted, global::System.String lastUpdate, global::System.Int32 maxExecutionCount, global::System.String owner, global::System.String scriptTypeDescription, global::System.Boolean acceptNonInvite, global::System.Boolean isReadOnly)
 {
     SIPDialPlan sIPDialPlan = new SIPDialPlan();
     sIPDialPlan.DialPlanName = dialPlanName;
     sIPDialPlan.ExecutionCount = executionCount;
     sIPDialPlan.ID = id;
     sIPDialPlan.Inserted = inserted;
     sIPDialPlan.LastUpdate = lastUpdate;
     sIPDialPlan.MaxExecutionCount = maxExecutionCount;
     sIPDialPlan.Owner = owner;
     sIPDialPlan.ScriptTypeDescription = scriptTypeDescription;
     sIPDialPlan.AcceptNonInvite = acceptNonInvite;
     sIPDialPlan.IsReadOnly = isReadOnly;
     return sIPDialPlan;
 }
Esempio n. 21
0
        public SIPDialPlan ToSIPDialPlan()
        {
            var entitySIPDialPlan = new SIPDialPlan()
            {
                Owner = String.Empty,
                ID = ID,
                DialPlanName = DialPlanName,
                TraceEmailAddress = TraceEmailAddress,
                DialPlanScript = DialPlanScript,
                ScriptTypeDescription = ScriptTypeDescription,
                AcceptNonInvite = AcceptNonInvite
            };

            return entitySIPDialPlan;
        }