Esempio n. 1
0
        public ActionResult KfNumberEditProvide()
        {
            KfNumber kfNumber   = new KfNumber();
            Guid     oldAdminId = Guid.Empty;

            if (!string.IsNullOrWhiteSpace(RQuery["KfNumberId"]))
            {
                kfNumber   = _kfNumberService.GetById(new Guid(RQuery["KfNumberId"]));
                oldAdminId = kfNumber.AdminId;
            }

            UpdateModel <KfNumber>(kfNumber);

            if (kfNumber.AdminId == Guid.Empty || kfNumber.AdminId == null)
            {
                return(JsonMessage(false, "请选择分配管理员"));
            }

            if (string.IsNullOrWhiteSpace(RQuery["KfNumberId"]))
            {
                Ocean.Entity.Admin admin = _adminService.GetById(kfNumber.AdminId);

                if (admin.KfNumbers.Count != 0)
                {
                    return(JsonMessage(false, "当前所选管理员已被分配过工号"));
                }

                _kfNumberService.Insert(kfNumber);
                return(JsonMessage(true, "添加客服工号成功"));
            }
            else
            {
                if (oldAdminId != kfNumber.AdminId)
                {
                    Ocean.Entity.Admin admin = _adminService.GetById(kfNumber.AdminId);

                    if (admin.KfNumbers.Count != 0)
                    {
                        return(JsonMessage(false, "当前所选管理员已被分配过工号"));
                    }
                }

                _kfNumberService.Update(kfNumber);
                return(JsonMessage(true, "修改客服工号成功"));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 设置在线状态[0:正常,1:离开]
        /// </summary>
        /// <returns></returns>
        public string SetOnlineStatus()
        {
            int      onlineStatus = int.Parse(Request["OnlineStatus"]);
            KfNumber kfNumber     = _kfNumberService.GetById(KfNumberId);

            kfNumber.OnlineStatus = onlineStatus;
            _kfNumberService.Update(kfNumber);
            return(JsonHelper.AnalysisJson <string>(onlineStatus.ToString(), "ok", null));
        }
Esempio n. 3
0
        public override void ExecuteNotice(CallerContext callerContext, string[] args, ref string message)
        {
            int type = int.Parse(args[1]);

            //客服离线
            if (type == 1)
            {
                Guid kfNumberId = new Guid(args[0]);
                //移除缓存中的客服
                MessageManager.Instance.RemoveCacheKF(kfNumberId);
                //离线时清理线程中的客服端(防止第一条离线信息丢失)
                CometThreadPool.DequeueCometWaitRequest(kfNumberId);
                //断开与所有访客的会话
                IKfNumberService         kfNumberService         = EngineContext.Current.Resolve <IKfNumberService>();
                IKfMeetingService        kfMeetingService        = EngineContext.Current.Resolve <IKfMeetingService>();
                IKfMeetingMessageService kfMeetingMessageService = EngineContext.Current.Resolve <IKfMeetingMessageService>();
                IMpUserService           mpUserService           = EngineContext.Current.Resolve <IMpUserService>();
                IList <KfMeeting>        listMeeting             = kfMeetingService.GetALL().Where(m => m.KfNumberId == kfNumberId && m.IsEnd == false).ToList();

                foreach (KfMeeting kfMeeting in listMeeting)
                {
                    kfMeeting.RecordCount = kfMeetingMessageService.GetCount(" where KfMeetingId='" + kfMeeting.Id + "'");
                    kfMeeting.EndDate     = DateTime.Now;
                    kfMeeting.IsEnd       = true;
                    kfMeetingService.Update(kfMeeting);
                    base.SendPrivateMessage(kfNumberId, kfMeeting.MpUserId, "本次会话已被断开,您可以重新发起会话请求");
                    //发送给微信
                    MpUser mpUser = mpUserService.GetById(kfMeeting.MpUserId);

                    if (mpUser != null && !string.IsNullOrWhiteSpace(mpUser.OpenID))
                    {
                        mpUserService.SendMessage(mpUser.OpenID, "本次会话已被断开,您可以重新发起会话请求");
                    }
                    //更新用户状态
                    mpUserService.ChangeMpUserState(kfMeeting.MpUserId, 0);
                }
                //把客服设置成离线
                KfNumber kfNumber = kfNumberService.GetById(kfNumberId);
                kfNumber.IsOnline = false;
                kfNumberService.Update(kfNumber);
            }

            //访客离线
            if (type == 2)
            {
                Guid mpUserId = new Guid(args[0]);
                //离线时清理线程中的访客端(防止第一条离线信息丢失)
                CometThreadPool.DequeueCometWaitRequest(mpUserId);
                //断开与客服的会话
                IKfMeetingService        kfMeetingService        = EngineContext.Current.Resolve <IKfMeetingService>();
                IKfMeetingMessageService kfMeetingMessageService = EngineContext.Current.Resolve <IKfMeetingMessageService>();
                IList <KfMeeting>        listMeeting             = kfMeetingService.GetALL().Where(m => m.MpUserId == mpUserId && m.IsEnd == false).ToList();

                foreach (KfMeeting kfMeeting in listMeeting)
                {
                    kfMeeting.RecordCount = kfMeetingMessageService.GetCount(" where KfMeetingId='" + kfMeeting.Id + "'");
                    kfMeeting.EndDate     = DateTime.Now;
                    kfMeeting.IsEnd       = true;
                    kfMeetingService.Update(kfMeeting);
                    base.SendNotice(mpUserId, "访客_" + new Random().Next(100), kfMeeting.KfNumberId, 3, 0, mpUserId.ToString());
                }
            }
        }