public void SimpleDialPlanTest()
        {
            Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            string testDialPlan = @"
					exten => 100,1,Switch(""anonymous.invalid"", ""password"", ""*****@*****.**"")
					exten => 101,1,Switch(""username"", ""password"", ""*****@*****.**"")
				"                ;

            SIPDialPlan         dialPlan        = new SIPDialPlan(null, null, null, testDialPlan, SIPDialPlanScriptTypesEnum.Asterisk);
            DialPlanLineContext dialPlanContext = new DialPlanLineContext(null, null, null, null, null, dialPlan, null, null, null, null);

            Console.WriteLine("dst=" + dialPlanContext.m_commands[0].Destination + ", data=" + dialPlanContext.m_commands[0].Data + ".");
            Console.WriteLine("dst=" + dialPlanContext.m_commands[1].Destination + ", data=" + dialPlanContext.m_commands[1].Data + ".");

            Assert.IsTrue(dialPlanContext.m_commands.Count == 2, "The dial plan was not correctly parsed.");
            Assert.IsTrue(dialPlanContext.m_commands[0].Operation == DialPlanOpsEnum.Equals, "Command 1 oeration not correct.");
            Assert.IsTrue(dialPlanContext.m_commands[1].Operation == DialPlanOpsEnum.Equals, "Command 2 oeration not correct.");
            Assert.IsTrue(dialPlanContext.m_commands[0].Destination == "100", "Command 1 destination not correct.");
            Assert.IsTrue(dialPlanContext.m_commands[1].Destination == "101", "Command 2 destination not correct.");
            Assert.IsTrue(dialPlanContext.m_commands[0].Command == "Switch", "Command 1 command not correct.");
            Assert.IsTrue(dialPlanContext.m_commands[1].Command == "Switch", "Command 2 command not correct.");
            Assert.IsTrue(dialPlanContext.m_commands[0].Data == "\"anonymous.invalid\", \"password\", \"[email protected]\"", "Command 1 data not correct.");
            Assert.IsTrue(dialPlanContext.m_commands[1].Data == "\"username\", \"password\", \"[email protected]\"", "Command 2 data not correct.");

            Console.WriteLine("---------------------------------");
        }
示例#2
0
        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);
            }
        }
        //public event Action DialPlanComplete;

        public DialPlanContext(
            SIPMonitorLogDelegate monitorLogDelegate,
            SIPTransport sipTransport,
            DialogueBridgeCreatedDelegate createBridge,
            SIPEndPoint outboundProxy,
            ISIPServerUserAgent sipServerUserAgent,
            SIPDialPlan dialPlan,
            List <SIPProvider> sipProviders,
            string traceDirectory,
            string callersNetworkId,
            Customer customer,
            DialPlanEngine dialPlanEngine,
            GetCanonicalDomainDelegate getCanonicalDomain)
        {
            Log_External          = monitorLogDelegate;
            CreateBridge_External = createBridge;
            m_sipTransport        = sipTransport;
            m_outboundProxy       = outboundProxy;
            m_sipServerUserAgent  = sipServerUserAgent;
            m_dialPlan            = dialPlan;
            m_sipProviders        = sipProviders;
            m_traceDirectory      = traceDirectory;
            CallersNetworkId      = callersNetworkId;
            Customer                    = customer;
            m_dialPlanEngine            = dialPlanEngine;
            GetCanonicalDomain_External = getCanonicalDomain;

            m_sipServerUserAgent.CallCancelled       += ClientCallCancelled;
            m_sipServerUserAgent.NoRingTimeout       += ClientCallNoRingTimeout;
            m_sipServerUserAgent.TransactionComplete += ClientTransactionRemoved;
            m_sipServerUserAgent.SetTraceDelegate(TransactionTraceMessage);
        }
示例#4
0
        public DialPlanDetailsControl(
            DetailsControlModesEnum mode,
            SIPDialPlan dialPlan,
            string owner,
            DialPlanUpdateDelegate dialPlanAdd,
            DialPlanUpdateDelegate dialPlanUpdate,
            ControlClosedDelegate closed)
        {
            InitializeComponent();

            m_detailsMode = mode;
            m_owner       = owner;
            m_dialPlan    = dialPlan;

            DialPlanAdd_External    = dialPlanAdd;
            DialPlanUpdate_External = dialPlanUpdate;
            ControlClosed_External  = closed;

            if (mode == DetailsControlModesEnum.Edit)
            {
                m_applyButton.Content = "Update";
                PopulateDataFields(m_dialPlan);
            }
            else
            {
                m_dialPlanIdCanvas.Visibility = Visibility.Collapsed;
                m_applyButton.Content         = "Add";
            }
        }
