Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
inprogress [2019/08/29 16:32] – gerardorourkeinprogress [2019/09/04 22:24] (current) – gerardorourke
Line 2: Line 2:
  
 <code> <code>
-<%@language=JScript%>+<%@language = JScript %>
  
-<%+    <%
  
-/* +    /* 
-Author: Gerard O'Rourke +    Author: Gerard O'Rourke - Purplepi.ie 
-Date: 29 Auguest 2019+    Date: 02 September 2019 
 +    Version 1.0 
 +    /*
  
-To Do: Timeouts, Error handling when Site returns incorrect data or no data, put code into functions.+    /* 
 +    MIT License
  
-/*+    Copyright (c) 2019 Gerard O'Rourke - purplepi.ie
  
-/* +    Permission is hereby granted, free of charge, to any person obtaining a copy 
-MIT License+    of this software and associated documentation files (the "Software"), to deal 
 +    in the Software without restriction, including without limitation the rights 
 +    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
 +    copies of the Software, and to permit persons to whom the Software is 
 +    furnished to do so, subject to the following conditions:
  
-Copyright (c) 2019 Gerard O'Rourke - purplepi.ie+    The above copyright notice and this permission notice shall be included in all 
 +    copies or substantial portions of the Software.
  
-Permission is hereby granted, free of charge, to any person obtaining a copy +    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
-of this software and associated documentation files (the "Software"), to deal +    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
-in the Software without restriction, including without limitation the rights +    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
-copies of the Software, and to permit persons to whom the Software is +    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
-furnished to do so, subject to the following conditions:+    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
 +    SOFTWARE. 
 +    */
  
