상속: ISIPAsset
        private bool IsValidCustomer(Dictionary<string, string> rules, Customer customer) {
            try {
                if (rules != null) {
                    foreach (KeyValuePair<string, string> rule in rules) {

                        if (rule.Key == "CustomerUsername") {
                            if (Regex.Match(customer.CustomerUsername, rule.Value).Success) {
                                logger.Debug("CustomerUsername rule invalidated account " + customer.CustomerUsername + ".");
                                return false;
                            }
                        }
                        else if (rule.Key == "EmailAddress") {
                            if (Regex.Match(customer.EmailAddress, rule.Value).Success) {
                                logger.Debug("EmailAddress rule invalidated account " + customer.CustomerUsername + ".");
                                return false;
                            }
                        }
                        else if (rule.Key == "CreatedFromIPAddress") {
                            if (Regex.Match(customer.CreatedFromIPAddress, rule.Value).Success) {
                                logger.Debug("CreatedFromIPAddress rule invalidated account " + customer.CustomerUsername + ".");
                                return false;
                            }
                        }
                    }
                }

                return true;
            }
            catch (Exception excp) {
                logger.Error("Exception CheckValidationRules. " + excp.Message);
                return true;
            }
        }
        private void CreateCustomerButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                m_statusTextBlock.Text = String.Empty;

                Customer customer = new Customer()
                {
                    Id = Guid.NewGuid(),
                    FirstName = m_firstNameTextBox.Text.Trim(),
                    LastName = m_lastNameTextBox.Text.Trim(),
                    EmailAddress = m_emailAddressTextBox.Text.Trim(),
                    CustomerUsername = m_usernameTextBox.Text.Trim(),
                    CustomerPassword = m_passwordTextBox.Password.Trim(),
                    SecurityQuestion = ((TextBlock)m_securityQuestionListBox.SelectedItem).Text,
                    SecurityAnswer = m_securityAnswerTextBox.Text.Trim(),
                    City = m_cityTextBox.Text.Trim(),
                    Country = ((TextBlock)m_countryListBox.SelectedItem).Text,
                    WebSite = m_webSiteTextBox.Text.Trim(),
                    TimeZone = ((TextBlock)m_timezoneListBox.SelectedItem).Text,
                    InviteCode = InviteCode,
                    Inserted = DateTime.Now.ToUniversalTime()
                };

                string validationError = Customer.ValidateAndClean(customer);
                if (validationError != null)
                {
                    m_statusTextBlock.Text = validationError;
                }
                else
                {

                    if (m_retypePasswordTextBox.Password.IsNullOrBlank())
                    {
                        m_statusTextBlock.Text = "The retyped password must be specified.";
                    }
                    else if (m_retypePasswordTextBox.Password.Trim() != customer.CustomerPassword.Trim())
                    {
                        m_statusTextBlock.Text = "The password and retyped password did not match.";
                    }
                    else
                    {
                        SetDataEntryEnabled(false);
                        UIHelper.SetText(m_statusTextBlock, "Attempting to create new customer, please wait...");

                        CreateCustomer_External(customer);

                        m_emailAddress = customer.EmailAddress;
                    }
                }
            }
            catch (Exception excp)
            {
                SetDataEntryEnabled(true);
                m_statusTextBlock.Text = "Exception creating customer. " + excp.Message;
            }
        }
예제 #3
0
 public DialPlanLineContext(
     SIPMonitorLogDelegate monitorLogDelegate,
     SIPTransport sipTransport,
     DialogueBridgeCreatedDelegate createBridge,
     SIPEndPoint outboundProxy,
     ISIPServerUserAgent sipServerUserAgent,
     SIPDialPlan dialPlan,
     List<SIPProvider> sipProviders,
     string traceDirectory,
     string callersNetworkId,
     Customer customer)
     : base(monitorLogDelegate, sipTransport, createBridge, outboundProxy, sipServerUserAgent, dialPlan, sipProviders, traceDirectory, callersNetworkId, customer, null, null)
 {
     ContextType = DialPlanContextsEnum.Line;
      string[] dialPlanEntries = dialPlan.DialPlanScript.Split(new char[] { '\n' });
      ParseDialPlan(dialPlanEntries);
 }
