<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="iframeocx.aspx.cs" Inherits="HySoft.BaseCallCenter.Web.iframeocx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="seatformjs/formopt.js" type="text/javascript"></script>
    <script type="text/javascript">
        /*/// <summary>
        /// 取保持结果事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="strres"></param>*/
        function EvtUnHold(blres, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtUnHold");
            if (blres == "True") {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席接回成功";
                parent.setLinkStatus("true");
                parent.Form_setWinfromenble("True", "false", "false", "false", "True", "True", "True", "false", "false", "false");
                parent.setAgentStatus("忙");
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席接回失败：" + strres;
                //parent.Form_setWinfromenble("false", "True", "false", "True", "false", "false", "True", "false", "false", "True");
            }
        }

        /*/// <summary>
        /// 转移电话结果事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="strres"></param>*/
        function EvtTransferToPhone(blres, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtTransferToPhone");
            if (blres == "True") {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席转移电话成功";
                parent.Form_setWinfromenble("false", "false", "false", "false", "false", "false", "false", "false", "false", "false");
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席转移电话失败：" + strres;
                //parent.Form_setWinfromenble("false", "True", "false", "True", "false", "false", "True", "false", "false", "True");
            }
        }

        /*/// <summary>
        /// 转IVR结果事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="strres"></param>*/
        function EvtTransferToIVR(blres, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtTransferToIVR");
            if (blres == "True") {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席转IVR成功";
                parent.Form_setWinfromenble("false", "false", "false", "false", "false", "false", "false", "false", "false", "false");
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席转IVR失败：" + strres;
                //parent.Form_setWinfromenble("false", "True", "false", "True", "false", "false", "True", "false", "false", "True");
            }
        }

        /*/// <summary>
        /// 三方通话结果事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="strres"></param>*/
        function EvtThirdParty(blres, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtThirdParty");
            if (blres == "True") {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席三方通话成功";
                parent.Form_setWinfromenble("True", "false", "false", "false", "false", "false", "false", "false", "false", "false");
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席三方通话失败：" + strres;
                //parent.Form_setWinfromenble("false", "True", "false", "True", "false", "false", "True", "false", "false", "True");
            }
        }

        /*/// <summary>
        /// 坐席置闲结果事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="strres"></param>*/
        function EvtSetFree(blres, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtSetFree");
            if (blres == "True") {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席置闲成功";
                parent.setLinkStatus("True");
                parent.Form_setWinfromenble("false", "True", "True", "false", "false", "false", "false", "false", "false", "True");
                parent.setAgentStatus("空闲");
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席置闲失败：" + strres;
                //parent.Form_setWinfromenble("false", "True", "True", "false", "false", "false", "false", "false", "false", "True");
            }
        }

        /*/// <summary>
        /// 坐席置忙结果事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="strres"></param>*/
        function EvtSetBusy(blres, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtSetBusy");
            if (blres == "True") {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席置忙成功";
                parent.setLinkStatus("True");
                parent.Form_setWinfromenble("false", "True", "false", "True", "false", "false", "false", "false", "false", "True");
                parent.setAgentStatus("忙");
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席置忙失败：" + strres;
                //parent.Form_setWinfromenble("false", "True", "false", "True", "false", "false", "false", "false", "false", "True");
            }
        }

        /*/// <summary>
        /// 电话保持结果事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="strres"></param>*/
        function EvtHold(blres, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtHold");
            if (blres == "True") {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席保持成功";
                parent.setLinkStatus("True");
                parent.Form_setWinfromenble("True", "false", "false", "false", "false", "false", "false", "True", "false", "True");
                parent.setAgentStatus("忙");
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席保持失败：" + strres;
                //parent.Form_setWinfromenble("false", "True", "false", "True", "false", "false", "false", "True", "false", "True");
            }
        }

        /*/// <summary>
        /// 挂机结果事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="strres"></param>*/
        function EvtHangup(blres, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtHangup");
            if (blres == "True") {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席挂机成功";
                parent.setLinkStatus("false");
                parent.Form_setWinfromenble("false", "True", "false", "True", "false", "false", "false", "True", "false", "True");
                parent.setAgentStatus("离席");
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席挂机失败：" + strres;
                parent.Form_setWinfromenble("false", "True", "false", "True", "false", "false", "false", "True", "false", "True");
            }
        }

        /*/// <summary>
        /// 咨询磋商结果事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="strres"></param>*/
        function EvtConsult(blres, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtConsult");
        }

        /*/// <summary>
        /// 坐席外呼结果事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="strres"></param>*/
        function EvtCallOut(blres, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtCallOut");
            if (blres == "True") {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席外呼成功";
                parent.Form_setWinfromenble("True", "false", "false", "false", "false", "false", "false", "false", "false", "false");
                parent.setAgentStatus("忙");
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席外呼失败：" + strres;
                //parent.Form_setWinfromenble("false", "True", "false", "True", "false", "false", "false", "True", "false", "True");
            }
        }

        /*/// <summary>
        /// 坐席登出结果事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="strres"></param>*/
        function EvtAgentLogout(blres, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtAgentLogout");
            if (blres == "True") {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席签出成功";
                parent.setLinkStatus("false");
                parent.Form_setWinfromenble("false", "false", "false", "false", "false", "false", "false", "false", "True", "false");
                parent.setAgentStatus("离席");
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席签出失败：" + strres;
                //parent.Form_setWinfromenble("false", "false", "false", "false", "false", "false", "false", "false", "True", "false");
            }
        }

        /*/// <summary>
        /// 坐席登录结果事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="strres"></param>*/
        function EvtAgentLogin(blres, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtAgentLogin");
            if (blres=="True") {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席签入成功";
                parent.setLinkStatus("True");
                parent.Form_setWinfromenble("false", "True", "True", "false", "false", "false", "false", "false", "false", "True");
                parent.setAgentStatus("空闲");
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席签入失败：" + strres;
                parent.setLinkStatus("false");
                parent.Form_setWinfromenble("false", "false", "false", "false", "false", "false", "false", "false", "True", "false");
                parent.setAgentStatus("未签入");
            }
        }

        /*/// <summary>
        /// 挂机事件
        /// </summary>
        /// <param name="sender"></param>*/
        function EvtTelephoneHangup() {
            WriteFileLogs(1, "iframeocx.aspx", "EvtTelephoneHangup");
            if (blres == "True") {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席挂机成功";
                parent.setLinkStatus("True");
                parent.Form_setWinfromenble("false", "True", "True", "false", "false", "false", "false", "false", "false", "True");
                parent.setAgentStatus("空闲");
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "坐席挂机失败：" + strres;
                parent.setLinkStatus("false");
                parent.Form_setWinfromenble("True", "True", "True", "false", "false", "false", "True", "false", "false", "True");
            }
        }

        /*/// <summary>
        /// 服务状态改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="serverState"></param>*/
        function EvtServerStateChange(serverState) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtServerStateChange:" + serverState);
            switch (serverState) {
                case "0":
                    parent.document.getElementById("spanServerRes").innerHTML = "未签入";
                    parent.setLinkStatus("True");
                    parent.setAgentStatus("未签入");
                    parent.Form_setWinfromenble("false", "false", "false", "false", "false", "false", "false", "false", "True", "false");
                    break;
                case "1":
                    parent.document.getElementById("spanServerRes").innerHTML = "线路空闲";
                    parent.setLinkStatus("True");
                    parent.setAgentStatus("空闲");
                    parent.Form_setWinfromenble("false", "True", "True", "false", "false", "false", "false", "false", "false", "True");
                    break;
                case "2":
                    break;
                case "3":
                    break;
                case "4":
                    parent.document.getElementById("spanServerRes").innerHTML = "呼出振铃";
                    parent.setLinkStatus("True");
                    parent.setAgentStatus("忙");
                    parent.Form_setWinfromenble("True", "false", "false", "false", "false", "false", "True", "false", "false", "false");
                    break;
                case "5":
                    parent.document.getElementById("spanServerRes").innerHTML = "来电振铃";
                    parent.setLinkStatus("True");
                    parent.setAgentStatus("忙");
                    parent.Form_setWinfromenble("True", "false", "false", "false", "false", "false", "false", "false", "false", "false");
                    break;
                case "6":
                    parent.document.getElementById("spanServerRes").innerHTML = "通话中";
                    parent.setLinkStatus("True");
                    parent.setAgentStatus("忙");
                    parent.Form_setWinfromenble("True", "false", "false", "false", "True", "True", "True", "false", "false", "false");
                    break;
                case "7":
                    parent.document.getElementById("spanServerRes").innerHTML = "通话保持中";
                    parent.setLinkStatus("True");
                    parent.setAgentStatus("忙");
                    parent.Form_setWinfromenble("True", "false", "false", "false", "false", "false", "false", "True", "false", "false");
                    break;

            }
        }

        /*/// <summary>
        /// 坐席状态改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="agentState"></param>*/
        function EvtAgentStateChange(agentState) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtAgentStateChange:" + agentState);
            switch (agentState) {
                case "1":
                    parent.document.getElementById("spanServerRes").innerHTML = "登陆中...";
                    parent.setLinkStatus("false");
                    parent.setAgentStatus("未签入");
                    parent.Form_setWinfromenble("false", "false", "false", "false", "false", "false", "false", "false", "false", "True");
                    break;
                case "2":
                    parent.document.getElementById("spanServerRes").innerHTML = "线路空闲";
                    parent.setLinkStatus("True");
                    parent.setAgentStatus("空闲");
                    parent.Form_setWinfromenble("false", "True", "True", "false", "false", "false", "false", "false", "false", "True");
                    break;
                case "3":
                    parent.document.getElementById("spanServerRes").innerHTML = "通话中";
                    parent.setLinkStatus("True");
                    parent.setAgentStatus("忙");
                    parent.Form_setWinfromenble("True", "false", "false", "false", "True", "True", "True", "false", "false", "false");
                    parent.telajaxopt("../telmanage/ajax/telrecords.ashx?action=zhaijiEvent&callid=" + parent.document.getElementById("CallHjbh").value); //更新摘机事件 
                    break;
                case "4":
                    parent.document.getElementById("spanServerRes").innerHTML = "话后处理";
                    parent.setLinkStatus("True");
                    parent.setAgentStatus("忙");
                    parent.Form_setWinfromenble("false", "false", "false", "True", "false", "false", "false", "false", "false", "True");
                    parent.telajaxopt("../telmanage/ajax/telrecords.ashx?action=guajiEvent&callid=" + parent.document.getElementById("CallHjbh").value); //更新挂机事件
                    break;
                case "5":
                    parent.document.getElementById("spanServerRes").innerHTML = "置闲成功";
                    parent.setLinkStatus("True");
                    parent.setAgentStatus("忙");
                    parent.Form_setWinfromenble("false", "false", "false", "false", "false", "false", "false", "false", "false", "false");
                    break;
                case "7":
                    parent.document.getElementById("spanServerRes").innerHTML = "注销";
                    parent.setLinkStatus("false");
                    parent.setAgentStatus("未签入");
                    parent.Form_setWinfromenble("false", "false", "false", "false", "false", "false", "false", "false", "false", "True");
                    break;
            }
        }

        /*/// <summary>
        /// 来电弹屏事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="callerNum"></param>
        /// <param name="callID"></param>
        /// <param name="dataParam"></param>*/
        function EvtCallComming(callerNum, callID, dataParam) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtCallComming");
            try {
                var userid = parent.document.getElementById("txtAgentId").value;
                var usercode = parent.document.getElementById("lblAgentCode").innerHTML;
                var username = parent.document.getElementById("lblAgentName").innerHTML;
                var extnumber = parent.document.getElementById("lblAgentExt").innerHTML;
                //获取呼叫编号
                //var callid = parent.telajaxopt("../telmanage/ajax/telrecords.ashx?action=getCallIdByPhone&telphone=" + callerNum);
                parent.document.getElementById("CallHjbh").value = callID;
                username = encodeURI(username);
                parent.telajaxopt("../telmanage/ajax/telrecords.ashx?action=zhenlingEvent&callid=" + callID + "&userid=" + userid + "&usercode=" + usercode + "&username=" + username + "&extnumber" + extnumber);   //更新摘机事件
            } catch (e) {alert(e.Message);
            }
            parent.Form_callCommingCaller(callerNum, callID);
        }

        /*/// <summary>
        /// 外呼振铃
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="callerNum">来电号码</param>
        /// <param name="callID">呼叫编号</param>
        /// <param name="dataParam">任务Id</param>*/
        function EvtCallOutRing(callerNum, callID, dataParam) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtCallOutRing");
            try {
                //alert("外呼振铃：" + callerNum + ":" + callID + ":" + dataParam);
            } catch (e) {

            }
        }

        /*/// <summary>
        /// 录音通知事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="path">path</param>
        /// <param name="callID">呼叫编号</param>
        /// <param name="dataParam">任务Id</param>*/
        function EvtRecordInfo(path, callID, dataParam) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtRecordInfo: path=" + path + ";callID:" + callID + ";dataParam=" + dataParam);
            try {
                //alert("外呼振铃：" + callerNum + ":" + callID + ":" + dataParam);
                parent.telajaxopt("../telmanage/ajax/telrecords.ashx?action=luyinEvent&callid=" + callID + "&path=" + path);  //录音开始事件
                //Form_setWinfromenble("True", "false", "false", "false", "True", "True", "True", "false", "false", "false");
            } catch (e) {

            }
        }
    </script>
    <script type="text/javascript">
        /*-----------------------------------------------------------*/
        //var ismonitoring = false;//是否开启监控
        /*/// <summary>
        /// 订阅数据改变通知事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="type"></param>
        /// <param name="data1"></param>
        /// <param name="data2"></param>
        /// <param name="substr"></param>*/
        function EvtSubscribeDataChanged(type, data1, data2, substr) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtSubscribeDataChanged--type(" + type + ")--data1(" + data1 + ")--data2(" + data2 + ")--substr(" + substr + ")");
            if (parent.document.getElementById("ismonitoring").value=="false")
                return false;
            try {
                switch (type) {
                    case "0":
                        //坐席状态
                        parent.window.frames["frame_zxjkgl"].GetState(data1, substr);
                        //document.getElementById("frame_zxjkgl").GetState(data1, substr);
                        break;
                    case "1":
                        //线路状态
                        if (substr == "5") {
                            parent.window.frames["frame_zxjkgl"].GetState(data1, "9");
                        }
                        break;
                    case "2":
                        //空闲坐席
                        break;
                    case "3":
                        //忙
                        break;
                    case "4":
                        //来电振铃
                        if (substr != "") {
                            var arr = substr.split('|');
                            for (var i = 0; i < arr.length; i++) {
                                parent.window.frames["frame_zxjkgl"].GetState(arr[i].split(',')[0], "9");
                            }
                        }
                        break;
                    case "5":
                        //通话中
                        break;
                    default:
                        break;
                }
            } catch (e) {
                WriteFileLogs(1, "iframeocx.aspx-javascript", "EvtSubscribeDataChanged:"+e.Message);
            }
        }

        /*/// <summary>
        /// <summary>
        /// 强制坐席状态结果通知事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="blres"></param>
        /// <param name="callid"></param>
        /// <param name="strres"></param>*/
        function EvtForceAgentState(blres, callid, strres) {
            WriteFileLogs(1, "iframeocx.aspx", "EvtForceAgentState--blres(" + blres + ")--callid(" + callid + ")--strres(" + strres + ")");
            if (parent.document.getElementById("ismonitoring").value == "false")
                return false;
            if (blres == "True") {
                parent.document.getElementById("spanServerRes").innerHTML = "强制坐席状态成功";
            }
            else {
                parent.document.getElementById("spanServerRes").innerHTML = "强制坐席状态失败：" + strres;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    </form>
</body>
</html>
