public ApiResult SendImageMessage(BLL.Sys.DTOs.Request.RequestSendImageDTO request) { XuHos.Integration.QQCloudy.IMHelper bll = new XuHos.Integration.QQCloudy.IMHelper(); SysFileIndexService fileIndexService = new SysFileIndexService(CurrentOperatorUserID); var file = fileIndexService.Single <SysFileIndex>(a => a.MD5 == request.FileMD5); if (CurrentOperatorUserIdentifier <= 0) { throw new ArgumentException($"user {CurrentOperatorUserID} Identifier<=0"); } using (XuHos.EventBus.MQChannel channel = new EventBus.MQChannel()) { return(channel.Publish <EventBus.Events.ChannelSendGroupMsgEvent <ResponseUserFileDTO> >(new EventBus.Events.ChannelSendGroupMsgEvent <ResponseUserFileDTO>() { ChannelID = request.ChannelID, FromAccount = CurrentOperatorUserIdentifier, Msg = new ResponseUserFileDTO() { FileUrl = $"{file.FileType}/{file.FileUrl}", FileID = file.MD5, FileName = file.FileUrl, FileType = 0, OutID = "", Remark = "" } }).ToApiResultForBoolean()); } }
public bool Handle(EventBus.Events.UserRegisteredEvent evt) { try { if (evt == null) { return(true); } XuHos.Integration.QQCloudy.IMHelper imService = new XuHos.Integration.QQCloudy.IMHelper(); ConversationIMUidService imUidService = new ConversationIMUidService(""); var identifier = imUidService.GetUserIMUid(evt.UserID); if (imService.CreateMember(identifier, "", "")) { return(imUidService.EnableUid(new int[] { identifier })); } } catch (Exception E) { XuHos.Common.LogHelper.WriteError(E); } return(false); }
public ApiResult MediaConfig(int ChannelID, int Identifier) { var bll = new XuHos.Integration.QQCloudy.IMHelper(); BLL.Sys.Implements.ConversationRoomService roomService = new BLL.Sys.Implements.ConversationRoomService(); var room = roomService.GetChannelInfo(ChannelID); //获取服务时长 var Duration = room.Duration; var TotalTime = room.TotalTime; //如果没有服务时长,则默认30分钟 if (Duration <= 0) { Duration = 60 * 30; //30分钟 } var config = bll.MediaConfig(ChannelID, Identifier, Duration, TotalTime, room.DisableWebSdkInteroperability); return(config.ToApiResultForObject()); }
/// <summary> /// 创建聊天的房间 /// </summary> /// <param name="OPDRegisterID"></param> /// <returns></returns> public bool CreateIMRoom(string OPDRegisterID) { try { using (DAL.EF.DBEntities db = new DBEntities()) { var model = (from opd in db.UserOpdRegisters.Where(a => a.OPDRegisterID == OPDRegisterID) join user in db.Users on opd.UserID equals user.UserID join member in db.UserMembers on opd.MemberID equals member.MemberID select new { OPDType = opd.OPDType, DoctorID = opd.DoctorID, //opd.DoctorID, UserID = opd.UserID, MemberID = opd.MemberID, member.MemberName, user.PhotoUrl, user.UserCNName, user.UserENName }).FirstOrDefault(); if (model != null) { #region 创建IM群组 XuHos.Integration.QQCloudy.IMHelper imservice = new XuHos.Integration.QQCloudy.IMHelper(); ConversationIMUidService imUidService = new ConversationIMUidService(CurrentOperatorUserID); var roomService = new BLL.Sys.Implements.ConversationRoomService(); BLL.Doctor.Implements.DoctorService doctorService = new Doctor.Implements.DoctorService(); //房间信息 var room = roomService.GetChannelInfo(OPDRegisterID); if (room != null) { var GroupName = model.OPDType.GetEnumDescript(); var Introduction = ""; var Notification = ""; var groupMembers = new List <int>(); var channelMembers = new List <RequestChannelMemberDTO>(); //患者信息 var userIdentifier = imUidService.GetUserIMUid(model.UserID); if (userIdentifier > 0) { groupMembers.Add(userIdentifier); channelMembers.Add(new RequestChannelMemberDTO() { Identifier = userIdentifier, UserType = EnumUserType.User, UserID = model.UserID, UserMemberID = model.MemberID, PhotoUrl = model.PhotoUrl, UserCNName = model.MemberName, UserENName = model.MemberName }); } //获取医生信息(如果走导诊系统,此时还未分配医生,分诊后才会把分诊医生加入到IM组) if (!string.IsNullOrEmpty(model.DoctorID)) { var doctorInfo = doctorService.GetDoctorInfo(model.DoctorID); var doctorIdentifier = imUidService.GetDoctorIMUid(model.DoctorID); if (doctorIdentifier > 0) { groupMembers.Add(doctorIdentifier); channelMembers.Add(new RequestChannelMemberDTO() { Identifier = doctorIdentifier, UserID = doctorInfo.UserID, UserType = EnumUserType.Doctor, UserMemberID = doctorInfo.User.MemberID, PhotoUrl = doctorInfo.User._PhotoUrl,//DTO已经进行了路径转换,这里需要使用没有转换之前的数据 UserENName = doctorInfo.DoctorEnName, UserCNName = doctorInfo.DoctorName }); } } if (room.Enable) { if (imservice.AddGroupMember(room.ChannelID, groupMembers)) { return(roomService.InsertChannelMembers(room.ChannelID, channelMembers)); } } else { //创建裙子成功 if (imservice.CreateGroup(room.ChannelID, GroupName, model.OPDType, groupMembers, Introduction, Notification)) { using (XuHos.EventBus.MQChannel mqChannel = new EventBus.MQChannel()) { if (mqChannel.Publish <EventBus.Events.ChannelCreatedEvent>(new EventBus.Events.ChannelCreatedEvent() { ChannelID = room.ChannelID, ServiceID = room.ServiceID, ServiceType = room.ServiceType })) { room.Enable = true; if (roomService.CompareAndSetChannelInfo(room)) { return(roomService.InsertChannelMembers(room.ChannelID, channelMembers)); } } else { return(false); } } } } } else { return(true); } #endregion } else { return(true); } } } //出现数据库并发更新异常需要重试 catch (DbUpdateConcurrencyException ex) { return(CreateIMRoom(OPDRegisterID)); } return(false); }
public ApiResult Config() { var bll = new XuHos.Integration.QQCloudy.IMHelper(); return(bll.Config(CurrentOperatorUserIdentifier).ToApiResultForObject()); }