示例#1
0
        public string EndKfMeeting()
        {
            KfMeeting kfMeeting = _kfMeetingService.GetById(KfMeetingId);

            if (!kfMeeting.IsEnd)
            {
                kfMeeting.RecordCount = _kfMeetingMessageService.GetCount(" where KfMeetingId='" + kfMeeting.Id + "'");
                kfMeeting.EndDate     = DateTime.Now;
                kfMeeting.IsEnd       = true;
                _kfMeetingService.Update(kfMeeting);
                //向用户发送会话断开的消息
                string message2 = string.Empty;
                new CommandManager(null).TryHandleCommand("SendPrivateMessage", new string[] { KfNumberId.ToString(), kfMeeting.MpUserId.ToString(), "本次会话已被断开" }, ref message2);
                //把消息发送给微信端客户
                MpUser mpUser = _mpUserService.GetById(kfMeeting.MpUserId);

                if (mpUser != null && !string.IsNullOrWhiteSpace(mpUser.OpenID))
                {
                    _mpUserService.SendMessage(mpUser.OpenID, "本次会话已被断开");
                }
                //断开当前用户的所有连接
                _kfMeetingService.ExcuteSql("update KfMeeting set IsEnd=1 where MpUserId='" + kfMeeting.MpUserId + "'");
                //更新用户状态
                _mpUserService.ChangeMpUserState(kfMeeting.MpUserId, 0);
            }
            return(JsonHelper.AnalysisJson <string>(string.Empty, "ok", null));
        }
示例#2
0
        public string EndKfMeeting()
        {
            if (!string.IsNullOrWhiteSpace(Token))
            {
                if (Token != "ocean")
                {
                    return(JsonHelper.AnalysisJson <string>("凭证错误", "error", null));
                }
            }

            KfMeeting kfMeeting = _kfMeetingService.GetById(KfMeetingId);

            if (!kfMeeting.IsEnd)
            {
                kfMeeting.RecordCount = _kfMeetingMessageService.GetCount(" where KfMeetingId='" + kfMeeting.Id + "'");
                kfMeeting.EndDate     = DateTime.Now;
                kfMeeting.IsEnd       = true;
                _kfMeetingService.Update(kfMeeting);
                //向客服发送断开通知
                string message = string.Empty;
                //访客名称
                string visitName = string.Empty;
                MpUser mpUser    = _mpUserService.GetById(kfMeeting.MpUserId);
                if (mpUser != null)
                {
                    visitName = mpUser.NickName;

                    if (!string.IsNullOrWhiteSpace(mpUser.OpenID))
                    {
                        _mpUserService.SendMessage(mpUser.OpenID, "成功退出聊天,输入【客服】或【kf】转人工客服");
                    }
                }
                else
                {
                    visitName = "访客_" + new Random().Next(100);
                }
                new CommandManager(null).TryHandleCommand("Notice", new string[] { kfMeeting.MpUserId.ToString(), visitName, kfMeeting.KfNumberId.ToString(), "3", "0", kfMeeting.MpUserId.ToString() }, ref message);
                //断开当前用户的所有连接
                _kfMeetingService.ExcuteSql("update KfMeeting set IsEnd=1 where MpUserId='" + kfMeeting.MpUserId + "'");
            }

            //更新用户状态
            _mpUserService.ChangeMpUserState(kfMeeting.MpUserId, 0);
            return(JsonHelper.AnalysisJson <string>(string.Empty, "ok", null));
        }