예제 #1
0
        private BcomPortTriggerResponse TriggerLnpPort(string orderid)
        {
            // Create an HTTPS_ Interface.
            HTTPS_Interface httpsInterface = new HTTPS_Interface();

            // Create Trigger Request
            BComPortTriggerRequest request =
                new BComPortTriggerRequest();

            request.ActivationStatus = new ActivationStatus();

            // Load OrderId into the request.
            request.OrderId = this.orderid;

            // Set the date for immediate activation.
            request.ActivationStatus.SetImmediateActivateDate();

            // Send the request and get the response.
            BcomPortTriggerResponse response =
                httpsInterface.TriggerPort(request);

            // Return the response.
            return(response);
        }
예제 #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";

            // Response declared.
            this.response = new TriggerPortResponse();

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

            // Get the orderID
            try
            {
                this.orderid =
                    this.db.LoadLnpOrderIdFromOppid(oppid);
            }
            catch (Exception ex)
            {
                string jeop = "Unable to retrieve the orderID: " + 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;
            }

            // No OrderID?
            if (string.IsNullOrEmpty(this.orderid))
            {
                string jeop = "No order id returned for this oppid: " + this.oppid;
                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;
            }

            DataRow processingStatus = null;

            // Get Order IDs Processing Status
            try
            {
                // Check if processing status is FOC
                processingStatus = db.LoadProcessingStatusByOrderID(orderid);
                if (processingStatus["ProcessingStatus"].SafeToString() != "FOC")
                {
                    string jeop = "Order is not in FOC.";
                    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;
                }
            }
            catch (Exception Ex)
            {
                string jeop = "Unable to retrieve the Processing Status of the orderID: " + 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;
            }

            // Trigger the port.
            BcomPortTriggerResponse triggerResponse = null;

            try
            {
                triggerResponse = TriggerLnpPort(orderid);
            }
            catch (Exception ex)
            {
                string jeop = "Error triggering port: " + 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 not succeed?
            if (triggerResponse.Status != "Success")
            {
                string jeop = "Trigger failed: " + triggerResponse.ErrorMessage;
                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;
            }

            // Assume success.
            this.response.SetComplete();
            this.db.CompleteStep(
                this.oppid, this.wf_id, this.wf_step_id);

            // Return result.
            Response.Write(response.ToXml());
            return;
        }