static private void async(Calltype type, Packet inputpacket) { calldata.mutex.WaitOne(); calldata.type = type; calldata.inputpacket = inputpacket; calldata.outputpacket = null; calldata.mutex.ReleaseMutex(); }
/// 插入临时记录 /// <summary> /// 插入临时记录 /// </summary> /// <param name="state"></param> /// <param name="agentAuxState"></param> /// <param name="callType"></param> /// <param name="agTime"></param> /// <param name="startTime"></param> /// <returns></returns> public bool InsertAgentState2DB(AgentState state, BusyStatus agentAuxState, Calltype callType, int agTime, DateTime startTime) { int busystate = (int)agentAuxState; if (state != AgentState.AS4_置忙) { busystate = -1; } return(agentService.InsertAgentState2DB(CallRecordAuthorizeCode, (int)state, busystate, (int)callType, agTime, startTime, LoginUser.UserID.ToString(), LoginUser.TrueName, LoginUser.BGID, LoginUser.ExtensionNum)); }
/// 获取发送msg类 /// <summary> /// 获取发送msg类 /// </summary> /// <param name="userevent"></param> /// <param name="callid"></param> /// <param name="calltype"></param> /// <param name="date"></param> /// <returns></returns> public UserEventData InitUserEventData(UserEvent userevent, Calltype calltype, DateTime date, long?callid = null, string taskid = null, int?tasktype = null) { UserEventData ud = new UserEventData(); ud.UserEvent = userevent; ud.CallType = calltype; ud.CurrentDate = date; //如果callid有值 if (callid.HasValue == true) { ud.CallID = callid.Value; } //主叫 if (CallRecordORIG == null || string.IsNullOrEmpty(CallRecordORIG.PhoneNum)) { ud.ZhujiaoNum = HollyContactHelper.Instance.GetZhujiaoPhone(); } else { ud.ZhujiaoNum = CallRecordORIG.PhoneNum;//主叫 } //被叫 if (CallRecordORIG == null || string.IsNullOrEmpty(CallRecordORIG.ANI)) { ud.BejiaoNum = HollyContactHelper.Instance.GetBeijiaoPhone(); } else { ud.BejiaoNum = CallRecordORIG.ANI;//被叫 } ud.UserChoice = HollyContactHelper.Instance.GetSkillGroup(); //技能组 ud.SYS_DNIS = HollyContactHelper.Instance.GetLuodiNum(); //落地号码 ud.RecordID = HollyContactHelper.Instance.GetHollyCallID(); //厂家callid //取值 if (CallRecordORIG != null) { ud.IsEstablished = CallRecordORIG.EstablishedTime.HasValue; ud.EstablishedStartTime = CallRecordORIG.EstablishedTime; ud.RecordIDURL = CallRecordORIG.AudioURL;//录音地址 //callid 没有值,从CallRecordORIG中取 if (callid.HasValue == false) { ud.CallID = CallRecordORIG.CallID.HasValue ? CallRecordORIG.CallID.Value : -1; } } ud.TaskID = taskid; ud.TaskType = tasktype; Loger.Log4Net.Info("[==BusinessProcess=] InitUserEventData " + userevent + "-" + ud.CallID + "-" + calltype + "-" + date); return(ud); }
/// 获取话务类 /// <summary> /// 获取话务类 /// </summary> /// <param name="callid"></param> /// <param name="calltype"></param> /// <returns></returns> public void InitCallRecordORIG(long callid, Calltype calltype) { CallRecordORIG = new CallRecord_ORIG(); CallRecordORIG.CallID = callid; CallRecordORIG.SiemensCallID = -1; CallRecordORIG.ExtensionNum = LoginUser.ExtensionNum; //设置主叫和被叫 CallRecordORIG.CallStatus = (int)calltype; SetPhoneNumAndAni(); CallRecordORIG.OutBoundType = (int)OutBoundType; CallRecordORIG.AfterWorkTime = 0; CallRecordORIG.TallTime = 0; CallRecordORIG.CreateTime = Common.GetCurrentTime(); CallRecordORIG.CreateUserID = LoginUser.UserID; //设置厂家id CallRecordORIG.SessionID = HollyContactHelper.Instance.GetHollyCallID(); //厂家callid CallRecordORIG.GenesysCallID = HollyContactHelper.Instance.GetHollyCallID(); //厂家callid Loger.Log4Net.Info("[==BusinessProcess=] InitCallRecordORIG callid:" + callid + "-calltype:" + calltype); }
static private Packet call(Calltype type, Packet inputpacket) { calldata.mutex.WaitOne(); calldata.type = type; calldata.inputpacket = inputpacket; calldata.outputpacket = null; calldata.manualevent.Reset(); calldata.mutex.ReleaseMutex(); calldata.manualevent.WaitOne(); calldata.mutex.WaitOne(); calldata.type = Calltype.None; calldata.inputpacket = null; Packet outputpacket = calldata.outputpacket; calldata.mutex.ReleaseMutex(); return(outputpacket); }
/// 更新客服状态表 /// <summary> /// 更新客服状态表 /// </summary> /// <param name="Cur_AgentState"></param> private void UpdatAgentDB(AgentState Cur_AgentState) { Loger.Log4Net.Info("[Main][UpdatAgentDB] 更新客服状态表" + Cur_AgentState); //签入和签出另有地方记录日志,此处不重复记录 if (Cur_AgentState != AgentState.AS1_签出 && Cur_AgentState != AgentState.AS2_签入) { //当前时间 DateTime date = Common.GetCurrentTime(); Calltype ctype = Calltype.C0_未知; if (LoginHelper.PreOid == -1) { //没有上一个数据,直接插入新数据 //1.插入CAgent表 AgentTimeStateHelper.Instance.InsertAgentState2DBAsync(Cur_AgentState, Main_BusyStatus, ctype, 0, date); Loger.Log4Net.Info("[Main][UpdatAgentDB] 插入CAgent表"); } else { //有上一个数据,先更新上一个数据,再插入新数据,在重置PreOid //1.更新CAgent表 AgentTimeStateHelper.Instance.UpdateAgentState2DBAsync(Cur_AgentState, Main_BusyStatus, ctype, 0, date); //2.更新AgentStateDetail表(更新上一个状态的结束时间) AgentTimeStateHelper.Instance.UpdateStateDetail2DBAsync(LoginHelper.PreOid, date); Loger.Log4Net.Info("[Main][UpdatAgentDB] 更新上一个状态的结束时间 PreOid....IS:" + LoginHelper.PreOid + ",结束时间为:" + date); } //3.插入AgentStateDetail表(新状态) LoginHelper.PreOid = AgentTimeStateHelper.Instance.InsertAgentStateDetail2DB(Cur_AgentState, Main_BusyStatus, ctype, date, date); Loger.Log4Net.Info("[Main][UpdatAgentDB] 插入新的状态 PreOid....IS:" + LoginHelper.PreOid); } else if (Cur_AgentState == AgentState.AS1_签出) { //当前时间 DateTime date = Common.GetCurrentTime(); LoginHelper.Instance.SingOutUpdateDate(date); } }
/// 插入明细记录 /// <summary> /// 插入明细记录 /// </summary> /// <param name="state"></param> /// <param name="agentAuxState"></param> /// <param name="callType"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public int InsertAgentStateDetail2DB(AgentState state, BusyStatus agentAuxState, Calltype callType, DateTime startTime, DateTime endTime) { int busystate = (int)agentAuxState; if (state != AgentState.AS4_置忙) { busystate = -1; } return(agentService.InsertAgentStateDetail2DB(CallRecordAuthorizeCode, (int)state, busystate, (int)callType, startTime, endTime, LoginUser.TrueName, LoginUser.UserID.ToString(), LoginUser.ExtensionNum, Convert.ToInt32(LoginUser.BGID))); }
/// 更新临时记录 /// <summary> /// 更新临时记录 /// </summary> /// <param name="state"></param> /// <param name="agentAuxState"></param> /// <param name="callType"></param> /// <param name="agTime"></param> /// <param name="startTime"></param> /// <returns></returns> public void UpdateAgentState2DBAsync(AgentState state, BusyStatus agentAuxState, Calltype callType, int agTime, DateTime startTime) { int busystate = (int)agentAuxState; if (state != AgentState.AS4_置忙) { busystate = -1; } agentService.UpdateAgentState2DBAsync(CallRecordAuthorizeCode, (int)state, busystate, (int)callType, agTime, startTime, LoginUser.UserID.ToString()); }
/// 挂断通用事件 /// <summary> /// 挂断通用事件 /// </summary> /// <param name="releasetype"></param> private void OnHangup(ReleaseType releasetype) { Loger.Log4Net.Info("[事件][OnHangup] 挂断"); //3种情况=呼入,呼出,未知 Calltype ctype = HollyContactHelper.Instance.GetCallDir(); //话后处理 if (ctype == Calltype.C2_呼出) { //合力bug:外呼假失败 HollyBUGForCallOut(); //呼出没有话后 Action <object> callback = new Action <object>(x => { //结束话后 HollyContactHelper.Instance.AfterCallEnd(); //呼出时计算话后信息 Loger.Log4Net.Info("[==BusinessProcess=][UpdateCallRecordAfterTime] 呼出时退出话后更新话后信息"); BusinessProcess.Instance.UpdateCallRecordAfterTime(); }); ToAfterCallCallBack(callback); } else { //呼入+自动外呼 存在话后时间 //话后有时间限制 AfterTime = CommonFunction.ObjectToInteger(ConfigurationUtil.GetAppSettingValue("AfterTime"), 60); SetlblAgentStatusName("话后 " + AfterTime); timer_after.Enabled = true; } if (BusinessProcess.CallRecordORIG != null) { //初始化话务数据 DateTime date = Common.GetCurrentTime(); //设置挂断时间 BusinessProcess.Instance.SetReleaseTime(date, releasetype); //数据入库 CallRecordHelper.Instance.InsertCallRecordNew(false); if (ctype != Calltype.C2_呼出) { //呼入+自动外呼时,计算话后信息 //注册退出话后的事件 Action <object> callback = new Action <object>(x => { Loger.Log4Net.Info("[==BusinessProcess=][UpdateCallRecordAfterTime] 呼入时退出话后更新话后信息"); BusinessProcess.Instance.UpdateCallRecordAfterTime(); }); //退出话后时触发 ExitAfterCallCallBack(callback); } //发送消息到客户端 if (BusinessProcess.OutBoundType != OutBoundTypeEnum.OT2_客户端呼出) { UserEventData ud = null; //呼入(普通呼入,转接,拦截) if (ctype == Calltype.C1_呼入 && HollyContactHelper.Instance.IsAutoCall == false) { ud = BusinessProcess.Instance.InitUserEventData(UserEvent.Released, Calltype.C1_呼入, date); } //呼出(呼出,自动外呼,未知) else { ud = BusinessProcess.Instance.InitUserEventData(UserEvent.Released, Calltype.C2_呼出, date); } SendToWeb(ud.ToString()); } //挂断是,数据还原初始值 BusinessProcess.OutBoundType = OutBoundTypeEnum.OT0_未知; } else { Loger.Log4Net.Info("[事件][OnHangup] 异常:BusinessProcess.CallRecordORIG 为空"); } }
/// 设置按钮样式 /// <summary> /// 设置按钮样式 /// </summary> /// <param name="phonestatus"></param> public void SetButtonStyle(PhoneStatus phonestatus, Calltype calltype) { //禁用全部按钮 ButtonInit(); switch (phonestatus) { case PhoneStatus.PS01_就绪: break; case PhoneStatus.PS02_签出: //签入 this.toolSbtnAgentCheckIn.Enabled = true; break; case PhoneStatus.PS03_置闲: case PhoneStatus.PS18_客服被锁定: //签出 this.toolSbtnAgentCheckOff.Enabled = true; //置忙 this.toolSbtnSetBusy.Enabled = true; //拨号 this.toolSbtnAgentMakeCall.Enabled = true; //监控 this.toolSbtnAgentListen.Enabled = true; this.toolSbtnAgentListen.Text = "监控"; break; case PhoneStatus.PS04_置忙: case PhoneStatus.PS05_休息: //签出 this.toolSbtnAgentCheckOff.Enabled = true; //置闲 this.toolSbtnAgentReady.Enabled = true; //拨号 this.toolSbtnAgentMakeCall.Enabled = true; //监控 this.toolSbtnAgentListen.Enabled = true; this.toolSbtnAgentListen.Text = "监控"; break; case PhoneStatus.PS06_话后: //签出 this.toolSbtnAgentCheckOff.Enabled = true; //置闲 this.toolSbtnAgentReady.Enabled = true; //置忙 this.toolSbtnSetBusy.Enabled = true; break; case PhoneStatus.PS07_来电振铃: //摘机 this.toolSbtnAgentReleaseCall.Enabled = true; this.toolSbtnAgentReleaseCall.Text = "摘机"; this.toolSbtnAgentReleaseCall.Image = System.Drawing.Bitmap.FromFile(System.Environment.CurrentDirectory + "\\images\\摘机.png"); break; case PhoneStatus.PS08_普通通话: //保持 this.toolSbtnHold.Enabled = true; this.toolSbtnHold.Text = "保持"; if (calltype == Calltype.C1_呼入) { //转接 this.toolSbtnAgentConsult.Enabled = true; this.toolSbtnAgentConsult.Text = "转接"; if (HollyContactHelper.Instance.IsAutoCall == false) { //转IVR this.toolSbtnIVRSatisfaction.Enabled = true; } } //挂断 this.toolSbtnAgentReleaseCall.Enabled = true; this.toolSbtnAgentReleaseCall.Text = "挂断"; break; case PhoneStatus.PS09_咨询通话_发起方: //完成 this.toolSbtnAgentConsult.Enabled = true; this.toolSbtnAgentConsult.Text = "完成"; //会议 this.toolSbtnAgentConference.Enabled = true; this.toolSbtnAgentConference.Text = "会议"; //恢复 this.toolSbtnAgentReconnect.Enabled = true; //挂断 this.toolSbtnAgentReleaseCall.Enabled = true; this.toolSbtnAgentReleaseCall.Text = "挂断"; break; case PhoneStatus.PS10_咨询方通话_接受者: //挂断 this.toolSbtnAgentReleaseCall.Enabled = true; this.toolSbtnAgentReleaseCall.Text = "挂断"; break; case PhoneStatus.PS11_会议通话_发起方: //会议 this.toolSbtnAgentConference.Enabled = true; this.toolSbtnAgentConference.Text = "结束"; //挂断 this.toolSbtnAgentReleaseCall.Enabled = true; this.toolSbtnAgentReleaseCall.Text = "挂断"; break; case PhoneStatus.PS12_会议方通话_接受者: //挂断 this.toolSbtnAgentReleaseCall.Enabled = true; this.toolSbtnAgentReleaseCall.Text = "挂断"; break; case PhoneStatus.PS13_保持: //取消 this.toolSbtnHold.Enabled = true; this.toolSbtnHold.Text = "取消"; if (calltype == Calltype.C1_呼入) { //转接 this.toolSbtnAgentConsult.Enabled = true; this.toolSbtnAgentConsult.Text = "转接"; if (HollyContactHelper.Instance.IsAutoCall == false) { //转IVR this.toolSbtnIVRSatisfaction.Enabled = true; } } //挂断 this.toolSbtnAgentReleaseCall.Enabled = true; this.toolSbtnAgentReleaseCall.Text = "挂断"; break; case PhoneStatus.PS14_呼出拨号中: case PhoneStatus.PS15_咨询拨号中: case PhoneStatus.PS16_会议拨号中: case PhoneStatus.PS17_转接拨号中: //挂断 this.toolSbtnAgentReleaseCall.Enabled = true; this.toolSbtnAgentReleaseCall.Text = "挂断"; break; case PhoneStatus.PS19_监听振铃: case PhoneStatus.PS21_强插振铃: ////摘机 //this.toolSbtnAgentReleaseCall.Enabled = true; //this.toolSbtnAgentReleaseCall.Text = "摘机"; //this.toolSbtnAgentReleaseCall.Image = System.Drawing.Bitmap.FromFile(System.Environment.CurrentDirectory + "\\images\\摘机.png"); break; case PhoneStatus.PS20_监听中: //挂断 this.toolSbtnAgentReleaseCall.Enabled = true; this.toolSbtnAgentReleaseCall.Text = "取消监听"; break; case PhoneStatus.PS22_强插中: //挂断 this.toolSbtnAgentReleaseCall.Enabled = true; this.toolSbtnAgentReleaseCall.Text = "取消强插"; break; } }