-The above copyright notice and this permission notice shall be included in all +    /* 
-copies or substantial portions of the Software.+ Location of File:  
 + Example: D:\ECE\eService\templates\chat\businessHours\ 
 + Example URL: http://ucce-ece-db-12.lab2.purplepi.ie/system/templates/chat/businessHours/chatStatus.asp?businessHoursId=5001&chatEntryId=1001 
 + */
  
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
-SOFTWARE. 
-*/ 
  
 +    try { //Start of Global Try
  
-// CCE & ECE Server Details +// ******************************************************************************************** // 
-var ccehostname = 'ucce-hds-a.lab2.purplepi.ie'; +// ******************* You should review and change the BELOW variables  ********************** // 
-var ecehostname = 'ucce-ece-db-12.lab2.purplepi.ie'; +// ******************************************************************************************** //
-var cceuser = '[email protected]'; +
-var ccepass = 'myPa$$w0rd!';+
  
-// Default Values if unable to read valid values from BusinessHours Name +        // Variables CCE & ECE Server Details 
-var defaultProactiveChatTimer = '0'; +        var ccehostname = 'ucce-hds-a.lab2.purplepi.ie'; 
-var defaultMinAgentCount = '0'; +        var ecehostname = 'ucce-ece-db-12.lab2.purplepi.ie'; 
-var defaultMaxQueueDepth = '10'; +        var cceuser = '[email protected]'; //create a PCCE User Administrator dedicated for this role. 
-var defaultMaxWaitTime = '120';+        var ccepass = 'myPa$$w0rd!'; 
 +        var debuglevel = 1; // 0 = disabled, 1 = minimum, 2 = all - recommend to set to 1  
 +        var SXH_OPTION_2_VALUE = 13056; // SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS -> 'SXH_OPTION_2_VALUE = 13056;' to ignore all SSL errors 
 +        var resolveTimeout = 3000; // DNS Resolve Timeout (ms) 
 +        var connectTimeout = 3000; // Value (ms) is applied to establishing a communication socket with the target server 
 +        var sendTimeout = 3000; // The value applies to sending an individual packet of request data (if any) on the communication socket to the target server. (ms) 
 +        var receiveTimeout = 3000; // The value applies to receiving a packet of response data from the target server (ms)
  
-// Query String - Retrieve dyanmic values for the Business Hours and ECE API IDs. +        // Default Values if unable to read valid values from BusinessHours Name 
-var myQuerySring = Request.QueryString; +        var defaultProactiveChatTimer = '0'; // value here is set in ms, e.g. for a 10 second Proactive Chat, enter '10000' 
-var myChatEntryId = Request.QueryString("chatEntryId"); +        var defaultMinAgentCount = '0'; 
-var myBusinessHoursId= Request.QueryString("businessHoursId");+        var defaultMaxQueueDepth = '0'; 
 +        var defaultMaxWaitTime = '120';
  
-// CCE & ECE URLs +// ******************************************************************************************** // 
-var businessHoursUrl = 'https://' + ccehostname + '/unifiedconfig/config/businesshour/' + myBusinessHoursId; +// ******************* You should review and change the ABOVE variables  ********************** // 
-var liveSessionStatusUrl = 'http://' + ecehostname + '/system/egain/chat/entrypoint/liveSessionStatus/' + myChatEntryId; +// ******************************************************************************************** //
-var capacityUrl = 'http://' + ecehostname + '/system/egain/chat/entrypoint/capacity/' + myChatEntryId;+
  
  
-var srvXmlHttp 
-srvXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0"); 
-srvXmlHttp.setOption(2,13056);  //Ignore SSL Certs 
  
-//Retrieve BusinessHours Details from CCE BusinessHours API +        // Declare Global Variables used in both businessHours and ECE APIs 
-srvXmlHttp.open ("GET", businessHoursUrl, false, cceuser, ccepass); +        var myProactiveChatTimer 
-srvXmlHttp.send();+        var myMaxQueueDepth 
 +        var myMaxWaitTime 
 +        var myMinAgentCount
  
-var businessHours = srvXmlHttp.responseXML; +        // Query String - Retrieve dyanmic values for the Business Hours and ECE API IDs. 
-var businessHoursName = businessHours.selectSingleNode("//businessHour/name"); +        var myQuerySring = Request.QueryString; 
-var runTimeStatus = businessHours.selectSingleNode("//businessHour/runTimeStatus");+        var myChatEntryId = Request.QueryString("chatEntryId"); 
 +        var myBusinessHoursId = Request.QueryString("businessHoursId");
  
-//Parse Business Hours Name to retrieve the Proactive Chat Timer, Min Agent Count, Max Queue Depth & Max Wait Timeouts +        // CCE & ECE URLs 
-var businessHoursNameArray = businessHoursName.text.split("_"); +        var businessHoursUrl = 'https://' + ccehostname + '/unifiedconfig/config/businesshour/' + myBusinessHoursId; 
-var myBusinessHoursName = businessHoursNameArray[0]; +        var liveSessionStatusUrl = 'http://' + ecehostname + '/system/egain/chat/entrypoint/liveSessionStatus/' + myChatEntryId; 
-var myProactiveChatTimer = businessHoursNameArray[1]; +        var capacityUrl = 'http://' + ecehostname + '/system/egain/chat/entrypoint/capacity/' + myChatEntryId;
-var myMinAgentCount = businessHoursNameArray[2]; +
-var myMaxQueueDepth = businessHoursNameArray[3]; +
-var myMaxWaitTime = businessHoursNameArray[4];+
  
-// Check if Valid Values from BusinessHour - if not - overwrite with the default values. +        // Initial JS variable values 
-if (isNaN(myProactiveChatTimer)){ +        var chatStatus = 'closed'; //Defaults value until overwritten 
- myProactiveChatTimer = defaultProactiveChatTimer; +        var chatStatusReason = 'out of service'; //Defaults value until overwritten 
-}  +        var chatTimer = '0'; //Defaults value until overwritten
-if (isNaN(myMinAgentCount)){ +
- myMinAgentCount = defaultMinAgentCount; +
-}  +
-if (isNaN(myMaxQueueDepth)){ +
- myMaxQueueDepth = defaultMaxQueueDepth; +
-}  +
-if (isNaN(myMaxWaitTime)){ +
- myMaxWaitTime = defaultMaxWaitTime; +
-} +
  
-var chatStatus = 'closed'; +        Response.ContentType = "application/javascript"; // Set Content Type
-var chatBusyReason = 'unknown'; +
-var chatTimer = '0';+
  
-if (runTimeStatus.text == 1 || runTimeStatus.text == 3){chatStatus = 'open';}+        if (debuglevel > 0) { 
 +            Response.Write("\nconsole.log('chatStatus QueryString: " + Request.QueryString + "');"); 
 +        }
  
-srvXmlHttp.open ("GET", liveSessionStatusUrl, false); +        chatstatus = businessHoursAPI() // BusinessHours API - returns 'open' or 'closed'
-srvXmlHttp.send(); +
-var liveSessionStatus = srvXmlHttp.responseXML; +
-var waitTime = liveSessionStatus.selectSingleNode("//ns2:waitTime"); +
-var queueDepth = liveSessionStatus.selectSingleNode("//ns2:queueDepth");+
  
-srvXmlHttp.open ("GET", capacityUrl, false); +        if (chatstatus == 'open') { 
-srvXmlHttp.send(); +            chatstatus = liveSessionStatusAPI() // ECE  liveSessionStatus API  -  returns 'open' or 'busy' or if unable to read - 'closed' with chatStatusReason 'out of service' 
-var capacity = srvXmlHttp.responseXML; +        }
-var count = capacity.selectSingleNode("//ns2:count");+
  
 +        if (chatstatus == 'open' && myMinAgentCount > 0) {
 +            chatstatus = capacityAPI() // ECE  Capacity API  - returns 'open' or 'busy' or if unable to read - 'closed' with chatStatusReason 'out of service'
 +        }
  
-Response.ContentType="application/javascript"; +        Response.Write("\nvar chatStatus = '" + chatStatus + "';"); 
-Response.Write("var chatStatus = '" + chatStatus + "';\n"); +        Response.Write("\nvar chatStatusReason = '" + chatStatusReason + "';"); 
-Response.Write("var chatBusyReason = '" + chatBusyReason + "';\n"); +        Response.Write("\nvar chatTimer = '" + myProactiveChatTimer + "';");
-Response.Write("var chatTimer = '" + chatTimer + "';\n");+
  
 + Response.Write("\nconsole.log('chatStatus chatStatus: " + chatStatus + "');");
 + Response.Write("\nconsole.log('chatStatus chatStatusReason: " + chatStatusReason + "');");
 + Response.Write("\nconsole.log('chatStatus chatTimer: " + myProactiveChatTimer + "');");
  
-Response.Write("\nconsole.log('------- Cisco CCE Custom chatStatus Console Output - Start ------')"); 
-Response.Write("\nconsole.log('QueryString: " + Request.QueryString + "');"); 
-Response.Write("\nconsole.log('businessHoursId: " + myBusinessHoursId + "');"); 
-Response.Write("\nconsole.log('ChatEntryId: " + myChatEntryId + "');"); 
-Response.Write("\nconsole.log('Full BusinessHoursName: " + businessHoursName.text + "')"); 
-Response.Write("\nconsole.log('myBusinessHoursName: " + myBusinessHoursName + "')"); 
-Response.Write("\nconsole.log('myProactiveChatTimer: " + myProactiveChatTimer + "')"); 
-Response.Write("\nconsole.log('myMinAgentCount: " + myMinAgentCount + "')"); 
-Response.Write("\nconsole.log('myMaxQueueDepth: " + myMaxQueueDepth + "')"); 
-Response.Write("\nconsole.log('myMaxWaitTime: " + myMaxWaitTime + "')"); 
-Response.Write("\nconsole.log('runTimeStatus: " + runTimeStatus.text + "')"); 
-Response.Write("\nconsole.log('waitTime: " + waitTime.text + "')"); 
-Response.Write("\nconsole.log('queueDepth: " + queueDepth.text + "')"); 
-Response.Write("\nconsole.log('agentCount: " + count.text + "')"); 
-Response.Write("\nconsole.log('------- Cisco CCE Custom chatStatus Console Output - End ------')"); 
-%> 
  
-</code>+// ******************************************************************************************** // 
 +// ******************************** Functions ************************************************* // 
 +// ******************************************************************************************** //
  
 +        function businessHoursAPI() {
 +            try {
 +                var srvXmlHttp
 +                srvXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0");
 +                srvXmlHttp.setOption(2, SXH_OPTION_2_VALUE); //Ignore SSL Certs
 +                srvXmlHttp.setTimeouts(resolveTimeout, connectTimeout, sendTimeout, receiveTimeout);
 +                srvXmlHttp.open("GET", businessHoursUrl, false, cceuser, ccepass);
 +                srvXmlHttp.send();
  
 +                var httpstatus = srvXmlHttp.status;
  
-Reference:  +                if (debuglevel > 0) { 
-https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms763809(v%3Dvs.85)+                    Response.Write("\nconsole.log('chatStatus CCE API HTTP Status: " + httpstatus + "')"); 
 +                }
  
-<code> +                if (httpstatus != 200) { 
-<%@language=JScript%>+                    chatStatus = 'closed'; 
 +                    chatStatusReason = 'out of service'; 
 + myProactiveChatTimer = '0'; 
 +                    return chatStatus; 
 +                }
  
-<%+                chatStatusReason = ''; //Clear 'out of service' value
  
-/* +                var businessHours = srvXmlHttp.responseXML; 
-MIT License+                var businessHoursName = businessHours.selectSingleNode("//businessHour/name"); 
 +                var runTimeStatus = businessHours.selectSingleNode("//businessHour/runTimeStatus"); 
 +                var configuredStatus = businessHours.selectSingleNode("//businessHour/configuredStatus/status"); 
 +                if (configuredStatus.text > 0) { 
 +                    var reasonText = businessHours.selectSingleNode("//businessHour/configuredStatus/statusReason/reasonText"); 
 +                }
  
-Copyright (c) 2019 Gerard O'Rourke - purplepi.ie+                //Parse Business Hours Name to retrieve the Proactive Chat Timer, Min Agent Count, Max Queue Depth & Max Wait Timeouts 
 +                var businessHoursNameArray = businessHoursName.text.split("_"); 
 +                var myBusinessHoursName = businessHoursNameArray[0]; 
 +                myProactiveChatTimer = businessHoursNameArray[1]; 
 +                myMinAgentCount = businessHoursNameArray[2]; 
 +                myMaxQueueDepth = businessHoursNameArray[3]; 
 +                myMaxWaitTime = businessHoursNameArray[4];
  
-Permission is hereby granted, free of charge, to any person obtaining a copy +                myProactiveChatTimer = myProactiveChatTimer*1000; //Convert ChatTimer from seconds to milliseconds
-of this software and associated documentation files (the "Software"), to deal +
-in the Software without restriction, including without limitation the rights +
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +
-copies of the Software, and to permit persons to whom the Software is +
-furnished to do so, subject to the following conditions:+
  
-The above copyright notice and this permission notice shall be included in all +                // Check if Valid Values from BusinessHour - if not - overwrite with the default values. 
-copies or substantial portions of the Software.+                if (isNaN(myProactiveChatTimer)) { 
 +                    myProactiveChatTimer = defaultProactiveChatTimer; 
 +                } 
 +                if (isNaN(myMinAgentCount)) { 
 +                    myMinAgentCount = defaultMinAgentCount; 
 +                } 
 +                if (isNaN(myMaxQueueDepth)) { 
 +                    myMaxQueueDepth = defaultMaxQueueDepth; 
 +                } 
 +                if (isNaN(myMaxWaitTime)) { 
 +                    myMaxWaitTime = defaultMaxWaitTime; 
 +                }
  
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +                if ((runTimeStatus.text == 0 || runTimeStatus.text == 2) && configuredStatus.text > 0) { 
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +                    chatStatusReason = reasonText.text; 
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +                }
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +
-SOFTWARE. +
-*/+
  
-// Query String - Retrieve dyanmic values for the Business Hours and ECE API IDs. +                if (runTimeStatus.text == 1 || runTimeStatus.text == 3) { 
-var myQuerySring = Request.QueryString; +                    chatStatus = 'open'; 
-var myChatEntryId = Request.QueryString("chatEntryId"); +                }
-var myBusinessHoursId= Request.QueryString("businessHoursId");+
  
-//var myChatEntryId = getUrlVars()["chatEntryId"]; +                if (debuglevel > 1) { 
-//Response.Write("\nconsole.log('myChatEntryId: " + myChatEntryId + "')");+                    Response.Write("\nconsole.log('chatStatus BusinessHoursName: " + businessHoursName.text + "')"); 
 +                    if (configuredStatus.text > 0) { 
 +                        Response.Write("\nconsole.log('chatStatus reasonText: " + reasonText.text + "')"); 
 +                    } 
 +                    Response.Write("\nconsole.log('chatStatus myBusinessHoursName: " + myBusinessHoursName + "')"); 
 +                    Response.Write("\nconsole.log('chatStatus myProactiveChatTimer: " + myProactiveChatTimer + "')"); 
 +                    Response.Write("\nconsole.log('chatStatus myMinAgentCount: " + myMinAgentCount + "')"); 
 +                    Response.Write("\nconsole.log('chatStatus myMaxQueueDepth: " + myMaxQueueDepth + "')"); 
 +                    Response.Write("\nconsole.log('chatStatus myMaxWaitTime: " + myMaxWaitTime + "')"); 
 +                    Response.Write("\nconsole.log('chatStatus runTimeStatus: " + runTimeStatus.text + "')"); 
 +                }
  
 +                return chatStatus;
 +            } //Try
 + catch (err) {
 +                chatStatus = 'closed';
 +                chatStatusReason = 'out of service';
 + myProactiveChatTimer = '0';
  
-var businessHoursUrl = "http://localhost/xmlfiles/businessHours.xml" +                if (debuglevel > 0) { 
-var liveSessionStatusUrl = "http://localhost/xmlfiles/liveSessionStatus.xml" +                    Response.Write("\nconsole.log('chatStatus Error BusinessHours API')"); 
-var capacityUrl = "http://localhost/xmlfiles/capacity.xml"+                } 
 +                return chatStatus; 
 +            } //Catch 
 +        } //Function
  
  
 +        function liveSessionStatusAPI() {
 +            try {
 +                var srvXmlHttp
 +                srvXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0");
 +                srvXmlHttp.setOption(2, SXH_OPTION_2_VALUE); //Ignore SSL Certs
 +                srvXmlHttp.open("GET", liveSessionStatusUrl, false);
 +                srvXmlHttp.send();
  
-// Default Values if unable to read valid values from BusinessHours Name +                var httpstatus = srvXmlHttp.status;
-var defaultProactiveChatTimer = '0'; +
-var defaultMinAgentCount = '0'; +
-var defaultMaxQueueDepth = '10'; +
-var defaultMaxWaitTime = '120';+
  
-//Retrieve BusinessHours Details from CCE BusinessHours API +                if (debuglevel > 0) { 
-var srvXmlHttp +                    Response.Write("\nconsole.log('chatStatus ECE LiveSession API HTTP Status: " + httpstatus + "')"); 
-srvXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0"); +                }
-srvXmlHttp.open ("GET", businessHoursUrl, false); +
-srvXmlHttp.send();+
  
-var businessHours = srvXmlHttp.responseXML; +                if (httpstatus != 200) { 
-var businessHoursName = businessHours.selectSingleNode("//department/name"); +                    chatStatus = 'closed'; 
-var runTimeStatus = businessHours.selectSingleNode("//runTimeStatus");+                    chatStatusReason = 'out of service'; 
 + myProactiveChatTimer = '0'; 
 +                    return chatStatus; 
 +                }
  
-var businessHoursNameArray = businessHoursName.text.split("_"); +                var liveSessionStatus = srvXmlHttp.responseXML; 
-var myBusinessHoursName = businessHoursNameArray[0]; +                var waitTime = liveSessionStatus.selectSingleNode("//ns2:waitTime"); 
-var myProactiveChatTimer = businessHoursNameArray[1]; +                var queueDepth = liveSessionStatus.selectSingleNode("//ns2:queueDepth");
-var myMinAgentCount = businessHoursNameArray[2]; +
-var myMaxQueueDepth = businessHoursNameArray[3]; +
-var myMaxWaitTime = businessHoursNameArray[4];+
  
-// Check if Valid Values from BusinessHour - if not - overwrite with the default values. +                if (parseInt(queueDepth.text, 10) > myMaxQueueDepth) { 
-if (isNaN(myProactiveChatTimer)){ +                    chatStatus = 'busy'; 
- myProactiveChatTimer = defaultProactiveChatTimer; +                    chatStatusReason = 'MaxQueueDepth'; 
-}  + myProactiveChatTimer = '0'; 
-if (isNaN(myMinAgentCount)){ +                }
- myMinAgentCount = defaultMinAgentCount; +
-}  +
-if (isNaN(myMaxQueueDepth)){ +
- myMaxQueueDepth = defaultMaxQueueDepth; +
-}  +
-if (isNaN(myMaxWaitTime)){ +
- myMaxWaitTime = defaultMaxWaitTime; +
-} +
  
-var chatStatus = 'closed'; +                if (parseInt(waitTime.text, 10) > myMaxWaitTime) { 
-var chatBusyReason = 'unknown'; +                    chatStatus = 'busy'; 
-var chatTimer = '0';+                    chatStatusReason = 'MaxWaitTime'; 
 + myProactiveChatTimer = '0'; 
 +                }
  
-if (runTimeStatus.text == 1 || runTimeStatus.text == 3){chatStatus = 'open';}+                if (debuglevel > 1) { 
 +                    Response.Write("\nconsole.log('chatStatus waitTime: " + waitTime.text + "')"); 
 +                    Response.Write("\nconsole.log('chatStatus queueDepth: " + queueDepth.text + "')"); 
 +                }
  
-srvXmlHttp.open ("GET", liveSessionStatusUrl, false); +                return chatStatus; 
-srvXmlHttp.send(); +            } //Try 
-var liveSessionStatus = srvXmlHttp.responseXML; +            catch (err) { 
-var waitTime = liveSessionStatus.selectSingleNode("//ns2:waitTime"); +                chatStatus = 'closed'; 
-var queueDepth = liveSessionStatus.selectSingleNode("//ns2:queueDepth");+                chatStatusReason = 'out of service'; 
 + myProactiveChatTimer = '0'; 
 +  
 +                if (debuglevel > 0) { 
 +                    Response.Write("\nconsole.log('chatStatus Error Live Session API')"); 
 +                } 
 +                return chatStatus; 
 +            } //Catch 
 +        } //Function
  
