Esempio n. 1
0
        /// <summary>
        /// 窗口加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Utils.WriteLog("Window_Loaded");
            string serverAddress = ConfigurationManager.AppSettings["server"];

            #region browser
            #region 初始化环境 禁用gpu 防止闪烁
            var setting = new CefSharp.CefSettings();
            setting.CefCommandLineArgs.Add("disable-gpu", "1");
            setting.Locale    = "zh-CN";
            setting.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36 LY_CRM_BOX";
            CefSharp.Cef.Initialize(setting);
            #endregion
            browser = new ChromiumWebBrowser();
            //browser.Address = System.AppDomain.CurrentDomain.BaseDirectory + "index.html";
            // 解决input框无法输入中文的BUG
            browser.PreviewTextInput += Browser_PreviewTextInput;

            browser.Address = serverAddress;

            browser.LifeSpanHandler = new prohibitNewPageJump();
            //browser.Address = "http://ie.icoa.cn";
            //注册JS调用函数
            browser.RegisterJsObject("__phone", new CallBackForJs());
            // 菜单处理事件
            browser.MenuHandler = new MenuHandler();
            // 下载处理事件
            browser.DownloadHandler = new browerDownLoad();

            this.main.Children.Add(browser);
            // 浏览器按键事件
            browser.KeyDown += Browser_KeyDown;

            #endregion

            #region 盒子初始化
            if (VoipHelper.OpenDevice() == 0)
            {
                VoipHelper.deviceState = false;
                MessageBox.Show("电话硬件设备连接存在问题,请关闭软件检查硬件后重试。");
            }

            hwnd = (new System.Windows.Interop.WindowInteropHelper(this)).Handle;//盒子事件注册
            for (Int16 i = 0; i < BriSDKLib.QNV_DevInfo(-1, BriSDKLib.QNV_DEVINFO_GETCHANNELS); i++)
            {
                //在windowproc处理接收到的消息
                BriSDKLib.QNV_Event(i, BriSDKLib.QNV_EVENT_REGWND, (int)hwnd, "", new StringBuilder(0), 0);
            }
            VoipHelper.init();
            #endregion

            #region   录音
            uploadRecordingFile         = new BackgroundWorker();
            uploadRecordingFile.DoWork += uploadRecordingFile_DoWork;
            uploadRecordingFile.WorkerSupportsCancellation = true;
            uploadRecordingFile.RunWorkerAsync();
            #endregion

            Utils.PreventSleep();
        }
Esempio n. 2
0
 /// <summary>
 /// 风险提示
 /// </summary>
 public void riskprompt()
 {
     if (VoipHelper.playHandle <= 0)
     {
         VoipHelper.domicToLine(0);
         VoipHelper.playHandle = VoipHelper.PlayVoice(VoipHelper.PLAYFILEPATH);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 开始通话
 /// </summary>
 /// <param name="phone">手机号</param>
 /// <param name="callId">通话ID</param>
 /// <returns>{code:number,msg:string}</returns>
 public void startTalk(string phone)
 {
     VoipHelper.callId     = Utils.GetCallId();
     VoipHelper.callState  = VoipHelper.telState.OUT;
     VoipHelper.callNumber = phone;
     VoipHelper.Call(phone);
     VoipHelper.OffOnHook(1);
 }
Esempio n. 4
0
        private void SetupCallContext()
        {
            if (_callChannel != null)
            {
                return;
            }

            var voipHelper = new VoipHelper();

            _callContext = new CallContext(this, voipHelper);
            _callChannel = new CallChannel(this, _callContext);
        }
Esempio n. 5
0
        /// <summary>
        /// 盒子事件
        /// </summary>
        /// <param name="lParam"></param>
        private void HandleWindowProc(System.IntPtr lParam)
        {
            BriSDKLib.TBriEvent_Data EventData = (BriSDKLib.TBriEvent_Data)Marshal.PtrToStructure(lParam, typeof(BriSDKLib.TBriEvent_Data));
            Debug.WriteLine("event==>>" + EventData.lEventType);

            switch (EventData.lEventType)
            {
            case BriSDKLib.BriEvent_PhoneHook:    //电话机摘机
                boxHandler.phoneHook();
                break;

            case BriSDKLib.BriEvent_PhoneHang:    //电话机挂机
                boxHandler.phoneHang();
                break;

            case BriSDKLib.BriEvent_GetCallID:    //接收到来电号码
                boxHandler.getCallID(VoipHelper.FromASCIIByteArray(EventData.szData));
                break;

            case BriSDKLib.BriEvent_Busy:    //忙音
                boxHandler.busy();
                break;

            case BriSDKLib.BriEvent_RemoteHook:     //对方接听
                boxHandler.remoteHook();
                break;

            case BriSDKLib.BriEvent_RemoteHang:    //远程挂机
                boxHandler.remoteHang();
                break;

            case BriSDKLib.BriEvent_PhoneDial:    //摘机手动拨号
                boxHandler.phoneDial(VoipHelper.FromASCIIByteArray(EventData.szData));
                break;

            case BriSDKLib.BriEvent_RingBack:    //电话机检查拨号结束
                boxHandler.ringBack(EventData.lResult);
                break;

            case BriSDKLib.BriEvent_EnableHook:     // 软摘/挂机 1是摘机  0是挂机
                boxHandler.enableHook(EventData.lResult);
                break;

            default:
                break;
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 挂断
 /// </summary>
 /// <returns>{code:number,msg:string}</returns>
 public void stopTalk()
 {
     VoipHelper.OffOnHook(0);
 }
Esempio n. 7
0
 /// <summary>
 /// 接听来电
 /// </summary>
 /// <param name="callId">通话ID</param>
 /// <returns>{code:number,msg:string}</returns>
 public void answerCall()
 {
     VoipHelper.OffOnHook(1);
 }
Esempio n. 8
0
 /// <summary>
 /// 窗口关闭
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Window_Closed(object sender, EventArgs e)
 {
     VoipHelper.windowClose();
     Utils.ResotreSleep();
     BriSDKLib.QNV_Event(0, BriSDKLib.QNV_EVENT_UNREGWND, (int)hwnd, "", new StringBuilder(0), 0);
 }