Ejemplo n.º 1
0
        public static BComLnpOrderResponse CancelTN(string order_id)
        {
            // Create an HTTPS_ Interface.
            HTTPS_Interface httpsInterface = new HTTPS_Interface();

            // Create Cancel Request
            BComLnpCancelRequest request = new BComLnpCancelRequest();

            // Load the request.
            request.OrderId = order_id;

            // Make a copy of the requests raw xml.
            //this.requestXML = request.ToXml();

            // Send the request and get the response.
            BComLnpOrderResponse response =
                httpsInterface.CancelOrder(request);

            // Return the response.
            return(response);
        }
Ejemplo n.º 2
0
        //private string requestXML;

        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.

            SetParameters();

            // 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;
            }

            // DataTable to load disconnect information.
            string order_id = null;

            // Load the disconnect data.
            try
            {
                order_id =
                    this.db.LoadLnpOrderIdFromOppid(oppid);
            }
            catch (Exception ex)
            {
                string jeop = "Unable to load order_id from Aviator: " + ex.Message;
                this.response.SetJeop(jeop);
                Response.Write(this.response.ToXml());
                this.db.JeopStep(
                    this.oppid, this.wf_id, this.wf_step_id, this.jeopname, jeop);
                this.db.Close();
                return;
            }

            // Make request
            BComLnpOrderResponse cancelResponse = null;

            try
            {
                cancelResponse = CancelTN(order_id);
            }
            catch (Exception ex)
            {
                string jeop = "Unable to cancel tn: " + ex.Message;
                this.response.SetJeop(jeop);
                Response.Write(this.response.ToXml());
                this.db.JeopStep(
                    this.oppid, this.wf_id, this.wf_step_id, this.jeopname, jeop);
                this.db.Close();
                return;
            }

            if (cancelResponse.Status != "Success")
            {
                string jeop = cancelResponse.ErrorMessage;
                this.response.SetJeop(jeop);

                try
                {
                    this.db.UpdateCancelPortOrdersTable(cancelResponse, this.oppid, this.wf_id, this.wf_step_id, this.jeopname,
                                                        this.response.Action, this.response.Message);
                }
                catch
                {
                    //ignore error
                }
                // Return the response.
                this.db.JeopStep(
                    this.oppid, this.wf_id, this.wf_step_id, this.jeopname, jeop);
                this.db.Close();
                // Return result.
                Response.Write(this.response.ToXml());
                return;
            }

            // Set to Continue if not failed.
            if (this.response.Action == "PENDING")
            {
                this.response.SetContinue();
            }

            // Update PortOrders information.
            try
            {
                // here we update info
                this.db.UpdateCancelPortOrdersTable(cancelResponse, this.oppid, this.wf_id, this.wf_step_id, this.jeopname,
                                                    this.response.Action, this.response.Message);
            }
            catch
            {
                // Ignore the error.
            }


            // Close the db
            this.db.Close();

            // Return result.
            Response.Write(this.response.ToXml());
            return;
        }