예제 #4
0
 public DialPlanScriptContext(           
     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)
     : base(monitorLogDelegate, sipTransport, createBridge, outboundProxy, sipServerUserAgent, dialPlan, sipProviders, traceDirectory, callersNetworkId, customer, dialPlanEngine, getCanonicalDomain)
 {
     ContextType = DialPlanContextsEnum.Script;
 }
        private void GetCustomerComplete(SIPSorcery.SIPSorceryProvisioningClient.GetCustomerCompletedEventArgs e) {
            if (e.Error != null) {
                UIHelper.SetText(m_statusTextBlock, e.Error.Message);
            }
            else {
                m_customer = e.Result;
                UIHelper.SetText(m_statusTextBlock, String.Empty);
                UIHelper.SetText(m_firstNameTextBox, m_customer.FirstName);
                UIHelper.SetText(m_lastNameTextBox, m_customer.LastName);
                UIHelper.SetText(m_emailAddressTextBox, m_customer.EmailAddress);
                UIHelper.SetText(m_securityAnswerTextBox, m_customer.SecurityAnswer);
                UIHelper.SetText(m_cityTextBox, m_customer.City);

                if (m_customer.WebSite != null)
                {
                    UIHelper.SetText(m_webSiteTextBox, m_customer.WebSite);
                }

                for (int questionIndex = 0; questionIndex < m_securityQuestionListBox.Items.Count; questionIndex++) {
                    if (((TextBlock)m_securityQuestionListBox.Items[questionIndex]).Text == m_customer.SecurityQuestion) {
                        m_securityQuestionListBox.SelectedIndex = questionIndex;
                        break;
                    }
                }

                for (int countryIndex = 0; countryIndex < m_countryListBox.Items.Count; countryIndex++) {
                    if (((TextBlock)m_countryListBox.Items[countryIndex]).Text == m_customer.Country) {
                        m_countryListBox.SelectedIndex = countryIndex;
                        break;
                    }
                }

                if (!m_customer.TimeZone.IsNullOrBlank()) {
                    for (int timezoneIndex = 0; timezoneIndex < m_timezoneListBox.Items.Count; timezoneIndex++) {
                        if (((TextBlock)m_timezoneListBox.Items[timezoneIndex]).Text == m_customer.TimeZone) {
                            m_timezoneListBox.SelectedIndex = timezoneIndex;
                            break;
                        }
                    }
                }

                SetUpdateButtonsEnabled(true);
            }
        }
        public SIPSorceryVT100Server(Customer customer)
        {
            m_customer = customer;
            Username = customer.CustomerUsername;
            AdminId = customer.AdminId;
            m_notificationsAddress = Guid.NewGuid().ToString();

            try
            {
                m_publisher = Dependency.Resolve<ISIPMonitorPublisher>();
                m_publisher.NotificationReady += NotificationReady;
                m_publisher.MonitorEventReady += MonitorEventAvailable;
            }
            catch (ApplicationException appExcp)
            {
                logger.Debug("Unable to resolve ISIPMonitorPublisher. " + appExcp.Message);
            }

            WriteWelcomeMessage(customer);
            OutStream.Write(Encoding.ASCII.GetBytes(FILTER_COMMAND_PROMPT));
            ThreadPool.QueueUserWorkItem(delegate { Listen(); });
        }
 public override void UpdateCustomerAsync(Customer customer) {
     if (UpdateCustomerComplete != null) {
         UpdateCustomerComplete(new AsyncCompletedEventArgs(null, false, null));
     }
 }
        public void UpdateCustomer(Customer updatedCustomer)
        {
            Customer customer = AuthoriseRequest();

            if (customer.CustomerUsername == updatedCustomer.CustomerUsername) {
                logger.Debug("Updating customer details for " + customer.CustomerUsername);
                customer.FirstName = updatedCustomer.FirstName;
                customer.LastName = updatedCustomer.LastName;
                customer.EmailAddress = updatedCustomer.EmailAddress;
                customer.SecurityQuestion = updatedCustomer.SecurityQuestion;
                customer.SecurityAnswer = updatedCustomer.SecurityAnswer;
                customer.City = updatedCustomer.City;
                customer.Country = updatedCustomer.Country;
                customer.WebSite = updatedCustomer.WebSite;
                customer.TimeZone = updatedCustomer.TimeZone;

                string validationError = Customer.ValidateAndClean(customer);
                if (validationError != null) {
                    throw new ApplicationException(validationError);
                }

                CRMCustomerPersistor.Update(customer);
            }
            else {
                throw new ApplicationException("You are not authorised to update customer for username " + updatedCustomer.CustomerUsername + ".");
            }
        }
        private string GetAuthorisedWhereExpression(Customer customer, string whereExpression)
        {
            try {
                if (customer == null) {
                    throw new ArgumentNullException("customer", "The customer cannot be empty when building authorised where expression.");
                }

                string authorisedWhereExpression = "owner=\"" + customer.CustomerUsername + "\"";
                if (customer.AdminId == Customer.TOPLEVEL_ADMIN_ID) {
                    // This user is the top level administrator and has permission to view all system assets.
                    //authorisedWhereExpression = "true";
                    authorisedWhereExpression = null;
                }
                else if (!customer.AdminId.IsNullOrBlank()) {
                    authorisedWhereExpression =
                        "(owner=\"" + customer.CustomerUsername + "\" or adminmemberid=\"" + customer.AdminId + "\")";
                }

                if (!whereExpression.IsNullOrBlank()) {
                    authorisedWhereExpression += " and " + whereExpression;
                }

                return authorisedWhereExpression;
            }
            catch (Exception excp) {
                logger.Error("Exception GetAuthorisedWhereExpression. " + excp.Message);
                throw new Exception("There was an exception constructing the authorisation filter for the request.");
            }
        }