示例#5
0
        private void CopyDialPlan(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            SIPDialPlan dialPlan = m_dialPlansDataGrid.SelectedItem as SIPDialPlan;

            LogActivityMessage_External(MessageLevelsEnum.Info, "Sending copy request for Dial Plan " + dialPlan.DialPlanName + ".");
            m_riaContext.CopySIPDialplan(dialPlan.ID, CopyDialPlanComplete, null);
        }
示例#6
0
        public JSONResult <string> AddDialPlan(SIPDialPlanJSON sipDialPlan)
        {
            try
            {
                var customer = AuthoriseRequest();

                if (sipDialPlan.ScriptTypeDescription.IsNullOrBlank())
                {
                    sipDialPlan.ScriptTypeDescription = SIPDialPlanScriptTypesEnum.Ruby.ToString();
                }

                SIPDialPlan entityDialPlan = sipDialPlan.ToSIPDialPlan();
                m_service.InsertSIPDialPlan(customer.Name, entityDialPlan);

                return(new JSONResult <string>()
                {
                    Success = true, Result = entityDialPlan.ID
                });
            }
            catch (Exception excp)
            {
                return(new JSONResult <string>()
                {
                    Success = false, Error = excp.Message
                });
            }
        }
示例#7
0
        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);
                }
            }
        }
示例#8
0
        private void UpdateDialPlanComplete(SubmitOperation so)
        {
            SIPDialPlan dialPlan = (SIPDialPlan)so.UserState;

            if (so.HasError)
            {
                if (m_editControl != null)
                {
                    m_editControl.WriteStatusMessage(MessageLevelsEnum.Error, "There was an error performing a Dial Plan update." + so.Error.Message);
                }
                else
                {
                    LogActivityMessage_External(MessageLevelsEnum.Error, "There was an error performing a Dial Plan update." + so.Error.Message);
                }

                so.MarkErrorAsHandled();
            }
            else
            {
                if (m_editControl != null)
                {
                    m_editControl.WriteStatusMessage(MessageLevelsEnum.Info, "Update completed successfully for " + dialPlan.DialPlanName + ".");
                }
            }
        }
示例#9
0
        public void UpdateSIPDialplanTest()
        {
            SIPEntitiesDomainService target = new SIPEntitiesDomainService(); // TODO: Initialize to an appropriate value
            SIPDialPlan currentSIPDialplan  = null;                           // TODO: Initialize to an appropriate value

            target.UpdateSIPDialplan(currentSIPDialplan);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
 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;
 }
