Пример #1
0
 public DoctorsController()
 {
     doctorBll  = new XuHos.BLL.Doctor.Implements.DoctorService();
     userDoctor = new BLL.User.Implements.UserDoctorService();;
 }
Пример #2
0
        public bool Handle(EventBus.Events.ChannelEnteredEvent evt)
        {
            if (evt == null || string.IsNullOrEmpty(evt.UserID))
            {
                return(true);
            }

            try
            {
                var    service  = new XuHos.BLL.Doctor.Implements.DoctorService();
                string doctorID = service.GetDoctorIDByUserID(evt.UserID);
                if (string.IsNullOrEmpty(doctorID))
                {
                    return(true);
                }

                ConversationRoomService roomService = new ConversationRoomService();
                var room = roomService.GetChannelInfo(evt.ChannelID);
                if (room == null)
                {
                    return(true);
                }

                // 判断医生是否已经进入过诊室
                var           enteredStateCacheKey = new XuHos.Common.Cache.Keys.EntityListCacheKey <string>(Common.Cache.Keys.StringCacheKeyType.Channel_EnteredState, evt.ChannelID.ToString());
                List <string> enteredStates        = enteredStateCacheKey.FromCache();
                if (enteredStates == null)
                {
                    enteredStates = new List <string>();
                }

                // 如果医生已进入过诊室
                if (enteredStates.Exists(x => x == evt.UserID))
                {
                    return(true);
                }

                enteredStates.Add(evt.UserID);

                // 将机器人加入诊室
                //int robotIdentifier = 0;
                //if (!AddRobotToChannel(evt.ChannelID, robotIdentifier))
                //    return false;
                int?doctorIdentifier = roomService.GetChannelUsersInfo(evt.ChannelID)?.Where(x => x.UserID == evt.UserID).Select(x => x.identifier).FirstOrDefault();
                if (!doctorIdentifier.HasValue)
                {
                    return(true);
                }

                using (MQChannel channle = new MQChannel())
                {
                    if (channle.Publish <EventBus.Events.ChannelSendGroupMsgEvent <string> >(new EventBus.Events.ChannelSendGroupMsgEvent <string>()
                    {
                        ChannelID = evt.ChannelID,
                        FromAccount = doctorIdentifier.Value,//robotIdentifier,
                        Msg = "您好,我是康美网络医院在线医生,很高兴为您服务!"
                    }))
                    {
                        // 记录进入诊室状态
                        enteredStates.ToCache(enteredStateCacheKey);
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                LogHelper.WriteError(e);
                return(false);
            }
        }