Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| inprogress [2019/08/29 13:42] – gerardorourke | inprogress [2019/09/04 22:24] (current) – gerardorourke | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== In progress ===== | ===== In progress ===== | ||
| - | |||
| - | Reference: | ||
| - | https:// | ||
| < | < | ||
| - | < | + | < |
| - | <% | + | |
| - | /* | + | |
| - | MIT License | + | |
| + | Date: 02 September 2019 | ||
| + | Version 1.0 | ||
| + | /* | ||
| - | Copyright (c) 2019 Gerard O' | + | /* |
| + | MIT License | ||
| - | Permission is hereby granted, free of charge, to any person obtaining a copy | + | Copyright |
| - | of this software and associated documentation files (the " | + | |
| - | in the Software without restriction, | + | |
| - | 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 | + | Permission is hereby granted, free of charge, to any person obtaining a copy |
| - | copies | + | of this software and associated documentation files (the " |
| + | | ||
| + | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| + | copies | ||
| + | furnished to do so, subject to the following conditions: | ||
| - | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | + | The above copyright notice and this permission notice shall be included in all |
| - | 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. | + | |
| - | */ | + | |
| - | // Query String - Retrieve dyanmic values for the Business Hours and ECE API IDs. | + | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| - | var myQuerySring = Request.QueryString; | + | |
| - | var myChatEntryId = Request.QueryString(" | + | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| - | var myBusinessHoursId= Request.QueryString(" | + | |
| + | 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. | ||
| + | */ | ||
| - | //var myChatEntryId = getUrlVars()[" | + | |
| - | //Response.Write(" | + | Location of File: |
| + | Example: D: | ||
| + | Example URL: http://ucce-ece-db-12.lab2.purplepi.ie/ | ||
| + | */ | ||
| - | var businessHoursUrl = "http://localhost/ | + | try { //Start of Global Try |
| - | var liveSessionStatusUrl = " | + | |
| - | var capacityUrl = " | + | |
| + | // ******************************************************************************************** // | ||
| + | // ******************* You should review and change the BELOW variables | ||
| + | // ******************************************************************************************** // | ||
| + | // Variables CCE & ECE Server Details | ||
| + | var ccehostname = ' | ||
| + | var ecehostname = ' | ||
| + | var cceuser = ' | ||
| + | var ccepass = ' | ||
| + | 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 -> ' | ||
| + | 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) | ||
| - | // Default Values if unable to read valid values from BusinessHours Name | + | |
| - | var defaultProactiveChatTimer = ' | + | var defaultProactiveChatTimer = ' |
| - | var defaultMinAgentCount = ' | + | var defaultMinAgentCount = ' |
| - | var defaultMaxQueueDepth = '10'; | + | var defaultMaxQueueDepth = '0'; |
| - | var defaultMaxWaitTime = ' | + | var defaultMaxWaitTime = ' |
| - | //Retrieve BusinessHours Details from CCE BusinessHours API | + | // ******************************************************************************************** // |
| - | var srvXmlHttp | + | // ******************* You should review and change the ABOVE variables |
| - | srvXmlHttp = Server.CreateObject(" | + | // ******************************************************************************************** // |
| - | srvXmlHttp.open (" | + | |
| - | srvXmlHttp.send(); | + | |
| - | var businessHours = srvXmlHttp.responseXML; | ||
| - | var businessHoursName = businessHours.selectSingleNode("// | ||
| - | var runTimeStatus = businessHours.selectSingleNode("// | ||
| - | var businessHoursNameArray = businessHoursName.text.split(" | ||
| - | var myBusinessHoursName = businessHoursNameArray[0]; | ||
| - | var myProactiveChatTimer = businessHoursNameArray[1]; | ||
| - | 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 (isNaN(myProactiveChatTimer)){ | + | |
| - | myProactiveChatTimer = defaultProactiveChatTimer; | + | |
| - | } | + | |
| - | if (isNaN(myMinAgentCount)){ | + | var myMinAgentCount |
| - | myMinAgentCount = defaultMinAgentCount; | + | |
| - | } | + | |
| - | if (isNaN(myMaxQueueDepth)){ | + | |
| - | myMaxQueueDepth = defaultMaxQueueDepth; | + | |
| - | } | + | |
| - | if (isNaN(myMaxWaitTime)){ | + | |
| - | myMaxWaitTime = defaultMaxWaitTime; | + | |
| - | } | + | |
| - | var chatStatus | + | // Query String - Retrieve dyanmic values for the Business Hours and ECE API IDs. |
| - | var chatBusyReason | + | |
| - | var chatTimer | + | var myChatEntryId |
| + | var myBusinessHoursId | ||
| - | if (runTimeStatus.text | + | // CCE & ECE URLs |
| + | var businessHoursUrl | ||
| + | var liveSessionStatusUrl | ||
| + | var capacityUrl | ||
| - | srvXmlHttp.open (" | + | // Initial JS variable values |
| - | srvXmlHttp.send(); | + | var chatStatus |
| - | var liveSessionStatus | + | var chatStatusReason |
| - | var waitTime | + | var chatTimer |
| - | var queueDepth | + | |
| - | srvXmlHttp.open ("GET", capacityUrl, | + | Response.ContentType = "application/ |
| - | srvXmlHttp.send(); | + | |
| - | var capacity = srvXmlHttp.responseXML; | + | |
| - | var count = capacity.selectSingleNode(" | + | |
| + | if (debuglevel > 0) { | ||
| + | Response.Write(" | ||
| + | } | ||
| - | Response.ContentType=" | + | chatstatus |
| - | Response.Write("var chatStatus = '" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | if (chatstatus == 'open' |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | } |
| - | Response.Write(" | + | |
| + | if (chatstatus == ' | ||
| + | chatstatus = capacityAPI() // ECE Capacity API - returns ' | ||
| + | } | ||
| - | Response.Write(" | + | |
| - | Response.Write(" | + | Response.Write(" |
| - | Response.Write(" | + | Response.Write(" |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | Response.Write(" | + | |
| - | %> | + | |
| - | </ | + | Response.Write(" |
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | |||
| + | // ******************************************************************************************** // | ||
| + | // ******************************** Functions ************************************************* // | ||
| + | // ******************************************************************************************** // | ||
| + | |||
| + | function businessHoursAPI() { | ||
| + | try { | ||
| + | var srvXmlHttp | ||
| + | srvXmlHttp = Server.CreateObject(" | ||
| + | srvXmlHttp.setOption(2, | ||
| + | srvXmlHttp.setTimeouts(resolveTimeout, | ||
| + | srvXmlHttp.open(" | ||
| + | srvXmlHttp.send(); | ||
| + | |||
| + | var httpstatus = srvXmlHttp.status; | ||
| + | |||
| + | if (debuglevel > 0) { | ||
| + | Response.Write(" | ||
| + | } | ||
| + | |||
| + | if (httpstatus != 200) { | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = 'out of service'; | ||
| + | myProactiveChatTimer = ' | ||
| + | return chatStatus; | ||
| + | } | ||
| + | |||
| + | chatStatusReason = ''; | ||
| + | |||
| + | var businessHours = srvXmlHttp.responseXML; | ||
| + | var businessHoursName = businessHours.selectSingleNode("// | ||
| + | var runTimeStatus = businessHours.selectSingleNode("// | ||
| + | var configuredStatus = businessHours.selectSingleNode("// | ||
| + | if (configuredStatus.text > 0) { | ||
| + | var reasonText = businessHours.selectSingleNode("// | ||
| + | } | ||
| + | |||
| + | //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]; | ||
| + | |||
| + | myProactiveChatTimer = myProactiveChatTimer*1000; | ||
| + | |||
| + | // Check if Valid Values from BusinessHour - if not - overwrite with the default values. | ||
| + | if (isNaN(myProactiveChatTimer)) { | ||
| + | myProactiveChatTimer = defaultProactiveChatTimer; | ||
| + | } | ||
| + | if (isNaN(myMinAgentCount)) { | ||
| + | myMinAgentCount = defaultMinAgentCount; | ||
| + | } | ||
| + | if (isNaN(myMaxQueueDepth)) { | ||
| + | myMaxQueueDepth = defaultMaxQueueDepth; | ||
| + | } | ||
| + | if (isNaN(myMaxWaitTime)) { | ||
| + | myMaxWaitTime = defaultMaxWaitTime; | ||
| + | } | ||
| + | |||
| + | if ((runTimeStatus.text == 0 || runTimeStatus.text == 2) && configuredStatus.text > 0) { | ||
| + | chatStatusReason = reasonText.text; | ||
| + | } | ||
| + | |||
| + | if (runTimeStatus.text == 1 || runTimeStatus.text == 3) { | ||
| + | chatStatus = ' | ||
| + | } | ||
| + | |||
| + | if (debuglevel > 1) { | ||
| + | Response.Write(" | ||
| + | if (configuredStatus.text > 0) { | ||
| + | Response.Write(" | ||
| + | } | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | } | ||
| + | |||
| + | return chatStatus; | ||
| + | } //Try | ||
| + | catch (err) { | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = 'out of service'; | ||
| + | myProactiveChatTimer = ' | ||
| + | |||
| + | if (debuglevel > 0) { | ||
| + | Response.Write(" | ||
| + | } | ||
| + | return chatStatus; | ||
| + | } //Catch | ||
| + | } //Function | ||
| + | |||
| + | |||
| + | function liveSessionStatusAPI() { | ||
| + | try { | ||
| + | var srvXmlHttp | ||
| + | srvXmlHttp = Server.CreateObject(" | ||
| + | srvXmlHttp.setOption(2, | ||
| + | srvXmlHttp.open(" | ||
| + | srvXmlHttp.send(); | ||
| + | |||
| + | var httpstatus = srvXmlHttp.status; | ||
| + | |||
| + | if (debuglevel > 0) { | ||
| + | Response.Write(" | ||
| + | } | ||
| + | |||
| + | if (httpstatus != 200) { | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = 'out of service'; | ||
| + | myProactiveChatTimer = ' | ||
| + | return chatStatus; | ||
| + | } | ||
| + | |||
| + | var liveSessionStatus = srvXmlHttp.responseXML; | ||
| + | var waitTime = liveSessionStatus.selectSingleNode("// | ||
| + | var queueDepth = liveSessionStatus.selectSingleNode("// | ||
| + | |||
| + | if (parseInt(queueDepth.text, | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = ' | ||
| + | myProactiveChatTimer = ' | ||
| + | } | ||
| + | |||
| + | if (parseInt(waitTime.text, | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = ' | ||
| + | myProactiveChatTimer = ' | ||
| + | } | ||
| + | |||
| + | if (debuglevel > 1) { | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | } | ||
| + | |||
| + | return chatStatus; | ||
| + | } //Try | ||
| + | catch (err) { | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = 'out of service'; | ||
| + | myProactiveChatTimer = ' | ||
| + | |||
| + | if (debuglevel > 0) { | ||
| + | Response.Write(" | ||
| + | } | ||
| + | return chatStatus; | ||
| + | } //Catch | ||
| + | } //Function | ||
| + | |||
| + | |||
| + | |||
| + | function capacityAPI() { | ||
| + | try { | ||
| + | |||
| + | srvXmlHttp = Server.CreateObject(" | ||
| + | srvXmlHttp.setOption(2, | ||
| + | srvXmlHttp.open(" | ||
| + | srvXmlHttp.send(); | ||
| + | |||
| + | var httpstatus = srvXmlHttp.status; | ||
| + | |||
| + | if (debuglevel > 0) { | ||
| + | Response.Write(" | ||
| + | } | ||
| + | |||
| + | if (httpstatus != 200) { | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = 'out of service'; | ||
| + | return chatStatus; | ||
| + | } | ||
| + | |||
| + | var capacity = srvXmlHttp.responseXML; | ||
| + | var count = capacity.selectSingleNode("// | ||
| + | |||
| + | if (parseInt(count.text, | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = ' | ||
| + | myProactiveChatTimer = ' | ||
| + | } | ||
| + | |||
| + | if (debuglevel > 1) { | ||
| + | Response.Write(" | ||
| + | } | ||
| + | |||
| + | return chatStatus; | ||
| + | } // Try | ||
| + | catch (err) { | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = 'out of service'; | ||
| + | chatTimer = ' | ||
| + | if (debuglevel > 0) { | ||
| + | Response.Write(" | ||
| + | } | ||
| + | return chatStatus; | ||
| + | |||
| + | } //Catch | ||
| + | } // | ||
| + | } //End of Global Try | ||
| + | |||
| + | catch (err) { | ||
| + | chatStatus = ' | ||
| + | chatStatusReason = 'out of service'; | ||
| + | chatTimer = ' | ||
| + | |||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | Response.Write(" | ||
| + | } | ||
| + | |||
| + | %> | ||
| + | </ | ||