-srvXmlHttp.open ("GET", capacityUrl, false); 
-srvXmlHttp.send(); 
-var capacity = srvXmlHttp.responseXML; 
-var count = capacity.selectSingleNode("//ns2:count"); 
  
  
-Response.ContentType="application/javascript"; +        function capacityAPI() { 
-Response.Write("var chatStatus = '" + chatStatus + "';\n"); +            try {
-Response.Write("var chatBusyReason = '" + chatBusyReason + "';\n"); +
-Response.Write("var chatTimer = '" + chatTimer + "';\n");+
  
-Response.Write("\nconsole.log('------- Cisco CCE Custom chatStatus Console Output - Start ------')"); +                srvXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0"); 
-Response.Write("\nconsole.log(" + Request.QueryString + ");"); +                srvXmlHttp.setOption(2, SXH_OPTION_2_VALUE); //Ignore SSL Certs 
-Response.Write("\nconsole.log(" + myChatEntryId + ");"); +                srvXmlHttp.open("GET", capacityUrl, false); 
-Response.Write("\nconsole.log(" + myBusinessHoursId + ");");+                srvXmlHttp.send();
  
 +                var httpstatus = srvXmlHttp.status;
  
-Response.Write("\nconsole.log('Full BusinessHoursName: " + businessHoursName.text + "')"); +                if (debuglevel > 0) { 
-Response.Write("\nconsole.log('myBusinessHoursName: " + myBusinessHoursName + "')"); +                    Response.Write("\nconsole.log('chatStatus ECE Capacity API HTTP Status: " + httpstatus + "')"); 
-Response.Write("\nconsole.log('myProactiveChatTimer: " + myProactiveChatTimer + "')"); +                }
-Response.Write("\nconsole.log('myMinAgentCount: " + myMinAgentCount + "')"); +
-Response.Write("\nconsole.log('myMaxQueueDepth: " + myMaxQueueDepth + "')"); +
-Response.Write("\nconsole.log('myMaxWaitTime: " + myMaxWaitTime + "')"); +
-Response.Write("\nconsole.log('runTimeStatus: " + runTimeStatus.text + "')"); +
-Response.Write("\nconsole.log('waitTime: " + waitTime.text + "')"); +
-Response.Write("\nconsole.log('queueDepth: " + queueDepth.text + "')"); +
-Response.Write("\nconsole.log('agentCount: " + count.text + "')"); +
-Response.Write("\nconsole.log('------- Cisco CCE Custom chatStatus Console Output - End ------')"); +
-%>+
  
-</code>+                if (httpstatus != 200) { 
 +                    chatStatus = 'closed'; 
 +                    chatStatusReason = 'out of service'; 
 +                    return chatStatus; 
 +                }
  
 +                var capacity = srvXmlHttp.responseXML;
 +                var count = capacity.selectSingleNode("//ns2:count");
  
 +                if (parseInt(count.text, 10) < myMinAgentCount) {
 +                    chatStatus = 'busy';
 +                    chatStatusReason = 'myMinAgentCount';
 + myProactiveChatTimer = '0';
 +                }
  
 +                if (debuglevel > 1) {
 +                    Response.Write("\nconsole.log('chatStatus agentCount: " + count.text + "')");
 +                }
 +
 +                return chatStatus;
 +            } // Try
 +            catch (err) {
 +                chatStatus = 'closed';
 +                chatStatusReason = 'out of service';
 + chatTimer = '0';
 +              if (debuglevel > 0) {
 +                    Response.Write("\nconsole.log('chatStatus Error Capacity API')");
 +                }
 +                return chatStatus;
 +
 +            } //Catch
 +        } //Function
 +    } //End of Global Try
 +
 +catch (err) {
 +    chatStatus = 'closed';
 +    chatStatusReason = 'out of service';
 +    chatTimer = '0';
 +
 +    Response.Write("\nvar chatStatus = '" + chatStatus + "';");
 +    Response.Write("\nvar chatStatusReason = '" + chatStatusReason + "';");
 +    Response.Write("\nvar chatTimer = '" + chatTimer + "';");
 +    Response.Write("\nconsole.log('chatStatus Global Error')");
 +}
 +
 +%>
 +</code>
  • inprogress.1567092722.txt.gz
  • Last modified: 2019/08/29 16:32
  • by gerardorourke