예제 #10
0
 /// <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;
 }
        public void CreateCustomer(Customer customer)
        {
            try {
                // Check whether the number of customers is within the allowed limit.
                if (m_newCustomersAllowedLimit != 0 && CRMCustomerPersistor.Count(null) >= m_newCustomersAllowedLimit) {
                    throw new ApplicationException("Sorry new account creations are currently disabled. Please monitor sipsorcery.wordpress.com for updates.");
                }
                else {
                    // Check whether the username is already taken.
                    customer.CustomerUsername = customer.CustomerUsername.ToLower();
                    Customer existingCustomer = CRMCustomerPersistor.Get(c => c.CustomerUsername == customer.CustomerUsername);
                    if (existingCustomer != null) {
                        throw new ApplicationException("The requested username is already in use please try a different one.");
                    }

                    // Check whether the email address is already taken.
                    customer.EmailAddress = customer.EmailAddress.ToLower();
                    existingCustomer = CRMCustomerPersistor.Get(c => c.EmailAddress == customer.EmailAddress);
                    if (existingCustomer != null) {
                        throw new ApplicationException("The email address is already associated with an account.");
                    }

                    string validationError = Customer.ValidateAndClean(customer);
                    if (validationError != null) {
                        throw new ApplicationException(validationError);
                    }

                    customer.MaxExecutionCount = Customer.DEFAULT_MAXIMUM_EXECUTION_COUNT;

                    CRMCustomerPersistor.Add(customer);
                    logger.Debug("New customer record added for " + customer.CustomerUsername + ".");

                    // Create a default dialplan.
                    SIPDialPlan defaultDialPlan = new SIPDialPlan(customer.CustomerUsername, "default", null, "sys.Log(\"hello world\")\n", SIPDialPlanScriptTypesEnum.Ruby);
                    DialPlanPersistor.Add(defaultDialPlan);
                    logger.Debug("Default dialplan added for " + customer.CustomerUsername + ".");

                    // Get default domain name.
                    string defaultDomain = SIPDomainManager.GetDomain("local", true);

                    // Create SIP account.
                    if (SIPAccountPersistor.Get(s => s.SIPUsername == customer.CustomerUsername && s.SIPDomain == defaultDomain) == null) {
                        SIPAccount sipAccount = new SIPAccount(customer.CustomerUsername, defaultDomain, customer.CustomerUsername, customer.CustomerPassword, "default");
                        SIPAccountPersistor.Add(sipAccount);
                        logger.Debug("SIP account " + sipAccount.SIPUsername + "@" + sipAccount.SIPDomain + " added for " + sipAccount.Owner + ".");
                    }
                    else {
                        int attempts = 0;
                        while (attempts < 10) {
                            string testUsername = customer.CustomerUsername + Crypto.GetRandomString(4);
                            if (SIPAccountPersistor.Get(s => s.SIPUsername == testUsername && s.SIPDomain == defaultDomain) == null) {
                                SIPAccount sipAccount = new SIPAccount(customer.CustomerUsername, defaultDomain, testUsername, customer.CustomerPassword, "default");
                                SIPAccountPersistor.Add(sipAccount);
                                logger.Debug("SIP account " + sipAccount.SIPUsername + "@" + sipAccount.SIPDomain + " added for " + sipAccount.Owner + ".");
                                break;
                            }
                            else {
                                attempts++;
                            }
                        }
                    }

                    logger.Debug("Sending new account confirmation email to " + customer.EmailAddress + ".");
                    Email.SendEmail(customer.EmailAddress, NEW_ACCOUNT_EMAIL_FROM_ADDRESS, NEW_ACCOUNT_EMAIL_SUBJECT, String.Format(NEW_ACCOUNT_EMAIL_BODY, customer.FirstName, customer.Id));
                }
            }
            catch (Exception excp) {
                logger.Error("Exception CreateNewCustomer. " + excp.Message);
                throw;
            }
        }