示例#11
0
        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 SIPDialPlan UpdateDialPlan(SIPDialPlan dialPlan)
        {
            Customer customer = AuthoriseRequest();

            if (customer.AdminId != Customer.TOPLEVEL_ADMIN_ID && dialPlan.Owner != customer.CustomerUsername)
            {
                throw new ApplicationException("You are not authorised to update the Dial Plan.");
            }

            return(DialPlanPersistor.Update(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();
        }
示例#14
0
        private void PopulateDataFields(SIPDialPlan dialPlan)
        {
            m_dialPlanId.Text   = dialPlan.Id.ToString();
            m_dialPlanName.Text = dialPlan.DialPlanName;
            m_dialPlanTraceEmailAddress.Text = (dialPlan.TraceEmailAddress != null) ? dialPlan.TraceEmailAddress : String.Empty;
            m_dialPlanText.Text = dialPlan.DialPlanScript;

            if (dialPlan.ScriptType == SIPDialPlanScriptTypesEnum.Asterisk)
            {
                m_dialPlanTypeExtension.IsChecked = true;
            }
        }
示例#15
0
        private void DeleteDialPlan(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            SIPDialPlan      dialPlan      = m_dialPlansDataGrid.SelectedItem as SIPDialPlan;
            MessageBoxResult confirmDelete = MessageBox.Show("Press Ok to delete " + dialPlan.DialPlanName + ".", "Confirm Delete", MessageBoxButton.OKCancel);

            if (confirmDelete == MessageBoxResult.OK)
            {
                LogActivityMessage_External(MessageLevelsEnum.Info, "Sending delete request for Dial Plan " + dialPlan.DialPlanName + ".");
                m_riaContext.SIPDialPlans.Remove(dialPlan);
                m_riaContext.SubmitChanges(DeleteDialPlanComplete, dialPlan);
            }
        }
        public SIPDialPlan AddDialPlan(SIPDialPlan dialPlan)
        {
            Customer customer = AuthoriseRequest();

            dialPlan.Owner = customer.CustomerUsername;

            if (customer.AdminId != Customer.TOPLEVEL_ADMIN_ID)
            {
                dialPlan.MaxExecutionCount = SIPDialPlan.DEFAULT_MAXIMUM_EXECUTION_COUNT;
            }

            return(DialPlanPersistor.Add(dialPlan));
        }
        public void RegexWithCommaLoadDialPlanTest()
        {
            Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            string testDialPlan =
                "exten =~ /3d{4,6}/,1,Switch(anon,,${dst}@sip.blueface.ie, \"sip switch\" <sip:[email protected]>, 194.213.29.100)";

            SIPDialPlan dialPlan = new SIPDialPlan(null, null, null, testDialPlan, SIPDialPlanScriptTypesEnum.Asterisk);

            Assert.IsNotNull(dialPlan, "The dial plan could not be loaded.");

            Console.WriteLine("---------------------------------");
        }
        private DialPlanLineContext GetDummyDialPlanContext(string testDialPlan, string dst)
        {
            SIPDialPlan          dialPlan          = new SIPDialPlan(null, null, null, testDialPlan, SIPDialPlanScriptTypesEnum.Asterisk);
            SIPTransactionEngine transactionEngine = new SIPTransactionEngine();
            SIPTransport         sipTransport      = new SIPTransport(MockSIPDNSManager.Resolve, transactionEngine);
            SIPURI               dummyURI          = SIPURI.ParseSIPURI(dst);
            SIPRequest           inviteRequest     = GetDummyINVITERequest(dummyURI);
            SIPEndPoint          dummyEndPoint     = SIPEndPoint.ParseSIPEndPoint("udp:0.0.0.0:5060");
            UASInviteTransaction uasTransaction    = sipTransport.CreateUASTransaction(inviteRequest, dummyEndPoint, dummyEndPoint, null);
            SIPServerUserAgent   uas             = new SIPServerUserAgent(sipTransport, null, "test", "sipsorcery.com", SIPCallDirection.In, null, null, null, uasTransaction);
            DialPlanLineContext  dialPlanContext = new DialPlanLineContext(null, null, null, null, uas, dialPlan, null, null, null, null);

            return(dialPlanContext);
        }
        public SIPDialPlan DeleteDialPlan(SIPDialPlan dialPlan)
        {
            Customer customer = AuthoriseRequest();

            if (customer.AdminId != Customer.TOPLEVEL_ADMIN_ID && dialPlan.Owner != customer.CustomerUsername)
            {
                throw new ApplicationException("You are not authorised to delete the Dial Plan.");
            }

            DialPlanPersistor.Delete(dialPlan);

            // Enables the caller to see which dialplan has been deleted.
            return(dialPlan);
        }
示例#20
0
        public void UpdateSIPDialplan(SIPDialPlan currentSIPDialplan)
        {
            //if (currentSIPDialplan.Owner != this.ServiceContext.User.Identity.Name)
            //{
            //    throw new ApplicationException("You are not authorised to update this record.");
            //}
            //else
            //{
            //    currentSIPDialplan.LastUpdate = DateTimeOffset.UtcNow.ToString("o");
            //    this.ObjectContext.SIPDialPlans.AttachAsModified(currentSIPDialplan, this.ChangeSet.GetOriginal(currentSIPDialplan));
            //}

            m_service.UpdateSIPDialPlan(this.ServiceContext.User.Identity.Name, currentSIPDialplan);
        }
示例#21
0
        public void InsertSIPDialplan(SIPDialPlan sipDialplan)
        {
            //string serviceLevel = (from cust in this.ObjectContext.Customers where cust.Name == this.ServiceContext.User.Identity.Name select cust.ServiceLevel).FirstOrDefault();

            //if (!serviceLevel.IsNullOrBlank() && serviceLevel.ToLower() == CustomerServiceLevels.Free.ToString().ToLower())
            //{
            //    // Check the number of dialplans is within limits.
            //    if ((from dialplan in this.ObjectContext.SIPDialPlans where dialplan.Owner == this.ServiceContext.User.Identity.Name select dialplan).Count() >= DIALPLAN_COUNT_FREE_SERVICE)
            //    {
            //        throw new ApplicationException("The dial plan cannot be added as your existing dial plan count has reached the allowed limit for your service level.");
            //    }
            //}

            //sipDialplan.Owner = this.ServiceContext.User.Identity.Name;
            //sipDialplan.Inserted = DateTime.UtcNow.ToString("o");
            //sipDialplan.MaxExecutionCount = SIPDialPlan.DEFAULT_MAXIMUM_EXECUTION_COUNT;

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

            //if ((sipDialplan.EntityState != EntityState.Detached))
            //{
            //    this.ObjectContext.ObjectStateManager.ChangeObjectState(sipDialplan, EntityState.Added);
            //}
            //else
            //{
            //    this.ObjectContext.SIPDialPlans.AddObject(sipDialplan);
            //}

            //if (sipDialplan.ScriptType == SIPDialPlanScriptTypesEnum.TelisWizard)
            //{
            //    // Create a new SIP dialplan options record.
            //    SIPDialplanOption options = this.ObjectContext.SIPDialplanOptions.CreateObject();
            //    options.ID = Guid.NewGuid().ToString();
            //    options.Owner = sipDialplan.Owner;
            //    options.DialPlanID = sipDialplan.ID;
            //    this.ObjectContext.SIPDialplanOptions.AddObject(options);
            //}

            m_service.InsertSIPDialPlan(this.ServiceContext.User.Identity.Name, sipDialplan);
        }
        public void SingleRangeNoMatchDialPlanTest()
        {
            Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            string testDialPlan = "exten => _3[2-57-9].,1,Switch(anon, password, [email protected])";

            SIPDialPlan         dialPlan        = new SIPDialPlan(null, null, null, testDialPlan, SIPDialPlanScriptTypesEnum.Asterisk);
            SIPRequest          request         = new SIPRequest(SIPMethodsEnum.INVITE, SIPURI.ParseSIPURI("sip:[email protected]"));
            DialPlanLineContext dialPlanContext = new DialPlanLineContext(null, null, null, null, null, dialPlan, null, null, null, null);
            DialPlanCommand     commandMatch    = dialPlanContext.GetDialPlanMatch(request.URI.User);

            Assert.IsNull(commandMatch, "The dial plan should not have returned a match.");

            Console.WriteLine("---------------------------------");
        }
 public DialPlanScriptContext(
     SIPMonitorLogDelegate monitorLogDelegate,
     SIPTransport sipTransport,
     DialogueBridgeCreatedDelegate createBridge,
     SIPEndPoint outboundProxy,
     ISIPServerUserAgent sipServerUserAgent,
     SIPDialPlan dialPlan,
     List <SIPProvider> sipProviders,
     string traceDirectory,
     string callersNetworkId,
     Guid customerId)
     : base(monitorLogDelegate, sipTransport, createBridge, outboundProxy, sipServerUserAgent, dialPlan, sipProviders, traceDirectory, callersNetworkId, customerId)
 {
     ContextType = DialPlanContextsEnum.Script;
 }
        public void RegexWithNoCommaMatchDialPlanTest()
        {
            Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            string testDialPlan =
                @"exten =~ \d{3},1,Switch(anon,,${dst}@sip.blueface.ie, ""sip switch"" <sip:[email protected]>, 194.213.29.100)";

            SIPDialPlan         dialPlan        = new SIPDialPlan(null, null, null, testDialPlan, SIPDialPlanScriptTypesEnum.Asterisk);
            SIPRequest          request         = new SIPRequest(SIPMethodsEnum.INVITE, SIPURI.ParseSIPURI("sip:[email protected]"));
            DialPlanLineContext dialPlanContext = new DialPlanLineContext(null, null, null, null, null, dialPlan, null, null, null, null);
            DialPlanCommand     commandMatch    = dialPlanContext.GetDialPlanMatch(request.URI.User);

            Assert.IsNotNull(commandMatch, "The dial plan should have returned a match.");

            Console.WriteLine("---------------------------------");
        }
        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);
        }
        public void TestLoadOldDefaultDialPlanTest()
        {
            Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            string testDialPlan =
                "; Example extensions\n" +
                "exten = 100,1,Switch(anon,,[email protected])\n" +
                "exten == 101,1,Switch(anon,,[email protected])\n" +
                "exten => _*1X.,1,Switch(user,pass,${EXTEN:2}@sip.blueface.ie)\n" +
                "exten => _*2X.,1,Switch(anon,,${EXTEN:2}@fwd.pulver.com)\n";

            SIPDialPlan dialPlan = new SIPDialPlan(null, null, null, testDialPlan, SIPDialPlanScriptTypesEnum.Asterisk);

            Assert.IsNotNull(dialPlan, "The default dial plan could not be loaded.");

            Console.WriteLine("---------------------------------");
        }