Ejemplo n.º 3
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 PlaceLnpOrderResponse();

            // First make sure the parameters are there.
            SetParameters();

            // Failed? Then Jeop.
            if (this.response.Action != "PENDING")
            {
                Response.Write(this.response.ToXml());
                return;
            }

            // 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;
            }

            // Set step to processing.
            try
            {
                // this.db.SetStepToProcessing(oppid, wf_id, wf_step_id);
            }
            catch (Exception ex)
            {
                this.response.SetJeop(
                    "Unable to open a database connection: " + ex.Message);
                Response.Write(this.response.ToXml());
                this.db.Close();
                return;
            }

            // DataTable to load install information.
            DataTable aviatorData = null;

            // Load the install data.
            try
            {
                aviatorData =
                    this.db.LoadAviatorLnpInstallData(oppid);
            }
            catch (Exception ex)
            {
                string jeop = "Unable to load data from Aviator: " + ex.Message;
                this.response.SetJeop(jeop);
                Response.Write(this.response.ToXml());
                this.db.JeopStep(
                    this.oppid, this.wf_id, this.wf_step_id, this.jeopname, jeop);
                this.db.Close();
                return;
            }

            // Load the cpid.
            try
            {
                this.cpid = long.Parse(
                    aviatorData.Rows[0]["cpid"].SafeToString());
            }
            catch
            {
                // Just assign -1.
                this.cpid = -1;
            }

            // Load the siteid.
            try
            {
                this.siteid = long.Parse(
                    aviatorData.Rows[0]["siteid"].SafeToString());
            }
            catch (Exception ex)
            {
                string jeop = "Unable to load data from Aviator: " + ex.Message;
                this.response.SetJeop(jeop);
                Response.Write(this.response.ToXml());
                this.db.JeopStep(
                    this.oppid, this.wf_id, this.wf_step_id, this.jeopname, jeop);
                this.db.Close();
                return;
            }

            // One last id to get, the coid.
            try
            {
                this.coid =
                    this.db.GeneratePortCOID();
            }
            catch (Exception ex)
            {
                string jeop = "Unable to generate Port COID: " + ex.Message;
                this.response.SetJeop(jeop);
                Response.Write(this.response.ToXml());
                this.db.JeopStep(
                    this.oppid, this.wf_id, this.wf_step_id, this.jeopname, jeop);
                this.db.Close();
                return;
            }

            // Now, using the ratecenter, order a TN.
            BComLnpOrderResponse lnpOrderResponse = null;

            try
            {
                lnpOrderResponse = LnpOrder(aviatorData);
            }
            catch (Exception ex)
            {
                string jeop = "Unable to place port order for an opp: " + ex.Message;
                this.response.SetJeop(jeop);
                Response.Write(this.response.ToXml());
                this.db.JeopStep(
                    this.oppid, this.wf_id, this.wf_step_id, this.jeopname, jeop);
                this.db.Close();
                return;
            }

            // Did the request fail?
            if (lnpOrderResponse.Status != "Success")
            {
                // Immediately Jeop with the error message.
                string jeop = lnpOrderResponse.ErrorMessage;
                this.response.SetJeop(jeop);

                // Update PortOrders information.
                try
                {
                    this.db.UpdatePortOrdersTable(
                        lnpOrderResponse, this.coid, this.cpid, this.siteid, this.oppid,
                        this.wf_id, this.wf_step_id, this.jeopname,
                        this.requestXML, this.response.Action, this.response.Message);
                }
                catch
                {
                    // Ignore the error
                }

                // Return the response.
                this.db.JeopStep(
                    this.oppid, this.wf_id, this.wf_step_id, this.jeopname, jeop);
                this.db.Close();
                // Return result.
                Response.Write(this.response.ToXml());
                return;
            }

            // Set to Continue if not failed.
            if (this.response.Action == "PENDING")
            {
                this.response.SetContinue();
            }

            // Update PortOrders information.
            try
            {
                this.db.UpdatePortOrdersTable(
                    lnpOrderResponse, this.coid, this.cpid, this.siteid, this.oppid,
                    this.wf_id, this.wf_step_id, this.jeopname,
                    this.requestXML, this.response.Action, this.response.Message);
            }
            catch
            {
                // Ignore the error.
            }

            // Close the db
            this.db.Close();

            // Return result.
            Response.Write(this.response.ToXml());
            return;
        }