예제 #12
0
        private bool GetDialPlanAndCustomer(string owner, string dialPlanName, ISIPServerUserAgent uas, out Customer customer, out SIPDialPlan dialPlan)
        {
            try
            {
                dialPlan = null;
                customer = m_customerPersistor.Get(c => c.CustomerUsername == owner);

                if (customer == null)
                {
                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Call rejected for customer " + owner + " as no matching account found.", null));
                    uas.Reject(SIPResponseStatusCodesEnum.DoesNotExistAnywhere, "No matching user was found", null);
                }
                else if (customer.Suspended)
                {
                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Call rejected for customer " + owner + " as account is suspended.", null));
                    uas.Reject(SIPResponseStatusCodesEnum.DoesNotExistAnywhere, "User account is suspended", null);
                }
                else if (customer.ServiceLevel == CustomerServiceLevels.PremiumPayReqd.ToString() || customer.ServiceLevel == CustomerServiceLevels.ProfessionalPayReqd.ToString() || customer.ServiceLevel == CustomerServiceLevels.SwitchboardPayReqd.ToString())
                {
                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Call rejected for customer " + owner + " as payment is outstanding.", null));
                    uas.Reject(SIPResponseStatusCodesEnum.PaymentRequired, null, null);
                }
                else if (dialPlanName.IsNullOrBlank() && uas.CallDirection == SIPCallDirection.Out)
                {
                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Call rejected for customer " + owner + " as no dialplan is configured for an " + uas.CallDirection + " call.", null));
                    uas.Reject(SIPResponseStatusCodesEnum.TemporarilyUnavailable, "SIP account missing dialplan setting", null);
                }
                else
                {
                    if (dialPlanName.IsNullOrBlank())
                    {
                        // Incoming call with no dialplan.
                        return true;
                    }
                    else
                    {
                        dialPlan = GetDialPlan_External(d => d.Owner == owner && d.DialPlanName == dialPlanName);

                        if (dialPlan == null)
                        {
                            Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Call rejected, dialplan " + dialPlanName + " could not be found.", owner));
                            uas.Reject(SIPResponseStatusCodesEnum.InternalServerError, "Could not load dialplan " + dialPlanName, null);
                        }
                        else if (dialPlan != null && dialPlan.IsReadOnly)
                        {
                            Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Call rejected for read only dialplan " + dialPlanName + ". Upgrade to a Premium service to enable.", owner));
                            uas.Reject(SIPResponseStatusCodesEnum.PaymentRequired, "Dial plan is readonly, upgrade to Premium service", null);
                        }
                        else if (customer.ServiceLevel == CustomerServiceLevels.Free.ToString() && dialPlan.ScriptType == SIPDialPlanScriptTypesEnum.Asterisk)
                        {
                            Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Your service level does not permit the use of Asterisk dial plans.", owner));
                            uas.Reject(SIPResponseStatusCodesEnum.PaymentRequired, "Free plans cannot use Asterisk dial plans", null);
                        }
                        else if (!IsDialPlanExecutionAllowed(dialPlan, customer))
                        {
                            Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Execution of dial plan " + dialPlanName + " was not processed as maximum execution count has been reached.", owner));
                            uas.Reject(SIPResponseStatusCodesEnum.TemporarilyUnavailable, "Dial plan execution exceeded maximum allowed", null);
                        }
                        else
                        {
                            if (m_dailyCallLimit == -1)
                            {
                                return true;
                            }
                            else
                            {
                                // Check whether the number of CDR's exceeds the daily call limit.
                                DateTime yesterday = DateTime.Now.AddDays(-1);
                                int cdrCount = m_sipCDRPersistor.Count(x => x.Owner == owner && x.Created > yesterday);
                                if (cdrCount >= m_dailyCallLimit)
                                {
                                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Execution of call for " + owner + " was not processed as daily call limit reached.", owner));
                                    uas.Reject(SIPResponseStatusCodesEnum.TemporarilyUnavailable, "Daily call limit reached", null);
                                }
                                else
                                {
                                    return true;
                                }
                            }
                        }
                    }
                }

                return false;
            }
            catch (Exception excp)
            {
                logger.Error("Exception GetDialPlanAndCustomer. " + excp.Message);
                throw;
            }
        }
