Exemple #1
0
        private void StartPlay(LineCallData lineupCallInfo, LineUpData lineupInfo)
        {
            BackgroundWorker bgWork = new BackgroundWorker();

            bgWork.DoWork             += DoWork;
            bgWork.ProgressChanged    += ProgessChanged;
            bgWork.RunWorkerCompleted += WorkerCompleted;

            bgWork.WorkerReportsProgress      = false;
            bgWork.WorkerSupportsCancellation = true;

            ThreadVoicePar lineVoicePar = new ThreadVoicePar();

            lineVoicePar.LineCallInfo = lineupCallInfo;
            lineVoicePar.LineUpInfo   = lineupInfo;

            bgWork.RunWorkerAsync(lineVoicePar);
        }
Exemple #2
0
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            lock (objLockWork)
            {
                if (e.Argument == null)
                {
                    throw new Exception("播放参数传递无效。");
                }

                ThreadVoicePar lineVoicePar = e.Argument as ThreadVoicePar;
                if (lineVoicePar == null)
                {
                    throw new Exception("播放参数信息无效。");
                }

                LineCallData lineCallInfo = lineVoicePar.LineCallInfo;
                LineUpData   lineupInfo   = lineVoicePar.LineUpInfo;
                try
                {
                    if (_isStop)
                    {
                        return;
                    }

                    if (_queueVoiceDesign.PlayHintSound)
                    {
                        SoundPlayer sp = new SoundPlayer(Properties.Resources.DingDong);
                        sp.PlaySync();
                    }

                    if (_isStop)
                    {
                        return;
                    }

                    //执行语音播放
                    for (int i = 0; i < _queueVoiceDesign.PlayCount; i++)
                    {
                        if (_isStop)
                        {
                            break;
                        }
                        PlaySound(lineCallInfo.呼叫信息.格式内容);
                    }

                    //更新状态为呼叫完成
                    lineupInfo.排队状态 = LineUpState.qsCalled;

                    QueueModel.TransactionBegin();

                    try
                    {
                        QueueModel.UpdateLineupInfo(lineupInfo);

                        //删除播放内容
                        QueueModel.DelCallInfoByCallId(lineCallInfo.呼叫ID);

                        QueueModel.TransactionCommit();

                        DataRow drBind = lineCallInfo.GetBindRow();
                        if (drBind != null)
                        {
                            _dtCall.Rows.Remove(drBind);
                        }
                        //e.Result = lineCallInfo.GetBindRow();
                    }
                    catch (Exception ex)
                    {
                        QueueModel.TransactionRollback();
                        throw new Exception("更新语音播放后的排队信息出现错误", ex);;
                    }
                }
                catch (Exception ex)
                {
                    try
                    {
                        lineupInfo.排队状态        = LineUpState.qsWaitCall;
                        lineupInfo.附加信息.末次呼叫时间 = QueueModel.GetServerDate();

                        QueueModel.UpdateLineupInfo(lineupInfo);
                    }
                    catch (Exception exd)
                    {
                        throw new Exception("恢复语音播放前的排队状态错误", exd);
                    }

                    throw new Exception("排队语音播放错误", ex);
                }
            }
        }