Ejemplo n.º 4
0
        private BComLnpOrderResponse LnpOrder(DataTable aviatorData)
        {
            // Create an HTTPS_ Interface.
            HTTPS_Interface httpsInterface = new HTTPS_Interface();

            // Create Lnp Order Request
            BComLnpOrderRequest request =
                new BComLnpOrderRequest();

            request.LnpOrder            = new LnpOrder();
            request.LnpOrder.Subscriber = new Subscriber();
            request.LnpOrder.Subscriber.ServiceAddress = new Address();
            request.LnpOrder.ListOfPhoneNumbers        = new ListOfPhoneNumbers();

            // Load the request.
            try
            {
                string subscriberType = aviatorData.Rows[0]["SubscriberType"].SafeToString();

                if (string.IsNullOrEmpty(subscriberType))
                {
                    throw new ApplicationException("Account Subscriber Type not set.");
                }
                request.LnpOrder.CustomerOrderId =
                    this.coid.SafeToString();
                request.LnpOrder.RequestedFocDate =
                    aviatorData.Rows[0]["RequestedFocDate"].SafeToString();
                request.LnpOrder.BillingTelephoneNumber =
                    aviatorData.Rows[0]["BillingTelephoneNumber"].SafeToString();
                request.LnpOrder.LoaAuthorizingPerson =
                    aviatorData.Rows[0]["LoaAuthorizingPerson"].SafeToString();
                request.LnpOrder.SiteId =
                    aviatorData.Rows[0]["SiteId"].SafeToString();
                request.LnpOrder.Triggered =
                    aviatorData.Rows[0]["Triggered"].SafeToString();
                request.LnpOrder.Subscriber.SubscriberType =
                    aviatorData.Rows[0]["SubscriberType"].SafeToString();
                request.LnpOrder.Subscriber.ServiceAddress.HouseNumber =
                    aviatorData.Rows[0]["HouseNumber"].SafeToString();
                request.LnpOrder.Subscriber.ServiceAddress.StreetName =
                    aviatorData.Rows[0]["StreetName"].SafeToString();
                request.LnpOrder.Subscriber.ServiceAddress.City =
                    aviatorData.Rows[0]["City"].SafeToString();
                request.LnpOrder.Subscriber.ServiceAddress.StateCode =
                    aviatorData.Rows[0]["StateCode"].SafeToString();
                request.LnpOrder.Subscriber.ServiceAddress.Zip =
                    aviatorData.Rows[0]["Zip"].SafeToString();
                request.LnpOrder.Subscriber.ServiceAddress.Country =
                    aviatorData.Rows[0]["Country"].SafeToString();

                // Determine if a business name is used or not.
                if (subscriberType == "RESIDENTIAL")
                {
                    request.LnpOrder.Subscriber.FirstName =
                        aviatorData.Rows[0]["FirstName"].SafeToString();
                    request.LnpOrder.Subscriber.LastName =
                        aviatorData.Rows[0]["LastName"].SafeToString();
                }
                else if (subscriberType == "BUSINESS")
                {
                    request.LnpOrder.Subscriber.BusinessName =
                        aviatorData.Rows[0]["BusinessName"].SafeToString();
                }
                else
                {
                    throw new ApplicationException("Unknown Subscriber Type: " + subscriberType);
                }

                // If Wireless info is provided, then set it.
                if (!string.IsNullOrEmpty(aviatorData.Rows[0]["Wireless_Account"].SafeToString()) ||
                    !string.IsNullOrEmpty(aviatorData.Rows[0]["Wireless_PIN"].SafeToString()))
                {
                    request.LnpOrder.WirelessInfo = new WirelessInfo();

                    // Add account number if present.
                    if (!string.IsNullOrEmpty(aviatorData.Rows[0]["Wireless_Account"].SafeToString()))
                    {
                        request.LnpOrder.WirelessInfo.AccountNumber =
                            aviatorData.Rows[0]["Wireless_Account"].SafeToString();
                    }

                    // Add PIN if present.
                    if (!string.IsNullOrEmpty(aviatorData.Rows[0]["Wireless_PIN"].SafeToString()))
                    {
                        request.LnpOrder.WirelessInfo.PinNumber =
                            aviatorData.Rows[0]["Wireless_PIN"].SafeToString();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed loading Aviator data into order: " + ex.Message);
            }

            foreach (DataRow r in aviatorData.Rows)
            {
                string tn = r["PhoneNumber"].SafeToString();
                if (!string.IsNullOrEmpty(tn))
                {
                    request.LnpOrder.ListOfPhoneNumbers.Add(tn);
                }
            }

            // Make a copy of the requests raw xml.
            this.requestXML = request.ToXml();

            // Send the request and get the response.
            BComLnpOrderResponse response =
                httpsInterface.LnpOrder(request);

            // Return the response.
            return(response);
        }
Ejemplo n.º 5
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 UpdatePortStatusResponse();

            // 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;
            }

            // DataTable to load active port order information.
            DataTable aviatorData = null;

            // Load the active port orders.
            try
            {
                aviatorData =
                    this.db.LoadActivePortOrders();
            }
            catch (Exception ex)
            {
                string jeop = "Unable to load data from Aviator: " + ex.Message;
                this.response.SetJeop(jeop);
                Response.Write(this.response.ToXml());
                this.db.Close();
                return;
            }

            // Check status and perform logic on each active order.
            foreach (DataRow orderRow in aviatorData.Rows)
            {
                // Get Partner Name.
                DataRow partnerName = this.db.LoadDataRowAviatorLnpInstallData(orderRow["oppid"].SafeToString());

                // Get the coid.
                string coid = orderRow["coid"].SafeToString();

                // Get the status.
                BComOrderStatusResponse orderStatusResponse = null;
                try
                {
                    orderStatusResponse = OrderStatus(orderRow);
                }
                catch
                {
                    // Skip this order.
                    continue;
                }

                // Get the Processing Status.
                string processingStatus = string.Empty;
                try
                {
                    processingStatus = orderStatusResponse.LnpOrderResponse.ProcessingStatus.SafeToString();
                }
                catch
                {
                    // Skip this order.
                    continue;
                }

                // Determins the action and the message.
                string Action  = string.Empty;
                string Message = string.Empty;

                switch (processingStatus)
                {
                case "PENDING_DOCUMENTS":
                    Action  = "CONTINUE";
                    Message = "Badnwidth is checking the authorization.";
                    try
                    {
                        this.db.UpdatePortOrderFlags(coid, true, true, false); // Order is active.
                    }
                    catch { continue; }                                        // Skip this order.
                    break;

                case "SUBMITTED":
                    Action  = "CONTINUE";
                    Message = "Port Order Submitted to Bandwidth.";
                    try
                    {
                        this.db.UpdatePortOrderFlags(coid, true, true, false); // Order is active.
                    }
                    catch { continue; }                                        // Skip this order.
                    break;

                case "REQUESTED_CANCEL":
                    Action  = "JEOP";
                    Message = "Port Order cancel has been requested.";
                    try
                    {
                        this.db.UpdatePortOrderFlags(coid, true, true, true); // Set the jeop flag.
                    }
                    catch { continue; }                                       // Skip this order.
                    break;

                case "CANCELLED":
                    Action = "CONTINUE";
                    Action = "JEOP";
                    if (orderStatusResponse.LnpOrderResponse != null &&
                        orderStatusResponse.LnpOrderResponse.Errors != null &&
                        orderStatusResponse.LnpOrderResponse.Errors.Length > 0)
                    {
                        foreach (Errors error in orderStatusResponse.LnpOrderResponse.Errors)
                        {
                            Message += error.Code.SafeToString() + " - " + error.Description.SafeToString() + "; ";
                        }
                    }
                    else
                    {
                        Message = "The order has been cancelled for unknown reason";
                    }
                    try
                    {
                        this.db.UpdatePortOrderFlags(coid, true, true, true); // Set the jeop flag.
                    }
                    catch { continue; }                                       // Skip this order.
                    break;

                case "EXCEPTION":
                    Action = "JEOP";
                    // Build message from status.
                    if (orderStatusResponse.LnpOrderResponse != null &&
                        orderStatusResponse.LnpOrderResponse.Errors != null &&
                        orderStatusResponse.LnpOrderResponse.Errors.Length > 0)
                    {
                        foreach (Errors error in orderStatusResponse.LnpOrderResponse.Errors)
                        {
                            Message += error.Code.SafeToString() + " - " + error.Description.SafeToString() + "; ";
                        }
                    }
                    else
                    {
                        Message = "Unknown exception.";
                    }
                    // Check for Partner Name.
                    if ((partnerName["PartnerName"].SafeToString() == "Hughes Consumer") && (orderRow["timestamp"].SafeToDateTime() > "2018-01-01".SafeToDateTime()))
                    {
                        // Cancel LNP.
                        try
                        {
                            // Make request
                            BComLnpOrderResponse cancelResponse = null;
                            try
                            {
                                cancelResponse = CancelTN(orderRow["OrderId"].SafeToString());
                            }
                            catch (Exception ex)
                            {
                                string jeop = "Unable to cancel Hughes Consumer tn: " + ex.Message;
                                this.response.SetJeop(jeop);
                                Response.Write(this.response.ToXml());
                                this.db.JeopStep(
                                    orderRow["oppid"].SafeToString(), int.Parse(orderRow["wf_id"].SafeToString()),
                                    int.Parse(orderRow["wf_step_id"].SafeToString()), orderRow["JeopName"].SafeToString(), jeop);
                                this.db.Close();
                                return;
                            }
                        }
                        catch (Exception Ex)
                        {
                            continue;
                        }
                    }
                    try
                    {
                        this.db.UpdatePortOrderFlags(coid, true, true, true); // Set the jeop flag.
                    }
                    catch { continue; }                                       // Skip this order.
                    break;

                case "REQUESTED_SUPP":
                    Action  = "CONTINUE";
                    Message = "Port Order has had a Supplement requested.";
                    try
                    {
                        this.db.UpdatePortOrderFlags(coid, true, true, false); // Order is active.
                    }
                    catch { continue; }                                        // Skip this order.
                    break;

                case "FOC":
                    Action  = "COMPLETE";
                    Message = "Port Order has reached FOC.";
                    try
                    {
                        this.db.UpdatePortOrderFlags(coid, true, true, false); // LSR Step is complete, but Order is active.
                    }
                    catch { continue; }                                        // Skip this order.
                    break;

                case "COMPLETE":
                    Action  = "COMPLETE";
                    Message = "Port Order is completed.";
                    try
                    {
                        this.db.UpdatePortOrderFlags(coid, false, false, false); // Order is complete.
                    }
                    catch { continue; }                                          // Skip this order.
                    break;

                default:
                    Action  = "JEOP";
                    Message = "Unknown processing status: " + processingStatus;
                    break;
                }

                // Record the status.
                try
                {
                    this.db.UpdatePortOrderStatus(
                        orderRow["oppid"].SafeToString(),
                        long.Parse(orderRow["coid"].SafeToString()),
                        long.Parse(orderRow["cpid"].SafeToString()),
                        orderRow["OrderId"].SafeToString(),
                        orderStatusResponse.LnpOrderResponse.ProcessingStatus.SafeToString(),
                        Action,
                        Message,
                        orderStatusResponse.ToXml(),
                        orderStatusResponse.LnpOrderResponse.RequestedFocDate.SafeToString()
                        );
                }
                catch
                {
                    // Skip this order.
                    continue;
                }

                // Jeop, if action is jeop.
                if (Action == "JEOP")
                {
                    try
                    {
                        this.db.JeopStep(
                            orderRow["oppid"].SafeToString(),
                            int.Parse(orderRow["wf_id"].SafeToString()),
                            int.Parse(orderRow["wf_step_id"].SafeToString()),
                            orderRow["JeopName"].SafeToString(),
                            Message);
                    }
                    catch
                    {
                        // Skip this order.
                        continue;
                    }
                }
                else if (Action == "COMPLETE")
                {
                    try
                    {
                        this.db.CompleteStep(
                            orderRow["oppid"].SafeToString(),
                            int.Parse(orderRow["wf_id"].SafeToString()),
                            int.Parse(orderRow["wf_step_id"].SafeToString()));
                    }
                    catch
                    {
                        // Skip this order.
                        continue;
                    }
                }
            }

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