예제 #13
0
        private bool IsDialPlanExecutionAllowed(SIPDialPlan dialPlan, Customer customer)
        {
            try
            {
                /*int dialPlanExecutionCount = (dialPlan != null) ? dialPlan.ExecutionCount : 0;
                int dialPlanMaxExecutionCount = (dialPlan != null) ? dialPlan.MaxExecutionCount : 0;

                if (customer.ExecutionCount >= customer.MaxExecutionCount ||
                    (dialPlan != null && dialPlanExecutionCount >= dialPlanMaxExecutionCount))
                {
                    return false;
                }
                else
                {
                    return true;
                }*/

                //logger.Debug("IsDialPlanExecutionAllowed for " + customer.CustomerUsername + " and " + dialPlan.DialPlanName + ", count=" + dialPlan.ExecutionCount + ", max=" + dialPlan.MaxExecutionCount + ".");

                //return (customer.ExecutionCount < customer.MaxExecutionCount);

                int currentlyExecuting = m_dialPlanEngine.GetExecutionCountForUser(customer.CustomerUsername);
                return currentlyExecuting < customer.MaxExecutionCount;

                //if (dialPlan != null)
                //{
                //    return currentlyExecuting < customer.MaxExecutionCount && currentlyExecuting < dialPlan.MaxExecutionCount;
                //}
                //else
                //{
                //    return currentlyExecuting < customer.MaxExecutionCount;
                //}
            }
            catch (Exception excp)
            {
                logger.Error("Exception IsDialPlanExecutionAllowed. " + excp.Message);
                throw excp;
            }
        }
예제 #14
0
        private List<ISIPClientUserAgent> m_uacWaitingForCallDetails = new List<ISIPClientUserAgent>(); // UACs can indicate they would like the call details when available.

        #endregion Fields

        #region Constructors

        //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);
        }
예제 #15
0
        private bool GetDialPlanAndCustomer(string owner, string dialPlanName, ISIPServerUserAgent uas, out Customer customer, out SIPDialPlan dialPlan)
        {
            try
            {
                dialPlan = null;
                customer = m_customerPersistor.Get(c => c.CustomerUsername == owner);

                if (customer == null)
                {
                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Call rejected for customer " + owner + " as no matching account found.", null));
                    uas.Reject(SIPResponseStatusCodesEnum.DoesNotExistAnywhere, "No matching user was found", null);
                }
                else if (customer.Suspended)
                {
                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Call rejected for customer " + owner + " as account is suspended.", null));
                    uas.Reject(SIPResponseStatusCodesEnum.DoesNotExistAnywhere, "User account is suspended", null);
                }
                else if (dialPlanName.IsNullOrBlank() && uas.CallDirection == SIPCallDirection.Out)
                {
                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Call rejected for customer " + owner + " as no dialplan is configured for an " + uas.CallDirection + " call.", null));
                    uas.Reject(SIPResponseStatusCodesEnum.TemporarilyUnavailable, "SIP account missing dialplan setting", null);
                }
                else
                {
                    dialPlan = GetDialPlan_External(d => d.Owner == owner && d.DialPlanName == dialPlanName);
                    if (!IsDialPlanExecutionAllowed(dialPlan, customer))
                    {
                        Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Execution of dial plan " + dialPlanName + " was not processed as maximum execution count has been reached.", owner));
                        uas.Reject(SIPResponseStatusCodesEnum.TemporarilyUnavailable, "Dial plan execution exceeded maximum allowed", null);
                    }
                    else
                    {
                        if (m_dailyCallLimit == -1)
                        {
                            return true;
                        }
                        else
                        {
                            // Check whether the number of CDR's exceeds the daily call limit.
                            DateTime yesterday = DateTime.Now.AddDays(-1);
                            int cdrCount = m_sipCDRPersistor.Count(x => x.Owner == owner && x.Created > yesterday);
                            if (cdrCount >= m_dailyCallLimit)
                            {
                                Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Execution of call for " + owner + " was not processed as daily call limit reached.", owner));
                                uas.Reject(SIPResponseStatusCodesEnum.TemporarilyUnavailable, "Daily call limit reached", null);
                            }
                            else
                            {
                                return true;
                            }
                        }
                    }
                }

                return false;
            }
            catch (Exception excp)
            {
                logger.Error("Exception GetDialPlanAndCustomer. " + excp.Message);
                throw;
            }
        }
 public override void CreateCustomerAsync(Customer customer) {
     throw new NotImplementedException();
 }
 public abstract void CreateCustomerAsync(Customer customer);
 public abstract void UpdateCustomerAsync(Customer customer);
 private void WriteWelcomeMessage(Customer customer)
 {
     OutStream.Write(new byte[] { 0x1B, 0x5B, 0x34, 0x37, 0x3b, 0x33, 0x34, 0x6d });
     OutStream.Write(Encoding.ASCII.GetBytes("Welcome " + customer.FirstName));
     OutStream.Write(new byte[] { 0x1B, 0x5B, 0x30, 0x6d });
     OutStream.Flush();
     OutStream.Write(Encoding.ASCII.GetBytes(CRLF));
 }
 public SIPSorceryIdentity(Customer customer)
 {
     Name = customer.CustomerUsername;
     Customer = customer;
 }
