示例#1
0
        public JSONResult <string> SetCustomerServiceLevel(string username, string serviceLevel, string renewalDate)
        {
            try
            {
                var reqCustomer = AuthoriseRequest();

                if (reqCustomer.AdminID != Customer.TOPLEVEL_ADMIN_ID)
                {
                    return(new JSONResult <string>()
                    {
                        Success = false, Error = "Sorry you are not authorised to add set customer service levels."
                    });
                }
                else
                {
                    CustomerServiceLevels newServiceLevel = (CustomerServiceLevels)Enum.Parse(typeof(CustomerServiceLevels), serviceLevel);
                    DateTimeOffset?       newRenewalDate  = (!renewalDate.IsNullOrBlank()) ? DateTimeOffset.Parse(renewalDate) : (DateTimeOffset?)null;
                    m_service.UpdateCustomerServiceLevel(username, newServiceLevel, newRenewalDate);
                    return(new JSONResult <string>()
                    {
                        Success = true
                    });
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception SetCustomerServiceLevel. " + excp);
                return(new JSONResult <string>()
                {
                    Success = false, Error = excp.Message
                });
            }
        }
 public PaymentRequiredException(CustomerServiceLevels serviceLevel, string message)
     : base(message)
 {
     ServiceLevel = serviceLevel;
 }
        /// <summary>
        /// Parses a dial string that has been used in a dial plan Dial command. The format of the dial string is likely to continue to evolve, check the class
        /// summary for the different formats available. This method determines which format the dial string is in and passes off to the appropriate method to 
        /// build the call list.
        /// </summary>
        /// <param name="dialPlanType">The type of dialplan that generated the Dial command.</param>
        /// <param name="sipRequest">The SIP Request that originated this command. Can be null if the call was not initiated by a SIP request such as 
        /// by a HTTP web service.</param>
        /// <param name="command">The Dial command string being parsed.</param>
        /// <param name="customHeaders">If non-empty contains a list of custom SIP headers that will be added to the forwarded request.</param>
        /// <param name="customContentType">If set indicates a custom content type header is required on the forwarded request and it
        /// overrides any other value.</param>
        /// <param name="customContent">If set indicates a custom body is required on the forwarded request and it
        /// overrides any other value.</param>
        /// <param name="callersNetworkId">If the call originated from a locally administered account this will hold the account's
        /// networkid which is used to determine if two local accounts are on the same network and therefore should have their SDP
        /// left alone.</param>
        /// <param name="fromDisplayName">If set will be used the From header display name instead of the value from the originating SIP request.</param>
        /// <param name="fromUsername">If set will be used the From header user name instead of the value from the originating SIP request.</param>
        /// <param name="fromHost">If set will be used the From header host instead of the value from the originating SIP request.</param>
        /// <returns>A queue where each item is a list of calls. If there was only a single forward there would only be one item in the list which contained a 
        /// single call. For dial strings containing multiple forwards each queue item can be a list with multiple calls.</returns>
        public Queue<List<SIPCallDescriptor>> ParseDialString(
            DialPlanContextsEnum dialPlanType,
            SIPRequest sipRequest,
            string command,
            List<string> customHeaders,
            string customContentType,
            string customContent,
            string callersNetworkId,
            string fromDisplayName,
            string fromUsername,
            string fromHost,
            CRMHeaders contact,
            CustomerServiceLevels serviceLevel)
        {
            try
            {
                if (command == null || command.Trim().Length == 0)
                {
                    throw new ArgumentException("The dial string cannot be empty.");
                }
                else
                {
                    Queue<List<SIPCallDescriptor>> prioritisedCallList = new Queue<List<SIPCallDescriptor>>();

                    if (dialPlanType == DialPlanContextsEnum.Line || (serviceLevel != CustomerServiceLevels.Free && (!command.Contains("[") && Regex.Match(command, @"\S+,.*,\S+").Success)))
                    {
                        // Singled legged call (Asterisk format).
                        SIPCallDescriptor SIPCallDescriptor = ParseAsteriskDialString(command, sipRequest);
                        List<SIPCallDescriptor> callList = new List<SIPCallDescriptor>();
                        callList.Add(SIPCallDescriptor);
                        prioritisedCallList.Enqueue(callList);
                    }
                    else
                    {
                        // Multi legged call (Script sys.Dial format).
                        //string providersString = (command.IndexOf(',') == -1) ? command : command.Substring(0, command.IndexOf(','));
                        prioritisedCallList = ParseScriptDialString(sipRequest, command, customHeaders, customContentType, customContent, callersNetworkId, fromDisplayName, fromUsername, fromHost, contact);
                    }

                    return prioritisedCallList;
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception ParseDialString. " + excp);
                throw excp;
            }
        }
示例#4
0
        /// <summary>
        /// Only available from the REST API service to admins.
        /// </summary>
        public void UpdateCustomerServiceLevel(string username, CustomerServiceLevels serviceLevel, DateTimeOffset? renewalDate)
        {
            logger.Debug("Updating customer " + username + " to service level " + serviceLevel + " and renewal date " + renewalDate + ".");

            using (var sipSorceryEntities = new SIPSorceryEntities())
            {
                var customer = (from cust in sipSorceryEntities.Customers where cust.Name.ToLower() == username.ToLower() select cust).SingleOrDefault();

                customer.ServiceLevel = serviceLevel.ToString();
                customer.ServiceRenewalDate = (renewalDate != null) ? renewalDate.Value.ToUniversalTime().ToString("o") : null;

                sipSorceryEntities.SaveChanges();
            }
        }
示例#5
0
 public PaymentRequiredException(CustomerServiceLevels serviceLevel, string message)
     : base(message)
 {
     ServiceLevel = serviceLevel;
 }