Example #1
0
        private BComRateCenterInventoryResponse rateCenterStatus(string state)
        {
            // Create an HTTPS_ Interface.
            HTTPS_Interface httpsInterface = new HTTPS_Interface();

            // Create SipPeer Request
            BComRateCenterInventoryRequest request =
                new BComRateCenterInventoryRequest();

            // Load the request.
            try
            {
                request.State = state.SafeToString();
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed loading the state code: " + ex.Message);
            }

            // Send the request and get the response.
            BComRateCenterInventoryResponse response =
                httpsInterface.rateCenterResponse(request);

            // Return the response.
            return(response);
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Clear the page.
            Response.Clear();

            // Set the type to XML.
            Response.ContentType = "text/xml";
            //Response.ContentType = "text/plain"; // For debuggin purposes.

            // Declare a response.
            this.response = new BandwidthRateCenterInventoryResponse();

            // Create a database interface.
            try
            {
                this.db = new DB();
            }
            catch (Exception ex)
            {
                this.response.SetJeop(
                    "Unable to open a database connection: " + ex.Message);
                Response.Write(this.response.ToXml());
                this.db.Close();
                return;
            }

            // Array of state codes.
            string[] state = new string[] { "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL", "GA", "HI", "ID", "IL", "IN",
                                            "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM",
                                            "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV",
                                            "WI", "WY" };

            // Declare the response.
            BComRateCenterInventoryResponse rateCenterResponse = null;

            for (int i = 0; i < state.Length; i++)
            {
                // Get the response
                try
                {
                    rateCenterResponse = rateCenterStatus(state[i]);
                }
                catch (Exception Ex)
                {
                    new ApplicationException("Cannot get Rate Center information from Bandwidth. " + Ex.Message);
                }

                foreach (RateCenter r in rateCenterResponse.RateCenterResponse.RateCenters)
                {
                    // Update database.
                    try
                    {
                        db.UpdateRateCenterInventory(r.Abbreviation,
                                                     r.AvailableTelephoneNumberCount,
                                                     r.Name,
                                                     state[i]);
                    }
                    catch
                    {
                        continue;
                    }
                }
            }

            // Set Action to Complete.
            this.response.SetComplete();
            Response.Write(this.response.ToXml());
            this.db.Close();
            return;
        }