示例#27
0
 public DialPlanLineContext(
     SIPMonitorLogDelegate monitorLogDelegate,
     SIPTransport sipTransport,
     DialogueBridgeCreatedDelegate createBridge,
     SIPEndPoint outboundProxy,
     ISIPServerUserAgent sipServerUserAgent,
     SIPDialPlan dialPlan,
     List <SIPProvider> sipProviders,
     string traceDirectory,
     string callersNetworkId,
     Guid customerID)
     : base(monitorLogDelegate, sipTransport, createBridge, outboundProxy, sipServerUserAgent, dialPlan, sipProviders, traceDirectory, callersNetworkId, customerID)
 {
     ContextType = DialPlanContextsEnum.Line;
     string[] dialPlanEntries = dialPlan.DialPlanScript.Split(new char[] { '\n' });
     ParseDialPlan(dialPlanEntries);
 }
示例#28
0
        public void DeleteSIPDialplan(SIPDialPlan sipDialplan)
        {
            //if (sipDialplan.Owner != this.ServiceContext.User.Identity.Name)
            //{
            //    throw new ApplicationException("You are not authorised to delete this record.");
            //}
            //else
            //{
            //    if ((sipDialplan.EntityState == EntityState.Detached))
            //    {
            //        this.ObjectContext.SIPDialPlans.Attach(sipDialplan);
            //    }
            //    this.ObjectContext.SIPDialPlans.DeleteObject(sipDialplan);
            //}

            m_service.DeleteSIPDialPlan(this.ServiceContext.User.Identity.Name, sipDialplan);
        }
