public bool Handle(Dto.EventBus.ChannelSendGroupMsgEvent <RequestCustomMsgRoomDurationChanged> evt)
        {
            try
            {
                return(imservice.SendGroupCustomMsg(evt.ChannelID, evt.FromAccount, evt.Msg));
            }
            catch (InvalidGroupException)
            {
                //自动修正房间不存在的问题
                using (MQChannel mq = new MQChannel())
                {
                    var room = roomService.GetChannelInfo(evt.ChannelID);
                    if (roomService.UpdateRoomEable(evt.ChannelID, false))
                    {
                        mq.Publish(new Dto.EventBus.ChannelCreateEvent()
                        {
                            ChannelID   = evt.ChannelID,
                            ServiceID   = room.ServiceID,
                            ServiceType = room.ServiceType,
                        });
                    }

                    return(false);
                }
            }
            catch (Exception ex)
            {
                LogHelper.DefaultLogger.Error(ex);
                return(false);
            }
        }
예제 #2
0
        public bool Handle(Dto.EventBus.ChannelSendGroupMsgEvent <ResponseUserFileDTO> evt)
        {
            try
            {
                //发送图片消息
                if (evt.Msg.FileType == 0)
                {
                    return(imservice.SendGroupImageMsg(evt.ChannelID, evt.FromAccount, evt.Msg.FileID, evt.Msg.FileUrl));
                }
                //发送图片消息
                else if (evt.Msg.FileType == 1)
                {
                    return(imservice.SendGroupFileMsg(evt.ChannelID, evt.FromAccount, evt.Msg.FileID, evt.Msg.FileSize, evt.Msg.FileName));
                }
                //发送音频消息
                //else if (evt.Msg.FileType == 2)
                //{
                //    using (var filestream = KMEHosp.Common.Storage.Manager.Instance.OpenFile("Audios", evt.Msg.FileUrl))
                //    {
                //        Task.WaitAll(filestream);

                //        var Second = Convert.ToInt32(KMEHosp.Common.Utility.AudioHelper.TotalSeconds(filestream.Result));
                //        return imservice.SendGroupAudioMsg(evt.ChannelID, evt.FromAccount, evt.Msg.FileID, evt.Msg.FileSize, Second);

                //    }
                //}
                else
                {
                    return(true);
                }
            }
            catch (InvalidGroupException)
            {
                //自动修正房间不存在的问题
                using (MQChannel mq = new MQChannel())
                {
                    var room = roomService.GetChannelInfo(evt.ChannelID);
                    room.Enable = false;
                    if (roomService.UpdateRoomEable(evt.ChannelID, false))
                    {
                        mq.Publish(new ChannelCreateEvent()
                        {
                            ChannelID   = evt.ChannelID,
                            ServiceID   = room.ServiceID,
                            ServiceType = room.ServiceType,
                        });
                    }

                    return(false);
                }
            }
            catch (Exception ex)
            {
                LogHelper.DefaultLogger.Error(ex);
                return(false);
            }
        }
예제 #3
0
        public bool Handle(Dto.EventBus.ChannelSendGroupMsgEvent <string> evt)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(evt.Msg))
                {
                    return(true);
                }
                else
                {
                    return(imservice.SendGroupTextMsg(evt.ChannelID, evt.FromAccount, evt.Msg));
                }
            }
            catch (InvalidGroupException)
            {
                //自动修正房间不存在的问题
                using (MQChannel mq = new MQChannel())
                {
                    var room = roomService.GetChannelInfo(evt.ChannelID);
                    if (roomService.UpdateRoomEable(evt.ChannelID, false))
                    {
                        mq.Publish(new Dto.EventBus.ChannelCreateEvent()
                        {
                            ChannelID   = evt.ChannelID,
                            ServiceID   = room.ServiceID,
                            ServiceType = room.ServiceType,
                        });
                    }

                    return(false);
                }
            }
            catch (Exception Ex)
            {
                LogHelper.DefaultLogger.Error(Ex);
                return(false);
            }
        }