コード例 #1
0
        private BComSipPeerResponse CreateNewPeerID(DataTable aviatorData)
        {
            // Create an HTTPS_ Interface.
            HTTPS_Interface httpsInterface = new HTTPS_Interface();

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

            request.SipPeer = new SipPeer();

            // Load the request.
            try
            {
                request.SiteID                = this.siteid.ToString();
                request.SipPeer.PeerName      = aviatorData.Rows[0]["BCOM_AcctName"].SafeToString();
                request.SipPeer.Description   = aviatorData.Rows[0]["AcctDescription"].SafeToString();
                request.SipPeer.IsDefaultPeer = "true";
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed loading Aviator data into order: " + ex.Message);
            }

            // Special load the voicehost
            string voicehostURL = string.Empty;

            if (aviatorData.Rows[0]["VoiceHost"].SafeToString() == "NATIONAL")
            {
                voicehostURL = Settings.VoiceHostNational;
            }
            else if (aviatorData.Rows[0]["VoiceHost"].SafeToString() == "CORE")
            {
                voicehostURL = Settings.VoiceHostCore;
            }
            else
            {
                throw new ApplicationException(
                          "Failed parsing VoiceHost indicator from Aviator: Value of '" + aviatorData.Rows[0]["VoiceHost"].SafeToString() + "'.");
            }
            request.SipPeer.VoiceHosts = new Host[] { new Host(voicehostURL) };

            // Send the request and get the response.
            BComSipPeerResponse peerResponse =
                httpsInterface.CreateSipPeer(request);

            // Did the request succeed?
            if (peerResponse.Status == "Success")
            {
                // Update Peer information.
                try
                {
                    this.db.UpdateSipPeersTable(request, peerResponse);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Failed update the SipPeers table with the new account: " + ex.Message);
                }
            }

            // Return the response.
            return(peerResponse);
        }
コード例 #2
0
        private void LoadBComAccount(DataTable aviatorData)
        {
            // Does the oppid need a siteid created by BCOM?
            this.siteid = -1;
            if (aviatorData.Rows[0]["siteid"].SafeToString() == "-1")
            {
                // Get the response.
                BComSiteResponse siteResponse = null;
                try
                {
                    siteResponse = CreateNewSiteID(aviatorData);
                }
                catch (Exception ex)
                {
                    this.response.SetJeop(
                        "Unable to request a SiteID for opp: " + ex.Message);
                    return;
                }

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

                // Extract the siteid.
                bool success = false;
                success = long.TryParse(
                    siteResponse.SiteID, out this.siteid);

                // Failed? Then Jeop.
                if (success == false)
                {
                    this.response.SetJeop(
                        "Unable to parse SiteID for opp: Returned value of " + siteResponse.SiteID);
                    return;
                }
            }
            else // It's there? Now parse it out to be used later.
            {
                bool success = false;
                success = long.TryParse(
                    aviatorData.Rows[0]["siteid"].SafeToString(), out this.siteid);

                // Failed? Then Jeop.
                if (success == false)
                {
                    this.response.SetJeop(
                        "Unable to parse SiteID for opp: Returned value of " + aviatorData.Rows[0]["siteid"].SafeToString());
                    return;
                }
            }

            // Debug, test write siteid.
            //Response.Write("SiteID: " + this.siteid.ToString());
            //Response.Write(Environment.NewLine + Environment.NewLine + Environment.NewLine);

            // Does the oppid need a peerid created by BCOM?
            this.peerid = -1;
            if (aviatorData.Rows[0]["peerid"].SafeToString() == "-1")
            {
                // Get the response.
                BComSipPeerResponse peerResponse = null;
                try
                {
                    peerResponse = CreateNewPeerID(aviatorData);
                }
                catch (Exception ex)
                {
                    this.response.SetJeop(
                        "Unable to request a SipPeerID for opp: " + ex.Message);
                    return;
                }

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

                // Extract the peerid.
                bool success = false;
                success = long.TryParse(
                    peerResponse.SipPeerID, out this.peerid);

                // Failed? Then Jeop.
                if (success == false)
                {
                    this.response.SetJeop(
                        "Unable to parse SipPeerID for opp: Returned value of " + peerResponse.SipPeerID);
                    return;
                }
            }
            else // It's there? Now parse it out to be used later.
            {
                bool success = false;
                success = long.TryParse(
                    aviatorData.Rows[0]["peerid"].SafeToString(), out this.peerid);

                // Failed? Then Jeop.
                if (success == false)
                {
                    this.response.SetJeop(
                        "Unable to parse SipPeerID for opp: Returned value of " + aviatorData.Rows[0]["peerid"].SafeToString());
                    return;
                }
            }

            // Debug, test write peerid.
            //Response.Write("SipPeerID: " + this.siteid.ToString());
            //Response.Write(Environment.NewLine + Environment.NewLine + Environment.NewLine);
        }