示例#29
0
        private void Add()
        {
            if (m_dialPlanName.Text.Trim().Length == 0)
            {
                WriteStatusMessage(MessageLevelsEnum.Warn, "The Dial Plan Name cannot be empty.");
            }
            else
            {
                SIPDialPlanScriptTypesEnum scriptType = (m_dialPlanTypeRuby.IsChecked.Value) ? SIPDialPlanScriptTypesEnum.Ruby : SIPDialPlanScriptTypesEnum.Asterisk;

                string      dialPlanText = (m_dialPlanText.Text != null) ? Regex.Replace(m_dialPlanText.Text.Trim(), "\r([^\n])", "\r\n${1}") : null;
                SIPDialPlan dialPlan     = new SIPDialPlan(m_owner, m_dialPlanName.Text.Trim(), m_dialPlanTraceEmailAddress.Text.Trim(), dialPlanText, scriptType);

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

                DialPlanAdd_External(dialPlan);
            }
        }
 /// <summary>
 /// Constructor for non-INVITE requests that can initiate dialplan executions.
 /// </summary>
 public DialPlanContext(
     SIPMonitorLogDelegate monitorLogDelegate,
     SIPTransport sipTransport,
     SIPEndPoint outboundProxy,
     SIPDialPlan dialPlan,
     List <SIPProvider> sipProviders,
     string traceDirectory,
     string callersNetworkId,
     Customer customer)
 {
     Log_External     = monitorLogDelegate;
     m_sipTransport   = sipTransport;
     m_outboundProxy  = outboundProxy;
     m_dialPlan       = dialPlan;
     m_sipProviders   = sipProviders;
     m_traceDirectory = traceDirectory;
     CallersNetworkId = callersNetworkId;
     Customer         = customer;
 }
        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);
            }
        }
 private void AddDialPlan(SIPDialPlan dialPlan)
 {
     m_addAction(dialPlan);
 }