예제 #21
0
        public static string ValidateAndClean(Customer customer)
        {
            if (customer.FirstName.IsNullOrBlank()) {
                return "A first name must be specified.";
            }
            else if (customer.FirstName.Trim().Length > MAX_FIELD_LENGTH) {
                return "The first name length must be less than " + MAX_FIELD_LENGTH + ".";
            }
            else if (customer.LastName.IsNullOrBlank()) {
                return "A last name must be specified.";
            }
            else if (customer.LastName.Trim().Length > MAX_FIELD_LENGTH) {
                return "The last name length must be less than " + MAX_FIELD_LENGTH + ".";
            }
            else if (customer.EmailAddress.IsNullOrBlank()) {
                return "An email address must be specified.";
            }
            else if (customer.EmailAddress.Trim().Length > MAX_FIELD_LENGTH) {
                return "The email address length must be less than " + MAX_FIELD_LENGTH + ".";
            }
            else if (!Regex.Match(customer.EmailAddress, @"\S+@\S+\.\S+").Success) {
                return "The email address was an invalid format.";
            }
            else if (customer.CustomerUsername.IsNullOrBlank()) {
                return "A username must be specified.";
            }
            else if (customer.CustomerUsername.Trim().Length > MAX_USERNAME_LENGTH || customer.CustomerUsername.Trim().Length < MIN_USERNAME_LENGTH) {
                return "The username length must be between " + MIN_USERNAME_LENGTH + " and " + MAX_USERNAME_LENGTH + ".";
            }
            else if (Regex.Match(customer.CustomerUsername.Trim(), "[^" + USERNAME_ALLOWED_CHARS + "]").Success) {
                return "The username had an invalid character, characters permitted are alpha-numeric and -_ (no full stop characters '.' are allowed).";
            }
            else if (customer.CustomerPassword.IsNullOrBlank()) {
                return "A password must be specified.";
            }
            else if (customer.CustomerPassword.Trim().Length > MAX_PASSWORD_LENGTH || customer.CustomerPassword.Trim().Length < MIN_PASSWORD_LENGTH) {
                return "The password length must be between " + MIN_PASSWORD_LENGTH + " and " + MAX_PASSWORD_LENGTH + ".";
            }
            else if (customer.SecurityAnswer.IsNullOrBlank()) {
                return "The answer to the security question must be specified.";
            }
            else if (customer.SecurityAnswer.Trim().Length > MAX_FIELD_LENGTH) {
                return "The security question answer length must be less than " + MAX_FIELD_LENGTH + ".";
            }
            else if (customer.City.IsNullOrBlank()) {
                return "Your city must be specified. If you don't live in a city please enter the one closest to you.";
            }
            else if (customer.City.Trim().Length > MAX_FIELD_LENGTH) {
                return "The city length must be less than " + MAX_FIELD_LENGTH + ".";
            }
            else if (!customer.WebSite.IsNullOrBlank() && customer.WebSite.Trim().Length > MAX_WEBSITE_FIELD_LENGTH) {
                return "The web site length must be less than " + MAX_WEBSITE_FIELD_LENGTH + ".";
            }

            return null;
        }
 public override void CreateCustomerAsync(Customer customer) {
     m_provisioningServiceProxy.CreateCustomerAsync(customer);
 }